MFEM v2.0
eltrans.cpp
Go to the documentation of this file.
00001 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
00002 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
00003 // reserved. See file COPYRIGHT for details.
00004 //
00005 // This file is part of the MFEM library. For more information and source code
00006 // availability see http://mfem.googlecode.com.
00007 //
00008 // MFEM is free software; you can redistribute it and/or modify it under the
00009 // terms of the GNU Lesser General Public License (as published by the Free
00010 // Software Foundation) version 2.1 dated February 1999.
00011 
00012 
00013 #include <math.h>
00014 #include "fem.hpp"
00015 
00016 const DenseMatrix & IsoparametricTransformation::Jacobian()
00017 {
00018    if (JacobianIsEvaluated)  return dFdx;
00019 
00020    dshape.SetSize(FElem->GetDof(), FElem->GetDim());
00021    dFdx.SetSize(PointMat.Height(), dshape.Width());
00022 
00023    FElem -> CalcDShape(*IntPoint, dshape);
00024    Mult(PointMat, dshape, dFdx);
00025 
00026    JacobianIsEvaluated = 1;
00027 
00028    return dFdx;
00029 }
00030 
00031 double IsoparametricTransformation::Weight()
00032 {
00033    if (FElem->GetDim() == 0)
00034       return 1.0;
00035    if (WeightIsEvaluated)
00036       return Wght;
00037    Jacobian();
00038    WeightIsEvaluated = 1;
00039    return (Wght = dFdx.Weight());
00040 }
00041 
00042 int IsoparametricTransformation::OrderJ()
00043 {
00044    switch (FElem->Space())
00045    {
00046    case FunctionSpace::Pk:
00047       return (FElem->GetOrder()-1);
00048    case FunctionSpace::Qk:
00049       return (FElem->GetOrder());
00050    default:
00051       mfem_error("IsoparametricTransformation::OrderJ()");
00052    }
00053    return 0;
00054 }
00055 
00056 int IsoparametricTransformation::OrderW()
00057 {
00058    switch (FElem->Space())
00059    {
00060    case FunctionSpace::Pk:
00061       return (FElem->GetOrder() - 1) * FElem->GetDim();
00062    case FunctionSpace::Qk:
00063       return (FElem->GetOrder() * FElem->GetDim() - 1);
00064    default:
00065       mfem_error("IsoparametricTransformation::OrderW()");
00066    }
00067    return 0;
00068 }
00069 
00070 int IsoparametricTransformation::OrderGrad(const FiniteElement *fe)
00071 {
00072    if (FElem->Space() == fe->Space())
00073    {
00074       int k = FElem->GetOrder();
00075       int d = FElem->GetDim();
00076       int l = fe->GetOrder();
00077       switch (fe->Space())
00078       {
00079       case FunctionSpace::Pk:
00080          return ((k-1)*(d-1)+(l-1));
00081       case FunctionSpace::Qk:
00082          return (k*(d-1)+(l-1));
00083       }
00084    }
00085    mfem_error("IsoparametricTransformation::OrderGrad(...)");
00086    return 0;
00087 }
00088 
00089 void IsoparametricTransformation::Transform (const IntegrationPoint &ip,
00090                                              Vector &trans)
00091 {
00092    shape.SetSize(FElem->GetDof());
00093    trans.SetSize(PointMat.Height());
00094 
00095    FElem -> CalcShape(ip, shape);
00096    PointMat.Mult(shape, trans);
00097 }
00098 
00099 void IsoparametricTransformation::Transform (const IntegrationRule &ir,
00100                                              DenseMatrix &tr)
00101 {
00102    int dof, n, dim, i, j, k;
00103 
00104    dim = PointMat.Height();
00105    dof = FElem->GetDof();
00106    n = ir.GetNPoints();
00107 
00108    shape.SetSize(dof);
00109    tr.SetSize(dim, n);
00110 
00111    for (j = 0; j < n; j++)
00112    {
00113       FElem -> CalcShape (ir.IntPoint(j), shape);
00114       for (i = 0; i < dim; i++)
00115       {
00116          tr(i, j) = 0.0;
00117          for (k = 0; k < dof; k++)
00118             tr(i, j) += PointMat(i, k) * shape(k);
00119       }
00120    }
00121 }
00122 
00123 void IntegrationPointTransformation::Transform (const IntegrationPoint &ip1,
00124                                                 IntegrationPoint &ip2)
00125 {
00126    double vec[3];
00127    Vector v (vec, Transf.GetPointMat().Height());
00128 
00129    Transf.Transform (ip1, v);
00130    ip2.x = vec[0];
00131    ip2.y = vec[1];
00132    ip2.z = vec[2];
00133 }
00134 
00135 void IntegrationPointTransformation::Transform (const IntegrationRule &ir1,
00136                                                 IntegrationRule &ir2)
00137 {
00138    int i, n;
00139 
00140    n = ir1.GetNPoints();
00141    for (i = 0; i < n; i++)
00142       Transform (ir1.IntPoint(i), ir2.IntPoint(i));
00143 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines