$extrastylesheet
inf_fe_map_eval.C
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 // Local includes
00020 #include "libmesh/libmesh_config.h"
00021 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
00022 #include "libmesh/inf_fe.h"
00023 
00024 namespace libMesh
00025 {
00026 
00027 // Anonymous namespace for local helper functions
00028 namespace {
00029 
00030 Real infinite_map_eval(Real v, unsigned i)
00031 {
00032   libmesh_assert (-1.-1.e-5 <= v && v < 1.);
00033 
00034   switch (i)
00035     {
00036     case 0:
00037       return -2.*v/(1.-v);
00038     case 1:
00039       return (1.+v)/(1.-v);
00040 
00041     default:
00042       libmesh_error_msg("bad index i = " << i);
00043     }
00044 
00045   libmesh_error_msg("We'll never get here!");
00046   return 0.;
00047 }
00048 
00049 
00050 
00051 Real infinite_map_eval_deriv(Real v, unsigned i)
00052 {
00053   libmesh_assert (-1.-1.e-5 <= v && v < 1.);
00054 
00055   switch (i)
00056     {
00057     case 0:
00058       return -2./((1.-v)*(1.-v));
00059     case 1:
00060       return 2./((1.-v)*(1.-v));
00061 
00062     default:
00063       libmesh_error_msg("bad index i = " << i);
00064     }
00065 
00066   libmesh_error_msg("We'll never get here!");
00067   return 0.;
00068 }
00069 
00070 } // anonymous namespace
00071 
00072 
00073   // Specialize the eval() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
00074   // to call the local helper function from the anonymous namespace.
00075 template <> Real InfFE<1,INFINITE_MAP,CARTESIAN>::eval(Real v, Order, unsigned i) { return infinite_map_eval(v, i); }
00076 template <> Real InfFE<2,INFINITE_MAP,CARTESIAN>::eval(Real v, Order, unsigned i) { return infinite_map_eval(v, i); }
00077 template <> Real InfFE<3,INFINITE_MAP,CARTESIAN>::eval(Real v, Order, unsigned i) { return infinite_map_eval(v, i); }
00078 
00079 // Specialize the eval_deriv() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
00080 // to call the local helper function from the anonymous namespace.
00081 template <> Real InfFE<1,INFINITE_MAP,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return infinite_map_eval_deriv(v, i); }
00082 template <> Real InfFE<2,INFINITE_MAP,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return infinite_map_eval_deriv(v, i); }
00083 template <> Real InfFE<3,INFINITE_MAP,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return infinite_map_eval_deriv(v, i); }
00084 
00085 } // namespace libMesh
00086 
00087 #endif // LIBMESH_ENABLE_INFINITE_ELEMENTS