public static TensorPlan CreateTensorPlanAtoO(Mpi mpi, OmegaModel model, int nTr, int nRc) { if (mpi != null && mpi.IsParallel) { var nxStart = mpi.CalcLocalNxStart(model.LateralDimensions); var nxTotalLength = mpi.CalcLocalNxLength(model.LateralDimensions); var nxCalcLength = nxTotalLength; if (nxStart >= model.Nx) { nxStart = -2 * model.Nx + nxStart; } if (nxStart == -model.Nx) { nxStart++; nxCalcLength--; } return(new TensorPlan(nxStart, nxCalcLength, nxTotalLength, nTr, nRc)); } else { var nxStart = -model.Nx + 1; var nxTotalLength = 2 * model.Nx; var nxCalcLength = nxTotalLength - 1; return(new TensorPlan(nxStart, nxCalcLength, nxTotalLength, nTr, nRc)); } }
public AtoAGreenTensorCalculatorComponent(ForwardSolver solver) : base(solver) { if (Solver.Engine == ForwardSolverEngine.Giem2g) { if (!Solver.IsParallel) { throw new NotImplementedException("GIEM2G works only in parallel mode!"); } _plan = null; _scalarCalc = null; _tensorCalc = null; _mirroringX = false; _realCalcNxStart = -1; _totalNxLength = -1; _calcNxLength = -1; return; } _plan = new ScalarPlansCreater(Model.LateralDimensions, HankelCoefficients.LoadN40(), Solver.Settings.NumberOfHankels) .CreateForAnomalyToAnomaly(); _scalarCalc = GreenScalarCalculator.NewAtoACalculator(Logger, Model); _tensorCalc = new AtoAGreenTensorCalculator(Logger, Model, MemoryProvider); if (Solver.IsParallel) { var localNxStart = Mpi.CalcLocalNxStart(Model.LateralDimensions); _totalNxLength = Mpi.CalcLocalNxLength(Model.LateralDimensions); _mirroringX = localNxStart >= Model.Nx; _realCalcNxStart = _mirroringX ? 2 * Model.Nx - localNxStart - _totalNxLength + 1 : localNxStart; _calcNxLength = _totalNxLength; if (_realCalcNxStart + _totalNxLength == Model.Nx + 1) { _calcNxLength--; } } else { _mirroringX = false; _realCalcNxStart = 0; _totalNxLength = 2 * Model.Nx; _calcNxLength = Model.Nx; } }