Esempio n. 1
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]];
            }
        }
Esempio n. 2
0
        private void UpdateArtificialViscosity()
        {
            // Determine piecewise constant viscosity
            this.ArtificialViscosityField.Clear();

            // Cell masks
            CellMask cutCells        = this.LevelSetTracker.Regions.GetCutCellMask();
            CellMask speciesA_nonCut = this.LevelSetTracker.Regions.GetSpeciesMask("A").Except(cutCells);
            CellMask speciesB_nonCut = this.LevelSetTracker.Regions.GetSpeciesMask("B").Except(cutCells);

            // Calculate AV
            SetAVForSpecies(speciesA_nonCut, "A");
            SetAVForSpecies(speciesB_nonCut, "B");
            SetAVForCutCells(cutCells);

            // Set AV manually for testing
            //this.ArtificialViscosityField.Clear();
            //this.ArtificialViscosityField.AccConstant(1.0);

            // Project visocsity onto continuous, multilinear space
            if (CompressibleEnvironment.NumberOfDimensions < 3)
            {
                // Standard version
                if (avSpecFEMBasis == null || !this.ArtificialViscosityField.Basis.Equals(avSpecFEMBasis.ContainingDGBasis))
                {
                    avSpecFEMBasis = new SpecFemBasis((GridData)this.GridData, 2);
                }
                SpecFemField specFemField = new SpecFemField(avSpecFEMBasis);
                specFemField.ProjectDGFieldMaximum(1.0, this.ArtificialViscosityField);
                this.ArtificialViscosityField.Clear();
                specFemField.AccToDGField(1.0, this.ArtificialViscosityField);
            }
            else
            {
                throw new NotImplementedException("Artificial viscosity has only been tested for 2D");
            }
        }