예제 #1
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="GridDat"></param>
        /// <param name="Temperature"></param>
        /// <param name="EoS"></param>
        /// <param name="edgeTagNames"></param>
        public NusseltNumber(IGridData GridDat, SinglePhaseField Temperature, MaterialLaw EoS, string[] edgeTagNames)
        {
            this.GridDat     = GridDat;
            this.Temperature = Temperature;

            //Basis BasisDerivative = new Basis(GridDat, Temperature.Basis.Degree - 1);
            Basis BasisDerivative = new Basis(GridDat, Temperature.Basis.Degree);

            dTdx = new SinglePhaseField(BasisDerivative);
            dTdy = new SinglePhaseField(BasisDerivative);

            NusseltIntegrals = new EdgeIntegral[edgeTagNames.Length];
            Nusselt          = new double[edgeTagNames.Length];

            for (int bc = 0; bc < edgeTagNames.Length; bc++)
            {
                NusseltIntegrals[bc] = new EdgeIntegral((BoSSS.Foundation.Grid.Classic.GridData)GridDat,
                                                        edgeTagNames[bc],
                                                        new NusseltFlux2D(EoS),
                                                        new CoordinateMapping(dTdx, dTdy, Temperature),
                                                        20);
            }
        }
예제 #2
0
파일: Force.cs 프로젝트: xj361685640/BoSSS
        void InitEdgeIntegrals()
        {
            if (m_app.GridData.SpatialDimension == 2)
            {
                for (int edge = 0; edge < NoOfEdges; edge++)
                {
                    CoordinateMapping m_CoordinateMapping = new CoordinateMapping(m_app.WorkingSet.Pressure, DuDx, DuDy, DvDx, DvDy);
                    var QuadratureOrder = m_CoordinateMapping.BasisS.Max(basis => basis.Degree) * 2 + 1;
                    XForceIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                            edgeTagNames[edge],
                                                            new ForceFlux2D(0, m_app),
                                                            m_CoordinateMapping,
                                                            QuadratureOrder);

                    YForceIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                            edgeTagNames[edge],
                                                            new ForceFlux2D(1, m_app),
                                                            m_CoordinateMapping,
                                                            QuadratureOrder);

                    ZMomentIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                             edgeTagNames[edge],
                                                             new MomentFlux2D(m_app),
                                                             m_CoordinateMapping,
                                                             QuadratureOrder);
                }
            }
            else
            {
                for (int edge = 0; edge < NoOfEdges; edge++)
                {
                    var m_CoordMap = new CoordinateMapping(m_app.WorkingSet.Pressure, DuDx, DuDy, DuDz, DvDx, DvDy, DvDz, DwDx, DwDy, DwDz);
                    var QuadOrder  = m_CoordMap.BasisS.Max(basis => basis.Degree) * 2 + 1;
                    XForceIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                            edgeTagNames[edge],
                                                            new ForceFlux3D(0, m_app),
                                                            m_CoordMap,
                                                            QuadOrder);

                    YForceIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                            edgeTagNames[edge],
                                                            new ForceFlux3D(1, m_app),
                                                            m_CoordMap,
                                                            QuadOrder);

                    ZForceIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                            edgeTagNames[edge],
                                                            new ForceFlux3D(2, m_app),
                                                            m_CoordMap,
                                                            QuadOrder);

                    XMomentIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                             edgeTagNames[edge],
                                                             new MomentFlux3D(0, m_app),
                                                             m_CoordMap,
                                                             QuadOrder);

                    YMomentIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                             edgeTagNames[edge],
                                                             new MomentFlux3D(1, m_app),
                                                             m_CoordMap,
                                                             QuadOrder);

                    ZMomentIntegral[edge] = new EdgeIntegral(m_app.GridData,
                                                             edgeTagNames[edge],
                                                             new MomentFlux3D(2, m_app),
                                                             m_CoordMap,
                                                             QuadOrder);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Calculates the lift and drag force on given edges, e.g edges around an airfoil.
        /// Currently only in 2D!!!
        /// </summary>
        /// <param name="edgeTagName">EdgeTag on which the drag force will be calculated</param>
        /// <returns>total drag force</returns>
        /// <remarks>It assumes that pressure and velocity fields exists</remarks>
        public static Query LiftAndDragForce(String edgeTagName)
        {
            return(delegate(IApplication <AppControl> app, double time) {
                if (dragIntegral == null)
                {
                    densityField = app.IOFields.SingleOrDefault((f) => f.Identification == "rho");
                    m0Field = app.IOFields.SingleOrDefault((f) => f.Identification == "m0");
                    m1Field = app.IOFields.SingleOrDefault((f) => f.Identification == "m1");
                    energyField = app.IOFields.SingleOrDefault((f) => f.Identification == "rhoE");

                    DrhoDx = new SinglePhaseField(densityField.Basis);
                    DrhoDy = new SinglePhaseField(densityField.Basis);

                    Dm0Dx = new SinglePhaseField(m0Field.Basis);
                    Dm0Dy = new SinglePhaseField(m0Field.Basis);
                    Dm1Dx = new SinglePhaseField(m1Field.Basis);
                    Dm1Dy = new SinglePhaseField(m1Field.Basis);

                    CNSControl c = app.Control as CNSControl;
                    Program prog = app as Program;

                    byte edgeTag = app.Grid.EdgeTagNames.First(item => item.Value.Equals(edgeTagName)).Key;

                    CoordinateMapping mapping = new CoordinateMapping(
                        densityField, m0Field, m1Field, energyField, DrhoDx, DrhoDy, Dm0Dx, Dm0Dy, Dm1Dx, Dm1Dy);

                    dragIntegral = new EdgeIntegral((BoSSS.Foundation.Grid.Classic.GridData)(app.GridData), edgeTag, new ForceFlux(
                                                        c.ReynoldsNumber, prog.SpeciesMap.GetMaterial(double.NaN), 0), mapping);
                    liftIntegral = new EdgeIntegral((BoSSS.Foundation.Grid.Classic.GridData)(app.GridData), edgeTag, new ForceFlux(
                                                        c.ReynoldsNumber, prog.SpeciesMap.GetMaterial(double.NaN), 1), mapping);

                    if (logger == null && app.CurrentSessionInfo.ID != Guid.Empty && app.MPIRank == 0)
                    {
                        logger = app.DatabaseDriver.FsDriver.GetNewLog("LiftAndDragForce", app.CurrentSessionInfo.ID);
                        string header = "PhysTime\t LiftForce\t DragForce";
                        logger.WriteLine(header);
                    }
                }

                DrhoDx.Clear();
                DrhoDy.Clear();

                DrhoDx.Derivative(1.0, densityField, 0);
                DrhoDy.Derivative(1.0, densityField, 1);

                Dm0Dx.Clear();
                Dm0Dy.Clear();
                Dm1Dx.Clear();
                Dm1Dy.Clear();

                Dm0Dx.Derivative(1.0, m0Field, 0);
                Dm0Dy.Derivative(1.0, m0Field, 1);
                Dm1Dx.Derivative(1.0, m1Field, 0);
                Dm1Dy.Derivative(1.0, m1Field, 1);

                double lift = liftIntegral.Evaluate();
                double drag = dragIntegral.Evaluate();

                if (logger != null && app.MPIRank == 0)
                {
                    string line = time + "\t" + lift + "\t" + drag;
                    logger.WriteLine(line);
                    logger.Flush();
                }
                return drag;
            });
        }