コード例 #1
0
ファイル: CgnsZoneToBoSSSGrid.cs プロジェクト: xyuan/BoSSS
 private int NumberOfFaceEdges(ElementType_t type)
 {
     if (Is3D(type))
     {
         if (type.Equals(ElementType_t.HEXA_8))
         {
             return(4);
         }
         return(3);
     }
     else
     {
         if (number_of_coord_dimensions == 3)
         {
             if (type.Equals(ElementType_t.TRI_3))
             {
                 return(3);
             }
             if (type.Equals(ElementType_t.QUAD_4))
             {
                 return(4);
             }
         }
         return(2);
     }
 }
コード例 #2
0
ファイル: CgnsZoneToBoSSSGrid.cs プロジェクト: xyuan/BoSSS
 private int NumberOfFacesPerElement(ElementType_t type)
 {
     if (number_of_coord_dimensions == 3)
     {
         if (type.Equals(ElementType_t.TRI_3) || type.Equals(ElementType_t.QUAD_4))
         {
             return(1);
         }
     }
     if (type.Equals(ElementType_t.HEXA_8))
     {
         return(6);
     }
     char[] number = type.ToString().ToCharArray();
     return(number[number.Length - 1] - 48);
 }
コード例 #3
0
ファイル: CgnsZoneToBoSSSGrid.cs プロジェクト: xyuan/BoSSS
 private bool ChoosenBoSSSCompliantElementType(ElementType_t type)
 {
     return(type.Equals(bosss_element_type));
 }
コード例 #4
0
ファイル: CgnsZoneToBoSSSGrid.cs プロジェクト: xyuan/BoSSS
 private static bool BoSSSCompliantElementType(ElementType_t type)
 {
     return(type.Equals(ElementType_t.TRI_3) || type.Equals(ElementType_t.TETRA_4) || type.Equals(ElementType_t.QUAD_4) || type.Equals(ElementType_t.HEXA_8));
 }
コード例 #5
0
ファイル: CgnsZoneToBoSSSGrid.cs プロジェクト: xyuan/BoSSS
 private static bool Is3D(ElementType_t type)
 {
     return(type.Equals(ElementType_t.TETRA_4) || type.Equals(ElementType_t.HEXA_8));
 }
コード例 #6
0
ファイル: CgnsZoneToBoSSSGrid.cs プロジェクト: xyuan/BoSSS
        /// <summary>
        /// Generates a grid commons object
        /// </summary>
        /// <returns>the grid commons object</returns>
        public GridCommons GenerateBoSSSGrid()
        {
            int j, k, l, i;
            int max_bc_index = -1;

            GenerateZonelessAndSectionlessArrays();
            CoordinateSystemTransformation();
            VertexIndexNumberingTransformation();
            //BuildFaces();
            //BuildAndShareBoundaryConditions();
            //BuildNeighbourship();

            double[, ,] vertices = new double[bosss_elements, verticesPerCell, number_of_coord_dimensions];
            long[] globalID = new long[bosss_elements];
            byte[,] edgeTags = new byte[bosss_elements, number_of_faces_per_element];

            for (l = 0, k = 0; l < bosss_elements; l++)
            {
                j = bosss_element_index_to_cgns_element_index[l];
                for (int n = 0; n < verticesPerCell; n++)
                {
                    k = cgns_element_index_to_bosss_element_index[j];

                    int node_no = elements[j][n];

                    vertices[k, n, 0] = x[node_no];
                    vertices[k, n, 1] = y[node_no];
                    if (number_of_coord_dimensions == 3)
                    {
                        vertices[k, n, 2] = z[node_no];
                    }
                }
            }

            GridCommons grd = null;

            if (bosss_element_type.Equals(ElementType_t.QUAD_4))
            {
                grd = new Grid2D(new Square());
            }
            else if (bosss_element_type.Equals(ElementType_t.TRI_3))
            {
                grd = new Grid2D(new Triangle());
            }
            else if (bosss_element_type.Equals(ElementType_t.HEXA_8))
            {
                throw new NotImplementedException();
            }
            else if (bosss_element_type.Equals(ElementType_t.TETRA_4))
            {
                throw new NotImplementedException();
            }
            else
            {
                throw new NotSupportedException("Unsupported BoSSS element type");
            }

            int tag_number = 1;

            for (i = 0; i < bcelements.Length; i++)         // over boundary condition indices
            {
                foreach (int z in bc_to_element_indices[i]) // over elements
                {
                    j = z >> number_of_faces_per_element;
                    j = cgns_element_index_to_bosss_element_index[j];
                    k = z & number_of_faces_per_element_mask;
                    edgeTags[j, k] = (byte)tag_number;
                    if (tag_number > max_bc_index)
                    {
                        max_bc_index = tag_number;
                    }
                }
                tag_number++;
            }


            bool          duplicatedBoundaryConditionNames = false;
            List <string> edgeTagNameList = new List <string>();

            for (i = 0; i < max_bc_index; i++)   // over boundary condition interfaces
            {
                string edgeTagName = CleanString(new string(boconames[i]));

                if (edgeTagNameList.Contains(edgeTagName))
                {
                    duplicatedBoundaryConditionNames = true;
                }
                edgeTagNameList.Add(edgeTagName);
            }

            tag_number = 1;
            List <string> edgeTagNameForbiddenList = new List <string>();
            List <int>    numberList = new List <int>();

            if (duplicatedBoundaryConditionNames)
            {
                for (i = 0; i < edgeTagNameList.Count; i++)
                {
                    string edgeTagName = edgeTagNameList[i];

                    if (edgeTagNameForbiddenList.Contains(edgeTagName))
                    {
                        continue;
                    }
                    for (j = i + 1; j < edgeTagNameList.Count; j++)
                    {
                        if (edgeTagNameList[j].Equals(edgeTagName))
                        {
                            replaceEdgeTagNumerInCaseOfDublicateBoundaryConditions(edgeTags, (byte)(j + 1), (byte)(i + 1));
                            max_bc_index--;
                            if (numberList.Contains(i + 1))
                            {
                                continue;
                            }
                            numberList.Add(i + 1);
                        }
                    }
                    edgeTagNameForbiddenList.Add(edgeTagName);
                }
                for (i = 0; i < max_bc_index; i++)   // over boundary condition interfaces
                {
                    replaceEdgeTagNumerInCaseOfDublicateBoundaryConditions(edgeTags, (byte)numberList[i], (byte)(i + 1));
                }
                for (i = 0; i < max_bc_index; i++)   // over boundary condition interfaces
                {
                    grd.EdgeTagsNames.Add((byte)tag_number, edgeTagNameForbiddenList[i]);
                    tag_number++;
                }
            }
            else
            {
                foreach (string edgeTagName in edgeTagNameList)
                {
                    grd.EdgeTagsNames.Add((byte)tag_number, edgeTagName);
                    tag_number++;
                }
            }

            /*
             *
             * // remove 'internal' boundaries ...
             * {
             *  // pointvise may also assign boundaries for internal edges...
             *  // this is not allowed by bosss, so we have to clear them
             *
             *  int E = cell_neighbours.GetLength(1);
             *
             *  for (j = 0; j < bosss_elements; j++) {
             *      for (int e = 0; e < E; e++) {
             *          if (cell_neighbours[j, e] >= 0)
             *              // this is an internal edge
             *              if (edgeTags[j, e] != 0)
             *                  edgeTags[j, e] = 0;
             *      }
             *  }
             *
             *  // remove unused edgetag-names
             *  int[] EdgeTagUseCnt = new int[tag_number];
             *  for (j = 0; j < bosss_elements; j++) {
             *      for (int e = 0; e < E; e++) {
             *          int tag = edgeTags[j, e];
             *          EdgeTagUseCnt[tag]++;
             *      }
             *  }
             *
             *
             *  for (int tag = 0; tag < tag_number; tag++) {
             *      if (EdgeTagUseCnt[tag] <= 0)
             *          grd.EdgeTagsNames.Remove((byte)tag);
             *  }
             *
             *
             *  //// test whether all boundary edges have an assigned edge tag...
             *  //// (it's legal for a BoSSS grid to have unspecified edge tags)
             *  //for (j = 0; j < bosss_elements; j++) {
             *  //    for (int e = 0; e < E; e++) {
             *  //        int tag = edgeTags[j, e];
             *  //        long neigh = cell_neighbours[j,e];
             *
             *  //        if (neigh < 0 && tag == 0)
             *  //            throw new ApplicationException("found boundary edge without assigned edge tag.");
             *  //    }
             *  //}
             *
             * } */

            grd.Description = "Created from BoSSS";

            grd.Cells = new Cell[bosss_elements];
            for (j = 0; j < bosss_elements; j++)
            {
                grd.Cells[j]          = new Cell();
                grd.Cells[j].GlobalID = j;

                //grd.Cells[j].Neighbours = new long[number_of_faces_per_element];
                //grd.Cells[j].EdgeTags = new byte[number_of_faces_per_element];
                throw new NotImplementedException("todo");
                for (i = 0; i < number_of_faces_per_element; i++)
                {
                    //grd.Cells[j].Neighbours[i] = cell_neighbours[j, i];
                    //grd.Cells[j].EdgeTags[i] = edgeTags[j, i];
                }
            }

            //grd.Vertices = vertices;

            throw new NotImplementedException("todo");

            //return grd;
        }