Exemple #1
0
int main(int argc, char** argv) {
  GammaFunction<size_t> G_1;

  std::cout << "G_1(1): " << G_1(1) << std::endl;
  if (G_1(1) != 1)
    return 1;

  std::cout << "G_1(2): " << G_1(2) << std::endl;
  if (G_1(2) != 1)
    return 1;

  try {
    std::cout << "G_1(0): " << G_1(0) << std::endl;
  }
  catch (BadArgumentException<size_t>& e) {
    std::cout << e.what() << std::endl;
  }

  FactorialFunction f;
  if (G_1(10) != f(9))
    return 1;

  GammaFunction<double> G_2;

  std::cout << "G_2(0.5): " << G_2(0.5) << std::endl;
  if (fabs(G_2(0.5) - sqrt(M_PI)) > std::numeric_limits<double>::epsilon())
    return 1;

  std::cout << "G_2(1.0): " << G_2(1.0) << std::endl;
  if (fabs(G_2(1.0) - 1.0) > std::numeric_limits<double>::epsilon())
    return 1;

  return 0;
}
  void SurfaceScalarGradient<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    ScalarT midPlaneAvg;
    for (int cell=0; cell < workset.numCells; ++cell) {
      for (int pt=0; pt < numQPs; ++pt) {

        Intrepid2::Vector<MeshScalarT> G_0(3, refDualBasis, cell, pt, 0, 0);
        Intrepid2::Vector<MeshScalarT> G_1(3, refDualBasis, cell, pt, 1, 0);
        Intrepid2::Vector<MeshScalarT> G_2(3, refDualBasis, cell, pt, 2, 0);
        Intrepid2::Vector<MeshScalarT> N(3, refNormal,cell, pt, 0);

        Intrepid2::Vector<ScalarT> scalarGradPerpendicular(0, 0, 0);
        Intrepid2::Vector<ScalarT> scalarGradParallel(0, 0, 0);

       // Need to inverse basis [G_0 ; G_1; G_2] and none of them should be normalized
        Intrepid2::Tensor<MeshScalarT> gBasis(3, refDualBasis,cell, pt, 0, 0);
        Intrepid2::Tensor<MeshScalarT> invRefDualBasis(3);

        // This map the position vector from parent to current configuration in R^3
        gBasis = Intrepid2::transpose(gBasis);
       invRefDualBasis = Intrepid2::inverse(gBasis);

        Intrepid2::Vector<MeshScalarT> invG_0(3, &invRefDualBasis( 0, 0));
        Intrepid2::Vector<MeshScalarT> invG_1(3, &invRefDualBasis( 1, 0));
        Intrepid2::Vector<MeshScalarT> invG_2(3, &invRefDualBasis( 2, 0));

        // in-plane (parallel) contribution
        for (int node(0); node < numPlaneNodes; ++node) {
          int topNode = node + numPlaneNodes;
          midPlaneAvg = 0.5 * (nodalScalar(cell, node) + nodalScalar(cell, topNode));
          for (int i(0); i < numDims; ++i) {
            scalarGradParallel(i) += 
              refGrads(node, pt, 0) * midPlaneAvg * invG_0(i) +
              refGrads(node, pt, 1) * midPlaneAvg * invG_1(i);
          }
        }

        // normal (perpendicular) contribution
        for (int i(0); i < numDims; ++i) {
          scalarGradPerpendicular(i) = jump(cell,pt) / thickness *invG_2(i);
        }

        // assign components to MDfield ScalarGrad
        for (int i(0); i < numDims; ++i )
          scalarGrad(cell, pt, i) = scalarGradParallel(i) + scalarGradPerpendicular(i);
      }
    }
  }