Exemplo n.º 1
0
  /**
   * \brief Defines a region of the computation domain where a new species may be created, using
   * restrictions in the protocol file
   *
   * <p>Defines a region of the computation domain where a new species may be created, using
   * restrictions in the protocol file. These restrictions for a particular species are specified in
   * 'coordinates' tags. There should be two such tags where this is used - one to start the
   * restriction and one to end it. Example of use: \<coordinates x="0" y="0" z="0"/\> \<coordinates
   * x="1" y="264" z="0"/\>. This method will read these in and create an array that represents this
   * area
   *
   * @param spRoot The information within the 'initArea' tags of the protocol file
   * @return A continuous vector representing the area of the domain specified in these tags
   */
  public ContinuousVector[] defineSquareArea(XMLParser spRoot) {
    List<XMLParser> area = spRoot.getChildrenParsers("coordinates");

    ContinuousVector[] initArea = new ContinuousVector[2];
    initArea[0] = new ContinuousVector();
    initArea[1] = new ContinuousVector();

    // KA NOV 13 - CHANGED THIS, AS WE'RE GOING TO LET THE USER NOT DECLARE AN INITIAL AREA IF THEY
    // WANT THE CELLS SPREAD ACROSS
    // THE WHOLE DOMAIN. THUS THIS NEEDS CHECKING AND FIXING
    if (area.size() > 0) {
      // First Coordinate Tag
      ContinuousVector cc1 = new ContinuousVector(area.get(0));
      // Second Coordinate Tag
      ContinuousVector cc2 = new ContinuousVector(area.get(1));

      // Set each point
      initArea[0].x = Math.min(cc1.x, cc2.x);
      initArea[1].x = Math.max(cc1.x, cc2.x);

      initArea[0].y = Math.min(cc1.y, cc2.y);
      initArea[1].y = Math.max(cc1.y, cc2.y);

      // In the case of 2D simulation, the agent's z-coordinate is 0.
      if (domain.is3D) {
        initArea[0].z = Math.min(cc1.z, cc2.z);
        initArea[1].z = Math.max(cc1.z, cc2.z);
      } else {
        initArea[0].z = initArea[1].z = 0.0;
      }

    } else {
      // NO INITIAL AREA HAS BEEN DECLARED, USE THE WHOLE SUBSTRATUM. NOTE THAT THE X (HEIGHT)
      // COORDINATE IS SET TO 1 SO THE
      // CELLS ARE PLACED NEAR THE SUBSTRATUM
      // Set each point
      initArea[0].x = 0.0;
      initArea[0].y = 0.0;
      initArea[0].z = 0.0;
      initArea[1].x = 1.0;
      initArea[1].y = domain.length_Y;
      initArea[1].z = domain.length_Z;
    }

    return initArea;
  }