Example #1
0
        void ConstructorCommon()
        {
            var Krefs = this.XDGSpaceMetrics.GridDat.Grid.RefElements;


            // initialize some mask's and subgrids
            // ===================================

            // since most methods of this class are non-collective,
            // an access to some Subgrid-member may cause an MPI-deadlock.
            // (this becomes even more unpredictable due to the on-demand-pattern in which most members of the Subgrid-class are implemented);

            //
            foreach (var spId in this.SpeciesList)
            {
                SubGrid spSgrd = this.XDGSpaceMetrics.LevelSetRegions.GetSpeciesSubGrid(spId);

                this.m_SpeciesSubgrid_InnerAndDomainEdges.Add(
                    spId,
                    spSgrd.InnerEdgesMask.Union(spSgrd.AllEdgesMask.Intersect(XDGSpaceMetrics.GridDat.BoundaryEdges)));
            }

            // all cut edges
            // =============
            m_CutCellSubgrid_InnerEdges = this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubGrid().InnerEdgesMask;

            // cut edges sorted according to reference element and level-set
            // =============================================================
            int NoOfLs = this.XDGSpaceMetrics.NoOfLevelSets;

            this.m_CutEdges       = new EdgeMask[Krefs.Length, NoOfLs];
            this.m_HMFEdgesDomain = new EdgeMask[Krefs.Length, NoOfLs];
            for (int iKref = 0; iKref < this.m_CutEdges.GetLength(0); iKref++)
            {
                for (int iLevSet = 0; iLevSet < this.m_CutEdges.GetLength(1); iLevSet++)
                {
                    EdgeMask cutEdges = this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubgrid4LevSet(iLevSet).InnerEdgesMask.Union(
                        this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubgrid4LevSet(iLevSet).AllEdgesMask.Intersect(this.XDGSpaceMetrics.GridDat.BoundaryEdges));



                    cutEdges = cutEdges.Intersect(this.XDGSpaceMetrics.GridDat.GetRefElementSubGrid(iKref).AllEdgesMask);
                    cutEdges = cutEdges.ToGeometicalMask();

                    Debug.Assert(cutEdges.MaskType == MaskType.Geometrical);
                    this.m_CutEdges[iKref, iLevSet] = cutEdges;

                    // (all edges of 'Kref'-elements) \cap (all edges of cells cut by 'iLevSet')
                    this.m_HMFEdgesDomain[iKref, iLevSet] = this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubgrid4LevSet(iLevSet).AllEdgesMask.Intersect(this.XDGSpaceMetrics.GridDat.GetRefElementSubGrid(iKref).AllEdgesMask);
                }
            }
        }
Example #2
0
        /*
         * /// <summary>
         * /// ctor.
         * /// </summary>
         * /// <param name="momentFittingVariant"></param>
         * /// <param name="order"></param>
         * /// <param name="NonAggCutCellMetric">Can be null, see <see cref="CellAgglomeration"/>.</param>
         * public XQuadSchemeHelper(CutCellMetrics NonAggCutCellMetric, XQuadFactoryHelper.MomentFittingVariants momentFittingVariant) {
         *  MPICollectiveWatchDog.Watch();
         *  this.lsTrk = NonAggCutCellMetric.Tracker;
         *  this.MomentFittingVariant = momentFittingVariant;
         *  this.CellAgglomeration = null;
         *  this.NonAgglomeratedMetrics = NonAggCutCellMetric;
         *  this.SpeciesList = NonAgglomeratedMetrics.SpeciesList.ToList().AsReadOnly();
         *  this.GhostSupport = false;
         *
         *  ConstructorCommon();
         * }
         *
         * /// <summary>
         * /// ctor.
         * /// </summary>
         * /// <param name="order"></param>
         * /// <param name="agg">Can be null, see <see cref="CellAgglomeration"/>.</param>
         * public XQuadSchemeHelper(MultiphaseCellAgglomerator agg) {
         *  MPICollectiveWatchDog.Watch();
         *  this.lsTrk = agg.Tracker;
         *  this.MomentFittingVariant = agg.HMFvariant;
         *  this.CellAgglomeration = agg;
         *  this.NonAgglomeratedMetrics = agg.NonAgglomeratedMetrics;
         *  this.SpeciesList = agg.SpeciesList.ToList().AsReadOnly();
         *  this.GhostSupport = false;
         *
         *  ConstructorCommon();
         * }
         */

        void ConstructorCommon()
        {
            var Krefs = this.XDGSpaceMetrics.GridDat.Grid.RefElements;


            // initialize some mask's and subgrids
            // ===================================

            // since most methods of this class are non-collective,
            // an access to some Subgrid-member may cause an MPI-deadlock.
            // (this becomes even more unpredictable due to the on-demand-pattern in which most members of the Subgrid-class are implemented);

            //
            foreach (var spId in this.SpeciesList)
            {
                SubGrid spSgrd = this.XDGSpaceMetrics.LevelSetRegions.GetSpeciesSubGrid(spId);

                this.m_SpeciesSubgrid_InnerAndDomainEdges.Add(
                    spId,
                    spSgrd.InnerEdgesMask.Union(spSgrd.AllEdgesMask.Intersect(XDGSpaceMetrics.GridDat.BoundaryEdges)));
            }

            // all cut edges
            // =============
            m_CutCellSubgrid_InnerEdges = this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubGrid().InnerEdgesMask;

            // cut edges sorted according to reference element and level-set
            // =============================================================
            int NoOfLs = this.XDGSpaceMetrics.NoOfLevelSets;

            this.m_CutEdges       = new EdgeMask[Krefs.Length, NoOfLs];
            this.m_HMFEdgesDomain = new EdgeMask[Krefs.Length, NoOfLs];
            for (int iKref = 0; iKref < this.m_CutEdges.GetLength(0); iKref++)
            {
                for (int iLevSet = 0; iLevSet < this.m_CutEdges.GetLength(1); iLevSet++)
                {
                    EdgeMask cutEdges = this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubgrid4LevSet(iLevSet).InnerEdgesMask.Union(
                        this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubgrid4LevSet(iLevSet).AllEdgesMask.Intersect(this.XDGSpaceMetrics.GridDat.BoundaryEdges));



                    cutEdges = cutEdges.Intersect(this.XDGSpaceMetrics.GridDat.GetRefElementSubGrid(iKref).AllEdgesMask);
                    cutEdges = cutEdges.ToGeometicalMask();

                    Debug.Assert(cutEdges.MaskType == MaskType.Geometrical);
                    this.m_CutEdges[iKref, iLevSet] = cutEdges;

                    // (all edges of 'Kref'-elements) \cap (all edges of cells cut by 'iLevSet')
                    this.m_HMFEdgesDomain[iKref, iLevSet] = this.XDGSpaceMetrics.LevelSetRegions.GetCutCellSubgrid4LevSet(iLevSet).AllEdgesMask.Intersect(this.XDGSpaceMetrics.GridDat.GetRefElementSubGrid(iKref).AllEdgesMask);
                }
            }

            //if (this.GhostSupport == true) {
            //    for (int iKref = 0; iKref < Krefs.Length; iKref++) {
            //        m_Subgrid4Kref_AllEdges.Add(
            //            Krefs[iKref],
            //            this.lsTrk.GridDat.GetRefElementSubGrid(iKref).AllEdgesMask);
            //    }
            //}

            //this.GhostIntegrationDomain = new Dictionary<SpeciesId, EdgeMask>();


            /*
             * if (this.CellAgglomeration != null) {
             *  if (!object.ReferenceEquals(this.CellAgglomeration.Tracker, this.lsTrk))
             *      throw new ArgumentException();
             *
             *  SpeciesId[] AgglomSpecies = this.CellAgglomeration.SpeciesList.ToArray();
             *
             *  var Edge2Cell = this.lsTrk.GridDat.Edges.CellIndices;
             *  int J = this.lsTrk.GridDat.Cells.NoOfLocalUpdatedCells;
             *  int JE = this.lsTrk.GridDat.Cells.NoOfCells;
             *  int E = this.lsTrk.GridDat.Edges.Count;
             *
             *
             *  // eliminate "empty" edges
             *  for (int iSpc = 0; iSpc < AgglomSpecies.Length; iSpc++) {
             *      var spId = AgglomSpecies[iSpc];
             *      MultidimensionalArray EdgeArea = this.NonAgglomeratedMetrics.CutEdgeAreas[spId];
             *      MultidimensionalArray Volumes = this.NonAgglomeratedMetrics.CutCellVolumes[spId];
             *
             *
             *      // compute ghost exclusions (part 1)
             *      // =================================
             *      List<int> GhostExclusions = new List<int>();
             *      var E2C = this.lsTrk.GridDat.Edges.CellIndices;
             *      foreach (int jEdge in this.GetEdgeMask(spId).ItemEnum) {
             *          int jCell0 = E2C[jEdge, 0];
             *          if (Volumes[jCell0] <= 1.0e-10) {
             *              GhostExclusions.Add(jEdge);
             *          } else {
             *              int jCell1 = E2C[jEdge, 1];
             *              if (jCell1 >= 0) {
             *                  if (Volumes[jCell1] <= 1.0e-10) {
             *                      GhostExclusions.Add(jEdge);
             *                  }
             *              }
             *          }
             *      }
             *
             *
             *      // determine edges over which agglomeration is forbidden
             *      // (because their measure is zero)
             *      // =====================================================
             *      {
             *
             *          var scheme = this.GetEdgeQuadScheme(spId).Compile(_lsTrk.GridDat, order);
             *
             *          foreach (ChunkRulePair<QuadRule> cqr in scheme) {
             *              for (int iEdge = cqr.Chunk.i0; iEdge < cqr.Chunk.JE; iEdge++) {
             *                  var edgArea = cqr.Rule.Weights.Sum();
             *                  EdgeArea[iEdge] = edgArea;
             *                  if (edgArea <= 1.0e-12) {
             *                      // edge has zero measure => should not be in the ghost scheme
             *                      GhostExclusions.Add(iEdge);
             *                  }
             *              }
             *          }
             *      }
             *
             *      if (GhostExclusions.Count > 0) {
             *          var _newGhostIntegrationDomain = _GhostIntegrationDomain.GetBitMask().CloneAs();
             *          foreach (int iEdge in GhostExclusions)
             *              _newGhostIntegrationDomain[iEdge] = false;
             *          _GhostIntegrationDomain = new EdgeMask(lsTrk.GridDat, _newGhostIntegrationDomain);
             *      }
             *
             *      this.GhostIntegrationDomain.Add(spId, _GhostIntegrationDomain);
             *  }
             * }
             */
        }