예제 #1
0
 /**
  * \brief Update the attachment, determining if an agent location crosses any boundaries
  *
  * <p>Update the attachment, determining if an agent location crosses any boundaries
  *
  * @return Boundary that has been crossed
  */
 public AllBC updateAttachment() {
   // Search a boundary which will be crossed
   double distance;
   for (AllBC aBoundary : getDomain().getAllBoundaries()) {
     if (aBoundary.isSupport()) {
       distance = aBoundary.getDistance(this._location);
       _isAttached = distance <= (3 * this._totalRadius);
       return aBoundary;
     }
   }
   return null;
 }
예제 #2
0
  /**
   * \brief Used by the move method to determine if an agents move crosses any of the domain's
   * boundaries
   *
   * <p>Used by the move method to determine if an agents move crosses any of the domain's
   * boundaries
   */
  public void checkBoundaries() {
    // Search a boundary which will be crossed
    _newLoc.set(_location);
    _newLoc.add(_movement);
    AllBC aBoundary = getDomain().testCrossedBoundary(_newLoc);
    int nDim = (_agentGrid.is3D ? 3 : 2);
    boolean test = (aBoundary != null);
    int counter = 0;

    // Test all boundaries and apply corrections according to crossed
    // boundaries
    while (test) {
      counter++;
      aBoundary.applyBoundary(this, _newLoc);
      aBoundary = getDomain().testCrossedBoundary(_newLoc);

      test = (aBoundary != null) | (counter > nDim);
      if (counter > nDim) System.out.println("LocatedAgent.move() : problem!");
    }
  }
예제 #3
0
  /**
   * \brief For self-attachment scenarios, determines whether a swimming agents move has taken it
   * across a boundary, correcting the coordinate accordingly
   *
   * <p>For self-attachment scenarios, the agents are swimming through the domain, and we need to
   * ensure that they perform the correct behaviour when the boundary is met. This method checks
   * whether an agents move has taken it over the boundary and applies the relevant correction
   * (either a bounce off the boundary or a reappearance on the other side). If the cell has hit the
   * surface, the cell is deemed to have adhered to that surface and a relevant x coordinate
   * generated to note that this is the case. The top of the domain is dealt with differently, as
   * this is checked by the call to isNewCoordAboveBoundaryLayer, which determines if the agent has
   * moved out of the boundary layer. If this is the case we assume this cell to have returned to
   * the bulk and do no further action with that cell. An integer is returned noting the fate of
   * this move - a 0 if the move is ok (after adjustment if required), a 1 if the agent has met the
   * substratum and attached, and a 2 if the cell has returned to the bulk
   *
   * @param distanceMoving Distance the agent is moving (in microns) in this move
   * @return Integer noting the fate of this move (0 move ok (after adjustment if required), 1 if
   *     attached to surface, 2 if returned to bulk
   */
  public int agentMoveBorderCheck() {
    // Simplest test to do first is to check if any boundaries have been crossed
    AllBC boundaryCrossed = domain.testCrossedBoundary(swimmingAgentPosition);

    // First is a simple test - has the cell returned to the bulk
    // If this is the case, we can just forget this and have another go
    // The cell will only have the capability to return to the bulk if the angle has it moving
    // upwards or directly across
    // (i.e 0-90 and 270-360 degrees)
    if (isNewCoordAboveBoundaryLayer()) {
      // The cell has returned into the bulk, and thus this try is over.
      // Return 2 so the process starts with a new cell.
      return 2;
    } else {
      // Now to see if the move takes the point outside any of the boundaries
      if (boundaryCrossed == null) {
        // No borders crossed, not back in the bulk.
        return 0;
      } else {
        String boundaryCrossedName = boundaryCrossed.getSideName();

        if (boundaryCrossedName.equals("y0z")) {
          // Detected that the move has crossed the substratum, thus
          // the cell has hit the biofilm. A return of 1 indicates
          // that this is the case.
          // Hit the biofilm, so set the species coordinates as required.

          // We may have hit the biofilm but the Y and Z coordinates
          // in this generated move may still be negative (as they
          // may have gone over another boundary). So before we set
          // the final x, we should check Y and Z.
          // So firstly, set the X position onto the surface
          swimmingAgentPosition.x = ExtraMath.getUniRandDbl();

          // Now set the final X position.
          // Do a new check on the boundary crossed.
          boundaryCrossed = domain.testCrossedBoundarySelfAttach(swimmingAgentPosition);

          if (boundaryCrossed != null) {
            boundaryCrossedName = boundaryCrossed.getSideName();
            if (boundaryCrossedName.equals("xNz") || boundaryCrossedName.equals("x0z"))
              correctCrossedLeftRightBoundaries(boundaryCrossed);
            else correctCrossedFrontBackBoundaries(boundaryCrossed);
          }
          return 1;
        } else if (boundaryCrossedName.equals("xNz") || boundaryCrossedName.equals("x0z")) {
          correctCrossedLeftRightBoundaries(boundaryCrossed);
          return 0;
        }
        // Deal with 3D boundary too
        else if (boundaryCrossedName.equals("x0y") || boundaryCrossedName.equals("xNy")) {
          correctCrossedFrontBackBoundaries(boundaryCrossed);
          return 0;
        } else {
          // This needs to be here so the function returns something.
          // However this deals with the top boundary (yNz) and this
          // has already been dealt with by the crossed bulk method.
          // So it is highly doubtful we will ever end up here.
          return 0;
        }
      }
    }
  }