double Interpolation3D::calculateIntersectionVolume(const MeshElement& srcElement, const MeshElement& targetElement)
{
- // std::cout << "Intersecting elems " << srcElement.getIndex() << " and " << targetElement.getIndex() << std::endl;
+ //std::cout << "Intersecting elems " << srcElement.getIndex() << " and " << targetElement.getIndex() << std::endl;
// (a), (b) and (c) not yet implemented
// (d) : without fine-level filtering (a) - (c) for the time being
-
+
+ std::cout << "Source : ";
+ srcElement.dumpCoords();
+ std::cout << "Target : ";
+ targetElement.dumpCoords();
+
// get array of points of target tetraeder
const double* tetraCorners[4];
for(int i = 0 ; i < 4 ; ++i)
// create AffineTransform
TetraAffineTransform T( tetraCorners );
- std::cout << "Transform : " << std::endl;
- T.dump();
- std::cout << std::endl;
-
+
+ // check if we have planar tetra element
if(T.determinant() == 0.0)
{
// tetra is planar
return 0.0;
}
+ std::cout << "Transform : " << std::endl;
+ T.dump();
+ std::cout << std::endl;
+
// triangulate source element faces (assumed tetraeder for the time being)
// do nothing
vector<TransformedTriangle> triangles;
//? fault in article, Grandy, [8] : it is the determinant of the inverse transformation that
// should be used
- return 1.0 / T.determinant() * volume ;
+ return std::abs(1.0 / T.determinant() * volume) ;
}
}
*/
const double* MeshElement::getCoordsOfNode(int node) const
{
+ assert(node >= 1);
+ assert(node <= getNumberNodes());
const int nodeOffset = node - 1;
const int elemIdx = _mesh->getConnectivityIndex(MED_NODAL, MED_CELL)[_index] - 1;
- return &(_mesh->getCoordinates(MED_FULL_INTERLACE)[elemIdx + 3*nodeOffset]);
+ const int connIdx = _mesh->getConnectivity(MED_FULL_INTERLACE, MED_NODAL, MED_CELL, MED_ALL_ELEMENTS)[elemIdx + nodeOffset] - 1;
+ return &(_mesh->getCoordinates(MED_FULL_INTERLACE)[3*connIdx]);
}
/**
CELLMODEL faceModel(faceType);
assert(faceModel.getDimension() == 2);
+ assert(faceModel.getNumberOfNodes() == 3);
double transformedNodes[3 * faceModel.getNumberOfNodes()];
- const double* coords = _mesh->getCoordinates(MED_FULL_INTERLACE);
+
// loop over nodes of face
for(int j = 1; j <= faceModel.getNumberOfNodes(); ++j)
//{ not totally efficient since we transform each node once per face
T.apply(&transformedNodes[3*(j-1)], node);
+ std::cout << "Node " << localNodeNumber << " = " << vToStr(node) << " transformed to " << vToStr(&transformedNodes[3*(j-1)]) << std::endl;
+
}
assert(faceType == MED_TRIA3);
- // create triangles from face
+ // create transformed triangles from face
switch(faceType)
{
case MED_TRIA3:
}
}
#endif
+
int MeshElement::getIndex() const
{
return _index + 1;
}
+ void MeshElement::dumpCoords() const
+ {
+ std::cout << "Element " << _index + 1 << " has nodes " << std::endl;
+ for(int i = 1 ; i <= getNumberNodes() ; ++i)
+ {
+ std::cout << vToStr(getCoordsOfNode(i)) << ", ";
+ }
+ std::cout << std::endl;
+ }
+
/// ElementBBoxOrder
bool ElementBBoxOrder::operator()( MeshElement* elem1, MeshElement* elem2)
int getIndex() const;
+ void dumpCoords() const;
+
private:
const int _index;
const MEDMEM::MESH* _mesh;
m = interpolator->interpol_maillages(sMesh, tMesh);
- dumpIntersectionMatrix(m);
-
std::cout << "Intersection calculation done. " << std::endl << std::endl;
}
TetraAffineTransform(const double** pts)
{
- std::cout << "Creating transform from tetraeder : " << std::endl;
- std::cout << vToStr(pts[0]) << ", " << vToStr(pts[1]) << ", " << vToStr(pts[2]) << ", " << vToStr(pts[3]) << ", " << std::endl;
+ // std::cout << "Creating transform from tetraeder : " << std::endl;
+ // std::cout << vToStr(pts[0]) << ", " << vToStr(pts[1]) << ", " << vToStr(pts[2]) << ", " << vToStr(pts[3]) << ", " << std::endl;
#if 0
do {
// calculate point
for(int i = 0; i < 3; ++i)
{
- std::cout << "tA = " << tA << " tB = " << tB << " alpha= " << alpha << std::endl;
+ // std::cout << "tA = " << tA << " tB = " << tB << " alpha= " << alpha << std::endl;
pt[i] = (1 - alpha) * COORDS_TET_CORNER[3*corners[0] + i] +
alpha * COORDS_TET_CORNER[3*corners[1] + i];
- std::cout << pt[i] << std::endl;
- //assert(pt[i] >= 0.0);
- //assert(pt[i] <= 1.0);
+ // std::cout << pt[i] << std::endl;
+ assert(pt[i] >= 0.0);
+ assert(pt[i] <= 1.0);
}
}
// special case : facet H = 0
bool cond2 = (facet == NO_TET_FACET) ? testSegmentIntersectsHPlane(seg) : testSegmentIntersectsFacet(seg, facet);
- std::cout << "Halfstrip tests (" << seg << ", " << edge << ") : " << (cVals[0]*cVals[1] < 0.0) << ", " << cond2 << ", " << (cVals[2]*cVals[3] > 0.0) << std::endl;
- std::cout << "c2 = " << cVals[2] << ", c3 = " << cVals[3] << std::endl;
+ // std::cout << "Halfstrip tests (" << seg << ", " << edge << ") : " << (cVals[0]*cVals[1] < 0.0) << ", " << cond2 << ", " << (cVals[2]*cVals[3] > 0.0) << std::endl;
+ // std::cout << "c2 = " << cVals[2] << ", c3 = " << cVals[3] << std::endl;
return (cVals[0]*cVals[1] < 0.0) && cond2 && (cVals[2]*cVals[3] > 0.0);
}
const double cQR = calcStableC(QR, DoubleProduct(edge));
const double cRP = calcStableC(RP, DoubleProduct(edge));
- std::cout << "TriangleSurroundsEdge : edge = " << edge << " c = [" << cPQ << ", " << cQR << ", " << cRP << "]" << std::endl;
+ // std::cout << "TriangleSurroundsEdge : edge = " << edge << " c = [" << cPQ << ", " << cQR << ", " << cRP << "]" << std::endl;
// if two or more c-values are zero we disallow x-edge intersection
// Grandy, p.446
if(numZeros >= 2 )
{
- std::cout << "TriangleSurroundsEdge test fails due to too many 0 dp" << std::endl;
+ // std::cout << "TriangleSurroundsEdge test fails due to too many 0 dp" << std::endl;
}
return (cPQ*cQR >= 0.0) && (cQR*cRP >= 0.0) && (cRP*cPQ >= 0.0) && numZeros < 2;
const double t2 = calcStableT(TRIPLE_PRODUCTS[2*edge + 1]);
//? should equality with zero use epsilon?
- std::cout << "testEdgeIntersectsTriangle : t1 = " << t1 << " t2 = " << t2 << std::endl;
+ // std::cout << "testEdgeIntersectsTriangle : t1 = " << t1 << " t2 = " << t2 << std::endl;
return (t1*t2 <= 0.0) && (t1 - t2 != 0.0);
}
//? NB here we have no correction for precision - is this good?
// Our authority Grandy says nothing
- std::cout << "dp in triSurrRay for corner " << corner << " = [" << cPQ << ", " << cQR << ", " << cRP << "]" << std::endl;
+ // std::cout << "dp in triSurrRay for corner " << corner << " = [" << cPQ << ", " << cQR << ", " << cRP << "]" << std::endl;
return ( cPQ*cQR > 0.0 ) && ( cPQ*cRP > 0.0 );
}