Example #1
0
        /// <summary>
        /// Constructs a new flux builder where the boundary conditions are
        /// evaluated using the convective fluxes defined by
        /// <paramref name="convectiveBuilder"/>.
        /// </summary>
        /// <param name="control"></param>
        /// <param name="boundaryMap"></param>
        /// <param name="speciesMap"></param>
        /// <param name="convectiveBuilder"></param>
        /// <param name="diffusiveBuilder"></param>
        public BoundaryConditionSourceFluxBuilder(
            IBMControl control, IBoundaryConditionMap boundaryMap, ISpeciesMap speciesMap, FluxBuilder convectiveBuilder, FluxBuilder diffusiveBuilder)
            : base(control, boundaryMap, speciesMap)
        {
            standardOperator = new Operator(control);

            if (convectiveBuilder != null)
            {
                convectiveBuilder.BuildFluxes(standardOperator);
            }

            if (diffusiveBuilder != null)
            {
                diffusiveBuilder.BuildFluxes(standardOperator);
            }

            string levelSetBoundaryType = control.LevelSetBoundaryTag;

            boundaryCondition = boundaryMap.GetBoundaryCondition(levelSetBoundaryType);
        }
Example #2
0
        /// <summary>
        /// Weakly imposes the specific boundary condition for this boundary
        /// type (defined by the edge tag) by calculating the outer value via a
        /// subclass of <see cref="BoundaryCondition"/> and
        /// inserting it into
        /// <see cref="InnerEdgeFlux(double, double[], double[], double[], double[], int)"/>
        /// </summary>
        protected override double BorderEdgeFlux(double time, double[] x, double[] normal, byte EdgeTag, double[] Uin, int jEdge)
        {
            StateVector stateIn = new StateVector(Uin, material);

            ilPSP.Vector Normal = new ilPSP.Vector(stateIn.Dimension);
            for (int i = 0; i < normal.Length; i++)
            {
                Normal[i] = normal[i];
            }

            // Get boundary condition on this edge
            BoundaryCondition boundaryCondition;

            if (this.boundaryMap is XDGCompressibleBoundaryCondMap xdgBoudaryMap)
            {
                boundaryCondition = xdgBoudaryMap.GetBoundaryConditionForSpecies(EdgeTag, this.speciesName);
            }
            else if (this.boundaryMap is CompressibleBoundaryCondMap boundaryMap)
            {
                boundaryCondition = boundaryMap.GetBoundaryCondition(EdgeTag);
            }
            else
            {
                throw new NotSupportedException("This type of boundary condition map is not supported.");
            }

            //StateVector stateBoundary = boundaryMap.GetBoundaryState(
            //    EdgeTag, time, x, normal, stateIn);

            StateVector stateBoundary = boundaryCondition.GetBoundaryState(time, x, normal, stateIn);

            double flux = InnerEdgeFlux(x, time, stateIn, stateBoundary, ref Normal, jEdge);

            Debug.Assert(!double.IsNaN(flux));
            return(flux);
        }
Example #3
0
        /// <summary>
        /// <see cref="INonlinearFlux.BorderEdgeFlux"/>
        /// </summary>
        public void BorderEdgeFlux(
            double time,
            int jEdge,
            MultidimensionalArray x,
            MultidimensionalArray normal,
            bool normalFlipped,
            byte[] EdgeTags,
            int EdgeTagsOffset,
            MultidimensionalArray[] Uin,
            int Offset,
            int Lenght,
            MultidimensionalArray Output)
        {
            int    NoOfNodes = Uin[0].GetLength(1);
            int    D         = CompressibleEnvironment.NumberOfDimensions;
            double sign      = normalFlipped ? -1.0 : 1.0;

            MultidimensionalArray[] Uout = new MultidimensionalArray[Uin.Length];
            for (int i = 0; i < Uin.Length; i++)
            {
                Uout[i] = MultidimensionalArray.Create(Uin[i].GetLength(0), Uin[i].GetLength(1));
            }

            // Loop over edges
            for (int e = 0; e < Lenght; e++)
            {
                int edge = e + Offset;

                // Get boundary condition on this edge
                BoundaryCondition boundaryCondition;
                if (this.boundaryMap is XDGCompressibleBoundaryCondMap xdgBoudaryMap)
                {
                    boundaryCondition = xdgBoudaryMap.GetBoundaryConditionForSpecies(EdgeTags[e + EdgeTagsOffset], this.speciesName);
                }
                else if (this.boundaryMap is CompressibleBoundaryCondMap boundaryMap)
                {
                    boundaryCondition = boundaryMap.GetBoundaryCondition(EdgeTags[e + EdgeTagsOffset]);
                }
                else
                {
                    throw new NotSupportedException("This type of boundary condition map is not supported.");
                }

                // Loop over nodes
                for (int n = 0; n < NoOfNodes; n++)
                {
                    double[] xLocal      = new double[D];
                    double[] normalLocal = new double[D];
                    for (int d = 0; d < D; d++)
                    {
                        xLocal[d]      = x[edge, n, d];
                        normalLocal[d] = normal[edge, n, d] * sign;
                    }

                    StateVector stateIn       = new StateVector(material, Uin, edge, n, D);
                    StateVector stateBoundary = boundaryCondition.GetBoundaryState(time, xLocal, normalLocal, stateIn);

                    Uout[0][edge, n] = stateBoundary.Density;
                    for (int d = 0; d < D; d++)
                    {
                        Uout[d + 1][edge, n] = stateBoundary.Momentum[d];
                    }
                    Uout[D + 1][edge, n] = stateBoundary.Energy;
                }
            }

            InnerEdgeFlux(time, jEdge, x, normal, Uin, Uout, Offset, Lenght, Output);
        }