Esempio n. 1
0
 /// <summary>
 /// ctor;
 /// </summary>
 internal SpeciesCoordinates(XDGField _owner, SpeciesId _SpeciesId)
 {
     owner      = _owner;
     NSep       = this.owner.m_CCBasis.DOFperSpeciesPerCell;
     LsTrk      = this.owner.m_CCBasis.Tracker;
     m_SpecisId = _SpeciesId;
 }
Esempio n. 2
0
        /// <summary>
        /// <see cref="DGField.FieldInitializer"/>
        /// </summary>
        /// <param name="tsi"></param>
        /// <param name="data"></param>
        /// <param name="loadedObjects"></param>
        public override void LoadData(ITimestepInfo tsi, IList <CellFieldDataSet> data, HashSet <object> loadedObjects)
        {
            if (loadedObjects.Contains(this))
            {
                return;
            }

            this.Basis.Tracker.LoadData(tsi, data, loadedObjects);

            int MyIndex = tsi.FieldInitializers.IndexOf(
                this.Initializer, (a, b) => a.Identification.Equals(b.Identification));
            XDGFieldInitializer myInfo = (XDGFieldInitializer)tsi.FieldInitializers.Single(info =>
                                                                                           info.Identification.Equals(this.Identification));

            if (this.Basis.Degree == myInfo.BasisInfo.Degree)
            {
                XDGField dis = this;
                LoadCoordinates(data, MyIndex, dis);
            }
            else
            {
                XDGField Temp = new XDGField(new XDGBasis(this.Basis.Tracker, myInfo.BasisInfo.Degree));
                LoadCoordinates(data, MyIndex, Temp);
                this.Clear();
                this.AccLaidBack(1.0, Temp);
            }
            loadedObjects.Add(this);
        }
Esempio n. 3
0
 /// <summary>
 /// ctor
 /// </summary>
 public SpeciesShadowField(XDGField owner, SpeciesId specId) :
     base(new Basis(owner.GridDat, owner.m_CCBasis.Degree),
          owner.Identification + "-" + owner.m_CCBasis.Tracker.GetSpeciesName(specId))
 {
     m_Coordinates = new SpeciesCoordinates(owner, specId);
     m_Owner       = owner;
 }
Esempio n. 4
0
        /// <summary>
        /// Overwrites the memory of a XDG field with the reference data
        /// </summary>
        static public void OverwriteDGField(this TestingIO t, XDGField f)
        {
            var trk = f.Basis.Tracker;

            foreach (string spc in trk.SpeciesNames)
            {
                var fs = f.GetSpeciesShadowField(spc);
                t.OverwriteDGField(fs);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Adds an XDG field.
        /// </summary>
        public static void AddDGField(this TestingIO t, XDGField f)
        {
            var trk = f.Basis.Tracker;

            foreach (string spc in trk.SpeciesNames)
            {
                var fs = f.GetSpeciesShadowField(spc);
                SinglePhaseField fsFatClone = new SinglePhaseField(fs.Basis, fs.Identification);
                CellMask         msk        = trk.Regions.GetSpeciesMask(spc);

                fsFatClone.Acc(1.0, fs, msk);

                t.AddDGField(fsFatClone);
            }
        }
Esempio n. 6
0
            /// <summary>
            /// <see cref="DGField.FieldInitializer"/>
            /// </summary>
            /// <param name="c"></param>
            /// <returns></returns>
            public override DGField Initialize(IInitializationContext c)
            {
                DGField sff;

                if (c.TryGetValue(this, out sff))
                {
                    return(sff);
                }

                var      Basis = (XDGBasis)(base.BasisInfo.Initialize(c));
                XDGField f     = new XDGField(Basis, this.Identification);

                myInstance = f;
                c.Add(this, f);
                return(f);
            }
Esempio n. 7
0
        /// <summary>
        /// Adds an XDG field.
        /// </summary>
        public static XDGField LocalError(this TestingIO t, XDGField f)
        {
            var trk = f.Basis.Tracker;

            var ErrLoc = f.CloneAs();

            ErrLoc.Clear();

            foreach (string spc in trk.SpeciesNames)
            {
                var fs = ErrLoc.GetSpeciesShadowField(spc);
                t.OverwriteDGField(fs);
            }

            ErrLoc.Scale(-1);
            ErrLoc.Acc(1.0, f);

            ErrLoc.Identification = "Error-" + ErrLoc.Identification;
            return(ErrLoc);
        }
Esempio n. 8
0
        /// <summary>
        /// Loads the XDG coordinates for the given <paramref name="field"/>
        /// from the given block of <paramref name="data"/>.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="MyIndex"></param>
        /// <param name="field"></param>
        private static void LoadCoordinates(IList <CellFieldDataSet> data, int MyIndex, XDGField field)
        {
            int J = field.GridDat.iLogicalCells.NoOfLocalUpdatedCells;

            for (int j = 0; j < J; j++)
            {
                //var coords_j = data[j].DGCoordinateData[MyIndex];
                var coords_j = data[j].GetDGCoordinates(MyIndex);

                //if (coords_j.Length != field.Basis.GetLength(j))
                if (coords_j.Length != field.Basis.GetLength(j))
                {
                    throw new Exception();
                    //Console.WriteLine("Bullshit in cell {0}", j);
                    //field.Coordinates.ClearRow(j);
                }
                else
                {
                    for (int n = 0; n < coords_j.Length; n++)
                    {
                        field.Coordinates[j, n] = coords_j[n];
                    }
                }
            }
        }