Ejemplo n.º 1
0
        public static IIdentifiable[] GetAvailableMethods(IBaseOutput adaptee, IBaseInput target)
        {
            ITimeSpaceOutput tsadaptee = adaptee as ITimeSpaceOutput;

            // Only works with timespace output as adaptee, and element set as spatial definition
            if (tsadaptee == null || !(tsadaptee.SpatialDefinition is IElementSet))
            {
                return(new IIdentifiable[0]);
            }

            IList <IIdentifiable> methods = new List <IIdentifiable>();

            GetAvailableOperationMethods(ref methods, tsadaptee.ElementSet().ElementType);

            // Check if the target is there and is a timespace input
            ITimeSpaceInput tstarget = target as ITimeSpaceInput;

            if (target == null || tstarget == null || !(tstarget.SpatialDefinition is IElementSet))
            {
                return(((List <IIdentifiable>)methods).ToArray());
            }

            GetAvailableMappingMethods(ref methods, tsadaptee.ElementSet().ElementType, tstarget.ElementSet().ElementType);

            return(((List <IIdentifiable>)methods).ToArray());
        }
 internal MeasurementsInterpolator(ITimeSpaceOutput parentOutput)
     : base(parentOutput.Caption + "-" + MeasurementsInterpolatorName)
 {
     _valueDefinition   = parentOutput.ValueDefinition;
     _spatialDefinition = parentOutput.ElementSet();
     _adaptee           = parentOutput;
 }
Ejemplo n.º 3
0
    public void CreateInitializeTest()
    {
      ITimeSpaceComponent gwModel = new GWModelLC();
      IBaseLinkableComponent lc = gwModel;
      Assert.IsTrue(gwModel.Status == LinkableComponentStatus.Created);

      List<IArgument> gwArguments = CreateTestArguments();

      gwModel.Arguments.ApplyArguments(gwArguments);
      gwModel.Initialize();
      Assert.IsTrue(gwModel.Status == LinkableComponentStatus.Initialized);
      Assert.AreEqual("GWModelLC", gwModel.Id);

      Assert.AreEqual(3, gwModel.Inputs.Count);
      Assert.AreEqual(3, gwModel.Outputs.Count);

      {
        // Check the ground water level output
        ITimeSpaceOutput gwLevel = lc.Outputs[2] as ITimeSpaceOutput;
        Assert.IsNotNull(gwLevel);
        Assert.AreEqual("Grid.gwLevel", gwLevel.Id);

        // Check quantity
        IQuantity quantity = gwLevel.ValueDefinition as IQuantity;
        Assert.IsNotNull(quantity);
        Assert.AreEqual("Ground water level", quantity.Caption);
        Assert.AreEqual("gw level", quantity.Unit.Caption);
        Assert.AreEqual(1, quantity.Unit.Dimension.GetPower(DimensionBase.Length));
        Assert.AreEqual(0, quantity.Unit.Dimension.GetPower(DimensionBase.Time));
        Assert.AreEqual(1, quantity.Unit.ConversionFactorToSI);

        // Check element set
        IElementSet gridSet = gwLevel.ElementSet();
        CheckRegularGridElmtSet(gridSet);

      }

      {
        // Check the ground water inflow input
        ITimeSpaceInput gwInput = lc.Inputs[2] as ITimeSpaceInput;
        Assert.IsNotNull(gwInput);
        Assert.AreEqual("Grid.Inflow", gwInput.Id);

        // Check quantity
        IQuantity quantity = gwInput.ValueDefinition as IQuantity;
        Assert.IsNotNull(quantity);
        Assert.AreEqual("Inflow", quantity.Caption);
        Assert.AreEqual("Discharge", quantity.Unit.Caption);
        Assert.AreEqual(3, quantity.Unit.Dimension.GetPower(DimensionBase.Length));
        Assert.AreEqual(-1, quantity.Unit.Dimension.GetPower(DimensionBase.Time));
        Assert.AreEqual(0.001, quantity.Unit.ConversionFactorToSI);

        // Check element set
        IElementSet gridSet = gwInput.ElementSet();
        CheckRegularGridElmtSet(gridSet);
      }

    }
        public override void Initialize()
        {
            _lengthExponent = _lengthExponentArgument.Value;
            IElementSet elementSet = _tsadaptee.ElementSet();

            _factors = new double[elementSet.ElementCount];

            // Update quantity to take area operation into account
            UpdateQuantity();

            // Setup area exponent
            CalculateFactors(elementSet);
        }
 public ElementMapperAdaptedOutput(IIdentifiable methodId, ITimeSpaceOutput adaptee, IElementSet target)
     : base(adaptee.Id + "->" + methodId, adaptee)
 {
     _timeSet       = new TimeSet();
     _methodId      = methodId;
     _target        = target;
     _elementMapper = new ElementMapper();
     _elementMapper.Initialise(_methodId, adaptee.ElementSet(), target);
     _query = new Input(_id)
     {
         Caption           = _caption,
         Description       = _description,
         ValueDefinition   = _valueDefinition,
         SpatialDefinition = _spatialDefinition,
         Component         = adaptee.Component, // because this._component is not set yet.
     };
 }
Ejemplo n.º 6
0
        public IIdentifiable[] GetAvailableAdaptedOutputIds(IBaseOutput adaptee, IBaseInput target)
        {
            ITimeSpaceOutput tsadaptee = adaptee as ITimeSpaceOutput;
            ITimeSpaceInput  tstarget  = target as ITimeSpaceInput;

            // This inly works with time space items, and target can not be null
            if (tsadaptee == null || tstarget == null)
            {
                return(new IIdentifiable[0]);
            }

            // This only works with element sets
            if (!(tsadaptee.SpatialDefinition is IElementSet && tstarget.SpatialDefinition is IElementSet))
            {
                return(new IIdentifiable[0]);
            }

            return(ElementMapper.GetAvailableMethods(tsadaptee.ElementSet().ElementType, tstarget.ElementSet().ElementType));
        }
        public ElementMapperAdaptedOutput(IIdentifiable methodId, ITimeSpaceOutput adaptee, IElementSet target)
            : base(adaptee.Id + "->" + methodId, adaptee)
        {
            _timeSet       = new TimeSet();
            _methodId      = methodId;
            _target        = target;
            _elementMapper = new ElementMapper();
            IElementSet set = adaptee.ElementSet();

            _elementMapper.Initialise(ref _methodId, ref set, ref target);

            // The query item must match the adaptee on every point but
            // the timeset.
            _query = new Input(_id)
            {
                Caption           = _caption,
                Description       = _description,
                ValueDefinition   = adaptee.ValueDefinition,
                SpatialDefinition = adaptee.SpatialDefinition,
                Component         = adaptee.Component, // because this._component is not set yet.
            };
        }
        public void Outputs()
        {
            Assert.AreEqual(3, simpleRiver.Outputs.Count);

            ITimeSpaceOutput output = (ITimeSpaceOutput)simpleRiver.Outputs[0];

            Assert.AreEqual("Branch:0:Flow", output.Id);
            Assert.AreEqual("Flow", output.ValueDefinition.Caption);
            Assert.AreEqual("m3/sec", ((IQuantity)output.ValueDefinition).Unit.Caption);
            Assert.AreEqual(typeof(double).ToString(), output.ValueDefinition.ValueType.ToString());
            Assert.AreEqual("Branch:0", output.ElementSet().Caption);
            Assert.AreEqual(ElementType.PolyLine, output.ElementSet().ElementType);
            Assert.AreEqual(1, output.ElementSet().ElementCount);
            Assert.AreEqual(2, output.ElementSet().GetVertexCount(0));
            Assert.AreEqual(1000.0, output.ElementSet().GetVertexXCoordinate(0, 0));
            Assert.AreEqual(7000.0, output.ElementSet().GetVertexXCoordinate(0, 1));
            Assert.AreEqual(9000.0, output.ElementSet().GetVertexYCoordinate(0, 0));
            Assert.AreEqual(6000.0, output.ElementSet().GetVertexYCoordinate(0, 1));

            output = (ITimeSpaceOutput)simpleRiver.Outputs[1];
            Assert.AreEqual("Branch:1:Flow", output.Id);
            Assert.AreEqual("Flow", output.ValueDefinition.Caption);
            Assert.AreEqual("m3/sec", ((IQuantity)output.ValueDefinition).Unit.Caption);
            Assert.AreEqual(typeof(double).ToString(), output.ValueDefinition.ValueType.ToString());
            Assert.AreEqual("Branch:1", output.ElementSet().Caption);
            Assert.AreEqual(ElementType.PolyLine, output.ElementSet().ElementType);
            Assert.AreEqual(1, output.ElementSet().ElementCount);
            Assert.AreEqual(2, output.ElementSet().GetVertexCount(0));
            Assert.AreEqual(7000.0, output.ElementSet().GetVertexXCoordinate(0, 0));
            Assert.AreEqual(9000.0, output.ElementSet().GetVertexXCoordinate(0, 1));
            Assert.AreEqual(6000.0, output.ElementSet().GetVertexYCoordinate(0, 0));
            Assert.AreEqual(3000.0, output.ElementSet().GetVertexYCoordinate(0, 1));

            output = (ITimeSpaceOutput)simpleRiver.Outputs[2];
            Assert.AreEqual("Branch:2:Flow", output.Id);
            Assert.AreEqual("Flow", output.ValueDefinition.Caption);
            Assert.AreEqual("m3/sec", ((IQuantity)output.ValueDefinition).Unit.Caption);
            Assert.AreEqual(typeof(double).ToString(), output.ValueDefinition.ValueType.ToString());
            Assert.AreEqual("Branch:2", output.ElementSet().Caption);
            Assert.AreEqual(ElementType.PolyLine, output.ElementSet().ElementType);
            Assert.AreEqual(1, output.ElementSet().ElementCount);
            Assert.AreEqual(2, output.ElementSet().GetVertexCount(0));
            Assert.AreEqual(9000.0, output.ElementSet().GetVertexXCoordinate(0, 0));
            Assert.AreEqual(14000.0, output.ElementSet().GetVertexXCoordinate(0, 1));
            Assert.AreEqual(3000.0, output.ElementSet().GetVertexYCoordinate(0, 0));
            Assert.AreEqual(1000.0, output.ElementSet().GetVertexYCoordinate(0, 1));
        }