Go to the documentation of this file.00001 #ifndef VIENNAFEM_TRANSFORM_HEXAHEDRON_HPP
00002 #define VIENNAFEM_TRANSFORM_HEXAHEDRON_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <iostream>
00018 #include <utility>
00019 #include "viennagrid/topology/triangle.hpp"
00020 #include "viennagrid/algorithm/spanned_volume.hpp"
00021 #include "viennagrid/domain.hpp"
00022 #include "viennafem/forwards.h"
00023
00024 #include "viennamath/manipulation/simplify.hpp"
00025
00030 namespace viennafem
00031 {
00032
00033 template <>
00034 struct dt_dx_handler<viennafem::unit_cube>
00035 {
00036 public:
00037
00038 template <typename CellType>
00039 static void apply(CellType const & cell)
00040 {
00041 typedef typename CellType::config_type Config;
00042 typedef typename viennagrid::result_of::point<Config>::type PointType;
00043
00044 PointType const & p0 = viennagrid::ncells<0>(cell)[0].point();
00045 PointType const & p1 = viennagrid::ncells<0>(cell)[1].point();
00046 PointType const & p2 = viennagrid::ncells<0>(cell)[2].point();
00047 PointType const & p3 = viennagrid::ncells<0>(cell)[3].point();
00048
00049 PointType const & p4 = viennagrid::ncells<0>(cell)[4].point();
00050 PointType const & p5 = viennagrid::ncells<0>(cell)[5].point();
00051 PointType const & p6 = viennagrid::ncells<0>(cell)[6].point();
00052 PointType const & p7 = viennagrid::ncells<0>(cell)[7].point();
00053
00054
00055
00056
00057
00058
00059
00060
00061 PointType a_0 = p1 - p0;
00062 PointType a_1 = p2 - p0;
00063 PointType a_2 = p4 - p0;
00064 PointType a_01 = p0 - p1 - p2 + p3;
00065 PointType a_02 = p0 - p1 - p4 + p5;
00066 PointType a_12 = p0 - p2 - p4 + p6;
00067 PointType a_012 = p1 - p0 + p2 - p3 + p4 - p5 - p6 + p7;
00068
00069 viennamath::variable xi(0);
00070 viennamath::variable eta(1);
00071 viennamath::variable nu(2);
00072
00073 viennamath::expr J_00 = a_0[0] + a_01[0] * eta + a_02[0] * nu + a_012[0] * eta * nu; viennamath::inplace_simplify(J_00);
00074 viennamath::expr J_10 = a_0[1] + a_01[1] * eta + a_02[1] * nu + a_012[1] * eta * nu; viennamath::inplace_simplify(J_10);
00075 viennamath::expr J_20 = a_0[2] + a_01[2] * eta + a_02[2] * nu + a_012[2] * eta * nu; viennamath::inplace_simplify(J_20);
00076
00077 viennamath::expr J_01 = a_1[0] + a_01[0] * xi + a_12[0] * nu + a_012[0] * xi * nu; viennamath::inplace_simplify(J_01);
00078 viennamath::expr J_11 = a_1[1] + a_01[1] * xi + a_12[1] * nu + a_012[1] * xi * nu; viennamath::inplace_simplify(J_11);
00079 viennamath::expr J_21 = a_1[2] + a_01[2] * xi + a_12[2] * nu + a_012[2] * xi * nu; viennamath::inplace_simplify(J_21);
00080
00081 viennamath::expr J_02 = a_2[0] + a_02[0] * xi + a_12[0] * eta + a_012[0] * xi * eta; viennamath::inplace_simplify(J_02);
00082 viennamath::expr J_12 = a_2[1] + a_02[1] * xi + a_12[1] * eta + a_012[1] * xi * eta; viennamath::inplace_simplify(J_12);
00083 viennamath::expr J_22 = a_2[2] + a_02[2] * xi + a_12[2] * eta + a_012[2] * xi * eta; viennamath::inplace_simplify(J_22);
00084
00085
00086 viennamath::expr det_J = J_00 * J_11 * J_22 + J_01 * J_12 * J_20 + J_02 * J_10 * J_21
00087 - J_20 * J_11 * J_02 - J_21 * J_12 * J_00 - J_22 * J_10 * J_01;
00088
00089 viennamath::inplace_simplify(det_J);
00090
00091 viennadata::access<det_dF_dt_key, viennamath::expr >()(cell) = det_J;
00092
00093
00094 typedef viennamath::expr ValueType;
00095
00096 viennadata::access<dt_dx_key<0, 0>, ValueType>()(cell) = viennamath::simplify(J_11*J_22 - J_21*J_12) / det_J;
00097 viennadata::access<dt_dx_key<0, 1>, ValueType>()(cell) = viennamath::simplify(J_21*J_02 - J_01*J_22) / det_J;
00098 viennadata::access<dt_dx_key<0, 2>, ValueType>()(cell) = viennamath::simplify(J_01*J_12 - J_11*J_02) / det_J;
00099
00100 viennadata::access<dt_dx_key<1, 0>, ValueType>()(cell) = viennamath::simplify(J_20*J_12 - J_10*J_22) / det_J;
00101 viennadata::access<dt_dx_key<1, 1>, ValueType>()(cell) = viennamath::simplify(J_00*J_22 - J_20*J_02) / det_J;
00102 viennadata::access<dt_dx_key<1, 2>, ValueType>()(cell) = viennamath::simplify(J_10*J_02 - J_00*J_12) / det_J;
00103
00104 viennadata::access<dt_dx_key<2, 0>, ValueType>()(cell) = viennamath::simplify(J_10*J_21 - J_20*J_11) / det_J;
00105 viennadata::access<dt_dx_key<2, 1>, ValueType>()(cell) = viennamath::simplify(J_20*J_01 - J_00*J_21) / det_J;
00106 viennadata::access<dt_dx_key<2, 2>, ValueType>()(cell) = viennamath::simplify(J_00*J_11 - J_10*J_01) / det_J;
00107 }
00108
00109 };
00110
00111
00112 }
00113
00114 #endif