Commit d96622e2 authored by Michael Turner's avatar Michael Turner

split off ho alignment code

parent 8fafbe50
......@@ -51,6 +51,7 @@ SET(NEKMESHUTILS_HEADERS
MeshElements/Pyramid.h
MeshElements/Prism.h
MeshElements/Hexahedron.h
MeshElements/HOAlignment.h
)
IF(NEKTAR_USE_MESHGEN)
......
////////////////////////////////////////////////////////////////////////////////
//
// File: Face.h
// File: Composite.h
//
// For more information, please see: http://www.nektar.info/
//
......@@ -29,12 +29,12 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Mesh manipulation objects.
// Description: Mesh Composite Object.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NekMeshUtils_MESHELEMENTS_COMPOSITE
#define NekMeshUtils_MESHELEMENTS_COMPOSITE
#ifndef NEKMESHUTILS_MESHELEMENTS_COMPOSITE
#define NEKMESHUTILS_MESHELEMENTS_COMPOSITE
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
#include <NekMeshUtils/MeshElements/Element.h>
......
////////////////////////////////////////////////////////////////////////////////
//
// File: Edge.h
// File: Edge.cpp
//
// For more information, please see: http://www.nektar.info/
//
......@@ -29,7 +29,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Mesh manipulation objects.
// Description: Mesh Edge.
//
////////////////////////////////////////////////////////////////////////////////
......@@ -37,6 +37,8 @@
#include <NekMeshUtils/CADSystem/CADCurve.h>
#include <NekMeshUtils/CADSystem/CADSurf.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
namespace Nektar
{
namespace NekMeshUtils
......
......@@ -29,16 +29,13 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Mesh manipulation objects.
// Description: Mesh Edge.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NekMeshUtils_MESHELEMENTS_EDGE
#define NekMeshUtils_MESHELEMENTS_EDGE
#ifndef NEKMESHUTILS_MESHELEMENTS_EDGE
#define NEKMESHUTILS_MESHELEMENTS_EDGE
#include <iomanip>
#include <LibUtilities/Foundations/ManagerAccess.h>
#include <SpatialDomains/SegGeom.h>
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
......
......@@ -29,14 +29,12 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Mesh manipulation objects.
// Description: Mesh element.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NekMeshUtils_MESHELEMENTS_ELEMENT
#define NekMeshUtils_MESHELEMENTS_ELEMENT
#include <iomanip>
#ifndef NEKMESHUTILS_MESHELEMENTS_ELEMENT
#define NEKMESHUTILS_MESHELEMENTS_ELEMENT
#include <LibUtilities/Foundations/PointsType.h>
#include <LibUtilities/BasicUtils/ShapeType.hpp>
......@@ -49,142 +47,7 @@ namespace Nektar
{
namespace NekMeshUtils
{
/**
* @brief A lightweight struct for dealing with high-order triangle
* alignment.
*
* The logic underlying these routines is taken from the original Nektar
* code.
*/
template <typename T> struct HOTriangle
{
HOTriangle(std::vector<int> pVertId, std::vector<T> pSurfVerts)
: vertId(pVertId), surfVerts(pSurfVerts)
{
}
HOTriangle(std::vector<int> pVertId) : vertId(pVertId)
{
}
/// The triangle vertex IDs
std::vector<int> vertId;
/// The triangle surface vertices -- templated so that this can
/// either be nodes or IDs.
std::vector<T> surfVerts;
/**
* @brief Rotates the triangle of data points inside #surfVerts
* counter-clockwise nrot times.
*
* @param nrot Number of times to rotate triangle.
*/
void Rotate(int nrot)
{
int n, i, j, cnt;
int np = ((int)sqrt(8.0 * surfVerts.size() + 1.0) - 1) / 2;
std::vector<T> tmp(np * np);
for (n = 0; n < nrot; ++n)
{
for (cnt = i = 0; i < np; ++i)
{
for (j = 0; j < np - i; ++j, cnt++)
{
tmp[i * np + j] = surfVerts[cnt];
}
}
for (cnt = i = 0; i < np; ++i)
{
for (j = 0; j < np - i; ++j, cnt++)
{
surfVerts[cnt] = tmp[(np - 1 - i - j) * np + i];
}
}
}
}
/**
* @brief Reflect data points inside #surfVerts.
*
* This applies a mapping essentially doing the following
* reordering:
*
* 9 9
* 7 8 -> 8 7
* 4 5 6 6 5 4
* 0 1 2 3 3 2 1 0
*/
void Reflect()
{
int i, j, cnt;
int np = ((int)sqrt(8.0 * surfVerts.size() + 1.0) - 1) / 2;
std::vector<T> tmp(np * np);
for (cnt = i = 0; i < np; ++i)
{
for (j = 0; j < np - i; ++j, cnt++)
{
tmp[i * np + np - i - 1 - j] = surfVerts[cnt];
}
}
for (cnt = i = 0; i < np; ++i)
{
for (j = 0; j < np - i; ++j, cnt++)
{
surfVerts[cnt] = tmp[i * np + j];
}
}
}
/**
* @brief Align this surface to a given vertex ID.
*/
void Align(std::vector<int> vertId)
{
if (vertId[0] == this->vertId[0])
{
if (vertId[1] == this->vertId[1] || vertId[1] == this->vertId[2])
{
if (vertId[1] == this->vertId[2])
{
Rotate(1);
Reflect();
}
}
}
else if (vertId[0] == this->vertId[1])
{
if (vertId[1] == this->vertId[0] || vertId[1] == this->vertId[2])
{
if (vertId[1] == this->vertId[0])
{
Reflect();
}
else
{
Rotate(2);
}
}
}
else if (vertId[0] == this->vertId[2])
{
if (vertId[1] == this->vertId[0] || vertId[1] == this->vertId[1])
{
if (vertId[1] == this->vertId[1])
{
Rotate(2);
Reflect();
}
else
{
Rotate(1);
}
}
}
}
};
/**
* @brief Basic information about an element.
*
......
......@@ -36,6 +36,8 @@
#include <NekMeshUtils/MeshElements/Face.h>
#include <NekMeshUtils/CADSystem/CADSurf.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
namespace Nektar
{
namespace NekMeshUtils
......
......@@ -36,6 +36,8 @@
#include <SpatialDomains/HexGeom.h>
#include <NekMeshUtils/MeshElements/Hexahedron.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
using namespace std;
namespace Nektar
......
......@@ -34,6 +34,9 @@
////////////////////////////////////////////////////////////////////////////////
#include <NekMeshUtils/MeshElements/Line.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
using namespace std;
namespace Nektar
......
......@@ -38,7 +38,10 @@
#include <SpatialDomains/PrismGeom.h>
#include <NekMeshUtils/MeshElements/Prism.h>
#include <NekMeshUtils/MeshElements/Quadrilateral.h>
#include <NekMeshUtils/MeshElements/HOAlignment.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
using namespace std;
namespace Nektar
......
......@@ -36,6 +36,8 @@
#include <LocalRegions/QuadExp.h>
#include <NekMeshUtils/MeshElements/Quadrilateral.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
using namespace std;
namespace Nektar
......
......@@ -86,158 +86,6 @@ public:
NEKMESHUTILS_EXPORT static unsigned int GetNumNodes(ElmtConfig pConf);
};
/**
* @brief A lightweight struct for dealing with high-order quadrilateral
* alignment.
*/
template <typename T> struct HOQuadrilateral
{
HOQuadrilateral(std::vector<int> pVertId, std::vector<T> pSurfVerts)
: vertId(pVertId), surfVerts(pSurfVerts)
{
}
HOQuadrilateral(std::vector<int> pVertId) : vertId(pVertId)
{
}
/// The quadrilateral vertex IDs
std::vector<int> vertId;
/// The quadrilateral surface vertices -- templated so that this can either
/// be nodes or IDs.
std::vector<T> surfVerts;
void ReverseX()
{
int np = (int)(sqrt((NekDouble)surfVerts.size()) + 0.5);
for (int i = 0; i < np; ++i)
{
for (int j = 0; j < np/2; ++j)
{
swap(surfVerts[i*np + j], surfVerts[i*np + np-j-1]);
}
}
}
void ReverseY()
{
int np = (int)(sqrt((NekDouble)surfVerts.size()) + 0.5);
// Reverse y direction
for (int j = 0; j < np; ++j)
{
for (int i = 0; i < np/2; ++i)
{
swap(surfVerts[i*np + j], surfVerts[(np-i-1)*np + j]);
}
}
}
void Transpose()
{
int np = (int)(sqrt((NekDouble)surfVerts.size()) + 0.5);
std::vector<T> tmp(surfVerts.size());
for (int i = 0; i < np; ++i)
{
for (int j = 0; j < np; ++j)
{
tmp[i*np+j] = surfVerts[j*np+i];
}
}
surfVerts = tmp;
}
/**
* @brief Align this surface to a given vertex ID.
*/
void Align(std::vector<int> vertId)
{
int vmap[4] = {-1, -1, -1, -1};
// Determine which vertices map to vertId
for (int i = 0; i < 4; ++i)
{
for (int j = 0; j < 4; ++j)
{
if (this->vertId[j] == vertId[i])
{
vmap[i] = j;
break;
}
}
ASSERTL1(vmap[i] != -1,
"Could not determine mapping between vertex IDs");
}
StdRegions::Orientation orient = StdRegions::eNoOrientation;
if (vmap[1] == (vmap[0]+1) % 4)
{
switch (vmap[0])
{
case 0:
orient = StdRegions::eDir1FwdDir1_Dir2FwdDir2;
break;
case 1:
orient = StdRegions::eDir1BwdDir2_Dir2FwdDir1;
break;
case 2:
orient = StdRegions::eDir1BwdDir1_Dir2BwdDir2;
break;
case 3:
orient = StdRegions::eDir1FwdDir2_Dir2BwdDir1;
break;
}
}
else
{
switch (vmap[0])
{
case 0:
orient = StdRegions::eDir1FwdDir2_Dir2FwdDir1;
break;
case 1:
orient = StdRegions::eDir1BwdDir1_Dir2FwdDir2;
break;
case 2:
orient = StdRegions::eDir1BwdDir2_Dir2BwdDir1;
break;
case 3:
orient = StdRegions::eDir1FwdDir1_Dir2BwdDir2;
break;
}
}
if (orient == StdRegions::eDir1FwdDir2_Dir2FwdDir1 ||
orient == StdRegions::eDir1BwdDir2_Dir2FwdDir1 ||
orient == StdRegions::eDir1FwdDir2_Dir2BwdDir1 ||
orient == StdRegions::eDir1BwdDir2_Dir2BwdDir1)
{
Transpose();
}
if (orient == StdRegions::eDir1BwdDir1_Dir2FwdDir2 ||
orient == StdRegions::eDir1BwdDir1_Dir2BwdDir2 ||
orient == StdRegions::eDir1FwdDir2_Dir2BwdDir1 ||
orient == StdRegions::eDir1BwdDir2_Dir2BwdDir1)
{
ReverseX();
}
if (orient == StdRegions::eDir1FwdDir1_Dir2BwdDir2 ||
orient == StdRegions::eDir1BwdDir1_Dir2BwdDir2 ||
orient == StdRegions::eDir1BwdDir2_Dir2FwdDir1 ||
orient == StdRegions::eDir1BwdDir2_Dir2BwdDir1)
{
ReverseY();
}
}
};
}
}
......
......@@ -40,6 +40,8 @@
#include <NekMeshUtils/MeshElements/Tetrahedron.h>
#include <NekMeshUtils/MeshElements/Triangle.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
using namespace std;
namespace Nektar
......
......@@ -37,6 +37,8 @@
#include <LocalRegions/TriExp.h>
#include <NekMeshUtils/MeshElements/Triangle.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
using namespace std;
namespace Nektar
......
......@@ -38,6 +38,7 @@
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
#include <NekMeshUtils/MeshElements/Element.h>
#include <NekMeshUtils/MeshElements/HOAlignment.h>
namespace Nektar
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment