当前位置: 首页>>代码示例>>C#>>正文


C# Cell.Init方法代码示例

本文整理汇总了C#中Cell.Init方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.Init方法的具体用法?C# Cell.Init怎么用?C# Cell.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cell的用法示例。


在下文中一共展示了Cell.Init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessSnapshotWithArrays


//.........这里部分代码省略.........
                            {
                                if (cell.Count > 0)
                                {
                                    // TODO(INDEX) create Cell index here
                                    if (writeParticlesBool)
                                    {
                                        particleBinWriter.WriteCell(cell);
                                    }
                                    //*********************************************************
                                    if (writeIndexBool)
                                    {
                                        List<ReverseIndexEntry> index = cell.createIndex();
                                        indexBinWriter.WriteReverseIndex(index);
                                    }
                                    //*********************************************************

                                    /*
                                    if (pars.firstSnapLoaded)
                                    {
                                        foreach (ReverseIndexEntry entry in index)
                                        {
                                            entry.WriteBinaryFirstSnap(indexBinWriter);
                                        }
                                    }
                                    else
                                    {
                                        foreach (ReverseIndexEntry entry in index)
                                        {
                                            entry.WriteBinaryForMerge(indexBinWriter);
                                        }
                                    }*/
                                }
                                currentPHkey = parts[i].phkey;
                                cell.Init(currentPHkey);
                            }
                            cell.AddToCell(parts[i]);
                        }
                        if (cell.Count > 0)
                        {
                            if (writeParticlesBool)
                            {
                                particleBinWriter.WriteCell(cell);
                            }
                            //*********************************************************
                            if (writeIndexBool)
                            {
                                List<ReverseIndexEntry> index = cell.createIndex();
                                indexBinWriter.WriteReverseIndex(index);
                            }
                            //*********************************************************
                            /*if (pars.firstSnapLoaded)
                            {
                                foreach (ReverseIndexEntry entry in index)
                                {
                                    entry.WriteBinaryFirstSnap(indexBinWriter);
                                }
                            }
                            else
                            {
                                foreach (ReverseIndexEntry entry in index)
                                {
                                    entry.WriteBinaryForMerge(indexBinWriter);
                                }
                            }
                            */
                        }
开发者ID:dcrankshaw,项目名称:GadgetLoader,代码行数:67,代码来源:Process.cs

示例2: ProcessSnapshotWithArrays

        private void ProcessSnapshotWithArrays(short snap)
        {
            DebugOut.PrintLine("PROCESSING SNAPSHOT WITH ARRAYS" + snap);
            // using this only if needed
            HsmlReader hsmlReader = new HsmlReader();

            // and make the directory, just to be safe
            try
            {
                Directory.CreateDirectory(GetSnapDir(outPath, snap));
            }
            catch (IOException e)
            {
                System.Console.WriteLine(e.Message);
            }

            int curFile = firstSnapshotFile; // index of current read/write file
            int numFile = 0;
            if (useHsml)
                hsmlReader = new HsmlReader(GetHsmlPath(inPath, snap));

            if (lastSnapshotFile < firstSnapshotFile)
            {
                lastSnapshotFile = firstSnapshotFile;
                numFile = -1;
            }
            while (curFile <= lastSnapshotFile)
            {
                DebugOut.PrintLine("..file " + curFile + "/" + lastSnapshotFile);

                string filename = "";
                try
                {
                    filename = GetSnapFile(inPath, snap, snapshotFilePrefix, curFile);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    return;
                }
                // now load the file
                SnapFile curSnap = new SnapFile(filename, samplingRate);
                // and open the stream for writing
                using (SqlBinaryWriter binwriter = new SqlBinaryWriter(new FileStream(GetSnapDefault(outPath, snap, snapshotFilePrefix, curFile), FileMode.Create)))
                {
                    Structs[] parts = new Structs[curSnap.numSample];
                    // now write each particle into the array
                    for (int i = 0; i < curSnap.numSample; i++)
                    {
                        parts[i].x = curSnap.pos[i, 0];
                        parts[i].y = curSnap.pos[i, 1];
                        parts[i].z = curSnap.pos[i, 2];
                        parts[i].vx = curSnap.vel[i, 0];
                        parts[i].vy = curSnap.vel[i, 1];
                        parts[i].vz = curSnap.vel[i, 2];
                        parts[i].snapnum = snap;
                        parts[i].id = curSnap.id[i];
                        // add in highest-order bit
                        parts[i].id |= ((UInt64)curSnap.nLargeSims[1]) << 32;
                        // make ph-key
                        parts[i].phkey = GetPHKey(parts[i].x, parts[i].y, parts[i].z);
                        // read hsml, if desired
                        if (useHsml) // TODO fix this part for random sampling
                        {
                            parts[i].hsml = hsmlReader.GetHsml();
                            parts[i].veldisp = hsmlReader.GetVelDisp();
                            parts[i].density = hsmlReader.GetDensity();
                            // and advance read pointer
                            hsmlReader.Next();
                        }
                    }
                    // now sort before writing files
                    // TBD this may not be necessary if the particles
                    // are sorted in the files already.
                    Array.Sort<Structs>(parts, new ParticleComparator());

                    Cell cell = new Cell(snap);
                    int currentPHkey = -1;
                    for (int i = 0; i < curSnap.numSample; i++)
                    {
                        if (parts[i].phkey != currentPHkey)
                        {
                            if(cell.Count > 0)
                                binwriter.Write(cell);
                            currentPHkey = parts[i].phkey;
                            cell.Init(currentPHkey);
                        }
                        cell.Add(parts[i]);
                    }
                    if (cell.Count > 0)
                        binwriter.Write(cell);

                    // and add a bulk insert
                    DebugOut.AddCommand(GetSnapDefault(outPath, snap, snapshotFilePrefix, curFile), snapshotTable);

                    DebugOut.PrintLine("..wrote " + curSnap.numSample + "/" + curSnap.numTotals[1] + " points");
                }

                // and set numFiles
                if (numFile == -1)
//.........这里部分代码省略.........
开发者ID:dcrankshaw,项目名称:GadgetLoader,代码行数:101,代码来源:Process.cs

示例3: ProcessSnapshotWithArrays

        private void ProcessSnapshotWithArrays(short snap)
        {
            //DebugOut.PrintLine("PROCESSING SNAPSHOT WITH ARRAYS" + snap);
            // using this only if needed

            List<SnapFileSummary> results = new List<SnapFileSummary>();
            //and make the directory, just to be safe
            try
            {
                Directory.CreateDirectory(outPath);

            }
            catch (IOException e)
            {
                globals.summary.addError(e.Message);
                return;
            }

            int curFile = firstSnapshotFile; // index of current read/write file
            int numFile = 0;

            if (lastSnapshotFile < firstSnapshotFile)
            {
                lastSnapshotFile = firstSnapshotFile;
                numFile = -1;
            }

            while (curFile <= lastSnapshotFile)
            {
                //DebugOut.PrintLine("..file " + curFile + "/" + lastSnapshotFile);
                Console.WriteLine("..file " + curFile + "/" + lastSnapshotFile);
                SnapFileSummary currentFileSummary = new SnapFileSummary();
                results.Add(currentFileSummary);
                currentFileSummary.start = DateTime.Now;
                currentFileSummary.fileNumber = curFile;

                string filename = "";
                try
                {
                    filename = GetSnapFile(inPath, snap, snapshotFilePrefix, curFile);
                    currentFileSummary.inFileName = filename;
                }

                catch (Exception e)
                {
                    currentFileSummary.badStatus = true;
                    currentFileSummary.statusMessage = e.Message;
                    globals.summary.setFileSummaries(results);
                    return;
                }
                // now load the file
                try
                {
                    SnapFile curSnap = new SnapFile(filename);
                    // and open the stream for writing
                    using (SqlBinaryWriter binwriter = new SqlBinaryWriter(new FileStream(GetSnapDefault(outPath, snap, snapshotFilePrefix, curFile), FileMode.Create)))
                    {
                        Structs[] parts = new Structs[curSnap.numSample];
                        //record destination path in file summary
                        currentFileSummary.outFileName = GetSnapDefault(outPath, snap, snapshotFilePrefix, curFile);
                        // now write each particle into the array
                        for (int i = 0; i < curSnap.numSample; i++)
                        {
                            parts[i].x = curSnap.pos[i, 0];
                            parts[i].y = curSnap.pos[i, 1];
                            parts[i].z = curSnap.pos[i, 2];
                            parts[i].vx = curSnap.vel[i, 0];
                            parts[i].vy = curSnap.vel[i, 1];
                            parts[i].vz = curSnap.vel[i, 2];
                            parts[i].snapnum = snap;
                            parts[i].id = curSnap.id[i];
                            // add in highest-order bit
                            parts[i].id |= ((UInt64)curSnap.nLargeSims[1]) << 32;
                            // make ph-key
                            parts[i].phkey = GetPHKey(parts[i].x, parts[i].y, parts[i].z);

                        }
                        // now sort before writing files
                        // TODO
                        //TBD this may not be necessary if the particles
                        // are sorted in the files already.
                        Array.Sort<Structs>(parts, new ParticleComparator());

                        Cell cell = new Cell(snap);
                        int currentPHkey = -1;
                        for (int i = 0; i < curSnap.numSample; i++)
                        {
                            if (parts[i].phkey != currentPHkey)
                            {
                                if (cell.Count > 0)
                                    binwriter.WriteCell(cell);
                                currentPHkey = parts[i].phkey;
                                cell.Init(currentPHkey);
                            }
                            cell.AddToCell(parts[i]);
                        }
                        if (cell.Count > 0)
                            binwriter.WriteCell(cell);

                        // and add a bulk insert
//.........这里部分代码省略.........
开发者ID:dcrankshaw,项目名称:pp_final_project,代码行数:101,代码来源:process_fof.cs

示例4: startColliding

        public void startColliding()
        {
            String filename = prefix + j;
            SnapFile curSnap = new SnapFile(filename);
            Console.Out.WriteLine("Processing file " + j);
            Console.Out.Flush();
            Structs[] parts = new Structs[curSnap.numSample];

            // now write each particle into the array
            for (int i = 0; i < curSnap.numSample; i++)
            {
                parts[i].x = curSnap.pos[i, 0];
                parts[i].y = curSnap.pos[i, 1];
                parts[i].z = curSnap.pos[i, 2];
                parts[i].vx = curSnap.vel[i, 0];
                parts[i].vy = curSnap.vel[i, 1];
                parts[i].vz = curSnap.vel[i, 2];
                parts[i].snapnum = snap;
                parts[i].id = curSnap.id[i];
                // add in highest-order bit
                parts[i].id |= ((UInt64)curSnap.nLargeSims[1]) << 32;
                // make ph-key
                parts[i].phkey = GetPHKey(parts[i].x, parts[i].y, parts[i].z);

            }
            // now sort before writing files
            // TODO
            //TBD this may not be necessary if the particles
            // are sorted in the files already.
            Array.Sort<Structs>(parts, new ParticleComparator());

            Cell cell = new Cell(snap);
            int currentPHkey = -1;

            //for (int i = 0; i < 10000; i++)
            for (int i = 0; i < curSnap.numSample; i++)
            {
                if (parts[i].phkey != currentPHkey)
                {
                    if (cell.Count > 0)
                        processCell(cell, datapoints);
                    currentPHkey = parts[i].phkey;
                    cell.Init(currentPHkey);
                }
                cell.AddToCell(parts[i]);
                if (i % 100000 == 0)
                {
                    Console.Out.WriteLine("Particle " + i + " from file " + j);
                    Console.Out.Flush();
                }

            }
            if (cell.Count > 0)
                processCell(cell, datapoints);
        }
开发者ID:dcrankshaw,项目名称:GadgetLoader,代码行数:55,代码来源:Driver.cs


注:本文中的Cell.Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。