Пример #1
0
double BGMBase::get_field_value(double u, double v, double w,
                                const DoubleStorageType &data)
{
  // TODO C++11 Remove const_cast
  MElement *e = const_cast<MElement *>(findElement(u, v, w));
  if(!e) return -1000.;
  std::vector<double> val = get_nodal_values(e, data);
  std::vector<double> element_uvw = get_element_uvw_from_xyz(e, u, v, w);
  std::vector<double> values(e->getNumVertices());
  for(std::size_t i = 0; i < e->getNumVertices(); i++) values[i] = val[i];

  return e->interpolate(&values[0], element_uvw[0], element_uvw[1],
                        element_uvw[2], 1, order);
}
Пример #2
0
double frameFieldBackgroundMesh2D::angle(double u, double v)
{
    MElement *e = const_cast<MElement*>(findElement(u, v));
    if (!e) return -1000.0;
    std::vector<double> val = get_nodal_values(e,angles);
    std::vector<double> element_uvw = get_element_uvw_from_xyz(e,u,v,0.);
    std::vector<double> cosvalues(e->getNumVertices()), sinvalues(e->getNumVertices());
    for (int i=0; i<e->getNumVertices(); i++) {
        cosvalues[i]=cos(4*val[i]);
        sinvalues[i]=sin(4*val[i]);
    }
    double cos4 = e->interpolate(&cosvalues[0], element_uvw[0], element_uvw[1], element_uvw[2], 1, order);
    double sin4 = e->interpolate(&sinvalues[0], element_uvw[0], element_uvw[1], element_uvw[2], 1, order);
    double a = atan2(sin4,cos4)/4.0;
    normalizeAngle (a);
    return a;
}
Пример #3
0
std::vector<double> BGMBase::get_field_value(double u, double v, double w,
                                             const VectorStorageType &data)
{
  // TODO C++11 remove const_cast and enforce const-correctness otherwise
  MElement *e = const_cast<MElement *>(findElement(u, v, w));

  if(!e) return std::vector<double>(3, -1000.);

  std::vector<std::vector<double> > val = get_nodal_values(e, data);
  std::vector<double> element_uvw = get_element_uvw_from_xyz(e, u, v, w);

  std::vector<double> res(3);

  for(int j = 0; j < 3; j++) {
    std::vector<double> values(e->getNumVertices());

    for(std::size_t i = 0; i < e->getNumVertices(); i++) {
      values[i] = val[i][j];
    }
    res[j] = e->interpolate(&values[0], element_uvw[0], element_uvw[1],
                            element_uvw[2], 1, order);
  }
  return res;
}