pax_global_header 0000666 0000000 0000000 00000000064 13544137132 0014515 g ustar 00root root 0000000 0000000 52 comment=a46e1929ee2c8d446e8f2cac181168e4295fa108
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/ 0000775 0000000 0000000 00000000000 13544137132 0017601 5 ustar 00root root 0000000 0000000 GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/ 0000775 0000000 0000000 00000000000 13544137132 0023324 5 ustar 00root root 0000000 0000000 GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/Unstructured_mesh.pro 0000664 0000000 0000000 00000000735 13544137132 0027576 0 ustar 00root root 0000000 0000000 TEMPLATE = app
CONFIG += console c++17
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
main.cpp \
../debug/debug.cpp
HEADERS += \
cellboundaryconnection.h \
cellconnection.h \
../debug/debug.h \
../debug/htmllogger.h \
computationaly_significant_element.h \
inline_array_operations.h \
mesh_element.h \
mesh_functions.h \
meshdatacontainer.h \
unstructed_mesh_define.h \
unstructuredmesh.h \
vector.h \
vertex.h
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/Unstructured_mesh.pro.user 0000664 0000000 0000000 00000060210 13544137132 0030545 0 ustar 00root root 0000000 0000000
EnvironmentId
{912ef53d-bd6a-4c34-9c17-3b65230ae21f}
ProjectExplorer.Project.ActiveTarget
0
ProjectExplorer.Project.EditorSettings
true
false
true
Cpp
CppGlobal
QmlJS
QmlJSGlobal
2
UTF-8
false
4
false
80
true
true
1
true
false
0
true
true
0
8
true
1
true
true
true
false
ProjectExplorer.Project.PluginSettings
-fno-delayed-template-parsing
true
ProjectExplorer.Project.Target.0
Desktop Qt 5.12.1 MinGW 64-bit
Desktop Qt 5.12.1 MinGW 64-bit
qt.qt5.5121.win64_mingw73_kit
0
0
0
D:/Skola/Vyzkumak/nova sit/build-Unstructured_mesh-Desktop_Qt_5_12_1_MinGW_64_bit-Ladu011bnu00ed
true
qmake
QtProjectManager.QMakeBuildStep
true
false
false
false
true
Make
Qt4ProjectManager.MakeStep
false
false
2
Build
ProjectExplorer.BuildSteps.Build
true
Make
Qt4ProjectManager.MakeStep
true
clean
false
1
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Ladění
Ladění
Qt4ProjectManager.Qt4BuildConfiguration
2
true
D:/Skola/Vyzkumak/nova sit/build-Unstructured_mesh-Desktop_Qt_5_12_1_MinGW_64_bit-Vydu00e1nu00ed
true
qmake
QtProjectManager.QMakeBuildStep
false
false
false
true
true
Make
Qt4ProjectManager.MakeStep
false
false
2
Build
ProjectExplorer.BuildSteps.Build
true
Make
Qt4ProjectManager.MakeStep
true
clean
false
1
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Vydání
Vydání
Qt4ProjectManager.Qt4BuildConfiguration
0
true
D:/Skola/Vyzkumak/nova sit/build-Unstructured_mesh-Desktop_Qt_5_12_1_MinGW_64_bit-Profile
true
qmake
QtProjectManager.QMakeBuildStep
true
false
true
true
true
Make
Qt4ProjectManager.MakeStep
false
false
2
Build
ProjectExplorer.BuildSteps.Build
true
Make
Qt4ProjectManager.MakeStep
true
clean
false
1
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Profile
Profile
Qt4ProjectManager.Qt4BuildConfiguration
0
true
3
0
Nasazení
ProjectExplorer.BuildSteps.Deploy
1
Deploy Configuration
ProjectExplorer.DefaultDeployConfiguration
1
dwarf
cpu-cycles
250
-F
true
4096
false
false
1000
true
false
false
false
false
true
0.01
10
true
kcachegrind
1
25
1
true
false
true
valgrind
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
Unstructured_mesh
Qt4ProjectManager.Qt4RunConfiguration:D:/Skola/Vyzkumak/nova sit/Unstructured_mesh/Unstructured_mesh.pro
3768
false
true
true
false
false
true
D:/Skola/Vyzkumak/nova sit/build-Unstructured_mesh-Desktop_Qt_5_12_1_MinGW_64_bit-Ladu011bnu00ed
1
ProjectExplorer.Project.TargetCount
1
ProjectExplorer.Project.Updater.FileVersion
22
Version
22
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/cellboundaryconnection.h 0000664 0000000 0000000 00000012535 13544137132 0030246 0 ustar 00root root 0000000 0000000 #ifndef CELLBOUNDARYCONNECTION_H
#define CELLBOUNDARYCONNECTION_H
#include "unstructed_mesh_define.h"
#include "cellconnection.h"
template
class CellBoundaryConnection : public CellConnection {
/**
* @brief nextBElemWRTCL
*
* Index of the next boundary element with respect to the left cell
*/
indexType nextBElemWRTCL;
/**
* @brief nextBElemWRTCR
*
* Index of the next boundary element with respect to right cell
*/
indexType nextBElemWRTCR;
public:
CellBoundaryConnection(indexType cellLeft = INVALID_INDEX(indexType),
indexType cellRight = INVALID_INDEX(indexType),
indexType nextLeft = INVALID_INDEX(indexType),
indexType nextRight = INVALID_INDEX(indexType));
/*
** Set atribute methods
*/
void setNextBElemWRTCR(indexType nextIndex);
void setNextBElemWRTCL(indexType nextIndex);
bool setNextBElem(indexType nextBElemIndex, indexType cellIndex);
indexType getNextBElemWRTCL() const;
indexType getNextBElemWRTCR() const;
indexType getNextBElem(indexType cellIndex) const;
// Returns the other Cell than sent by parameter
indexType getOtherCellIndex(indexType cellIndex) const;
};
/**
* Implementation of methods
*/
template
CellBoundaryConnection::CellBoundaryConnection(indexType cellLeft, indexType cellRight, indexType nextLeft, indexType nextRight)
: CellConnection (cellLeft, cellRight) {
nextBElemWRTCL = nextLeft;
nextBElemWRTCR = nextRight;
}
template
void CellBoundaryConnection::setNextBElemWRTCR(indexType nextIndex){
nextBElemWRTCR = nextIndex;
}
template
void CellBoundaryConnection::setNextBElemWRTCL(indexType nextIndex){
nextBElemWRTCL = nextIndex;
}
template
bool CellBoundaryConnection::setNextBElem(indexType nextBElemIndex, indexType cellIndex){
// CellIndex is invalid then false returned
if (cellIndex == INVALID_INDEX(indexType)){
return false;
}
// first test wether cell index eaqules left or right
// then is posible to set up invalid indexes
if (CellConnection::getCellLeftIndex() == cellIndex) {
setNextBElemWRTCL(nextBElemIndex);
return true;
}
if (CellConnection::getCellRightIndex() == cellIndex){
setNextBElemWRTCR(nextBElemIndex);
return true;
}
// Attribute CellRightIndex is invalid then
// CellRightIndex is set as cellIndex
if (CellConnection::getCellLeftIndex() == INVALID_INDEX(indexType)){
CellConnection::setCellLeftIndex(cellIndex);
}
// Parameter cellIndex is equal to CellRightIndex
// then nextEdgeWRTCL is set as nextEdgeIndex, ret true
if (cellIndex == CellConnection::getCellLeftIndex()) {
setNextBElemWRTCL(nextBElemIndex);
return true;
} else {
// Attribute CellRightIndex is invalid
// but CellLeftIndex is already filled
// then set CellLeftIndex as cellIndex
if(CellConnection::getCellRightIndex() == INVALID_INDEX(indexType)){
CellConnection::setCellRightIndex(cellIndex);
}
// Parameter cellIndex is equal to CellLeftIndex then
// set NextEdgeWRTCR as nextEdgeIndex, ret true
if (cellIndex == CellConnection::getCellRightIndex()){
setNextBElemWRTCR(nextBElemIndex);
return true;
// If both CellLeftIndex and CellRightIndex
// has a non -1 value
// and parameter cellIndex does not
// equal CellRightIndex neither CellLeftIndex
// then return false
} else {
return false;
}
}
}
template
indexType CellBoundaryConnection::getNextBElemWRTCL() const {
return nextBElemWRTCL;
}
template
indexType CellBoundaryConnection::getNextBElemWRTCR() const {
return nextBElemWRTCR;
}
template
indexType CellBoundaryConnection::getNextBElem(indexType cellIndex) const{
// If cell is nullptr then ret nullptr
if (cellIndex == INVALID_INDEX(indexType)) {
return INVALID_INDEX(indexType);
}
// If the cell is equal the Cell1 then return the NextBElemWRTCR
if(cellIndex == CellConnection::getCellRightIndex()){
return getNextBElemWRTCR();
// If the cell is equal the Cell2 then return the NextBElemWRTCL
} else if (cellIndex == CellConnection::getCellLeftIndex()){
return getNextBElemWRTCL();
// If the cell is not equal left cell neither cell right then return invalid index
} else {
return INVALID_INDEX(indexType);
}
}
template
indexType CellBoundaryConnection::getOtherCellIndex(indexType cellIndex) const{
if (cellIndex == CellConnection::getCellLeftIndex()) {
return CellConnection::getCellRightIndex();
} else if (cellIndex == CellConnection::getCellRightIndex()){
return CellConnection::getCellLeftIndex();
}
return INVALID_INDEX(indexType);
}
#endif // CELLBOUNDARYCONNECTION_H
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/cellconnection.h 0000664 0000000 0000000 00000007472 13544137132 0026506 0 ustar 00root root 0000000 0000000 #ifndef CELLCONNECTION_H
#define CELLCONNECTION_H
#include "unstructed_mesh_define.h"
/**
* @brief The CellConnection class
*/
template
class CellConnection {
// Indexes to two cells which neighbours
// with this edge
indexType cellRightIndex, cellLeftIndex;
public:
/**
* @brief CellConnection
* @param cellRight
* @param cellLeft
*/
CellConnection(indexType cellLeft = INVALID_INDEX(indexType),
indexType cellRight = INVALID_INDEX(indexType));
/**
* @brief setCellRightIndex
* @param cellIndex
*/
void setCellRightIndex(indexType cellIndex);
/**
* @brief SetCellLeftIndex
* @param cellIndex
*/
void setCellLeftIndex(indexType cellIndex);
/**
* @brief SetCellIndex
* @param cellIndex
* @return
*/
bool setCellIndex(indexType cellIndex);
/**
* @brief GetCellRightIndex
* @return
*/
indexType getCellRightIndex() const;
/**
* @brief GetCellLeftIndex
* @return
*/
indexType getCellLeftIndex() const;
// Returns the other Cell than sent by parameter
/**
* @brief GetOtherCellIndex
* @param cellIndex
* @return
*/
indexType getOtherCellIndex(indexType cellIndex) const;
/**
* @brief CellsOK
* @return true if both cell indexes are set
*/
bool cellsOK() const;
/**
* @brief SwapCellsLR
*
* swaps the left and right cell indexes
*/
void swapCellsLR();
};
/***
*
* Implementation of methods
*
*/
template
CellConnection::CellConnection(indexType cellLeft, indexType cellRight){
cellRightIndex = cellRight;
cellLeftIndex = cellLeft;
}
template
void CellConnection::setCellRightIndex(indexType cellIndex){
cellRightIndex = cellIndex;
}
template
void CellConnection::setCellLeftIndex(indexType cellIndex){
cellLeftIndex = cellIndex;
}
template
bool CellConnection::setCellIndex(indexType cellIndex){
// If the parameter cell is nullptr then ret false
if (cellIndex == INVALID_INDEX(indexType)){
return false;
}
// If the CellLeftIndex is lower than 0
// then set CellLeftIndex as cellIndex, ret true
if (getCellLeftIndex() == INVALID_INDEX(indexType)) {
setCellLeftIndex(cellIndex);
return true;
// If the CellRightIndex is valid
// and CellLeftIndex is not
// then set CellRightIndex as cellIndex
} else if (getCellRightIndex() == INVALID_INDEX(indexType)) {
setCellRightIndex(cellIndex);
return true;
// If both CellLeftIndex and CellRightIndex are >= 0
// then return false
} else {
return false;
}
}
template
indexType CellConnection::getCellRightIndex() const {
return cellRightIndex;
}
template
indexType CellConnection::getCellLeftIndex() const {
return cellLeftIndex;
}
template
indexType CellConnection::getOtherCellIndex(indexType cellIndex) const{
if (cellIndex == getCellLeftIndex()) {
return getCellRightIndex();
} else if (cellIndex == getCellRightIndex()){
return getCellLeftIndex();
}
return INVALID_INDEX(indexType);
}
template
bool CellConnection::cellsOK() const {
return getCellRightIndex() != INVALID_INDEX(indexType) && getCellLeftIndex() != INVALID_INDEX(indexType);
}
template
void CellConnection::swapCellsLR() {
indexType cellLeftIndex = getCellRightIndex();
setCellRightIndex(getCellLeftIndex());
setCellLeftIndex(cellLeftIndex);
}
#endif // CELLCONNECTION_H
computationaly_significant_element.h 0000664 0000000 0000000 00000001361 13544137132 0032556 0 ustar 00root root 0000000 0000000 GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh #ifndef COMPUTATIONALY_SIGNIFICANT_ELEMENT_H
#define COMPUTATIONALY_SIGNIFICANT_ELEMENT_H
#include "vertex.h"
template
class ComputationallySignificantElement
{
protected:
Vertex center;
int flag;
public:
ComputationallySignificantElement() {
center = {};
flag = int();
}
Vertex& getCenter(){
return center;
}
const Vertex& getCenter() const {
return center;
}
void setCenter(const Vertex& v) {
center = v;
}
int& getFlag() {
return flag;
}
const int& getFlag() const {
return flag;
}
};
#endif // COMPUTATIONALY_SIGNIFICANT_ELEMENT_H
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/inline_array_operations.h 0000664 0000000 0000000 00000004746 13544137132 0030427 0 ustar 00root root 0000000 0000000 #ifndef INLINE_ARRAY_OPERATIONS_H
#define INLINE_ARRAY_OPERATIONS_H
template
struct inlineScalarProduct {
static inline Real computation(const Real *x, const Real *y){
return inlineScalarProduct::computation(x, y) + x[N-1] * y[N-1];
}
};
template
struct inlineScalarProduct<1, Real>
{
static inline double computation(const Real *x, const Real *y){
return x[0] * y[0];
}
};
template
struct inlineAddition{
static inline void computation(Real *res, const Real *x, const Real *y){
inlineAddition::computation(res, x, y);
res[N-1] = x[N-1] + y[N-1];
}
static inline void computation(Real *x, const Real *y){
inlineAddition::computation(x, y);
x[N-1] += y[N-1];
}
};
template
struct inlineAddition<1, Real>{
static inline void computation(Real *res, const Real *x, const Real *y){
res[0] = x[0] + y[0];
}
static inline void computation(Real *x, const Real *y){
x[0] += y[0];
}
};
template
struct inlineSubtraction{
static inline void computation(Real *res, const Real *x, const Real *y){
inlineSubtraction::computation(res, x, y);
res[N-1] = x[N-1] - y[N-1];
}
static inline void computation(Real *x, const Real *y){
inlineSubtraction::computation(x, y);
x[N-1] -= y[N-1];
}
};
template
struct inlineSubtraction<1, Real>{
static inline void computation(Real *res, const Real *x, const Real *y){
res[0] = x[0] - y[0];
}
static inline void computation(Real *x, const Real *y){
x[0] -= y[0];
}
};
template
struct inlineMultiplication{
static inline void computation(Real *res, const Real *x, const Real& alpha){
inlineMultiplication::computation(res, x, alpha);
res[N-1] = x[N-1] * alpha;
}
static inline void computation(Real *x, const Real alpha){
inlineMultiplication::computation(x, alpha);
x[N-1] *= alpha;
}
};
template
struct inlineMultiplication<1, Real>{
static inline void computation(Real *res, const Real *x, const Real& alpha){
res[0] = x[0] * alpha;
}
static inline void computation(Real *x, const Real alpha){
x[0] *= alpha;
}
};
#endif // INLINE_ARRAY_OPERATIONS_H
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/main.cpp 0000664 0000000 0000000 00000057047 13544137132 0024771 0 ustar 00root root 0000000 0000000 #include
#include "../debug/debug.h"
#include "unstructuredmesh.h"
#include "mesh_functions.h"
using namespace std;
void cube(UnstructuredMesh<3, size_t, double, 6>& mesh3){
DBGCHECK;
mesh3.GetVertices().push_back({0, {0,0,0}});
mesh3.GetVertices().push_back({1, {1,0,0}});
mesh3.GetVertices().push_back({2, {0,1,0}});
mesh3.GetVertices().push_back({3, {1,1,0}});
mesh3.GetVertices().push_back({4, {0,0,1}});
mesh3.GetVertices().push_back({5, {1,0,1}});
mesh3.GetVertices().push_back({6, {0,1,1}});
mesh3.GetVertices().push_back({7, {1,1,1}});
DBGCHECK;
mesh3.GetEdges().push_back({0,0,1});
mesh3.GetEdges().push_back({1,0,2});
mesh3.GetEdges().push_back({2,1,3});
mesh3.GetEdges().push_back({3,2,3});
mesh3.GetEdges().push_back({4,0,4});
mesh3.GetEdges().push_back({5,1,5});
mesh3.GetEdges().push_back({6,3,7});
mesh3.GetEdges().push_back({7,2,6});
mesh3.GetEdges().push_back({8,4,5});
mesh3.GetEdges().push_back({9,5,7});
mesh3.GetEdges().push_back({10,6,7});
mesh3.GetEdges().push_back({11,4,6});
DBGCHECK;
mesh3.GetFaces().push_back(0);
mesh3.GetFaces().at(0).getSubelements().addSubelement(0,true);
mesh3.GetFaces().at(0).getSubelements().addSubelement(1,true);
mesh3.GetFaces().at(0).getSubelements().addSubelement(2,true);
mesh3.GetFaces().at(0).getSubelements().addSubelement(3,true);
mesh3.GetFaces().push_back(1);
mesh3.GetFaces().at(1).getSubelements().addSubelement(0,true);
mesh3.GetFaces().at(1).getSubelements().addSubelement(5,true);
mesh3.GetFaces().at(1).getSubelements().addSubelement(8,true);
mesh3.GetFaces().at(1).getSubelements().addSubelement(4,true);
mesh3.GetFaces().push_back(2);
mesh3.GetFaces().at(2).getSubelements().addSubelement(1,true);
mesh3.GetFaces().at(2).getSubelements().addSubelement(4,true);
mesh3.GetFaces().at(2).getSubelements().addSubelement(11,true);
mesh3.GetFaces().at(2).getSubelements().addSubelement(7,true);
mesh3.GetFaces().push_back(3);
mesh3.GetFaces().at(3).getSubelements().addSubelement(3,true);
mesh3.GetFaces().at(3).getSubelements().addSubelement(6,true);
mesh3.GetFaces().at(3).getSubelements().addSubelement(10,true);
mesh3.GetFaces().at(3).getSubelements().addSubelement(7,true);
mesh3.GetFaces().push_back(4);
mesh3.GetFaces().at(4).getSubelements().addSubelement(2,true);
mesh3.GetFaces().at(4).getSubelements().addSubelement(6,true);
mesh3.GetFaces().at(4).getSubelements().addSubelement(9,true);
mesh3.GetFaces().at(4).getSubelements().addSubelement(5,true);
mesh3.GetFaces().push_back(5);
mesh3.GetFaces().at(5).getSubelements().addSubelement(8,true);
mesh3.GetFaces().at(5).getSubelements().addSubelement(9,true);
mesh3.GetFaces().at(5).getSubelements().addSubelement(10,true);
mesh3.GetFaces().at(5).getSubelements().addSubelement(11,true);
DBGCHECK;
mesh3.GetFaces().at(0).setNextBElem(1,0);
mesh3.GetFaces().at(1).setNextBElem(2,0);
mesh3.GetFaces().at(2).setNextBElem(3,0);
mesh3.GetFaces().at(3).setNextBElem(4,0);
mesh3.GetFaces().at(4).setNextBElem(5,0);
mesh3.GetFaces().at(5).setNextBElem(0,0);
mesh3.GetCells().push_back(0);
mesh3.GetCells().at(0).setBoundaryElementIndex(3);
DBGCHECK;
}
void twoPrisms(UnstructuredMesh<3, size_t, double, 6>& mesh3){
DBGCHECK;
mesh3.GetVertices().push_back({0, {0,0,0}});
mesh3.GetVertices().push_back({1, {1,0,0}});
mesh3.GetVertices().push_back({2, {0,1,0}});
mesh3.GetVertices().push_back({3, {1,1,0}});
mesh3.GetVertices().push_back({4, {0,0,1}});
mesh3.GetVertices().push_back({5, {1,0,1}});
mesh3.GetVertices().push_back({6, {0,1,1}});
mesh3.GetVertices().push_back({7, {1,1,1}});
DBGCHECK;
mesh3.GetEdges().push_back({0,0,1});
mesh3.GetEdges().push_back({1,0,2});
mesh3.GetEdges().push_back({2,1,3});
mesh3.GetEdges().push_back({3,2,3});
mesh3.GetEdges().push_back({4,0,4});
mesh3.GetEdges().push_back({5,1,5});
mesh3.GetEdges().push_back({6,3,7});
mesh3.GetEdges().push_back({7,2,6});
mesh3.GetEdges().push_back({8,4,5});
mesh3.GetEdges().push_back({9,5,7});
mesh3.GetEdges().push_back({10,6,7});
mesh3.GetEdges().push_back({11,4,6});
mesh3.GetEdges().push_back({12,6,5});
mesh3.GetEdges().push_back({13,2,1});
DBGCHECK;
size_t index = 0;
mesh3.GetFaces().push_back(index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(0,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(1,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(13,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(13,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(2,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(3,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(0,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(5,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(8,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(4,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(1,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(4,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(11,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(7,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(3,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(6,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(10,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(7,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(2,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(6,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(9,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(5,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(8,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(12,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(11,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(9,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(10,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(12,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(12,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(7,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(13,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(5,true);
DBGCHECK;
mesh3.GetFaces().at(0).setNextBElem(2,0);
mesh3.GetFaces().at(2).setNextBElem(3,0);
mesh3.GetFaces().at(3).setNextBElem(8,0);
mesh3.GetFaces().at(8).setNextBElem(6,0);
mesh3.GetFaces().at(6).setNextBElem(0,0);
mesh3.GetCells().push_back(0);
mesh3.GetCells().at(0).setBoundaryElementIndex(0);
mesh3.GetFaces().at(1).setNextBElem(5,1);
mesh3.GetFaces().at(5).setNextBElem(4,1);
mesh3.GetFaces().at(4).setNextBElem(8,1);
mesh3.GetFaces().at(8).setNextBElem(7,1);
mesh3.GetFaces().at(7).setNextBElem(1,1);
mesh3.GetCells().push_back(1);
mesh3.GetCells().at(1).setBoundaryElementIndex(1);
DBGCHECK;
}
void twoDeformedPrisms(UnstructuredMesh<3, size_t, double, 6>& mesh3){
DBGCHECK;
mesh3.GetVertices().push_back({0, {0,0,1}});
mesh3.GetVertices().push_back({1, {1,0,0}});
mesh3.GetVertices().push_back({2, {0,1,0}});
mesh3.GetVertices().push_back({3, {1,1,0}});
mesh3.GetVertices().push_back({4, {0,0,2}});
mesh3.GetVertices().push_back({5, {1,0,1}});
mesh3.GetVertices().push_back({6, {0,1,1}});
mesh3.GetVertices().push_back({7, {1,1,2}});
DBGCHECK;
mesh3.GetEdges().push_back({0,0,1});
mesh3.GetEdges().push_back({1,0,2});
mesh3.GetEdges().push_back({2,1,3});
mesh3.GetEdges().push_back({3,2,3});
mesh3.GetEdges().push_back({4,0,4});
mesh3.GetEdges().push_back({5,1,5});
mesh3.GetEdges().push_back({6,3,7});
mesh3.GetEdges().push_back({7,2,6});
mesh3.GetEdges().push_back({8,4,5});
mesh3.GetEdges().push_back({9,5,7});
mesh3.GetEdges().push_back({10,6,7});
mesh3.GetEdges().push_back({11,4,6});
mesh3.GetEdges().push_back({12,6,5});
mesh3.GetEdges().push_back({13,2,1});
DBGCHECK;
size_t index = 0;
mesh3.GetFaces().push_back(index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(0,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(1,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(13,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(13,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(2,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(3,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(0,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(5,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(8,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(4,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(1,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(4,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(11,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(7,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(3,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(6,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(10,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(7,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(2,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(6,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(9,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(5,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(8,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(12,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(11,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(9,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(10,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(12,true);
mesh3.GetFaces().push_back(++index);
mesh3.GetFaces().at(index).getSubelements().addSubelement(12,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(7,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(13,true);
mesh3.GetFaces().at(index).getSubelements().addSubelement(5,true);
DBGCHECK;
mesh3.GetFaces().at(0).setNextBElem(2,0);
mesh3.GetFaces().at(2).setNextBElem(3,0);
mesh3.GetFaces().at(3).setNextBElem(8,0);
mesh3.GetFaces().at(8).setNextBElem(6,0);
mesh3.GetFaces().at(6).setNextBElem(0,0);
mesh3.GetCells().push_back(0);
mesh3.GetCells().at(0).setBoundaryElementIndex(0);
mesh3.GetFaces().at(1).setNextBElem(5,1);
mesh3.GetFaces().at(5).setNextBElem(4,1);
mesh3.GetFaces().at(4).setNextBElem(8,1);
mesh3.GetFaces().at(8).setNextBElem(7,1);
mesh3.GetFaces().at(7).setNextBElem(1,1);
mesh3.GetCells().push_back(1);
mesh3.GetCells().at(1).setBoundaryElementIndex(1);
DBGCHECK;
}
void testMesh2D() {
using sit = UnstructuredMesh<2, size_t, double>;
sit mesh;
mesh.GetVertices().resize(4);
mesh.GetVertices().at(0).SetIndex(0);
mesh.GetVertices().at(0) = {0,0};
mesh.GetVertices().at(1).SetIndex(1);
mesh.GetVertices().at(1) = {0,1};
mesh.GetVertices().at(2).SetIndex(2);
mesh.GetVertices().at(2) = {1,0};
mesh.GetVertices().at(3).SetIndex(3);
mesh.GetVertices().at(3) = {1,1};
mesh.GetFaces().resize(5);
mesh.GetFaces().at(0).vertexAIndex = 1;
mesh.GetFaces().at(0).vertexBIndex = 0;
mesh.GetFaces().at(1).vertexAIndex = 0;
mesh.GetFaces().at(1).vertexBIndex = 2;
mesh.GetFaces().at(2).vertexAIndex = 2;
mesh.GetFaces().at(2).vertexBIndex = 1;
mesh.GetFaces().at(3).vertexAIndex = 3;
mesh.GetFaces().at(3).vertexBIndex = 1;
mesh.GetFaces().at(4).vertexAIndex = 2;
mesh.GetFaces().at(4).vertexBIndex = 3;
for(size_t i = 0; i < 5; i++)
mesh.GetFaces().at(i).SetIndex(i);
mesh.GetFaces().at(0).setNextBElem(1,0);
mesh.GetFaces().at(1).setNextBElem(2,0);
mesh.GetFaces().at(2).setNextBElem(0,0);
mesh.GetFaces().at(2).setNextBElem(3,1);
mesh.GetFaces().at(3).setNextBElem(4,1);
mesh.GetFaces().at(4).setNextBElem(2,1);
mesh.GetCells().resize(2);
mesh.GetCells().at(0).setBoundaryElementIndex(0);
mesh.GetCells().at(0).SetIndex(0);
mesh.GetCells().at(1).setBoundaryElementIndex(2);
mesh.GetCells().at(1).SetIndex(1);
mesh.InitializeCenters();
sit::MeshElementWrap<1> ele(&mesh, mesh.GetEdges().at(0));
sit::MeshElementWrap<2> cell(&mesh, mesh.GetCells().at(0));
DBGMSG("cell boundary iterator test");
for(auto i : cell.getSubelements()){
DBGVAR(i)
}
for(auto i : mesh.GetElement<2>(1).getSubelements()){
DBGVAR(i)
}
DBGMSG("cell vertices using iterator");
for(size_t i = 0; i < mesh.GetCells().size(); i++){
for(auto j : mesh.GetElement<2>(i).getSubelements()){
auto e = mesh.GetElement<1>(j);
DBGVAR(e.GetElement().GetVertexAIndex(), e.GetElement().GetVertexBIndex())
}
}
MeshDataContainer, 2> vertices(mesh);
DBGMSG("vertices of cells in 2D");
for (auto& cell : mesh.GetCells()){
std::set& _set = vertices.at(cell);
DBGVAR(cell.GetIndex())
for (size_t index: _set){
DBGVAR(index)
}
}
auto centers = ComputeCenters(mesh);
auto& faceCent = centers.GetDataDim<1>();
for(auto& center : faceCent) {
DBGVAR(center)
}
DBGMSG("cellCenter");
for(sit::Cell& cell : mesh.GetCells()){
DBGVAR(centers.GetDataDim<2>().at(cell.GetIndex()))
}
DBGMSG("computing measures");
auto measures = mesh.ComputeElementMeasures();
for(double edgeM :measures.GetDataDim<1>()) {
DBGVAR(edgeM)
}
for(double cellM :measures.GetDataDim<2>()) {
DBGVAR(cellM)
}
DBGMSG("2D normals test");
auto normals = ComputeFaceNormals(mesh);
for(auto& edge : mesh.GetEdges()){
DBGVAR(edge.GetIndex(),normals.at(edge))
}
DBGMSG("2D cells distances");
auto distances = ComputeCellsDistance(mesh);
for(auto& edge : mesh.GetEdges()){
DBGVAR(edge.GetIndex(),distances.at(edge))
}
}
void testMesh3D() {
DBGMSG("3D test");
using sit3 = UnstructuredMesh<3, size_t, double, 6>;
UnstructuredMesh<3, size_t, double, 6> mesh3;
twoPrisms(mesh3);
size_t tmp_face = mesh3.GetCells().at(0).getBoundaryElementIndex();
do {
DBGVAR(tmp_face)
for (auto& sube : mesh3.GetFaces().at(tmp_face).getSubelements()) {
DBGVAR(sube.index)
if (sube.index != INVALID_INDEX(size_t) ){
DBGVAR(sube.index, mesh3.GetVertices().at(mesh3.GetEdges().at(sube.index).GetVertexAIndex()),mesh3.GetVertices().at(mesh3.GetEdges().at(sube.index).GetVertexBIndex()))
}
}
tmp_face = mesh3.GetFaces().at(tmp_face).getNextBElem(0);
} while (tmp_face != mesh3.GetCells().at(0).getBoundaryElementIndex());
// mesh3.GetElements<0>().at(0).;
DBGMSG("Iterator wrapper test");
sit3::MeshElementWrap<2> elem(&mesh3, mesh3.GetFaces().at(0));
for(auto i : elem.getSubelements()){
DBGVAR(i.index)
}
DBGMSG("mesh conatiner test");
MeshDataContainer cont(mesh3);
MakeMeshDataContainer_t> cont1(mesh3);
//cont.GetDataDim<3>().resize(20);
DBGVAR(cont.GetDataPos<1>().size())
DBGVAR(cont.GetDataPos<0>().size())
DBGVAR(cont.GetDataDim<3>().size())
DBGMSG("faceCenters");
//MeshDataContainer, 3,2,1> centers(mesh3);
//_ComputeCenters<1,3, 3,2,1>::compute(centers, mesh3);
auto centers = ComputeCenters(mesh3);
for(auto& face : mesh3.GetFaces()) {
face.setCenter(centers.template GetDataDim<2>().at(face.GetIndex()));
DBGVAR(face.getCenter())
}
DBGMSG("cellCenter");
for(auto& cell : mesh3.GetCells()) {
cell.setCenter(centers.template GetDataDim<3>().at(cell.GetIndex()));
DBGVAR(cell.getCenter())
}
DBGMSG("measure computation");
auto measures = ComputeMeasures(mesh3);
for(double edgeM : measures.GetDataDim<1>()) {
DBGVAR(edgeM)
}
for(double faceM : measures.GetDataDim<2>()) {
DBGVAR(faceM)
}
for(double cellM : measures.GetDataDim<3>()) {
DBGVAR(cellM)
}
DBGMSG("2D normals test");
auto normals = mesh3.ComputeFaceNormals();
for(auto& face : mesh3.GetFaces()){
DBGVAR(face.GetIndex(),normals.at(face))
}
DBGMSG("mesh apply test");
temp1::MeshApply<3, 2, 3>::apply(mesh3, [](unsigned int S, unsigned int T, size_t ori, size_t i){
DBGVAR(S,T,ori,i)
});
DBGMSG("mesh apply test");
temp1::MeshApply<2, 3, 3>::apply(mesh3,[](unsigned int S, unsigned int T, size_t ori, size_t i){
DBGVAR(S,T,ori,i)
});
DBGMSG("connection test");
auto con = temp1::MeshConnections<3,0>::connections(mesh3);
for (auto& cell : mesh3.GetCells()){
DBGVAR(cell.GetIndex())
for(size_t i : con[cell]){
DBGVAR(i)
}
}
DBGMSG("connection test oposite");
auto con1 = temp1::MeshConnections<0,3>::connections(mesh3);
for (auto& vert : mesh3.GetVertices()){
DBGVAR(vert.GetIndex())
for(size_t i : con1[vert]){
DBGVAR(i)
}
}
DBGMSG("face to vertex colouring");
auto colours = temp1::ColourMesh<2,0>::colour(mesh3);
for (auto& face : mesh3.GetFaces()){
DBGVAR(face.GetIndex(), colours.at(face))
}
DBGMSG("vertex to face colouring");
auto colours1 = temp1::ColourMesh<0,2>::colour(mesh3);
for (auto& vert : mesh3.GetVertices()){
DBGVAR(vert.GetIndex(), colours1.at(vert))
}
}
void test3DMeshDeformedPrisms() {
UnstructuredMesh<3, size_t, double, 6> mesh3;
twoDeformedPrisms(mesh3);
//_ComputeCenters<1,3, 3,2,1>::compute(centers, mesh3);
auto centers = ComputeCenters(mesh3);
for(auto& face : mesh3.GetFaces()) {
face.setCenter(centers[face]);
DBGVAR(face.getCenter())
}
DBGMSG("cellCenter");
for(auto& cell : mesh3.GetCells()) {
cell.setCenter(centers[cell]);
DBGVAR(cell.getCenter())
}
DBGMSG("measure computation");
auto measures = ComputeMeasures(mesh3);
for(double edgeM : measures.GetDataDim<1>()) {
DBGVAR(edgeM)
}
for(double faceM : measures.GetDataDim<2>()) {
DBGVAR(faceM)
}
for(double cellM : measures.GetDataDim<3>()) {
DBGVAR(cellM)
}
}
void testMeshDataContainer() {
UnstructuredMesh<3, size_t, double, 6> mesh3;
twoDeformedPrisms(mesh3);
MeshDataContainer, 3,2,0> container(mesh3);
for(auto& c : container.GetDataDim<0>()) {
c=42;
}
for(auto& v : mesh3.GetVertices()){
DBGVAR(container.at(v))
}
MeshDataContainer, 3, 2, 0, 2> containerIni(mesh3,3, 42.15, 'a', 15);
for (auto& val : containerIni.GetDataPos<0>()){
DBGVAR(val)
}
for (auto& val : containerIni.GetDataPos<1>()){
DBGVAR(val)
}
for (auto& val : containerIni.GetDataPos<2>()){
DBGVAR(val)
}
for (auto& val : containerIni.GetDataPos<3>()){
DBGVAR(val)
}
}
template
class ClassA
{
public:
ClassA (std::integer_sequence)
{DBGVAR(sizeof... (Is), std::get<0>(std::array{Is...})) }
static void fun (std::index_sequence)
{DBGVAR(sizeof... (Is), std::get<0>(std::array{Is...})) }
};
//template class ClassB{};
template
class ClassB
{
public:
ClassB (const std::integer_sequence, Tuple t)
{std::tuple_element_t<0,Tuple> typ = 0;
DBGVAR(sizeof... (Is), std::get<0>(std::array{Is...}), std::get<0>(t), typ) }
};
template class ClassC{};
template
class ClassC, std::tuple>
{
public:
ClassC (const std::integer_sequence, std::tuple)
{std::tuple_element_t<0,std::tuple> typ = 0;
DBGVAR(sizeof... (Is), std::get<0>(std::array{Is...}), typ) }
ClassC () {
std::tuple_element_t<0,std::tuple> typ = 42.15;
std::tuple_element_t<1,std::tuple> typ2 = 42.15;
DBGVAR(sizeof... (Is), std::get<0>(std::array{Is...}), typ, typ2)
}
};
void testTemplate() {
ClassA n(std::make_integer_sequence{});
UnstructuredMesh<3,size_t, double,6> mesh3;
//MeshDataContainer, 0,1,2> centers2(mesh3,std::make_integer_sequence{}, Vertex<3, double>{});
//ComputeCenters(mesh3);
ClassA p(make_custom_integer_sequence_t{});
std::tuple t{};
t={1,2};
ClassB u(make_custom_integer_sequence_t{}, t);
ClassC, std::tuple> c(make_custom_integer_sequence_t{}, std::tuple{});
ClassC, std::tuple> cc;
ClassC, decltype(std::make_tuple(1.0, 'a'))> ccc;
}
int main()
{
testMesh2D();
testMesh3D();
test3DMeshDeformedPrisms();
testMeshDataContainer();
//testTemplate();
UnstructuredMesh<5, size_t, double, 6,5,4> m;
//m.ComputeElementMeasures();
}
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/mesh_element.h 0000664 0000000 0000000 00000040205 13544137132 0026143 0 ustar 00root root 0000000 0000000 #ifndef MESH_ELEMENT_H
#define MESH_ELEMENT_H
#include "unstructed_mesh_define.h"
#include "vertex.h"
#include "cellboundaryconnection.h"
#include "computationaly_significant_element.h"
#include "type_traits"
#include "tuple"
#include
#include
#include
template
class MeshElementBase{
/**
* @brief elementIndex
* Index of the element in the mesh or in mesh component
*/
IndexType elementIndex;
/**
* @brief globalElementIndex
*
* Global index of element in the mesh component
*/
//IndexType gobalElementIndex;
public:
MeshElementBase(IndexType index = INVALID_INDEX(IndexType)){
elementIndex = index;
}
IndexType GetIndex(){
return elementIndex;
}
void SetIndex(IndexType index){
elementIndex = index;
}
/*
IndexType GetGlobalIndex(){
return globalElementIndex;
}
void SetGlobalIndex(IndexType index){
globalElementIndex = index;
}
*/
};
template
struct Subelement{
IndexType index = INVALID_INDEX(IndexType);
bool isLeft = false;
};
template
class SubelementContainer : public std::array, Reserve>{
unsigned char numberOfElements = 0;
public:
unsigned char getNumberOfSubElements(){
return numberOfElements;
}
void addSubelement(IndexType index, bool isLeft) {
if (numberOfElements < Reserve){
this->at(numberOfElements).index = index;
this->at(numberOfElements).isLeft = isLeft;
numberOfElements++;
} else {
throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase::GetIndex()) +
") number of edges overgrew the number of reserved indexes (" + std::to_string(Reserve)
+")."));
}
}
void removeSubelement(unsigned char atIndex){
if (atIndex < numberOfElements){
for(unsigned char i = atIndex; i < numberOfElements - 1; i++){
this->at(i) = this->at(i+1);
}
this->at(numberOfElements) = {INVALID_INDEX(IndexType), false};
numberOfElements--;
} else {
throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase::GetIndex()) +
") removing index " + std::to_string(atIndex)
+" is greather than number of subelements " + std::to_string(numberOfElements)+ "."));
}
}
typename std::array, Reserve>::iterator end(){
return this->begin() + getNumberOfSubElements();
}
typename std::array, Reserve>::const_iterator cend(){
return this->cbegin() + getNumberOfSubElements();
}
};
struct emptyStruct{};
struct emptyStruct2{};
template
class MeshElement : public MeshElementBase,
public std::conditional, emptyStruct>::type,
public std::conditional, emptyStruct2>::type{
SubelementContainer subelements;
public:
SubelementContainer& getSubelements(){
return subelements;
}
const SubelementContainer& getSubelements() const {
return subelements;
}
MeshElement(IndexType index = INVALID_INDEX(IndexType))
:MeshElementBase(index), CellBoundaryConnection () {
subelements.fill({INVALID_INDEX(IndexType), false});
}
};
template
class MeshElement
: public MeshElementBase, public Vertex{
public:
MeshElement(IndexType index = INVALID_INDEX(IndexType), Vertex v = {})
:MeshElementBase(index), Vertex(v) {
}
MeshElement& operator =(std::initializer_list l){
this->Vertex::operator=(l);
return *this;
}
};
template
class MeshElement
: public MeshElementBase,
public std::conditional, emptyStruct>::type,
public std::conditional, emptyStruct2>::type{
public:
IndexType vertexAIndex;
IndexType vertexBIndex;
public:
MeshElement(IndexType index = INVALID_INDEX(IndexType),
IndexType vertexAIndex = INVALID_INDEX(IndexType),
IndexType vertexBIndex = INVALID_INDEX(IndexType))
:MeshElementBase(index) {
SetVertexAIndex(vertexAIndex);
SetVertexBIndex(vertexBIndex);
}
IndexType GetVertexAIndex(){
return vertexAIndex;
}
IndexType GetVertexBIndex(){
return vertexBIndex;
}
void SetVertexAIndex(IndexType index){
vertexAIndex = index;
}
void SetVertexBIndex(IndexType index){
vertexBIndex = index;
}
};
template
class MeshElement
: public MeshElementBase,
public ComputationallySignificantElement{
IndexType boundaryElementIndex;
public:
//GetBoundaryElement
MeshElement(IndexType index = INVALID_INDEX(IndexType))
:MeshElementBase(index) {
}
IndexType getBoundaryElementIndex(){
return boundaryElementIndex;
}
void setBoundaryElementIndex(IndexType index){
boundaryElementIndex = index;
}
};
template
struct MeshElements{
private:
template
struct _MeshElements : public _MeshElements<_Dimension, ElemDim - 1, _IndexType, _Real, _Reserve...>{
std::vector(std::array{Reserve...})>> elements;
};
template
struct _MeshElements<_Dimension, 0, _IndexType, _Real, _Reserve...>{
std::vector> elements;
};
template
struct _MeshElements<_Dimension, 1, _IndexType, _Real, _Reserve...> : public _MeshElements<_Dimension, 0, _IndexType, _Real, _Reserve...>{
std::vector> elements;
};
template
struct _MeshElements<_Dimension, _Dimension, _IndexType, _Real, _Reserve...> : public _MeshElements<_Dimension, _Dimension - 1, _IndexType, _Real, _Reserve...>{
std::vector> elements;
};
template
static unsigned int constexpr reserve(){
if constexpr (dim == Dimension || dim == 1 || dim == 0){
return 0;
} else {
return std::get<(dim == Dimension || dim == 1 || dim == 0) ? 0 : Dimension - dim - 1>(std::array{Reserve...});
}
}
_MeshElements Refs;
std::vector> BoundaryCells;
public:
using Vertex = MeshElement;
using Edge = MeshElement;
using Face = MeshElement()>;
using Cell = MeshElement;
template
struct ElemType //lze nahradit šablonovým using
{
using type = MeshElement()>;
};
template
std::vector::type>& GetElements(){
static_assert (Dimension >= dim, "In GetElements template parameter dim must be less or equal to Dimension.");
return Refs._MeshElements::elements;
}
template
const std::vector::type>& GetElements() const {
static_assert (Dimension >= dim, "In GetElements template parameter dim must be less or equal to Dimension.");
return Refs._MeshElements::elements;
}
std::vector& GetVertices(){
return GetElements<0>();
}
std::vector& GetEdges(){
return GetElements<1>();
}
std::vector& GetFaces(){
return GetElements();
}
std::vector& GetCells(){
return GetElements();
}
std::vector& GetBoundaryCells() {
return BoundaryCells;
}
void AppendBoundaryCell(IndexType cellIndex, IndexType faceIndex){
Cell c;
c.SetIndex(cellIndex);
c.SetBoundaryElementIndex(faceIndex);
BoundaryCells.push_back(c);
}
void SetupBoundaryCells(){
for (Face& face : GetFaces()){
if (face.GetCellLeftIndex == INVALID_INDEX(IndexType)){
IndexType cellIndex = BoundaryCells.size() | BOUNDARY_INDEX(IndexType);
face.SetCellLeftIndex(cellIndex);
AppendBoundaryCell(cellIndex, face.GetIndex());
}
if (face.GetCellRightIndex == INVALID_INDEX(IndexType)){
IndexType cellIndex = BoundaryCells.size() | BOUNDARY_INDEX(IndexType);
face.SetCellRightIndex(cellIndex);
AppendBoundaryCell(cellIndex, face.GetIndex());
}
}
BoundaryCells.shrink_to_fit();
}
void SetupBoundaryCellsCenters() {
for(Cell& cell : BoundaryCells){
cell.SetCenter(GetFaces().at(cell.getBoundaryElementIndex()).GetCenter());
}
}
struct CellSubelementIterator: public std::iterator
{
IndexType actual;
IndexType firstBElem;
IndexType cellIndex;
MeshElements* parentMesh;
public:
CellSubelementIterator(IndexType ci, IndexType act, MeshElements* parentMesh):cellIndex(ci){
firstBElem = act;
actual = firstBElem;
this->parentMesh = parentMesh;
}
CellSubelementIterator& operator++ () {actual = parentMesh->GetFaces().at(actual).getNextBElem(cellIndex) == firstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(actual).getNextBElem(cellIndex); return *this;}
CellSubelementIterator& operator++ (int) {actual = parentMesh->GetFaces().at(actual).getNextBElem(cellIndex) == firstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(actual).getNextBElem(cellIndex); return *this;}
IndexType operator* (){return actual;}
bool operator== (CellSubelementIterator& it) {return actual == it.actual;}
bool operator!= (CellSubelementIterator& it) {return actual != it.actual;}
};
class CellSubelements {
IndexType cellIndex;
MeshElements* parentMesh;
public:
CellSubelements(MeshElements* parentMesh, IndexType cellIndex){
this->cellIndex = cellIndex;
this->parentMesh = parentMesh;
}
CellSubelementIterator begin() {
return CellSubelementIterator(cellIndex, parentMesh->GetCells()[cellIndex].getBoundaryElementIndex(), parentMesh);
}
CellSubelementIterator end() {
return CellSubelementIterator(cellIndex, INVALID_INDEX(IndexType), parentMesh);
}
};
public:
template
class MeshElementWrap {
IndexType elementIndex;
MeshElements* parentMesh;
public:
MeshElementWrap(MeshElements* parentMesh, MeshElement()>& meshElement){
elementIndex = meshElement.GetIndex();
this->parentMesh = parentMesh;
}
MeshElementWrap(MeshElements* parentMesh, IndexType elementIndex){
this->elementIndex = elementIndex;
this->parentMesh = parentMesh;
}
IndexType GetIndex(){
return elementIndex;
}
SubelementContainer()>& getSubelements(){
return parentMesh->template GetElements()[elementIndex].getSubelements();
}
};
template
class MeshElementWrap {
IndexType elementIndex;
MeshElements* parentMesh;
public:
MeshElementWrap(MeshElements* parentMesh, MeshElement& meshElement){
elementIndex = meshElement.GetIndex();
this->parentMesh = parentMesh;
}
MeshElementWrap(MeshElements* parentMesh, IndexType elementIndex){
this->elementIndex = elementIndex;
this->parentMesh = parentMesh;
}
IndexType GetIndex(){
return elementIndex;
}
CellSubelements getSubelements(){
return CellSubelements(parentMesh, elementIndex);
}
};
template
class MeshElementWrap<1, Dummy> {
IndexType elementIndex;
MeshElements* parentMesh;
public:
MeshElementWrap(MeshElements* parentMesh, MeshElement& meshElement){
elementIndex = meshElement.GetIndex();
this->parentMesh = parentMesh;
}
MeshElementWrap(MeshElements* parentMesh, IndexType elementIndex){
this->elementIndex = elementIndex;
this->parentMesh = parentMesh;
}
IndexType GetIndex(){
return elementIndex;
}
Edge& GetElement() {
return parentMesh->GetEdges()[elementIndex];
}
};
template
class MeshElementWrap<0, Dummy> {
IndexType elementIndex;
MeshElements* parentMesh;
public:
MeshElementWrap(MeshElements* parentMesh, Vertex& meshElement){
elementIndex = meshElement.GetIndex();
this->parentMesh = parentMesh;
}
MeshElementWrap(MeshElements* parentMesh, IndexType elementIndex){
this->elementIndex = elementIndex;
this->parentMesh = parentMesh;
}
IndexType GetIndex(){
return elementIndex;
}
Vertex& GetElement() {
return parentMesh->GetVertices()[elementIndex];
}
};
template
MeshElementWrap GetElement(IndexType elementIndex){
return MeshElementWrap(this, elementIndex);
}
};
#endif // MESH_ELEMENT_H
GTMesh-a46e1929ee2c8d446e8f2cac181168e4295fa108/Unstructured_mesh/mesh_functions.h 0000664 0000000 0000000 00000064272 13544137132 0026534 0 ustar 00root root 0000000 0000000
#ifndef MESH_FUNCTIONS_H
#define MESH_FUNCTIONS_H
#include "mesh_element.h"
#include "meshdatacontainer.h"
#include "vector.h"
#include
#include
template
struct MakeCustomIntegerSequence : public MakeCustomIntegerSequence {
};
template
struct MakeCustomIntegerSequence {
using type = std::integer_sequence;
};
template
using make_custom_integer_sequence_t = typename MakeCustomIntegerSequence::type;
template
struct _ComputeCenters{
template
static void compute(
MakeMeshDataContainer_t, make_custom_integer_sequence_t>& centers,
MeshElements& mesh){
auto& elemCenters = centers.template GetDataDim();
auto& subElemCenters = centers.template GetDataDim();
for (IndexType i = 0; i < mesh.template GetElements().size(); i++) {
auto& element = mesh.template GetElements().at(i);
Real subElemCnt = 0;
for(auto& sub : element.getSubelements()){
elemCenters.at(i) += subElemCenters.at(sub.index);
subElemCnt++;
}
elemCenters.at(i) /= subElemCnt;
}
DBGMSG(dim);
_ComputeCenters::compute(centers, mesh);
}
};
template
struct _ComputeCenters{
template
static void compute(MakeMeshDataContainer_t, make_custom_integer_sequence_t>& centers,MeshElements& mesh){
auto& elemCenters = centers.template GetDataDim();
auto& subElemCenters = centers.template GetDataDim();
for (IndexType i = 0; i < mesh.template GetElements().size(); i++) {
auto& element = mesh.template GetElements().at(i);
Real subElemCnt = 0;
IndexType tmpFaceIndex = element.getBoundaryElementIndex();
do {
elemCenters.at(i) += subElemCenters.at(tmpFaceIndex);
subElemCnt++;
tmpFaceIndex = mesh.GetFaces()[tmpFaceIndex].getNextBElem(i);
} while (tmpFaceIndex != element.getBoundaryElementIndex());
elemCenters.at(i) /= subElemCnt;
}
DBGMSG(Dimension);
}
};
template
struct _ComputeCenters<1, Dimension>{
template
static void compute(
MakeMeshDataContainer_t, make_custom_integer_sequence_t>& centers,
MeshElements& mesh){
std::vector>& edgeCenters = centers.template GetDataDim<1>();
for (auto& edge : mesh.template GetElements<1>()) {
edgeCenters.at(edge.GetIndex()) = (mesh.template GetElements<0>().at(edge.GetVertexAIndex()) +
mesh.template GetElements<0>().at(edge.GetVertexBIndex())) * 0.5;
}
DBGMSG("1");
_ComputeCenters<2, Dimension>::compute(centers, mesh);
}
};
template | |