/// <summary> /// This method combines the passed base airfoil with the passed coefficients as aparallel processing. /// If finish the processing, it fires the event combinatedAirfoilUpdated. /// </summary> /// <param name="basisAirfoils"></param> /// <param name="coefficients"></param> public void CombineAirfoils(General.BasisAirfoils basisAirfoils, Double[,] coefficients) { List <Task> tasks = new List <Task>(); for (int i = 0; i < _numberOfAirfoils; i++) { // Null Check if (_combinedAirfoils[i] == null) { _combinedAirfoils[i] = new Representation.AirfoilCombiner(); } var x = i; var basis = basisAirfoils.AirfoilGroup.ToArray(); var coef = GetRowArray(coefficients, i); // Update Source and Re-Combinate Airfoil. tasks.Add(Task.Run(() => _combinedAirfoils[x].UpdateBaseSource(coef, basis))); } Task.WaitAll(tasks.ToArray()); // Fire the event combinedAirfoilsUpdated CombinedAirfoilsUpdated?.Invoke(this, new CombinedAirfoilsUpdatedEventArgs() { combinedAirfoils = this._combinedAirfoils }); }
public void AddElement(Representation.AirfoilCombiner element) { List <Representation.AirfoilCombiner> tempAirfoils = new List <Representation.AirfoilCombiner>(_combinedAirfoils); tempAirfoils.Add(element); _combinedAirfoils = tempAirfoils.ToArray(); // Increment number of airfoils ++this._numberOfAirfoils; // Fire the event combinedAirfoilsUpdated CombinedAirfoilsUpdated?.Invoke(this, new CombinedAirfoilsUpdatedEventArgs() { combinedAirfoils = this._combinedAirfoils }); }
public void Add(Representation.AirfoilCombiner combinedAirfoil) { var basisAirfoils = combinedAirfoil.BasisAirfoils; var coefficients = combinedAirfoil.Coefficients; // Format Check if (_numberOfBasisAirfoils != basisAirfoils.Length) { throw new FormatException("The combined airfoil that has different basis airfoils from defined in this instance are passed."); } // Add coefficients of new airfoil _coefficientsOfCombination ??= new CoefficientOfCombination(_numberOfBasisAirfoils); _coefficientsOfCombination.AddCoefficient(coefficients); // Add new combined airfoil _combinedAirfoils ??= new List <AirfoilManager>(); _combinedAirfoils.Add(combinedAirfoil.CombinedAirfoil); // Increment number of combined airfoils _numberOfAirfoils++; }