1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
// This file is part of ff3d - http://www.freefem.org/ff3d
// Copyright (C) 2001, 2002, 2003 Stphane Del Pino
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// $Id: CartesianHexahedron.hpp,v 1.9 2005/04/20 22:09:41 delpinux Exp $
#ifndef CARTESIAN_HEXAHEDRON_HPP
#define CARTESIAN_HEXAHEDRON_HPP
/**
* @file CartesianHexahedron.hpp
* @author Stephane Del Pino
* @date Wed Nov 27 13:12:18 2002
*
* @brief Rectangular Haxaheron
*
*
*/
#include <Cell.hpp>
#include <Quadrangle.hpp>
class CartesianHexahedron
: public Cell
{
public:
enum {
NumberOfVertices = 8, /**< number of vertices */
NumberOfFaces = 6, /**< number of faces */
NumberOfEdges = 12 /**< number of edges */
};
typedef Quadrangle FaceType;
static const size_t faces[NumberOfFaces][FaceType::NumberOfVertices];
static const size_t edges[NumberOfEdges][Edge::NumberOfVertices];
virtual Cell::Type type() const
{
return Cell::cartesianHexahedron;
}
/**
* computes local coordinates in the current hexahedron related to a
* given \a X position, in the basis of the reference element.
*
* @param X Cartesian coordinates
* @param lambda local coordinates
*
*/
void getLocalCoordinates(const TinyVector<3, real_t>& X,
TinyVector<3, real_t>& lambda) const
{
const TinyVector<3>& a = *__vertices[0];
const TinyVector<3>& b = *__vertices[6];
lambda = X-a;
for (size_t i=0; i<3; ++i) {
lambda[i] /= b[i]-a[i];
}
}
//! Number of Vertices.
size_t numberOfVertices() const
{
return NumberOfVertices;
}
//! Number of Edges.
size_t numberOfEdges() const
{
return NumberOfEdges;
}
//! sets equal to a given CartesianHexahedrons.
inline const CartesianHexahedron& operator=(const CartesianHexahedron& H)
{
Cell::operator=(H);
return *this;
}
//! Default constructor does nothing but reserving memory
CartesianHexahedron()
: Cell(NumberOfVertices)
{
;
}
CartesianHexahedron(Vertex& x0,
Vertex& x1,
Vertex& x2,
Vertex& x3,
Vertex& x4,
Vertex& x5,
Vertex& x6,
Vertex& x7)
: Cell(NumberOfVertices)
{
__vertices[0] = &x0;
__vertices[1] = &x1;
__vertices[2] = &x2;
__vertices[3] = &x3;
__vertices[4] = &x4;
__vertices[5] = &x5;
__vertices[6] = &x6;
__vertices[7] = &x7;
const TinyVector<3>& a = *__vertices[0];
const TinyVector<3>& b = *__vertices[6];
const real_t hx = b[0] - a[0];
const real_t hy = b[1] - a[1];
const real_t hz = b[2] - a[2];
__volume = hx*hy*hz;
}
~CartesianHexahedron()
{
;
}
};
#endif // CARTESIAN_HEXAHEDRON_HPP
|