AFEPack
|
00001 00006 #ifndef _FEMSpace_vector_value_templates_h_ 00007 #define _FEMSpace_vector_value_templates_h_ 00008 00009 #define value_type nVector<vector_length, double> 00010 #define vector_zero value_type(0.0) 00011 #define Number double 00012 00013 template <> 00014 value_type FEMFunction<value_type,DIM,DOW,TDIM,Number>::value(const afepack::Point<DOW>& p, 00015 const Element<value_type,DIM,DOW,TDIM>& e) const 00016 { 00017 int i, j, k; 00018 value_type val; 00019 const std::vector<int>& dof = e.dof(); 00020 std::vector<value_type> basis_value = e.basis_function_value(p); 00021 j = dof.size(); 00022 for (i = 0, val = vector_zero;i < j;i ++) { 00023 for (k = 0;k < vector_length;k ++) { 00024 val[k] += (*this)(dof[i])*basis_value[i][k]; 00025 } 00026 } 00027 return val; 00028 } 00029 00030 template <> 00031 std::vector<value_type> 00032 FEMFunction<value_type,DIM,DOW,TDIM,Number>::gradient(const afepack::Point<DOW>& p, 00033 const Element<value_type,DIM,DOW,TDIM>& e) const 00034 { 00035 int i, j, k, l; 00036 std::vector<value_type> val(DOW, vector_zero); 00037 const std::vector<int>& dof = e.dof(); 00038 std::vector<std::vector<value_type> > basis_gradient = e.basis_function_gradient(p); 00039 j = dof.size(); 00040 for (i = 0;i < j;i ++) { 00041 for (k = 0;k < DOW;k ++) { 00042 for (l = 0;l < vector_length;l ++) { 00043 val[k][l] += (*this)(dof[i])*basis_gradient[i][k][l]; 00044 } 00045 } 00046 } 00047 return val; 00048 } 00049 00050 template <> 00051 std::vector<value_type> 00052 FEMFunction<value_type,DIM,DOW,TDIM,Number>::value(const std::vector<afepack::Point<DOW> >& p, 00053 const Element<value_type,DIM,DOW,TDIM>& e) const 00054 { 00055 int i, j, i1, j1, k; 00056 i = p.size(); 00057 std::vector<value_type> val(i, vector_zero); 00058 const std::vector<int>& dof = e.dof(); 00059 j = dof.size(); 00060 std::vector<std::vector<value_type> > basis_value = e.basis_function_value(p); 00061 for (i1 = 0;i1 < i;i1 ++) { 00062 for (j1 = 0;j1 < j;j1 ++) { 00063 for (k = 0;k < vector_length;k ++) { 00064 val[i1][k] += (*this)(dof[j1])*basis_value[j1][i1][k]; 00065 } 00066 } 00067 } 00068 return val; 00069 } 00070 00071 template <> 00072 std::vector<std::vector<value_type> > 00073 FEMFunction<value_type,DIM,DOW,TDIM,Number>::gradient(const std::vector<afepack::Point<DOW> >& p, 00074 const Element<value_type,DIM,DOW,TDIM>& e) const 00075 { 00076 int i, j, i1, j1, l, m; 00077 i = p.size(); 00078 std::vector<std::vector<value_type> > val(i, std::vector<value_type>(DOW, vector_zero)); 00079 const std::vector<int>& dof = e.dof(); 00080 std::vector<std::vector<std::vector<value_type> > > basis_gradient = e.basis_function_gradient(p); 00081 j = dof.size(); 00082 for (i1 = 0;i1 < i;i1 ++) { 00083 for (j1 = 0;j1 < j;j1 ++) { 00084 for (m = 0;m < DOW;m ++) { 00085 for (l = 0;l < vector_length;l ++) { 00086 val[i1][m][l] += (*this)(dof[j1])*basis_gradient[j1][i1][m][l]; 00087 } 00088 } 00089 } 00090 } 00091 return val; 00092 } 00093 00094 00100 template <> 00101 value_type 00102 FEMFunction<value_type,DIM,DOW,TDIM,Number>::value(const std::vector<value_type>& basis_value, 00103 const Element<value_type,DIM,DOW,TDIM>& e) const 00104 { 00105 int i, j, l; 00106 value_type val; 00107 const std::vector<int>& dof = e.dof(); 00108 j = dof.size(); 00109 for (i = 0, val = vector_zero;i < j;i ++) { 00110 for (l = 0;l < vector_length;l ++) { 00111 val[l] += (*this)(dof[i])*basis_value[i][l]; 00112 } 00113 } 00114 return val; 00115 } 00116 00117 template <> 00118 std::vector<value_type> 00119 FEMFunction<value_type,DIM,DOW,TDIM,Number>::gradient(const std::vector<std::vector<value_type> >& basis_gradient, 00120 const Element<value_type,DIM,DOW,TDIM>& e) const 00121 { 00122 int i, j, k, l; 00123 std::vector<value_type> val(DOW, vector_zero); 00124 const std::vector<int>& dof = e.dof(); 00125 j = dof.size(); 00126 for (i = 0;i < j;i ++) { 00127 for (k = 0;k < DOW;k ++) { 00128 for (l = 0;l < vector_length;l ++) { 00129 val[k][l] += (*this)(dof[i])*basis_gradient[i][k][l]; 00130 } 00131 } 00132 } 00133 return val; 00134 } 00135 00136 template <> 00137 std::vector<value_type> 00138 FEMFunction<value_type,DIM,DOW,TDIM,Number>::value(const std::vector<std::vector<value_type> >& basis_value, 00139 const Element<value_type,DIM,DOW,TDIM>& e) const 00140 { 00141 int i, j, i1, j1, l; 00142 i = basis_value[0].size(); 00143 std::vector<value_type> val(i, vector_zero); 00144 const std::vector<int>& dof = e.dof(); 00145 j = dof.size(); 00146 for (i1 = 0;i1 < i;i1 ++) { 00147 for (j1 = 0;j1 < j;j1 ++) { 00148 for (l = 0;l < vector_length;l ++) { 00149 val[i1][l] += (*this)(dof[j1])*basis_value[j1][i1][l]; 00150 } 00151 } 00152 } 00153 return val; 00154 } 00155 00156 template <> 00157 std::vector<std::vector<value_type> > 00158 FEMFunction<value_type,DIM,DOW,TDIM,Number>::gradient(const std::vector<std::vector<std::vector<value_type> > >& basis_gradient, 00159 const Element<value_type,DIM,DOW,TDIM>& e) const 00160 { 00161 int i, j, i1, j1, l, m; 00162 i = basis_gradient[0].size(); 00163 std::vector<std::vector<value_type> > val(i, std::vector<value_type>(DIM, vector_zero)); 00164 const std::vector<int>& dof = e.dof(); 00165 j = dof.size(); 00166 for (i1 = 0;i1 < i;i1 ++) { 00167 for (j1 = 0;j1 < j;j1 ++) { 00168 for (m = 0;m < DOW;m ++) { 00169 for (l = 0;l < vector_length;l ++) { 00170 val[i1][m][l] += (*this)(dof[j1])*basis_gradient[j1][i1][m][l]; 00171 } 00172 } 00173 } 00174 } 00175 return val; 00176 } 00177 00178 #undef value_type 00179 #undef vector_zero 00180 #undef Number 00181 00182 #endif // _FEMSpace_vector_value_templates_h_ 00183