Exemplo n.º 1
0
        private static void UpdateAnomalyLocalSize(Mpi mpi, CartesianAnomaly anomaly)
        {
            var localSize = new Size2D(mpi.CalcLocalHalfNxLength(anomaly.LocalSize.Nx), anomaly.LocalSize.Ny);

            anomaly.ChangeLocalSize(localSize);
            anomaly.CreateSigma();
        }
Exemplo n.º 2
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);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static unsafe CartesianModel DistributedLoadModelSlave(Mpi mpi, string path)
        {
            var model      = LoadModelWithoutExternFiles(path);
            var anomaly    = model.Anomaly;
            var nxLength   = mpi.CalcLocalHalfNxLength(model.LateralDimensions.Nx);
            var recvLength = nxLength * anomaly.LocalSize.Ny;
            var sigma      = new double[nxLength, model.Anomaly.LocalSize.Ny, 1];

            UpdateAnomalyLocalSize(mpi, anomaly);

            if (nxLength != 0)
                fixed(double *data = &sigma[0, 0, 0])
                {
                    for (int k = 0; k < anomaly.Layers.Count; k++)
                    {
                        var actualSource = 0;
                        mpi.Recv(data, recvLength, Mpi.Double, 0, 0, out actualSource);
                        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];
                            }
                        }
                    }
                }


            return(model);
        }
Exemplo n.º 4
0
        private static CartesianModel GenerateModel(Mpi mpi, ModelSettings settings, Func <NonMeshedModel> genNonMeshed)
        {
            var nonMeshed = genNonMeshed();
            var converter = new NonMeshedToCartesianModelConverter(nonMeshed);
            var mesh      = settings.Mesh;

            converter.SetManualBoundaries(settings.ManualBoundaries);

            var nxStart  = 0;
            var nxLength = mesh.Nx;

            if (mpi != null && mpi.IsParallel)
            {
                nxStart  = mpi.CalcLocalHalfNxStart(mesh.Nx);
                nxLength = mpi.CalcLocalHalfNxLength(mesh.Nx);
            }

            var cartesian = converter.Convert(mesh, nxStart, nxLength);

            return(cartesian);
        }