예제 #1
0
        /// <summary>
        /// Calculate Nusselt number for Low-Mach number flows.
        /// </summary>
        /// <param name="Timestep"></param>
        /// <param name="GridDat"></param>
        /// <param name="Temperature"></param>
        /// <param name="SolverConf"></param>
        void CalculateNusselt(TimestepNumber Timestep, IGridData GridDat, SinglePhaseField Temperature, SIMPLEControl SolverConf)
        {
            // Initialize calculation of Nusselt number.
            if (NusseltNum == null)
            {
                LowMachSIMPLEControl lowMachConf = SolverConf as LowMachSIMPLEControl;
                NusseltNum = new NusseltNumber(GridDat, Temperature, lowMachConf.EoS, lowMachConf.EdgeTagsNusselt);

                if ((base.MPIRank == 0) && (CurrentSessionInfo.ID != Guid.Empty))
                {
                    LogNusselt = base.DatabaseDriver.FsDriver.GetNewLog("Nusselt", CurrentSessionInfo.ID);
                    LogNusselt.Write("Timestep");
                    for (int bc = 0; bc < NusseltNum.Nusselt.Length; bc++)
                    {
                        LogNusselt.Write("\t" + lowMachConf.EdgeTagsNusselt[bc]);
                    }
                    LogNusselt.WriteLine();
                }
            }

            // Calculate Nusselt number
            NusseltNum.CalculateNusseltNumber();

            // Write result to text file
            if ((base.MPIRank == 0) && (LogNusselt != null))
            {
                LogNusselt.Write(Timestep.ToString());
                for (int bc = 0; bc < NusseltNum.Nusselt.Length; bc++)
                {
                    LogNusselt.Write("\t" + NusseltNum.Nusselt[bc].ToString("0.0000000000E+00", NumberFormatInfo.InvariantInfo));
                }
                LogNusselt.WriteLine();
                LogNusselt.Flush();
            }
        }
예제 #2
0
        public ThermalMultiphaseBoundaryCondMap(IGridData f, IDictionary <string, BoSSS.Solution.Control.AppControl.BoundaryValueCollection> b, string[] SpeciesNames)
            : base(f, b, BndFunctions(f, SpeciesNames)) //
        {
            string S0 = "#" + SpeciesNames[0];

            base.bndFunction.Add(VariableNames.Temperature, base.bndFunction[VariableNames.Temperature + S0]);
        }
예제 #3
0
 /// <summary>
 /// coarsens level <paramref name="ag"/> (aggregation of grid data objects)
 /// </summary>
 /// <param name="ag">
 /// input grid, which should be aggregated
 /// </param>
 /// <param name="AggCellCount">
 /// desired number of parts for each aggregate cell
 /// </param>
 public static AggregationGridData Coarsen(IGridData ag, int AggCellCount)
 {
     using (new FuncTrace()) {
         int[][] Coarsened_ComositeCells = AggregationKernel(ag, AggCellCount);
         return(new AggregationGridData(ag, Coarsened_ComositeCells));
     }
 }
예제 #4
0
        private void DrawBlock(IGridData block)
        {
            Vector2 size       = new Vector2(200, 100);
            Rect    windowRect = new Rect(lastClickPoint, size);

            GUILayout.Window(2, windowRect, block.DrawEditorData, block.PrintCoordinates());
        }
예제 #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="aggregationGrid">
        /// Aggregation grid.
        /// </param>
        /// <param name="AggregationCells">
        /// Coarse cells which build up the fine cells.
        /// - 1st index: coarse (i.e. this) grid cell index
        /// - 2nd index: enumeration
        /// - content: local cell index into the parent grid <paramref name="pGrid"/>.
        /// </param>
        public AggregationGridData(AggregationGrid aggregationGrid, int[][] AggregationCells)
        {
            this.aggregationGrid = aggregationGrid;
            IGridData pGrid = aggregationGrid.ParentGrid.iGridData;

            InitializeGridData(pGrid, AggregationCells);
        }
예제 #6
0
파일: EdgeMask.cs 프로젝트: octwanna/BoSSS
 /// <summary>
 /// Retrieves a mask containing all edges (i.e. returns the
 /// complement of <see cref="GetEmptyMask"/>)
 /// </summary>
 /// <param name="gridDat">
 /// Grid data that the returned mask will be assigned with
 /// </param>
 /// <returns>A full mask</returns>
 public static EdgeMask GetFullMask(IGridData gridDat)
 {
     return(new EdgeMask(gridDat, new Chunk {
         i0 = 0,
         Len = gridDat.iLogicalEdges.Count
     }));
 }
예제 #7
0
 public OptimizedSIPGDensityFlux(CNSControl config, IBoundaryConditionMap boundaryMap, ISpeciesMap speciesMap, IGridData gridData, Func <MultidimensionalArray> cellMetric)
 {
     this.config      = config;
     this.speciesMap  = speciesMap;
     this.boundaryMap = boundaryMap;
     this.gridData    = gridData;
 }
예제 #8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gridData"></param>
        /// <param name="config"></param>
        public IBMFieldSet(IGridData gridData, IBMControl config)
            : base(gridData, config)
        {
            this.config = config;

            if (config.RestartInfo == null && !config.FieldOptions.ContainsKey(IBMVariables.LevelSet))
            {
                throw new Exception(
                          "Field 'levelSet' is required for IBM applications");
            }

            LevelSet = new LevelSet(
                new Basis(gridData, config.FieldOptions[IBMVariables.LevelSet].Degree),
                IBMVariables.LevelSet);

            if (config.ContinuousLevelSet)
            {
                SpecFemBasis specFEMBasis = new SpecFemBasis((GridData)gridData, LevelSet.Basis.Degree);

                SpecFemField specFemField = new SpecFemField(specFEMBasis);
                specFemField.ProjectDGFieldMaximum(1.0, LevelSet);
                LevelSet.Clear();
                specFemField.AccToDGField(1.0, LevelSet);
            }

            LevelSetGradient = new DGField[CompressibleEnvironment.NumberOfDimensions];
            for (int d = 0; d < CompressibleEnvironment.NumberOfDimensions; d++)
            {
                LevelSetGradient[d] = DerivedFields[IBMVariables.LevelSetGradient[d]];
            }
        }
예제 #9
0
        /// <summary>
        /// Builds an execution mask from a bit array. If an entry is set to
        /// true in the bit array, it indicates that an element should be part
        /// of the execution mask.
        /// </summary>
        /// <param name="Mask">The mask as <see cref="BitArray"/></param>
        /// <param name="grddat">
        /// the grid that this mask will be associated with;
        /// </param>
        /// <param name="__MaskType">
        /// <see cref="ExecutionMask.MaskType"/>
        /// </param>
        protected ExecutionMask(IGridData grddat, BitArray Mask, MaskType __MaskType)
        {
            if (grddat == null)
            {
                throw new ArgumentNullException();
            }

            List <int> _Sequence = new List <int>();

            m_GridData    = grddat;
            this.MaskType = __MaskType;

            int Lmax = GetUpperIndexBound(this.m_GridData);

            if (Mask.Count > Lmax)
            {
                throw new ArgumentException("length of mask must be smaller or equal to number of cells/edges;", "Mask");
            }

            int N = Mask.Count;

            Chunk c;

            c.i0  = -1;
            c.Len = 0;
            for (int n = 0; n < N; n++)
            {
                bool mn = Mask[n];

                if (mn == true)
                {
                    if (c.i0 < 0)
                    {
                        c.i0 = n;
                    }
                    c.Len++;
                }
                else
                {
                    if (c.i0 >= 0)
                    {
                        // close chunk
                        PushChunk(_Sequence, c);
                        c.i0  = -1;
                        c.Len = 0;
                    }
                }
            }
            if (c.i0 >= 0)
            {
                // close chunk
                PushChunk(_Sequence, c);
            }

            Sequence  = _Sequence.ToArray();
            m_BitMask = Mask;

            CompIMax();
            Verify();
        }
예제 #10
0
        /// <summary>
        /// Finds all neighbor cells for a given cell;
        /// </summary>
        /// <param name="jCell"></param>
        /// <returns>
        /// - 1st entry: local cell index of neighbor cell
        /// - 2nd index: edge index of connecting edge
        /// - 3rd index: whether the other cell is the in-cell (0) or the out-cell (1) of the edge
        /// </returns>
        /// <param name="OmmitPeriodic">
        /// If true, neighborship relations originating from periodic boundary conditions are ignored.
        /// </param>
        /// <param name="g">
        /// Grid object.
        /// </param>
        static public Tuple <int, int, int>[] GetCellNeighboursViaEdges(this IGridData g, int jCell, bool OmmitPeriodic = false)
        {
            List <Tuple <int, int, int> > ret = new List <Tuple <int, int, int> >();

            int[,] __Edges = g.iLogicalEdges.CellIndices;
            var Cell2Edges_jCell = g.iLogicalCells.Cells2Edges[jCell];
            int K = Cell2Edges_jCell.GetLength(0);

            byte[] __EdgeTags = g.iGeomEdges.EdgeTags;

            if (OmmitPeriodic && g.iLogicalEdges.EdgeToParts != null)
            {
                throw new NotImplementedException("todo"); // problem: edge tags have geometric index.
            }
            for (int k = 0; k < K; k++)
            {
                int q      = Cell2Edges_jCell[k];
                int iEdge  = Math.Abs(q) - 1;
                int iOther = q >= 0 ? 1 : 0;
                Debug.Assert(jCell == __Edges[iEdge, iOther == 1 ? 0 : 1]);

                int jCellOut = __Edges[iEdge, iOther];
                if (jCellOut >= 0 && (!OmmitPeriodic || __EdgeTags[iEdge] < GridCommons.FIRST_PERIODIC_BC_TAG))
                {
                    ret.Add(new Tuple <int, int, int>(jCellOut, iEdge, iOther));
                }
            }

            return(ret.ToArray());
        }
예제 #11
0
        /// <summary>
        /// Creates an <see cref="OperatorFactory"/> with appropriate terms
        /// (convective/diffusive) for the selected <paramref name="formulation"/>.
        /// </summary>
        /// <param name="formulation">
        /// The chosen equation system
        /// </param>
        /// <param name="control"></param>
        /// <param name="gridData"></param>
        /// <param name="speciesMap"></param>
        /// <param name="workingSet"></param>
        /// <param name="boundaryMap">
        /// Boundary information
        /// </param>
        /// <returns>
        /// An instance of <see cref="OperatorFactory"/> that has been
        /// configured with the fluxes defined by
        /// <see cref="CNSControl.ConvectiveFluxType"/> and/or
        /// <see cref="CNSControl.DiffusiveFluxType"/>.
        /// </returns>
        public static OperatorFactory GetOperatorFactory(
            this DomainTypes formulation, CNSControl control, IGridData gridData, BoundaryConditionMap boundaryMap, CNSFieldSet workingSet, ISpeciesMap speciesMap)
        {
            switch (formulation)
            {
            case DomainTypes.Standard:
                return(new OperatorFactory(
                           control, gridData, workingSet, speciesMap, boundaryMap));

            case DomainTypes.StaticImmersedBoundary:
            case DomainTypes.MovingImmersedBoundary:
                FluxBuilder convectiveBuilder = control.ConvectiveFluxType.GetBuilder(
                    control, boundaryMap, speciesMap);
                return(new IBMOperatorFactory(
                           (IBMControl)control,
                           gridData,
                           workingSet,
                           speciesMap,
                           boundaryMap));

            default:
                throw new Exception(
                          "Unknown formulation \"" + control.DomainType + "\"");
            }
        }
예제 #12
0
        /// <summary>
        /// Creates the appropriate instance of <see cref="CNSFieldSet"/>
        /// depending on the given <paramref name="domainType"/>
        /// </summary>
        /// <param name="domainType"></param>
        /// <param name="gridData"></param>
        /// <param name="control"></param>
        /// <returns></returns>
        public static CNSFieldSet CreateWorkingSet(this DomainTypes domainType, IGridData gridData, CNSControl control)
        {
            switch (domainType)
            {
            case DomainTypes.Standard:
                return(new CNSFieldSet(gridData, control));

            case DomainTypes.StaticImmersedBoundary:
            case DomainTypes.MovingImmersedBoundary:
                // Make level set gradient exists in list of derived fields
                for (int d = 0; d < CompressibleEnvironment.NumberOfDimensions; d++)
                {
                    if (!control.FieldOptions.ContainsKey(IBMVariables.LevelSetGradient[d]))
                    {
                        control.AddVariable(
                            IBMVariables.LevelSetGradient[d],
                            control.VariableToDegreeMap[IBMVariables.LevelSet] - 1);
                    }
                }
                return(new IBMFieldSet(gridData, (IBMControl)control));

            default:
                throw new Exception();
            }
        }
예제 #13
0
        static BitArray MaskFromSelector(IGridData grddat, Func <double[], bool> GeomSelector)
        {
            int      NoOfEdges = grddat.iLogicalEdges.Count;
            BitArray mask      = new BitArray(NoOfEdges);
            int      D         = grddat.SpatialDimension;

            for (int i = 0; i < NoOfEdges; i++)
            {
                int     iEref  = grddat.iGeomEdges.GetRefElementIndex(i);
                var     Eref   = grddat.iGeomEdges.EdgeRefElements[iEref];
                NodeSet Center = Eref.Center;

                MultidimensionalArray GlobalCoord = grddat.GlobalNodes.GetValue_EdgeSV(Center, i, 1);
                double[] X = new double[D];
                Debug.Assert(GlobalCoord.Dimension == 3);
                Debug.Assert(GlobalCoord.GetLength(0) == 1);
                Debug.Assert(GlobalCoord.GetLength(0) == 1);
                Debug.Assert(GlobalCoord.GetLength(0) == D);

                for (int d = 0; d < D; d++)
                {
                    X[d] = GlobalCoord[0, 0, d];
                }

                mask[i] = GeomSelector(X);
            }

            return(mask);
        }
예제 #14
0
        /// <summary>
        /// Utility function to evaluate DG fields together with global nodes.
        /// </summary>
        /// <param name="f">DG field to evaluate.</param>
        /// <param name="NS">node set.</param>
        /// <param name="cm">optional cell mask.</param>
        /// <returns>
        /// Global nodes and function values at these nodes;
        /// 1st index: cell index;
        /// 2nd index: node index;
        /// 3rd index: spatial direction
        /// </returns>
        public static MultidimensionalArray Evaluate(this DGField f, NodeSet NS, CellMask cm = null)
        {
            IGridData g = f.GridDat;

            if (cm == null)
            {
                cm = CellMask.GetFullMask(g);
            }
            int D = g.SpatialDimension;

            MultidimensionalArray ret = MultidimensionalArray.Create(new int[] { cm.NoOfItemsLocally, NS.NoOfNodes, D + 1 });

            int jsub = 0;

            foreach (Chunk ck in cm)
            {
                var globNodes = ret.ExtractSubArrayShallow(new int[] { jsub, 0, 0 }, new int[] { jsub + ck.Len - 1, NS.NoOfNodes - 1, D - 1 });
                var fldValues = ret.ExtractSubArrayShallow(new int[] { jsub, 0, D }, new int[] { jsub + ck.Len - 1, NS.NoOfNodes - 1, D - 1 });

                g.TransformLocal2Global(NS, ck.i0, ck.Len, globNodes);
                f.Evaluate(ck.i0, ck.Len, NS, fldValues);
            }

            return(ret);
        }
예제 #15
0
        /// <summary>
        /// Creates fields that mark the boundary conditions.
        /// </summary>
        public static DGField[] BoundaryMark(this IGridData m_gridData)
        {
            List <DGField> demo_fields = new List <DGField>();

            // mark boundary cells
            {
                SinglePhaseField boundary = new SinglePhaseField(new Basis(m_gridData, 0), "AllBndCells");
                int[,] Edges = m_gridData.iLogicalEdges.CellIndices;
                int E = Edges.GetLength(0);
                for (int ee = 0; ee < E; ee++)
                {
                    int j = Edges[ee, 0];
                    if (Edges[ee, 1] < 0)
                    {
                        boundary.SetMeanValue(j, boundary.GetMeanValue(j) + 1);
                    }
                }
                demo_fields.Add(boundary);
            }

            {
                DGField[] boundaries = new DGField[m_gridData.EdgeTagNames.Keys.Max() + 1];
                foreach (byte edgeTag in m_gridData.EdgeTagNames.Keys)
                {
                    if (edgeTag != 0)
                    {
                        boundaries[edgeTag] = new SinglePhaseField(new Basis(m_gridData, 0), "Boundary_" + m_gridData.EdgeTagNames[edgeTag]);
                    }
                }
                boundaries[0] = new SinglePhaseField(new Basis(m_gridData, 0), "UnspecifiedBoundary");

                for (int ii = 0; ii < boundaries.Length; ii++)
                {
                    if (boundaries[ii] == null)
                    {
                        boundaries[ii] = new SinglePhaseField(new Basis(m_gridData, 0), "notused-" + ii);
                    }
                }


                int[,] Edges = m_gridData.iGeomEdges.CellIndices;
                byte[] EdgeTags = m_gridData.iGeomEdges.EdgeTags;

                int E = Edges.GetLength(0);
                for (int ee = 0; ee < E; ee++)
                {
                    int j = Edges[ee, 0];
                    if (Edges[ee, 1] < 0)
                    {
                        int tag = EdgeTags[ee];

                        boundaries[tag].SetMeanValue(j, boundaries[tag].GetMeanValue(j) + 1);
                    }
                }
                demo_fields.AddRange(boundaries);
            }


            return(demo_fields.ToArray());
        }
예제 #16
0
        /// <summary>
        /// Selects algorithm variant based on the <paramref name="Option"/>
        /// </summary>
        /// <param name="ContBasis">DG basis for the continuous output data</param>
        /// <param name="DGBasis">DG basis for the discontinuous input data</param>
        /// <param name="gridData"></param>
        /// <param name="Option">Choice of algorithm</param>
        public ContinuityProjection(Basis ContBasis, Basis DGBasis, IGridData gridData, ContinuityProjectionOption Option)
        {
            myOption = Option;
            switch (Option)
            {
            case ContinuityProjectionOption.SpecFEM: {
                var ContinuousLevelSetBasis = new SpecFemBasis((BoSSS.Foundation.Grid.Classic.GridData)gridData, DGBasis.Degree + 1);
                MyProjection = new ContinuityProjectionSpecFem(ContinuousLevelSetBasis);
                break;
            }

            case ContinuityProjectionOption.ConstrainedDG: {
                MyProjection = new ContinuityProjectionCDG(ContBasis);
                break;
            }

            case ContinuityProjectionOption.None: {
                MyProjection = new NoProjection();
                break;
            }

            default:
                throw new ArgumentException();
            }
        }
예제 #17
0
        /// <summary>
        /// method to find the color of all particle
        /// </summary>
        /// <param name="gridData">
        /// the grid that this mask will be associated with
        /// </param>
        /// <param name="ColoredCellsSorted">
        /// a list of all cells sorted by color
        /// </param>
        /// <param name="Particles">
        /// a list of all particles
        /// </param>
        public int[] FindParticleColor(IGridData gridData, List <Particle> Particles, List <int[]> ColoredCellsSorted)
        {
            int        J            = gridData.iLogicalCells.NoOfLocalUpdatedCells;
            List <int> CurrentColor = new List <int>();

            for (int p = 0; p < Particles.Count; p++)
            {
                double h_min = m_LevelSetTracker.GridDat.Cells.h_minGlobal > Particles[p].GetLengthScales().Min()
                    ? 1.5 * m_LevelSetTracker.GridDat.Cells.h_minGlobal
                    : 2 * m_LevelSetTracker.GridDat.Cells.h_minGlobal;
                double[] ParticlePos = Particles[p].Motion.GetPosition();
                double   Upperedge   = ParticlePos[1] + h_min;
                double   Loweredge   = ParticlePos[1] - h_min;
                double   Leftedge    = ParticlePos[0] - h_min;
                double   Rightedge   = ParticlePos[0] + h_min;
                int      temp        = 0;
                for (int i = 0; i < ColoredCellsSorted.Count; i++)
                {
                    if (ColoredCellsSorted[i][0] < J)
                    {
                        double[] center = gridData.iLogicalCells.GetCenter(ColoredCellsSorted[i][0]);
                        if (center[0] > Leftedge && center[0] < Rightedge && center[1] > Loweredge && center[1] < Upperedge && ColoredCellsSorted[i][1] != 0)
                        {
                            temp = ColoredCellsSorted[i][1];
                            break;
                        }
                    }
                }
                CurrentColor.Add(temp);
            }
            return(CurrentColor.ToArray());
        }
예제 #18
0
        static void LocatPointHelper(IGridData gdat, int RootRank, int jL_MinDistCel, out long GlobalId, out long GlobalIndex, out bool OnThisProcess)
        {
            int j0      = gdat.CellPartitioning.i0;
            int MpiSize = gdat.CellPartitioning.MpiSize;
            int MpiRank = gdat.CellPartitioning.MpiRank;

            if (RootRank < 0 || RootRank >= MpiSize)
            {
                throw new ArgumentException();
            }

            if (RootRank == MpiRank)
            {
                OnThisProcess = true;
                GlobalIndex   = jL_MinDistCel + j0;
                GlobalId      = gdat.iLogicalCells.GetGlobalID(jL_MinDistCel);
            }
            else
            {
                OnThisProcess = false;
                GlobalIndex   = long.MinValue;
                GlobalId      = long.MinValue;
            }

            unsafe {
                long *buf = stackalloc long[2];
                buf[0] = GlobalId;
                buf[1] = GlobalIndex;

                csMPI.Raw.Bcast((IntPtr)buf, 2, csMPI.Raw._DATATYPE.LONG, RootRank, gdat.CellPartitioning.MPI_Comm);
                GlobalId    = buf[0];
                GlobalIndex = buf[1];
            }
            return;
        }
예제 #19
0
        /// <summary>
        /// finds the owning processor (<paramref name="TargetProc"/>) and the local index on this processor
        /// (<paramref name="iLocalTargetProc"/>) which corresponds to
        /// a local index in the external range of this processor.
        /// </summary>
        /// <param name="iLocalExt">
        /// a local index on this processor; If this argument is not within the external range (greater or equal to
        /// <see cref="NUpdate"/> and smaller than <see cref="Ntotal"/>), this method still works
        /// </param>
        /// <param name="TargetProc">
        /// on exit, the process rank of the owner process of local external index <paramref name="iLocalExt"/>;
        /// </param>
        /// <param name="iLocalTargetProc">
        /// on exit, the local index on process <paramref name="TargetProc"/> which corresponds to
        /// <paramref name="iLocalExt"/>
        /// </param>
        public void TransformLocalExternal(int iLocalExt, out int TargetProc, out int iLocalTargetProc)
        {
            Debug.Assert(!(iLocalExt < 0 || iLocalExt >= Ntotal), "Index out of range.");

            if (iLocalExt < LocalLength)
            {
                iLocalTargetProc = iLocalExt;
                TargetProc       = m_Context.CellPartitioning.MpiRank;
            }
            else
            {
                IGridData gd = m_Context;

                //Field f;
                int find;
                int j;
                int n;
                LocalFieldCoordinateIndex(iLocalExt, out find, out j, out n);

                j -= gd.iLogicalCells.NoOfLocalUpdatedCells;
                long jGlobal = gd.iParallel.GlobalIndicesExternalCells[j];
                TargetProc = gd.CellPartitioning.FindProcess(jGlobal);
                int jLocalTargetProc = (int)(jGlobal - gd.CellPartitioning.GetI0Offest(TargetProc));

                //int find = Array.IndexOf<Field>(m_Fields, f);

                iLocalTargetProc = jLocalTargetProc * m_MaxTotalNoOfCoordinatesPerCell + m_j0CoordinateIndex[find] + n;
            }
        }
예제 #20
0
        /// <summary>
        /// Standard constructor
        /// </summary>
        /// <param name="noOfIntegralsPerCell">
        /// The number of integrals to be computed
        /// </param>
        /// <param name="context">
        /// see <see cref="gridData"/>.
        /// </param>
        /// <param name="rule">
        /// quadrature domain and rules.
        /// </param>
        /// <param name="cs">integrate in physical or reference coordinates?</param>
        protected Quadrature(int[] noOfIntegralsPerCell, IGridData context, ICompositeQuadRule <TQuadRule> rule, CoordinateSystem cs)
        {
            m_TotalNoOfIntegralsPerItem = 1;
            foreach (var no in noOfIntegralsPerCell)
            {
                m_TotalNoOfIntegralsPerItem *= no;
            }
            m_IntegralsComponent = noOfIntegralsPerCell;

#if DEBUG
            if (rule.Count() > 0)
            {
                int J = rule.Max(crp => crp.Chunk.JE);
                System.Collections.BitArray ChunkTest = new System.Collections.BitArray(J);
                foreach (var chunk in rule)
                {
                    int IE = chunk.Chunk.JE;
                    for (int i = chunk.Chunk.i0; i < IE; i++)
                    {
                        if (ChunkTest[i])
                        {
                            throw new ArgumentException("More than one quadrature rule defined for integration item " + i + ".");
                        }
                        ChunkTest[i] = true;
                    }
                }
            }
#endif


            gridData         = context;
            m_compositeRule  = rule;
            CoordinateSystem = cs;
        }
예제 #21
0
        /// <summary>
        /// <see cref="EdgeMask.GetFullMask"/>
        /// </summary>
        /// <param name="gridData">
        /// <see cref="QuadratureScheme{S, T}.GetDefaultDomain"/>
        /// </param>
        /// <returns>
        /// A mask containing all edges of the grid.
        /// </returns>
        protected override EdgeMask GetDefaultDomain(IGridData gridData)
        {
            var edg = EdgeMask.GetFullMask(gridData, MaskType.Geometrical);

            Debug.Assert(edg.MaskType == MaskType.Geometrical);
            return(edg);
        }
예제 #22
0
        /// <summary>
        /// Updating Phasefield after changes in Grid and/or Basis
        /// </summary>
        public void UpdateFields(LevelSet _LevSet, SinglePhaseField _DGLevSet, LevelSetTracker _LsTrk, VectorField <SinglePhaseField> _Velocity, IGridData _GridData, AppControl _control, AggregationGridData[] _mgSeq)
        {
            // check if signature of external and local Grid changed
            if (this.GridData != _GridData)
            {
                Console.WriteLine("Grid changed, adapting Phasefield");
                LevSet = _LevSet;
                //LsTrk = _LsTrk;
                DGLevSet      = _DGLevSet;
                Velocity      = _Velocity;
                GridData      = _GridData;
                ParentControl = _control;
                mgSeq         = _mgSeq;

                double Cahn_Old = this.Control.cahn;

                CreateFields();

                if (Math.Abs(Cahn_Old - this.Control.cahn) > 1e-3 * Cahn_Old)
                {
                    //RelaxationStep();
                    ReInit(Cahn_Old, this.Control.cahn);
                }

                m_SOperator = GetOperatorInstance(GridData.SpatialDimension);
                CreateEquationsAndSolvers(null);

                // remember last cahn number for potential reinit
                Cahn_Reinit = this.Control.cahn;
            }
        }
예제 #23
0
        /// <summary>
        /// Calculation of SIP penalty base, cf. Chapter 3 in
        /// K. Hillewaert, “Development of the discontinuous Galerkin method for high-resolution, large scale CFD and acoustics in industrial geometries”,
        /// Université catholique de Louvain, 2013.
        /// </summary>
        /// <param name="DegreeBasis"></param>
        /// <param name="GridDat"></param>
        /// <returns>
        /// Base part of SIP penalty.
        /// </returns>
        private double GetSIPPenaltyBase(int DegreeBasis, IGridData GridDat)
        {
            if (!(GridDat is BoSSS.Foundation.Grid.Classic.GridData))
            {
                throw new NotImplementedException("SIP penalty is only implemented for Classic grid.");
            }

            if (GridDat.iGeomCells.RefElements.Length > 1)
            {
                throw new NotImplementedException("SIP penalty implemented only for one type of RefElements.");
            }

            Type GridType = GridDat.iGeomCells.RefElements[0].GetType();

            double PenaltyBase;

            if ((GridType == typeof(Triangle)) || (GridType == typeof(Tetra)))
            {
                PenaltyBase = (DegreeBasis + 1.0) * (DegreeBasis + GridDat.SpatialDimension) / GridDat.SpatialDimension;
            }
            else if ((GridType == typeof(Square)) || (GridType == typeof(Cube)))
            {
                PenaltyBase = (DegreeBasis + 1.0) * (DegreeBasis + 1.0);
            }
            else
            {
                throw new NotImplementedException("Unknown RefElement.");
            }

            return(PenaltyBase);
        }
예제 #24
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="pGrid">
        /// Parent grid.
        /// </param>
        /// <param name="AggregationCells">
        /// Coarse cells which build up the fine cells.
        /// - 1st index: coarse (i.e. this) grid cell index
        /// - 2nd index: enumeration
        /// - content: local cell index into the parent grid <paramref name="pGrid"/>.
        /// </param>
        public AggregationGrid(IGridData pGrid, int[][] AggregationCells)
        {
            ParentGrid = pGrid;

            int JlocFine  = pGrid.iLogicalCells.NoOfLocalUpdatedCells;
            int JElocFine = pGrid.iLogicalCells.NoOfCells;

            m_GeomCellData = new GeomCellData()
            {
                m_Owner = this
            };
            m_LogicalCellData = new LogicalCellData()
            {
                m_Owner = this
            };
            m_GeomEdgeData = new GeomEdgeData()
            {
                m_Owner = this
            };
            m_LogEdgeData = new LogEdgeData();
            m_VertexData  = new VertexData();
            m_Parallel    = new Parallelization()
            {
                m_owner = this
            };

            CellPartitioning = new Partitioning(AggregationCells.Length, pGrid.CellPartitioning.MPI_Comm);

            int j0Coarse = CellPartitioning.i0;

            BuildNeighborship(AggregationCells);
            DefineCellParts();
            CollectEdges();
        }
예제 #25
0
 public Grid(IGridData gridData)
 {
     _numTilesX           = System.Math.Max(1, gridData.NumTilesX);
     _numTilesY           = System.Math.Max(1, gridData.NumTilesY);
     _originWorldPosition = gridData.OriginWorldPosition ??
                            new Vector2(-_numTilesX * TileSize / 2.0f, -_numTilesY * TileSize / 2.0f);
 }
예제 #26
0
        ///// <summary>
        ///// true, if edge <paramref name="e"/> is affine-linear, false if not
        ///// </summary>
        //static public bool IsEdgeAffineLinear(this IGeometricalEdgeData ge, int e) {
        //    return (ge.Info[e] & EdgeInfo.EdgeIsAffineLinear) != 0;
        //}


        /// <summary>
        /// Returns a mask containing all cells which lie at the domain boundary
        /// </summary>
        static public CellMask GetBoundaryCells(this IGridData gdat)
        {
            int      J             = gdat.iLogicalCells.NoOfLocalUpdatedCells;
            BitArray boundaryCells = new BitArray(J);

            int E = gdat.iLogicalEdges.Count;


            int[,] CellIndices = gdat.iLogicalEdges.CellIndices;

            // loop over all Edges
            for (int e = 0; e < E; e++)
            {
                int Cel1 = CellIndices[e, 0];
                int Cel2 = CellIndices[e, 1];

                if (Cel2 < 0)
                {
                    // edge is located on the computational domain boundary


                    boundaryCells[Cel1] = true;
                }
            }

            return(new CellMask(gdat, boundaryCells, MaskType.Logical));
        }
예제 #27
0
        public override Action <EntityDTO> CreateDtoFiller(IGridData data, IDisplayFormatter formatter, IUrlRegistry urls)
        {
            var displaySource = data.GetterFor(Accessor);
            var idSource      = data.GetterFor(IdAccessor);
            var urlSource     = this.toUrlSource(urls, idSource);

            if (_disabled)
            {
                return(dto =>
                {
                    var rawValue = displaySource();
                    var display = _literalText == null?formatter.GetDisplayForValue(Accessor, rawValue) : _literalText.ToString();

                    dto.AddCellDisplay(display);
                });
            }

            return(dto =>
            {
                var rawValue = displaySource();
                var display = _literalText == null?formatter.GetDisplayForValue(Accessor, rawValue) : _literalText.ToString();

                dto.AddCellDisplay(display);

                dto[_linkName] = urlSource();
            });
        }
예제 #28
0
        /// <summary>
        /// exchange of an <see cref="MultidimensionalArray"/>
        /// </summary>
        /// <param name="master"></param>
        /// <param name="vector">
        /// The array must be continuous and have zero offset;
        /// first dimension must match local number of cells (including external).
        /// </param>
        static public void MPIExchange(this MultidimensionalArray vector, IGridData master)
        {
            int[] i0     = new int[vector.Dimension];
            int   offset = vector.Index(i0);

            if (!vector.IsContinious || !(offset == 0) || !(vector.Storage.Length == vector.Length))
            {
                throw new NotSupportedException();
            }

            if (vector.GetLength(0) != master.iLogicalCells.Count)
            {
                throw new ArgumentException("fist dimension must match number of local cells (including external)");
            }

            double[] Stor = vector.Storage;
            int      J    = master.iLogicalCells.Count;
            int      L    = Stor.Length;

            Debug.Assert(L % J == 0);

            var Trx = new VectorTransceiver <double[], double>(master, Stor, L / J);

            Trx.TransceiveStartImReturn();
            Trx.TransceiveFinish();
        }
예제 #29
0
 public EdgeQuadratureImpl(int[] noOfIntegralsPerCell,
                           IGridData context,
                           ICompositeQuadRule <QuadRule> domNrule,
                           CoordinateSystem cs)
     : base(noOfIntegralsPerCell, context, domNrule, cs)
 {
 }
예제 #30
0
        private void PopulateDataFramePreview(IGridData <string> gridData)
        {
            var dg = DataFramePreview;

            dg.Columns.Clear();

            for (int i = 0; i < gridData.ColumnHeader.Range.Count; i++)
            {
                dg.Columns.Add(new DataGridTextColumn()
                {
                    Header  = gridData.ColumnHeader[gridData.ColumnHeader.Range.Start + i],
                    Binding = new Binding(Invariant($"Values[{i}]")),
                });
            }

            var rows = new List <DataFramePreviewRowItem>();

            for (var r = 0; r < gridData.Grid.Range.Rows.Count; r++)
            {
                var row = new DataFramePreviewRowItem {
                    RowName = gridData.RowHeader[gridData.RowHeader.Range.Start + r]
                };

                for (int c = 0; c < gridData.Grid.Range.Columns.Count; c++)
                {
                    row.Values.Add(gridData.Grid[gridData.Grid.Range.Rows.Start + r, gridData.Grid.Range.Columns.Start + c].ToUnicodeQuotes());
                }

                rows.Add(row);
            }
            dg.ItemsSource = rows;
        }
예제 #31
0
        private void DrawVisuals(
            GridRange dataViewport,
            IGridData<string> data,
            GridUpdateType updateType,
            Rect visualViewport,
            bool suppressNotification) {

            using (var deferal = Points.DeferChangeNotification(suppressNotification)) {
                // measure points
                ColumnHeader?.MeasurePoints(
                    Points.GetAccessToPoints(ColumnHeader.ScrollDirection),
                    new GridRange(new Range(0, 1), dataViewport.Columns),
                    new RangeToGrid<string>(dataViewport.Columns, data.ColumnHeader, true),
                    updateType);

                RowHeader?.MeasurePoints(
                    Points.GetAccessToPoints(RowHeader.ScrollDirection),
                    new GridRange(dataViewport.Rows, new Range(0, 1)),
                    new RangeToGrid<string>(dataViewport.Rows, data.RowHeader, false),
                    updateType == GridUpdateType.Sort ? GridUpdateType.Refresh : updateType);

                DataGrid?.MeasurePoints(
                    Points.GetAccessToPoints(DataGrid.ScrollDirection),
                    dataViewport,
                    data.Grid,
                    updateType == GridUpdateType.Sort ? GridUpdateType.Refresh : updateType);

                // adjust Offset in case of overflow
                if ((Points.HorizontalOffset + visualViewport.Width).GreaterThanOrClose(Points.HorizontalExtent)) {
                    Points.HorizontalOffset = Points.HorizontalExtent - visualViewport.Width;
                }
                if ((Points.VerticalOffset + visualViewport.Height).GreaterThanOrClose(Points.VerticalExtent)) {
                    Points.VerticalOffset = Points.VerticalExtent - visualViewport.Height;
                }

                // arrange and draw gridline
                ColumnHeader?.ArrangeVisuals(Points.GetAccessToPoints(ColumnHeader.ScrollDirection));
                RowHeader?.ArrangeVisuals(Points.GetAccessToPoints(RowHeader.ScrollDirection));
                DataGrid?.ArrangeVisuals(Points.GetAccessToPoints(DataGrid.ScrollDirection));

                Points.ViewportHeight = DataGrid.RenderSize.Height;
                Points.ViewportWidth = DataGrid.RenderSize.Width;
            }
        }
예제 #32
0
        private void DrawVisuals(GridRange dataViewport, IGridData<string> data) {
            if (DataGrid != null) {
                DataGrid.DrawVisuals(dataViewport, data.Grid);
            }

            if (ColumnHeader != null) {
                GridRange columnViewport = new GridRange(
                    new Range(0, 1),
                    dataViewport.Columns);
                ColumnHeader.DrawVisuals(columnViewport, new Grid<string>(columnViewport, data.ColumnHeader)); // TODO: new data
            }

            if (RowHeader != null) {
                GridRange rowViewport = new GridRange(
                    dataViewport.Rows,
                    new Range(0, 1));
                RowHeader.DrawVisuals(rowViewport, new Grid<string>(rowViewport, data.RowHeader));    // TODO: new data
            }
        }
예제 #33
0
        private void PopulateDataFramePreview(IGridData<string> gridData) {
            var dg = DataFramePreview;
            dg.Columns.Clear();

            for (int i = 0; i < gridData.ColumnHeader.Range.Count; i++) {
                dg.Columns.Add(new DataGridTextColumn() {
                    Header = gridData.ColumnHeader[gridData.ColumnHeader.Range.Start + i],
                    Binding = new Binding(Invariant($"Values[{i}]")),
                });
            }

            var rows = new List<DataFramePreviewRowItem>();
            for (var r = 0; r < gridData.Grid.Range.Rows.Count; r++) {
                var row = new DataFramePreviewRowItem {
                    RowName = gridData.RowHeader[gridData.RowHeader.Range.Start + r]
                };

                for (int c = 0; c < gridData.Grid.Range.Columns.Count; c++) {
                    row.Values.Add(gridData.Grid[gridData.Grid.Range.Rows.Start + r, gridData.Grid.Range.Columns.Start + c].ToUnicodeQuotes());
                }

                rows.Add(row);
            }
            dg.ItemsSource = rows;
        }