Ejemplo n.º 1
0
void Interpolator<Complex>::
interpolate(const MElement& element,
            const FunctionSpace& fs,
            const std::vector<Complex>& coef,
            const fullVector<double>& xyz,
            fullVector<Complex>& value){

  // Real & Imaginary //
  const size_t size = coef.size();

  vector<double> coefReal(size);
  vector<double> coefImag(size);

  for(size_t i = 0; i < size; i++)
    coefReal[i] = coef[i].real();

  for(size_t i = 0; i < size; i++)
    coefImag[i] = coef[i].imag();

  // Scalar or Vector ?
  const bool isScalar = fs.isScalar();

  if(isScalar){
    // Function Space Scalar
    const FunctionSpaceScalar* fsScalar =
      static_cast<const FunctionSpaceScalar*>(&fs);

    // Alloc value
    value.resize(1);

    // Interpolate
    double real = fsScalar->interpolate(element, coefReal, xyz);
    double imag = fsScalar->interpolate(element, coefImag, xyz);

    // Complex
    value(0) = Complex(real, imag);
  }

  else{
    // Function Space Vector
    const FunctionSpaceVector* fsVector =
      static_cast<const FunctionSpaceVector*>(&fs);

    // Alloc value
    value.resize(3);

    // Interpolate
    fullVector<double> real = fsVector->interpolate(element, coefReal, xyz);
    fullVector<double> imag = fsVector->interpolate(element, coefImag, xyz);

    // Complex
    value(0) = Complex(real(0), imag(0));
    value(1) = Complex(real(1), imag(1));
    value(2) = Complex(real(2), imag(2));
  }
}
Ejemplo n.º 2
0
void Interpolator<double>::
interpolate(const MElement& element,
            const FunctionSpace& fs,
            const std::vector<double>& coef,
            const fullVector<double>& xyz,
            fullVector<double>& value){

  // Scalar or Vector ?
  const bool isScalar = fs.isScalar();

  if(isScalar){
    // Function Space Scalar
    const FunctionSpaceScalar* fsScalar =
      static_cast<const FunctionSpaceScalar*>(&fs);

    // Alloc value
    value.resize(1);

    // Interpolate
    value(0) = fsScalar->interpolate(element, coef, xyz);
  }

  else{
    // Function Space Vector
    const FunctionSpaceVector* fsVector =
      static_cast<const FunctionSpaceVector*>(&fs);

    // Alloc & Interpolate
    value = fsVector->interpolate(element, coef, xyz);
  }
}
Ejemplo n.º 3
0
bool fullMatrix<double>::luFactor(fullVector<int> &ipiv)
{
  int M = size1(), N = size2(), lda = size1(), info;
  ipiv.resize(std::min(M, N));
  F77NAME(dgetrf)(&M, &N, _data, &lda, &ipiv(0), &info);
  if(info == 0) return true;
  return false;
}
Ejemplo n.º 4
0
void Quadrature::point(fullMatrix<double>& gC,
                       fullVector<double>& gW){
  gW.resize(1);
  gC.resize(1, 1);

  gW(0)    = 1;
  gC(0, 0) = 0;
  gC(0, 1) = 0;
  gC(0, 2) = 0;
}
Ejemplo n.º 5
0
template<class T2> void LinearTermBase<T2>::get(MElement *ele, int npts, IntPt *GP, fullVector<T2> &vec) const
{
  std::vector<fullVector<T2> > vv;
  vv.resize(npts);
  get(ele,npts,GP,vv);
  int nbFF=vv[0].size();
  vec.resize(nbFF);
  vec.setAll(T2());
  double jac[3][3];
  for(int i = 0; i < npts; i++)
  {
    const double u = GP[i].pt[0]; const double v = GP[i].pt[1]; const double w = GP[i].pt[2];
    const double weight = GP[i].weight; const double detJ = ele->getJacobian(u, v, w, jac);
    for(int j = 0; j < nbFF; j++)
    {
      double contrib = weight * detJ;
      vec(j) += contrib*vv[i](j);
    }
  }
}
Ejemplo n.º 6
0
template<class T1> void LoadTerm<T1>::get(MElement *ele, int npts, IntPt *GP, fullVector<double> &m) const
{
  if(ele->getParent()) ele = ele->getParent();
  int nbFF = LinearTerm<T1>::space1.getNumKeys(ele);
  double jac[3][3];
  m.resize(nbFF);
  m.scale(0.);
  for(int i = 0; i < npts; i++){
    const double u = GP[i].pt[0]; const double v = GP[i].pt[1]; const double w = GP[i].pt[2];
    const double weight = GP[i].weight; const double detJ = ele->getJacobian(u, v, w, jac);
    std::vector<typename TensorialTraits<T1>::ValType> Vals;
    LinearTerm<T1>::space1.f(ele, u, v, w, Vals);
    SPoint3 p;
    ele->pnt(u, v, w, p);
    typename TensorialTraits<T1>::ValType load = (*Load)(p.x(), p.y(), p.z());
    for(int j = 0; j < nbFF ; ++j)
    {
      m(j) += dot(Vals[j], load) * weight * detJ;
    }
  }
}