You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/FITK_Component/FITKOFMeshIO/FITKOpenFOAMMeshReader.h

308 lines
9.9 KiB
C

/**
* @file FITKOpenFOAMMeshReader.h
* @brief OpenFOAM
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
#ifndef FITKOPENFOAMMESHREADER_H
#define FITKOPENFOAMMESHREADER_H
#include "FITKOFMeshIOAPI.h"
#include "FITK_Interface/FITKInterfaceIO/FITKAbstractIO.h"
class QFile;
namespace Interface {
class FITKUnstructuredMeshVTK;
class FITKAbstractElement;
class FITKBoundaryMeshVTKManager;
class FITKElementHex8;
class FITKElementPolygon;
}
namespace IO {
/**
* @brief OpenFOAM
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
typedef struct {
QString format{};
QString clazz{};
QString location{};
QString object{};
}FoamFileHeader;
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-22
*/
typedef struct {
QString name{};
QString type{};
QString group{};
int nFaces{0};
int startFace{0};
bool isValid() {
return !name.isEmpty() && !type.isEmpty() && nFaces != 0 && startFace != 0;
}
} Boundary;
/**
* @brief OpenFOAM
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
class FITKOFMeshIOAPI FITKOpenFOAMMeshReader : public Interface::FITKAbstractIO
{
public:
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
FITKOpenFOAMMeshReader();
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
~FITKOpenFOAMMeshReader() override;
/**
* @brief 线
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
void run() override;
/**
* @brief
* @param[i] level 1 normal 2 warning 3error
* @param[i] str
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
void consoleMessage(int level, const QString &str) override;
/**
* @brief
* @param data Interface::FITKUnstructureFluidMeshVTK
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-25
*/
void setDataObject(Core::FITKAbstractDataObject* data) override;
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool read();
protected:
/**
* @brief
* @param line
* @param inComment
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool processLine(QString& line, bool inComment = false);
/**
* @brief OpenFOAM
* @param file
* @param[out] header
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readFoamFileHeader(QFile& file, FoamFileHeader& header);
/**
* @brief points
* @param file
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readPointsData(QFile& file);
/**
* @brief points
* @param points points
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readPoints(const QString &points);
/**
* @brief faces
* @param file
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readFacesData(QFile& file);
/**
* @brief faces
* @param points faces
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readFaces(const QString &faces);
/**
* @brief owner
* @param file
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readOwnerData(QFile& file);
/**
* @brief owner
* @param points owner
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readOwner(const QString &owner);
/**
* @brief neighbour
* @param file
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readNeighbourData(QFile& file);
/**
* @brief neighbour
* @param points neighbour
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool readNeighbour(const QString &owner);
/**
* @brief boundary
* @param file
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-22
*/
bool readSingleBoundaryData(QFile& file, Boundary*);
/**
* @brief boundary
* @param file
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-22
*/
bool readBoundaryData(QFile& file);
/**
* @brief boundary
* @param file
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-22
*/
bool readBoundary(const QString & boundary);
/**
* @brief hex8
* @param face
* @param inIdPrev 1OpenFOAM
* @param inIdNext 2OpenFOAM
* @param[out] outIdPrev 1OpenFOAM
* @param[out] outIdNext 2OpenFOAM
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool getHex8IdsByFace(QList<int> face, int inIdPrev, int inIdNext, int& outIdPrev, int& outIdNext);
/**
* @brief hex8
* @param eleIndex
* @param points
* @return hex8
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
Interface::FITKElementHex8* setupHex8Cell(int eleIndex, QVector<QList<int>> points);
/**
* @brief
* @param eleIndex
* @param points
* @return
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
Interface::FITKElementPolygon* setupPolygonCell(QList<int> face);
/**
* @brief
* @param eleIndex
* @param faces
* @return
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
Interface::FITKAbstractElement* setupCell(int eleIndex, QList<int> faces);
/**
* @brief 3D
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool setup3DCells();
/**
* @brief 2D
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-17
*/
bool setup2DCells();
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-25
*/
bool setupBoundarys();
private:
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-16
*/
Interface::FITKUnstructuredMeshVTK* _fluidMesh{};
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-25
*/
Interface::FITKBoundaryMeshVTKManager* _boundaryManager{};
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-16
*/
int _pointsNum{};
/**
* @brief face
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-16
*/
int _facesNum{};
/**
* @brief face<>
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-16
*/
QVector<QList<int>> _faces{};
/**
* @brief owner<ownerface>
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-16
*/
QMap<int, QList<int>> _owner{};
/**
* @brief <face, >
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-16
*/
QMap<int, int> _neighbour{};
/**
* @brief <, face>
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-16
*/
QMap<int, QList<int>> _tempNeighbour{};
/**
* @brief
* @author YanZhiHui (chanyuantiandao@126.com)
* @date 2024-07-22
*/
QList<Boundary*> _Boundarys{};
};
}
#endif // FITKOPENFOAMMESHREADER_H