Exemple #1
0
        protected override void CreateFields()
        {
            levelSet        = testCase.GetLevelSet((BoSSS.Foundation.Grid.Classic.GridData)GridData);
            levelSetTracker = new LevelSetTracker((BoSSS.Foundation.Grid.Classic.GridData)GridData,
                                                  XQuadFactoryHelper.MomentFittingVariants.Classic, // should have no effect, this app creates its own quad-rules independent of the tracker
                                                  1, new string[] { "A", "B" }, levelSet);

            XDGField = new XDGField(
                new XDGBasis(levelSetTracker, testCase.IntegrandDegree), "XDGField");
            SinglePhaseField = new SinglePhaseField(
                new Basis(GridData, testCase.IntegrandDegree), "SinglePhaseField");

            if (levelSet is LevelSet)
            {
                m_IOFields.Add((LevelSet)levelSet);
            }
            else
            {
                LevelSet projectedLevelSet = new LevelSet(new Basis(GridData, 4), "projectedAnalyticLevelSet");
                projectedLevelSet.ProjectField(testCase.GetLevelSet((BoSSS.Foundation.Grid.Classic.GridData)GridData).Evaluate);
                m_IOFields.Add(projectedLevelSet);
            }
            m_IOFields.Add(XDGField);
            m_IOFields.Add(SinglePhaseField);
        }
Exemple #2
0
        /// <summary>
        /// Sets level-set and solution at time (<paramref name="time"/> + <paramref name="dt"/>).
        /// </summary>
        double DelUpdateLevelset(DGField[] CurrentState, double time, double dt, double UnderRelax, bool _incremental)
        {
            // new time
            double t = time + dt;

            // project new level-set
            double s = 1.0;

            LevSet.ProjectField((x, y) => - (x - s * t).Pow2() - y.Pow2() + (2.4).Pow2());
            LsTrk.UpdateTracker(incremental: _incremental);

            // exact solution for new timestep
            uEx.GetSpeciesShadowField("A").ProjectField((x, y) => x + alpha_A * t);
            uEx.GetSpeciesShadowField("B").ProjectField((x, y) => x + alpha_B * t);

            u.Clear();
            u.Acc(1.0, uEx);

            // markieren, wo ueberhaupt A und B sind
            Amarker.Clear();
            Bmarker.Clear();
            Amarker.AccConstant(+1.0, LsTrk.Regions.GetSpeciesSubGrid("A").VolumeMask);
            Bmarker.AccConstant(1.0, LsTrk.Regions.GetSpeciesSubGrid("B").VolumeMask);

            // MPI rank
            MPICellRank.Clear();
            MPICellRank.AccConstant(base.MPIRank);

            // return level-set residual
            return(0.0);
        }
        /// <summary>
        /// Sets level-set and solution at time (<paramref name="time"/> + <paramref name="dt"/>).
        /// </summary>
        double DelUpdateLevelset(DGField[] CurrentState, double time, double dt, double UnderRelax, bool _incremental)
        {
            // new time
            double t = time + dt;

            // project new level-set
            double s = 1.0;

            LevSet.ProjectField((x, y) => - (x - s * t).Pow2() - y.Pow2() + (2.4).Pow2());
            LsTrk.UpdateTracker(incremental: _incremental);
            LsTrk.PushStacks();

            // exact solution for new timestep
            uXEx.GetSpeciesShadowField("A").ProjectField((x, y) => x + alpha_A * t);
            uXEx.GetSpeciesShadowField("B").ProjectField((x, y) => x + alpha_B * t);

            // uX.Clear();
            //uX.Acc(1.0, uXEx);

            // single-phase-properties
            u.Clear();
            u.ProjectField(NonVectorizedScalarFunction.Vectorize(uEx, t));

            Grad_u.Clear();
            Grad_u.Gradient(1.0, u);

            MagGrad_u.Clear();
            MagGrad_u.ProjectFunction(1.0,
                                      (double[] X, double[] U, int jCell) => Math.Sqrt(U[0].Pow2() + U[1].Pow2()),
                                      new Foundation.Quadrature.CellQuadratureScheme(),
                                      Grad_u.ToArray());

            // return level-set residual
            return(0.0);
        }
        /// <summary>
        /// Sets level-set and solution at time (<paramref name="time"/> + <paramref name="dt"/>).
        /// </summary>
        double DelUpdateLevelset(DGField[] CurrentState, double time, double dt, double UnderRelax, bool _incremental)
        {
            // new time
            double t = time + dt;

            // project new level-set
            LevSet.ProjectField(this.Control.LevelSet.Vectorize(t));
            LsTrk.UpdateTracker(incremental: _incremental);

            // exact solution for new timestep
            uEx.GetSpeciesShadowField("A").ProjectField(NonVectorizedScalarFunction.Vectorize(this.Control.uEx_A, t));
            uEx.GetSpeciesShadowField("B").ProjectField(NonVectorizedScalarFunction.Vectorize(this.Control.uEx_B, t));

            u.Clear();
            u.Acc(1.0, uEx);

            // markieren, wo ueberhaupt A und B sind
            Amarker.Clear();
            Bmarker.Clear();
            Amarker.AccConstant(+1.0, LsTrk._Regions.GetSpeciesSubGrid("A").VolumeMask);
            Bmarker.AccConstant(1.0, LsTrk._Regions.GetSpeciesSubGrid("B").VolumeMask);

            // MPI rank
            MPICellRank.Clear();
            MPICellRank.AccConstant(base.MPIRank);

            // return level-set residual
            return(0.0);
        }
Exemple #5
0
        //internal double THRESHOLD = 0;

        void LsUpdate(double t)
        {
            double offset = t;

            Phi.ProjectField((x, y) => - (x - offset).Pow2() - y.Pow2() + (0.707).Pow2());
            LsTrk.UpdateTracker(t);
        }
Exemple #6
0
        /// <summary>
        /// Projects the initial level set after calling
        /// <see cref="CNSFieldSet.ProjectInitialValues"/>
        /// </summary>
        /// <param name="speciesMap"></param>
        /// <param name="initialValues"></param>
        public override void ProjectInitialValues(ISpeciesMap speciesMap, IDictionary <string, Func <double[], double> > initialValues)
        {
            LevelSet.ProjectField(NonVectorizedScalarFunction.Vectorize(
                                      X => config.LevelSetFunction(X, 0.0)));
            speciesMap.As <ImmersedSpeciesMap>().Tracker.UpdateTracker(0.0);

            base.ProjectInitialValues(speciesMap, initialValues);
        }
Exemple #7
0
        void LsUpdate(double t)
        {
            double offset = t;

            Phi.ProjectField((x, y) => - (x - offset).Pow2() - y.Pow2() + (2.4).Pow2());
            //Phi.ProjectField((x, y) => x);
            //Console.WriteLine("more testcode");
            LsTrk.UpdateTracker();
        }
Exemple #8
0
        public override void UpdateLevelSet(ILevelSet levelSet)
        {
            LevelSet levelSetField = levelSet as LevelSet;

            if (levelSetField == null)
            {
                throw new ArgumentException();
            }

            levelSetField.ProjectField(LevelSetInitialValue);
        }
Exemple #9
0
        void LsUpdate(double t)
        {
            double offset = t;

            Console.WriteLine("LSUpdate t = " + t);


            Phi0.ProjectField((x, y) => - (x - offset).Pow2() - y.Pow2() + (0.85).Pow2());
            Phi1.ProjectField((x, y) => - (x - offset).Pow2() - y.Pow2() + (2.4).Pow2());
            LsTrk.UpdateTracker();

            if (LsTrk.Regions.GetSpeciesSubGrid("X").GlobalNoOfCells > 0)
            {
                throw new ApplicationException("there should be no X-species");
            }
        }
Exemple #10
0
        public override void UpdateLevelSet(ILevelSet levelSet)
        {
            //AnalyticStarLevelSet analyticLevelSet = levelSet as AnalyticStarLevelSet;
            //if (analyticLevelSet == null) {
            //    throw new Exception();
            //}
            //analyticLevelSet.SetParameters(CurrentShift.OffsetX, CurrentShift.OffsetY);

            LevelSet levelSetField = levelSet as LevelSet;

            if (levelSetField == null)
            {
                throw new Exception();
            }

            levelSetField.ProjectField(LevelSetInitialValue);
        }
Exemple #11
0
        public override void UpdateLevelSet(ILevelSet levelSet)
        {
            //AnalyticSphereLevelSet analyticLevelSet = levelSet as AnalyticSphereLevelSet;
            //if (analyticLevelSet == null) {
            //    throw new Exception();
            //}

            //analyticLevelSet.SetOffset(CurrentShift.OffsetX, CurrentShift.OffsetY, CurrentShift.OffsetZ);

            LevelSet field = levelSet as LevelSet;

            if (field == null)
            {
                throw new Exception();
            }

            field.ProjectField(LevelSetInitialValue);
        }
Exemple #12
0
        protected void MoveLevelSetTo(double time)
        {
            LevelSet levelSet = speciesMap.Tracker.LevelSets[0].As <LevelSet>();

            levelSet.Clear();
            levelSet.ProjectField(X => speciesMap.Control.LevelSetFunction(X, time));
            speciesMap.Tracker.UpdateTracker();

            cutCells          = speciesMap.Tracker.Regions.GetCutCellMask();
            cutAndTargetCells = cutCells.Union(speciesMap.Agglomerator.AggInfo.TargetCells);

            // EVIL HACK SINCE UPDATE OF GRADIENT ONLY HAPPENS AFTER TIME-STEP SO FAR
            foreach (var gradientField in boundaryParameterMap.Fields)
            {
                int d = int.Parse(gradientField.Identification.Last().ToString());

                gradientField.Clear();
                gradientField.Derivative(
                    -1.0,
                    levelSet,
                    d,
                    cutCells);
            }
        }
Exemple #13
0
            public XDGTestSetup(
                int p,
                double AggregationThreshold,
                int TrackerWidth,
                MultigridOperator.Mode mumo,
                XQuadFactoryHelper.MomentFittingVariants momentFittingVariant,
                ScalarFunction LevSetFunc = null)
            {
                // Level set, tracker and XDG basis
                // ================================

                if (LevSetFunc == null)
                {
                    LevSetFunc = ((_2D)((x, y) => 0.8 * 0.8 - x * x - y * y)).Vectorize();
                }
                LevSet = new LevelSet(new Basis(grid, 2), "LevelSet");
                LevSet.Clear();
                LevSet.ProjectField(LevSetFunc);
                LsTrk = new LevelSetTracker(grid, XQuadFactoryHelper.MomentFittingVariants.Classic, TrackerWidth, new string[] { "A", "B" }, LevSet);
                LsTrk.UpdateTracker();

                XB = new XDGBasis(LsTrk, p);

                XSpatialOperator Dummy = new XSpatialOperator(1, 0, 1, QuadOrderFunc.SumOfMaxDegrees(RoundUp: true), "C1", "u");

                //Dummy.EquationComponents["c1"].Add(new
                Dummy.Commit();

                //Tecplot.PlotFields(new DGField[] { LevSet }, "agglo", 0.0, 3);


                // operator
                // ========

                Debug.Assert(p <= 4);
                XDGBasis opXB = new XDGBasis(LsTrk, 4); // we want to have a very precise quad rule
                var      map  = new UnsetteledCoordinateMapping(opXB);

                int quadOrder = Dummy.QuadOrderFunction(map.BasisS.Select(bs => bs.Degree).ToArray(), new int[0], map.BasisS.Select(bs => bs.Degree).ToArray());

                //agg = new MultiphaseCellAgglomerator(new CutCellMetrics(momentFittingVariant, quadOrder, LsTrk, LsTrk.SpeciesIdS.ToArray()), AggregationThreshold, false);
                agg = LsTrk.GetAgglomerator(LsTrk.SpeciesIdS.ToArray(), quadOrder, __AgglomerationTreshold: AggregationThreshold);


                foreach (var S in LsTrk.SpeciesIdS)
                {
                    Console.WriteLine("Species {0}, no. of agglomerated cells {1} ",
                                      LsTrk.GetSpeciesName(S),
                                      agg.GetAgglomerator(S).AggInfo.SourceCells.Count());
                }

                // mass matrix factory
                // ===================

                // Basis maxB = map.BasisS.ElementAtMax(b => b.Degree);
                //MassFact = new MassMatrixFactory(maxB, agg);
                MassFact = LsTrk.GetXDGSpaceMetrics(LsTrk.SpeciesIdS.ToArray(), quadOrder, 1).MassMatrixFactory;


                // Test field
                // ==========

                // set the test field: this is a polynomial function,
                // but different for each species; On this field, restriction followed by prolongation should be the identity
                this.Xdg_uTest = new XDGField(this.XB, "uTest");
                Dictionary <SpeciesId, double> dumia = new Dictionary <SpeciesId, double>();
                int i = 2;

                foreach (var Spc in LsTrk.SpeciesIdS)
                {
                    dumia.Add(Spc, i);
                    i -= 1;
                }
                SetTestValue(Xdg_uTest, dumia);


                // dummy operator matrix which fits polynomial degree p
                // ====================================================

                Xdg_opMtx = new BlockMsrMatrix(Xdg_uTest.Mapping, Xdg_uTest.Mapping);
                Xdg_opMtx.AccEyeSp(120.0);

                // XDG Aggregation BasiseS
                // =======================

                //XAggB = MgSeq.Select(agGrd => new XdgAggregationBasis[] { new XdgAggregationBasis(uTest.Basis, agGrd) }).ToArray();
                XAggB = new XdgAggregationBasis[MgSeq.Length][];
                var _XAggB = AggregationGridBasis.CreateSequence(MgSeq, Xdg_uTest.Mapping.BasisS);

                for (int iLevel = 0; iLevel < XAggB.Length; iLevel++)
                {
                    XAggB[iLevel] = new[] { (XdgAggregationBasis)(_XAggB[iLevel][0]) };
                    XAggB[iLevel][0].Update(agg);
                }

                // Multigrid Operator
                // ==================



                Xdg_opMtx = new BlockMsrMatrix(Xdg_uTest.Mapping, Xdg_uTest.Mapping);
                Xdg_opMtx.AccEyeSp(120.0);

                XdgMultigridOp = new MultigridOperator(XAggB, Xdg_uTest.Mapping,
                                                       Xdg_opMtx,
                                                       MassFact.GetMassMatrix(Xdg_uTest.Mapping, false),
                                                       new MultigridOperator.ChangeOfBasisConfig[][] {
                    new MultigridOperator.ChangeOfBasisConfig[] {
                        new MultigridOperator.ChangeOfBasisConfig()
                        {
                            VarIndex = new int[] { 0 }, mode = mumo, Degree = p
                        }
                    }
                });
            }
 protected override void SetInitial()
 {
     Phi.ProjectField(test.GetLevelSet);
     this.LsTrk.UpdateTracker(0.0);
 }