Beispiel #1
0
        public static void SaveWithPlainTextAnomaly(string path, CartesianModel model)
        {
            var dir       = Path.GetDirectoryName(path);
            var fileNames = SaveAnomalyLayersToPlainText(dir, model.Anomaly);

            SaveWithPlainTextAnomaly(path, model, fileNames);
        }
Beispiel #2
0
        public static void Save(string path, CartesianModel model)
        {
            var xdoc = new XDocument();

            var xmodel = ToXElement(model, null);

            xdoc.Add(xmodel);
            xdoc.Save(path);
        }
Beispiel #3
0
        public static OmegaModel BuildOmegaModel(CartesianModel startModel, double[,,] sigma, double frequency)
        {
            var omega = OmegaModelUtils.FrequencyToOmega(frequency);

            var section1D = ConvertSection1DIntoOmegaDependent(omega, startModel);
            var anomaly   = OmegaAnomaly.CreateFromCartesianAnomaly(omega, startModel.Anomaly, sigma);

            return(new OmegaModel(startModel, section1D, anomaly, omega));
        }
Beispiel #4
0
        private static XElement ToXElement(CartesianModel model, string[] fileNames)
        {
            var xmodel = new XElement(Model, new XAttribute(ModelVersionAttr, SecondVersion));

            SaveLateralDimensions(xmodel, model.LateralDimensions);
            SaveBackground(xmodel, model.Section1D);
            SaveAnomalies(xmodel, model.Anomaly, fileNames);

            return(xmodel);
        }
Beispiel #5
0
        public static void SaveWithPlainTextAnomaly(string path, CartesianModel model, string[] fileNames)
        {
            if (fileNames.Length != model.Anomaly.Layers.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(fileNames));
            }

            var xdoc = new XDocument();

            var xmodel = ToXElement(model, fileNames);

            xdoc.Add(xmodel);
            xdoc.Save(path);
        }
Beispiel #6
0
        public OmegaModel(CartesianModel model, Section1D <IsotropyLayer> section1D, OmegaAnomaly anomaly, double omega)
        {
            LateralDimensions = model.LateralDimensions;
            Section1D         = section1D;
            Anomaly           = anomaly;
            Omega             = omega;

            _backgroundDepths    = new decimal[section1D.NumberOfLayers];
            _backgroundDepths[0] = Section1D.ZeroAirLevelAlongZ;

            for (int i = 0; i < section1D.NumberOfLayers - 1; i++)
            {
                _backgroundDepths[i + 1] = _backgroundDepths[i] + section1D[i].Thickness;
            }
        }
Beispiel #7
0
 public static XElement ToXElement(CartesianModel model)
 {
     return(ToXElement(model, null));
 }
Beispiel #8
0
        private static unsafe void DistributedLoadModelMaster(Mpi mpi, string fullPath, CartesianModel model, int k)
        {
            using (var lr = new LinesReader(fullPath))
            {
                for (int rank = 0; rank < mpi.Size; rank++)
                {
                    var nxLength   = mpi.CalcLocalHalfNxLength(rank, model.LateralDimensions.Nx);
                    var sigma      = new double[nxLength, model.Anomaly.LocalSize.Ny, 1];
                    var sendLength = nxLength * model.Anomaly.LocalSize.Ny;

                    if (nxLength == 0)
                    {
                        continue;
                    }

                    AnomalyLoaderUtils.ReadAnomalyDataFromPlainText(lr, sigma, 0);

                    if (rank == 0)
                    {
                        for (int i = 0; i < nxLength; i++)
                        {
                            for (int j = 0; j < model.Anomaly.LocalSize.Ny; j++)
                            {
                                model.Anomaly.Sigma[i, j, k] = sigma[i, j, 0];
                            }
                        }
                    }
                    else if (nxLength != 0)
                    {
                        fixed(double *data = &sigma[0, 0, 0])
                        mpi.Send(data, sendLength, Mpi.Double, rank, 0);
                    }
                }
            }
        }
Beispiel #9
0
 public static void SaveModelWithPlaintTextAnomaly(string path, CartesianModel model)
 {
     ModelWriter.SaveWithPlainTextAnomaly(path, model);
 }
Beispiel #10
0
 public static void SaveModel(string path, CartesianModel model)
 {
     ModelWriter.Save(path, model);
 }
Beispiel #11
0
        public static Section1D <IsotropyLayer> ConvertSection1DIntoOmegaDependent(double omega, CartesianModel model)
        {
            int length     = model.Section1D.NumberOfLayers;
            var layersData = new IsotropyLayer[length];

            for (int i = 0; i < length; i++)
            {
                var layer = model.Section1D[i];

                layersData[i] = CreateIsotropy1DLayerDataFrom(omega, layer);
            }

            return(new Section1D <IsotropyLayer>(model.Section1D.ZeroAirLevelAlongZ, layersData));
        }