예제 #1
0
        /// <summary>
        /// Loads a BoSSS grid from an grid file; the file type (see <see cref="ImporterTypes"/>) are determined by the file ending.
        /// </summary>
        public static GridCommons Import(string fileName)
        {
            using (var tr = new FuncTrace()) {
                ImporterTypes importerType = GetImporterType(fileName);

                tr.Info(string.Format("Loading {0} file '{1}'...", importerType.ToString(), fileName));
                IGridImporter importer;
                using (new BlockTrace("Import", tr)) {
                    switch (importerType)
                    {
                    case ImporterTypes.Gambit:
                        GambitNeutral gn = new GambitNeutral(fileName);
                        if (gn.BoSSSConversionNeccessary())
                        {
                            gn = gn.ToLinearElements();
                        }

                        importer = gn;
                        break;

                    case ImporterTypes.CGNS:
                        importer = new Cgns(fileName);
                        break;

                    case ImporterTypes.Gmsh:
                        importer = new Gmsh(fileName);
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }

                tr.Info("Converting to BoSSS grid ...");
                GridCommons grid;
                using (new BlockTrace("Conversion", tr)) {
                    grid = importer.GenerateBoSSSGrid();
                }

                return(grid);
            }
        }
예제 #2
0
        /// <summary>
        /// Loads a BoSSS grid from an grid file; the file type (see <see cref="ImporterTypes"/>) are determined by the file ending.
        /// </summary>
        public static GridCommons Import(string fileName)
        {
            using (var tr = new FuncTrace()) {
                int myrank;
                int size;
                csMPI.Raw.Comm_Rank(csMPI.Raw._COMM.WORLD, out myrank);
                csMPI.Raw.Comm_Size(csMPI.Raw._COMM.WORLD, out size);

                ImporterTypes importerType = default(ImporterTypes);
                if (myrank == 0)
                {
                    importerType = GetImporterType(fileName);
                }
                importerType = importerType.MPIBroadcast(0);


                IGridImporter importer;
                {
                    tr.Info(string.Format("Loading {0} file '{1}'...", importerType.ToString(), fileName));

                    using (new BlockTrace("Import", tr)) {
                        switch (importerType)
                        {
                        case ImporterTypes.Gambit:
                            if (size > 1)
                            {
                                throw new NotSupportedException("Not supported in parallel mode");
                            }
                            GambitNeutral gn = new GambitNeutral(fileName);
                            if (gn.BoSSSConversionNeccessary())
                            {
                                gn = gn.ToLinearElements();
                            }

                            importer = gn;
                            break;

                        case ImporterTypes.CGNS:
                            if (size > 1)
                            {
                                throw new NotSupportedException("Not supported in parallel mode");
                            }
                            importer = new Cgns(fileName);
                            break;

                        case ImporterTypes.Gmsh:
                            importer = new Gmsh(fileName);
                            break;

                        default:
                            throw new NotImplementedException();
                        }
                    }

                    tr.Info("Converting to BoSSS grid ...");
                }

                GridCommons grid;
                using (new BlockTrace("Conversion", tr)) {
                    grid = importer.GenerateBoSSSGrid();
                }


                return(grid);
            }
        }