//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // PPPPP H H EEEEE N N GGGGG L EEEEE III + // P P H H E NN N G L E I + // PPPPP HHHHH EEEEE N N N G GG L EEEEE I + // P H H E N N N G G L E I + // P H H EEEEE N N GGGGG LLLLL EEEEE III + //------------------------------------------------------------------------+ // Platform for Hybrid Engineering Simulation of Flows + // China Aerodynamics Research and Development Center + // (C) Copyright, Since 2010 + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //! @file Pre_Block_Struct.h //! @brief Structured grid partition: block definition. //! @author Guo Yongheng. #pragma once #include "Geo_StructBC.h" using namespace std; namespace PHSPACE { class Pre_Block_Struct; class Pre_Patch_Struct; //! @brief Pre_BcFace_Struct defines boundary face for struct grid. class Pre_BcFace_Struct { private: //! Boundary type of current face. int boundaryType; string bcName; int s_dir3d[3]; //! Range of node index and local axis label. vector nodeStart, nodeEnd, axisLabel; //! Boundary Direction. int bcDirection; //! Unit matrix which is used to describe axis mapping between source block to target one. vector > unitMatrix; //! Pointer of attached struct grid. Pre_Block_Struct *simpleBlock; //! Pointer of correlative patch face. Pre_Patch_Struct *next; //! Children of current boundary face. vector *child; public: LIB_EXPORT Pre_BcFace_Struct(); LIB_EXPORT ~Pre_BcFace_Struct(); public: //! Recursive function for freeing space of Bc faces and patch faces. LIB_EXPORT void Free(); //! Erect vertex index mapping between patch faces. LIB_EXPORT void ErectVertexMapping(int geometricDimension); //! Get absolute value of node index and sort them. LIB_EXPORT void Normalize(int geometricDimension); //! Compute local node index according to block parameter. LIB_EXPORT void ComputeLocalCoordinate(); //! Output current boundary face information to file. LIB_EXPORT void OutputBoundaryInformation(fstream &file, int geometricDimension); LIB_EXPORT void OutputBoundaryInformation(StructBC *bcregion, int geometricDimension); //! Extract leaves of Bc faces which can not be split any more. LIB_EXPORT vector GetLeaves(); void SetRegion(vector &nodeStart, vector &nodeEnd); void SetDirection(int bcDirection) { this->bcDirection =bcDirection; } void SetAxisLabel(vector &axisLabel); void SetSimpleBlock(Pre_Block_Struct *simpleBlock); void SetNext(Pre_Patch_Struct *next); void SetChild(vector *child); void SetBoundaryType(int boundaryType); void SetBoundaryName(string bcName); void SetFaceMatchingTargetDirIndex(int *dir3dIn); vector & GetNodeStart(); vector & GetNodeEnd(); vector & GetAxisLabel(); Pre_Block_Struct * GetSimpleBlock(); Pre_Patch_Struct * GetNext(); int GetBoundaryType(); int GetDirection() { return bcDirection; } string GetBoundaryName(); int * GetFaceMatchingTargetDirIndex(); vector * GetChild(); private: void GetSurfaceDirection(vector &st, vector &ed, vector &nd, int bcDirection, int geometricDimension); void InitUnitMatrix(); }; //! @brief Pre_Patch_Struct defines patch face for current boundary face. class Pre_Patch_Struct { private: //! Correlative block index. int targetBlockLabel; //! Range of node index and local axis label. vector nodeStart, nodeEnd, axisLabel; //! Boundary Direction. int bcDirection; //! Node index mapping operator. vector > frameOfAxes; //! Pointer of target struct block; Pre_Block_Struct *simpleBlock; public: LIB_EXPORT Pre_Patch_Struct(); LIB_EXPORT ~Pre_Patch_Struct(); public: void SetRegion(vector &nodeStart, vector &nodeEnd); void SetNodeMapping(vector > &frameOfAxes); void SetAxisLabel(vector &axisLabel); void SetSimpleBlock(Pre_Block_Struct *simpleBlock); void SetTargetBlockLabel(int i); void SetDirection(int bcDirection) { this->bcDirection =bcDirection; } int GetDirection() { return bcDirection; } vector & GetNodeStart(); vector & GetNodeEnd(); vector & GetAxisLabel(); Pre_Block_Struct * GetSimpleBlock(); vector > & GetFrameOfAxes(); }; //! @brief Pre_Block_Struct defines basal structured grid. class Pre_Block_Struct { private: //! For multigrid case, numberOfUnitCells equals 2**(numberOfMultigrid - 1). static int numberOfUnitCells; //! Current zone index. int zoneIndex; //! Original zone index. int originalZoneIndex; //! Processor index of current zone. int processorIndex; //! Parent pointer of current zone. Pre_Block_Struct *parent; //! Child pointer of current zone. vector *child; //! Bc face pointer group of current zone. vector boundaryFaceList; //! Relative start and end node index in parent zone. vector originalIndex; //! For current zone, node number along i,j,k directions. vector nodeDimension; //! For original zone, ni, nj, nk are node number along i, j, k directions. int ni, nj, nk; //! For original zone, x, y, z are node coordinates with circulation k, j, i. vector x, y, z; public: LIB_EXPORT Pre_Block_Struct(); LIB_EXPORT ~Pre_Block_Struct(); public: //! Calculate number of unit cells for multi-grid case. LIB_EXPORT static void CalculateNumberOfUnitCells(int numberOfMultigrid); //! Generate space for node coordinates, i.e. x, y and z. LIB_EXPORT void GenerateCoordinateSpace(); //! Split current block by the parameter "numberOfCells" and compute relative locations for the left and right block. LIB_EXPORT void Split(RDouble numberOfCells, vector &leftDimension, vector &rightDimension, vector &leftOriginalIndex, vector &rightOriginalIndex); //! Create boundary face for new zones. LIB_EXPORT void CreateBoundaryFace(int geometricDimension); //! Normalize every boundary face for current zone. LIB_EXPORT void NormalizeBoundaryFace(int geometricDimension); void PatchChild(vector &t_st, vector &t_ed, Pre_Block_Struct *sourceBlock, int geometricDimension); void CreateBoundaryFace(Pre_BcFace_Struct *boundaryFace, int geometricDimension); void GetAbsoluteCoordinate(vector &st, vector &ed); void GetLocalCoordinate(vector &st, vector &ed, vector &local_st, vector &local_ed); void OutputBoundaryInformation(fstream &file, int geometricDimension); void GetRootInformation(Pre_Block_Struct *&root, vector &ref); void GenerateBoundaryFaceList(int numberOfBoundaryFaces); void WriteGridCoordinate(fstream &file, vector &nst, vector &ned); void CorrectSplitDimension(int axisSelect, RDouble numberOfCells, int geometricDimension, int &isplit); static int GetNumberOfUnitCells(); int GetNumberOfNodes(); int GetNumberOfCells(); void AddBoundaryFace(Pre_BcFace_Struct *boundaryFace); void SetZoneIndex(int iZone); void SetProcessorIndex(int iProcessor); void SetOriginalZoneIndex(int iZone); void SetParentBlock(Pre_Block_Struct *parent); void SetBoundaryFace(int i, Pre_BcFace_Struct *boundaryFace); int GetZoneIndex(); int GetOriginalZoneIndex(); Pre_BcFace_Struct * GetBoundaryFace(int i); vector GetBoundaryFaceList() { return this->boundaryFaceList; } void SetOriginalIndex(vector &od); void SetNodeDimension(vector &nd); vector & GetOriginalIndex(); vector & GetNodeDimension(); int GetNI() const; int GetNJ() const; int GetNK() const; void SetNI(int ni); void SetNJ(int nj); void SetNK(int nk); RDouble * GetX(); RDouble * GetY(); RDouble * GetZ(); private: bool IsOverlapBoundaryFace(vector &st, vector &ed, int geometricDimension); bool IsPoleBoundaryFace(int iDimension); bool PatchChild(Pre_BcFace_Struct *boundaryFace, vector &t_st, vector &t_ed, Pre_Block_Struct *sourceBlock, int geometricDimension); void GerneralSplit(Pre_BcFace_Struct *boundaryFace, Pre_BcFace_Struct *overlapBoundaryFace, int geometricDimension); void PatchSplit(Pre_BcFace_Struct *boundaryFace, Pre_BcFace_Struct *overlapBoundaryFace, int geometricDimension); void Free(); Pre_BcFace_Struct * GetOverlapBoundaryFace(vector &st, vector &ed, vector &st_ref, vector &ed_ref, int geometricDimension); }; #include "Pre_Block_Struct.hxx" int GetSurfaceLabel(vector &st, vector &ed); int SignFunction(int value); void CalculateVertexIndexOnTargetBlock(vector > &frameOfAxes, vector &p1, vector &p2); void GetIJKRegion(vector &blockNodeStart, vector &blockNodeEnd, vector &faceNodeStart, vector &faceNodeEnd, int localFaceLabel); }