Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

tricoef.h

00001 //
00002 // tricoef.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifndef _math_isosurf_tricoef_h
00029 #define _math_isosurf_tricoef_h
00030 
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034 
00035 #include <util/ref/ref.h>
00036 
00037 class TriInterpCoefKey {
00038   private:
00039     int order_;
00040     double L2_;
00041     double L3_;
00042   public:
00043     TriInterpCoefKey(int order, double L2, double L3):
00044       order_(order), L2_(L2), L3_(L3) {}
00045     int order() const { return order_; }
00046     double L1() const { return 1.0 - L2_ - L3_; }
00047     double L2() const { return L2_; }
00048     double L3() const { return L3_; }
00049     int cmp(const TriInterpCoefKey&t) const {
00050         if (order_ < t.order_) return -1;
00051         if (order_ > t.order_) return 1;
00052         if (L2_ < t.L2_) return -1;
00053         if (L2_ > t.L2_) return 1;
00054         if (L3_ < t.L3_) return -1;
00055         if (L3_ > t.L3_) return 1;
00056         return 0;
00057       }
00058 };
00059 
00060 #define TriInterpCoefKeyEQ(k1,k2) ((k1).cmp(k2)==0)
00061 #define TriInterpCoefKeyCMP(k1,k2) ((k1).cmp(k2))
00062 
00063 class TriInterpCoef: public RefCount {
00064     double *coef_;
00065     double *rderiv_;
00066     double *sderiv_;
00067   public:
00068     TriInterpCoef(const TriInterpCoefKey& key);
00069     ~TriInterpCoef();
00070     double& coef(int i, int j, int k) {return coef_[ijk_to_index(i,j,k)];}
00071     double& rderiv(int i, int j, int k) {return rderiv_[ijk_to_index(i,j,k)];}
00072     double& sderiv(int i, int j, int k) {return sderiv_[ijk_to_index(i,j,k)];}
00073 
00074     static int
00075     ijk_to_index(int i, int j, int k)
00076     {
00077       int n = i + j + k;
00078       int ir = n - i;
00079       return (ir*(ir+1)>>1) + j;
00080     }
00081 
00082     static int
00083     order_to_nvertex(int order)
00084     {
00085       return ((order+1)*(order+2)>>1);
00086     }
00087 };
00088 
00089 
00090 
00091 #endif
00092 
00093 // Local Variables:
00094 // mode: c++
00095 // c-file-style: "CLJ"
00096 // End:

Generated at Thu Oct 4 18:08:48 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.