Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _CHAINCON_AWDIAGCUBS_H_
00030 #define _CHAINCON_AWDIAGCUBS_H_
00031
00032
00033
00034 #include <istream>
00035 #include <ostream>
00036
00037
00038 #include "chomp/system/config.h"
00039 #include "chomp/cubes/pointbas.h"
00040
00041
00042 #include "chaincon/cubcell.h"
00043 #include "chaincon/combtensor.h"
00044 #include "chaincon/combchain.h"
00045 #include "chaincon/simplex.h"
00046 #include "chaincon/awdiagsim.h"
00047 #include "chaincon/awdiag.h"
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 template <class CoordT>
00060 inline tCombTensor<tCubCell<CoordT> > AWdiagonal (const tCubCell<CoordT> &c)
00061 {
00062
00063 if (c. dim () != 2)
00064 throw "A-W diagonal implemented for 2-dim cubes only.";
00065
00066
00067 int dim = c. spaceDim ();
00068 CoordT coord [4] [chomp::homology::MaxBasDim];
00069 int indices [2];
00070 int index = 0;
00071 for (int i = 0; i < dim; ++ i)
00072 {
00073 coord [0] [i] = c. left (i);
00074 coord [3] [i] = c. right (i);
00075 if (coord [0] [i] != coord [3] [i])
00076 {
00077 coord [1] [i] = index ? coord [3] [i] :
00078 coord [0] [i];
00079 coord [2] [i] = index ? coord [0] [i] :
00080 coord [3] [i];
00081 indices [index ++] = i;
00082 }
00083 else
00084 {
00085 coord [1] [i] = coord [0 ][i];
00086 coord [2] [i] = coord [0] [i];
00087 }
00088 }
00089
00090
00091 int_t num [4];
00092 for (int i = 0; i < 4; ++ i)
00093 {
00094 num [i] = chomp::homology::tPointBase<CoordT>::number
00095 (coord [i], dim);
00096 }
00097
00098
00099 tCombChain<tSimplex<int_t> > s;
00100 int_t numbers [3];
00101 numbers [0] = num [0];
00102 numbers [1] = num [1];
00103 numbers [2] = num [3];
00104 std::sort (numbers, numbers + 3);
00105 s. add (tSimplex<int_t> (2, numbers));
00106 numbers [0] = num [0];
00107 numbers [1] = num [2];
00108 numbers [2] = num [3];
00109 std::sort (numbers, numbers + 3);
00110 s. add (tSimplex<int_t> (2, numbers));
00111
00112
00113 tCombTensor<tSimplex<int_t> > simplTensor (AWdiagonal (s));
00114
00115
00116
00117 tCombTensor<tCubCell<CoordT> > tensor;
00118 int_t size = simplTensor. size ();
00119 for (int_t n = 0; n < size; ++ n)
00120 {
00121
00122
00123 tSimplex<int_t> sim [2];
00124 for (int side = 0; side < 2; ++ side)
00125 {
00126 sim [side] = side ? simplTensor. right (n) :
00127 simplTensor. left (n);
00128 }
00129 if ((sim [0]. dim () != 1) || (sim [1]. dim () != 1))
00130 continue;
00131
00132
00133 int_t vert [2] [2];
00134 for (int side = 0; side < 2; ++ side)
00135 {
00136 for (int v = 0; v < 2; ++ v)
00137 {
00138 int_t n = sim [side] [v];
00139 int index = 0;
00140 while (num [index] != n)
00141 ++ index;
00142 vert [side] [v] = index;
00143 }
00144 if (vert [side] [0] > vert [side] [1])
00145 std::swap (vert [side] [0], vert [side] [1]);
00146 }
00147
00148
00149 tCombChain<tCubCell<CoordT> > cc [2];
00150 for (int side = 0; side < 2; ++ side)
00151 {
00152 if ((vert [side] [0] == 0) && (vert [side] [1] == 3))
00153 {
00154 cc [side]. add (tCubCell<CoordT> (dim,
00155 coord [0], coord [1]));
00156 cc [side]. add (tCubCell<CoordT> (dim,
00157 coord [1], coord [3]));
00158 }
00159 else
00160 {
00161 cc [side]. add (tCubCell<CoordT> (dim,
00162 coord [vert [side] [0]],
00163 coord [vert [side] [1]]));
00164 }
00165 }
00166
00167
00168 for (int_t i = 0; i < cc [0]. size (); ++ i)
00169 {
00170 for (int_t j = 0; j < cc [1]. size (); ++ j)
00171 {
00172 tensor. add (cc [0] [i], cc [1] [j]);
00173 }
00174 }
00175 }
00176
00177 return tensor;
00178 }
00179
00180
00181 #endif // _CHAINCON_AWDIAGCUBS_H_
00182