Program: 70948
Project: 70948
Buggy source:
/** 
 * Adds a copy of the nodes, elements, markers and attachments from <code>fem1</code> to <code>fem0</code>.
 * @param fem0 FEM model to which components should be added
 * @param fem1 FEM model providing components
 * @param nodeMergeDist If >= 0, causes nearby nodes of <code>fem1</code> and <code>fem0</code> to be merged: any node of <code>fem1</code> that is within <code>nodeMergeDist</code> of a node in <code>fem0</code> is replaced by the nearest node in <code>fem0</code>.
 */
public static void addFem(FemModel3d fem0,FemModel3d fem1,double nodeMergeDist){
  int flags=CopyableComponent.COPY_REFERENCES;
  HashMap<ModelComponent,ModelComponent> copyMap=new HashMap<ModelComponent,ModelComponent>();
  ArrayList<FemNode3d> newNodes=new ArrayList<FemNode3d>();
  for (  FemNode3d n : fem1.myNodes) {
    FemNode3d newn;
    if (nodeMergeDist < 0 || (newn=fem0.findNearestNode(n.getPosition(),nodeMergeDist)) == null) {
      newn=n.copy(flags,copyMap);
      newn.setName(n.getName());
      newNodes.add(newn);
    }
    copyMap.put(n,newn);
  }
  for (  FemNode3d n : newNodes) {
    fem0.myNodes.add(n);
  }
  for (  FemElement3d e : fem1.myElements) {
    FemElement3d newe=e.copy(flags,copyMap);
    newe.setName(e.getName());
    copyMap.put(e,newe);
    fem0.myElements.add(newe);
  }
  for (  FemMarker m : fem1.myMarkers) {
    FemMarker newm=m.copy(flags,copyMap);
    newm.setName(m.getName());
    fem0.myMarkers.add(newm);
  }
  for (  DynamicAttachment a : fem1.myAttachments) {
    DynamicAttachment newa=a.copy(flags,copyMap);
    newa.setName(a.getName());
    fem0.myAttachments.add(newa);
  }
}

Fixed version (ground truth):
/** 
 * Adds a copy of the nodes, elements, markers and attachments from <code>fem1</code> to <code>fem0</code>.
 * @param fem0 FEM model to which components should be added
 * @param fem1 FEM model providing components
 * @param nodeMergeDist If &gt;= 0, causes nearby nodes of <code>fem1</code> and <code>fem0</code> to be merged: any node of <code>fem1</code> that is within <code>nodeMergeDist</code> of a node in <code>fem0</code> is replaced by the nearest node in <code>fem0</code>.
 */
public static void addFem(FemModel3d fem0,FemModel3d fem1,double nodeMergeDist){
  int flags=CopyableComponent.COPY_REFERENCES;
  HashMap<ModelComponent,ModelComponent> copyMap=new HashMap<ModelComponent,ModelComponent>();
  ArrayList<FemNode3d> newNodes=new ArrayList<FemNode3d>();
  for (  FemNode3d n : fem1.myNodes) {
    FemNode3d newn;
    if (nodeMergeDist < 0 || (newn=fem0.findNearestNode(n.getPosition(),nodeMergeDist)) == null) {
      newn=n.copy(flags,copyMap);
      newn.setName(n.getName());
      newNodes.add(newn);
    }
    copyMap.put(n,newn);
  }
  for (  FemNode3d n : newNodes) {
    fem0.myNodes.add(n);
  }
  for (  FemElement3d e : fem1.myElements) {
    FemElement3d newe=e.copy(flags,copyMap);
    newe.setName(e.getName());
    copyMap.put(e,newe);
    fem0.myElements.add(newe);
  }
  for (  FemMarker m : fem1.myMarkers) {
    FemMarker newm=m.copy(flags,copyMap);
    newm.setName(m.getName());
    fem0.myMarkers.add(newm);
  }
  for (  DynamicAttachment a : fem1.myAttachments) {
    DynamicAttachment newa=a.copy(flags,copyMap);
    newa.setName(a.getName());
    fem0.myAttachments.add(newa);
  }
}