MPQC  3.0.0-alpha
tricoef.h
1 //
2 // tricoef.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _math_isosurf_tricoef_h
29 #define _math_isosurf_tricoef_h
30 
31 #include <util/ref/ref.h>
32 
33 namespace sc {
34 
36  private:
37  int order_;
38  double L2_;
39  double L3_;
40  public:
41  TriInterpCoefKey(int order, double L2, double L3):
42  order_(order), L2_(L2), L3_(L3) {}
43  int order() const { return order_; }
44  double L1() const { return 1.0 - L2_ - L3_; }
45  double L2() const { return L2_; }
46  double L3() const { return L3_; }
47  int cmp(const TriInterpCoefKey&t) const {
48  if (order_ < t.order_) return -1;
49  if (order_ > t.order_) return 1;
50  if (L2_ < t.L2_) return -1;
51  if (L2_ > t.L2_) return 1;
52  if (L3_ < t.L3_) return -1;
53  if (L3_ > t.L3_) return 1;
54  return 0;
55  }
56 };
57 
58 #define TriInterpCoefKeyEQ(k1,k2) ((k1).cmp(k2)==0)
59 #define TriInterpCoefKeyCMP(k1,k2) ((k1).cmp(k2))
60 
61 class TriInterpCoef: public RefCount {
62  double *coef_;
63  double *rderiv_;
64  double *sderiv_;
65  public:
66  TriInterpCoef(const TriInterpCoefKey& key);
67  ~TriInterpCoef();
68  double& coef(int i, int j, int k) {return coef_[ijk_to_index(i,j,k)];}
69  double& rderiv(int i, int j, int k) {return rderiv_[ijk_to_index(i,j,k)];}
70  double& sderiv(int i, int j, int k) {return sderiv_[ijk_to_index(i,j,k)];}
71 
72  static int
73  ijk_to_index(int i, int j, int k)
74  {
75  int n = i + j + k;
76  int ir = n - i;
77  return (ir*(ir+1)>>1) + j;
78  }
79 
80  static int
81  order_to_nvertex(int order)
82  {
83  return ((order+1)*(order+2)>>1);
84  }
85 };
86 
87 }
88 
89 #endif
90 
91 // Local Variables:
92 // mode: c++
93 // c-file-style: "CLJ"
94 // End:
sc::TriInterpCoefKey
Definition: tricoef.h:35
sc::TriInterpCoef
Definition: tricoef.h:61
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:192
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14

Generated at Sun Jan 26 2020 23:24:00 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.