Ejemplo n.º 1
0
 public void SetValues(string QuantityID, string ElementSetID, Oatc.UpwardsComp.Standard.IValueSet values)
 {
     for (int i = 0; i < _storage.Length; i++)
     {
         _storage[i] = ((IScalarSet)values).GetScalar(i);
     }
 }
Ejemplo n.º 2
0
        public void SetValues(string QuantityID, string ElementSetID, Oatc.UpwardsComp.Standard.IValueSet values)
        {
            char[] separator = new char[] { ':' };

            if (!(values is IScalarSet))
            {
                throw new Exception("Illigal data type for values argument in method SetValues");
            }

            if (ElementSetID == "WholeRiver")
            {
                if (values.Count != _numberOfNodes - 1)
                {
                    throw new Exception("Illigal number of values in ValueSet in argument to SetValues method");
                }
                for (int i = 1; i < _numberOfNodes; i++)
                {
                    _storage[i] += ((IScalarSet)values).GetScalar(i) * _timeStepLength;
                }
            }
            else if (ElementSetID.Split(separator)[0] == "Node")
            {
                if (values.Count != 1)
                {
                    throw new Exception("illigal number of values in ValueSet in argument to SetValues method");
                }
                int nodeIndex = Convert.ToInt32(ElementSetID.Split(separator)[1]);
                _storage[nodeIndex] += ((IScalarSet)values).GetScalar(0) * _timeStepLength;
            }
            else
            {
                throw new Exception("Failed to recognize ElementSetID in method SetValues");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The ValueSet is converted. This method does not support VectorSet, so if the ValueSet is a Vectorset
        /// an exception will be thrown. The parameters passed in this method is not used, since all needed information
        /// is already assigned in the Prepare method.
        /// </summary>
        /// <param name="values">argumens but not used in this method</param>
        /// <returns>The converted ValueSet</returns>
        public Oatc.UpwardsComp.Standard.IValueSet PerformDataOperation(Oatc.UpwardsComp.Standard.IValueSet values)
        {
            if (_isActivated)
            {
                if (!(values is IScalarSet))
                {
                    throw new Exception("The Wrapper packages only supports ScalarSets (Not VectorSets)");
                }

                double[] x = new double[values.Count];

                for (int i = 0; i < values.Count; i++)
                {
                    x[i] = ((IScalarSet)values).GetScalar(i) * _a + _b;
                }

                return(new ScalarSet(x));
            }

            return(values);            // return the values unchanged.
        }