Newer
Older
// Gmsh - Copyright (C) 1997-2011 C. Geuzaine, J.-F. Remacle
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#include "GmshConfig.h"
#include "GmshMessage.h"
#include "MPoint.h"
#include "MLine.h"
#include "MTriangle.h"
#include "MQuadrangle.h"
#include "MTetrahedron.h"
#include "MHexahedron.h"
#include "MPrism.h"
#include "MPyramid.h"
#include "MElementCut.h"
double MElement::_isInsideTolerance = 1.e-6;
Gauthier Becker
committed
MElement::MElement(int num, int part) : _visible(1)
{
#pragma omp critical
{
if(num){
_num = num;
_globalNum = std::max(_globalNum, _num);
}
else{
_num = ++_globalNum;
}
Gauthier Becker
committed
_partition = (short)part;
Gauthier Becker
committed
void MElement::_getEdgeRep(MVertex *v0, MVertex *v1,
double *x, double *y, double *z, SVector3 *n,
{
x[0] = v0->x(); y[0] = v0->y(); z[0] = v0->z();
x[1] = v1->x(); y[1] = v1->y(); z[1] = v1->z();
if(faceIndex >= 0){
n[0] = n[1] = getFace(faceIndex).normal();
}
else{
MEdge e(v0, v1);
n[0] = n[1] = e.normal();
}
}
Gauthier Becker
committed
void MElement::_getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2,
Gauthier Becker
committed
x[0] = v0->x(); x[1] = v1->x(); x[2] = v2->x();
y[0] = v0->y(); y[1] = v1->y(); y[2] = v2->y();
z[0] = v0->z(); z[1] = v1->z(); z[2] = v2->z();
SVector3 t1(x[1] - x[0], y[1] - y[0], z[1] - z[0]);
SVector3 t2(x[2] - x[0], y[2] - y[0], z[2] - z[0]);
SVector3 normal = crossprod(t1, t2);
normal.normalize();
for(int i = 0; i < 3; i++) n[i] = normal;
}
if(CTX::instance()->hideUnselected && _visible < 2) return false;
Gauthier Becker
committed
return _visible;
double MElement::minEdge()
{
double m = 1.e25;
for(int i = 0; i < getNumEdges(); i++){
}
return m;
}
double MElement::maxEdge()
{
double m = 0.;
for(int i = 0; i < getNumEdges(); i++){
}
return m;
}
double MElement::rhoShapeMeasure()
{
double min = minEdge();
double max = maxEdge();
if(max)
return min / max;
else
return 0.;
}
void MElement::getNode(int num, double &u, double &v, double &w)
{
// only for MElements that don't have a lookup table for this
// (currently only 1st order elements have)
double uvw[3];
MVertex* ver = getVertex(num);
double xyz[3] = {ver->x(), ver->y(), ver->z()};
xyz2uvw(xyz, uvw);
u = uvw[0];
v = uvw[1];
w = uvw[2];
}
void MElement::getShapeFunctions(double u, double v, double w, double s[], int o)

Christophe Geuzaine
committed
const polynomialBasis* fs = getFunctionSpace(o);
else Msg::Error("Function space not implemented for this type of element");
Gauthier Becker
committed
void MElement::getGradShapeFunctions(double u, double v, double w, double s[][3],

Christophe Geuzaine
committed
const polynomialBasis* fs = getFunctionSpace(o);
else Msg::Error("Function space not implemented for this type of element");
Gauthier Becker
committed
void MElement::getHessShapeFunctions(double u, double v, double w, double s[][3][3],
int o)
{
const polynomialBasis* fs = getFunctionSpace(o);
if(fs) fs->ddf(u, v, w, s);
else Msg::Error("Function space not implemented for this type of element");
}
int n = getNumVertices();
for(int i = 0; i < n; i++) {
MVertex *v = getVertex(i);
p[0] += v->x();
p[1] += v->y();
p[2] += v->z();
p[0] /= (double)n;
p[1] /= (double)n;
p[2] /= (double)n;
return p;
double MElement::getVolume()
{
int npts;
IntPt *pts;
getIntegrationPoints(getDim() * (getPolynomialOrder() - 1), &npts, &pts);
double vol = 0.;
for (int i = 0; i < npts; i++){
vol += getJacobianDeterminant(pts[i].pt[0], pts[i].pt[1], pts[i].pt[2])
* pts[i].weight;
}
return vol;
}
int MElement::getVolumeSign()
{
double v = getVolume();
if(v < 0.) return -1;
else if(v > 0.) return 1;
else return 0;
}
bool MElement::setVolumePositive()
{
int s = getVolumeSign();
if(s < 0) revert();
if(!s) return false;
return true;
}
std::string MElement::getInfoString()
{
char tmp[256];
sprintf(tmp, "Element %d", getNum());
return std::string(tmp);
}
static double _computeDeterminantAndRegularize(MElement *ele, double jac[3][3])
Loading
Loading full blame...