package run.elements;
import run.*;

import java.util.Vector;

import jp.lang.DistributedRuntime;

public class Beam_Spring_2 extends Element implements uka.patch.Patchable, uka.transport.Transportable {
   public void createPatch(Object _copy, uka.patch.PatchOutput po) throws java.io.IOException {
      Beam_Spring_2 copy = (Beam_Spring_2)_copy;
      super.createPatch(copy, po);
      if (po.writeDiff(this.Contact, copy.Contact)) copy.Contact = this.Contact;
      if (po.writeDiff(this.D_is_set, copy.D_is_set)) copy.D_is_set = this.D_is_set;
      if (po.writeDiff(this.Material_is_set, copy.Material_is_set)) copy.Material_is_set = this.Material_is_set;
      if (po.writeDiff(this.Factor_is_set, copy.Factor_is_set)) copy.Factor_is_set = this.Factor_is_set;
      if (po.writeDiff(this.Nodes_are_set, copy.Nodes_are_set)) copy.Nodes_are_set = this.Nodes_are_set;
      if (po.writeDiff(this.diameter, copy.diameter)) copy.diameter = this.diameter;
      if (po.writeDiff(this.factor, copy.factor)) copy.factor = this.factor;
      if (po.writeDiff(this.length, copy.length)) copy.length = this.length;
      if (po.writeDiff(this.cross_section_area, copy.cross_section_area)) copy.cross_section_area = this.cross_section_area;
      copy.material = this.material = (run.Material)po.writeDiff(this.material, copy.material);
      copy.internal_contact_element = this.internal_contact_element = (run.elements.Contact_Line)po.writeDiff(this.internal_contact_element, copy.internal_contact_element);
      copy.temp = this.temp = (Jama.Matrix)po.writeDiff(this.temp, copy.temp);
      copy.global_m = this.global_m = (Jama.Matrix)po.writeDiff(this.global_m, copy.global_m);
      copy.m = this.m = (Jama.Matrix)po.writeDiff(this.m, copy.m);
      copy.force = this.force = (Jama.Matrix)po.writeDiff(this.force, copy.force);
      copy.velocity = this.velocity = (Jama.Matrix)po.writeDiff(this.velocity, copy.velocity);
      copy.displacement = this.displacement = (Jama.Matrix)po.writeDiff(this.displacement, copy.displacement);
      copy.global_moment = this.global_moment = (Jama.Matrix)po.writeDiff(this.global_moment, copy.global_moment);
      copy.global_force = this.global_force = (Jama.Matrix)po.writeDiff(this.global_force, copy.global_force);
      copy.local_coordinate_system = this.local_coordinate_system = (Jama.Matrix)po.writeDiff(this.local_coordinate_system, copy.local_coordinate_system);
      copy.control_node = this.control_node = (run.Node)po.writeDiff(this.control_node, copy.control_node);
   }
   public void applyPatch(Object _copy, uka.patch.PatchInput pi) throws java.io.IOException, ClassNotFoundException {
      Beam_Spring_2 copy = (Beam_Spring_2)_copy;
      super.applyPatch(copy, pi);
      if (pi.hasDiff()) copy.Contact = this.Contact = pi.getDiffAsInt();
      if (pi.hasDiff()) copy.D_is_set = this.D_is_set = pi.getDiffAsBoolean();
      if (pi.hasDiff()) copy.Material_is_set = this.Material_is_set = pi.getDiffAsBoolean();
      if (pi.hasDiff()) copy.Factor_is_set = this.Factor_is_set = pi.getDiffAsBoolean();
      if (pi.hasDiff()) copy.Nodes_are_set = this.Nodes_are_set = pi.getDiffAsBoolean();
      if (pi.hasDiff()) copy.diameter = this.diameter = pi.getDiffAsDouble();
      if (pi.hasDiff()) copy.factor = this.factor = pi.getDiffAsDouble();
      if (pi.hasDiff()) copy.length = this.length = pi.getDiffAsDouble();
      if (pi.hasDiff()) copy.cross_section_area = this.cross_section_area = pi.getDiffAsDouble();
      if (pi.hasDiff()) copy.material = this.material = (run.Material)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.internal_contact_element = this.internal_contact_element = (run.elements.Contact_Line)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.temp = this.temp = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.global_m = this.global_m = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.m = this.m = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.force = this.force = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.velocity = this.velocity = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.displacement = this.displacement = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.global_moment = this.global_moment = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.global_force = this.global_force = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.local_coordinate_system = this.local_coordinate_system = (Jama.Matrix)pi.getDiffAsObject();
      if (pi.hasDiff()) copy.control_node = this.control_node = (run.Node)pi.getDiffAsObject();
   }
   public void descendReferences(uka.patch.ReferenceConsumer c) throws java.io.IOException {
      super.descendReferences(c);
      c.descend(this.material);
      c.descend(this.internal_contact_element);
      c.descend(this.temp);
      c.descend(this.global_m);
      c.descend(this.m);
      c.descend(this.force);
      c.descend(this.velocity);
      c.descend(this.displacement);
      c.descend(this.global_moment);
      c.descend(this.global_force);
      c.descend(this.local_coordinate_system);
      c.descend(this.control_node);
   }
   public void filterReferences(uka.patch.ReferenceFilter f) {
      super.filterReferences(f);
      this.material = (run.Material)f.filter(this.material);
      this.internal_contact_element = (run.elements.Contact_Line)f.filter(this.internal_contact_element);
      this.temp = (Jama.Matrix)f.filter(this.temp);
      this.global_m = (Jama.Matrix)f.filter(this.global_m);
      this.m = (Jama.Matrix)f.filter(this.m);
      this.force = (Jama.Matrix)f.filter(this.force);
      this.velocity = (Jama.Matrix)f.filter(this.velocity);
      this.displacement = (Jama.Matrix)f.filter(this.displacement);
      this.global_moment = (Jama.Matrix)f.filter(this.global_moment);
      this.global_force = (Jama.Matrix)f.filter(this.global_force);
      this.local_coordinate_system = (Jama.Matrix)f.filter(this.local_coordinate_system);
      this.control_node = (run.Node)f.filter(this.control_node);
   }
   public static final uka.transport.TransportDescriptor TRANSPORT_DESCRIPTOR = new uka.transport.TransportDescriptor(){
      public Object unmarshalReference(uka.transport.UnmarshalStream s, int id) throws java.io.IOException, ClassNotFoundException {
         return new Beam_Spring_2(s, id);
      }
      public boolean unmarshal(Object obj, uka.transport.UnmarshalStream s) throws ClassNotFoundException, java.io.IOException {
         ((Beam_Spring_2)obj).unmarshal(s);
         return false;
      }
      public void marshalReference(Object obj, uka.transport.MarshalStream s) throws java.io.IOException {
         ((Beam_Spring_2)obj).marshalReference(s);
      }
      public void marshal(Object obj, uka.transport.MarshalStream s) throws java.io.IOException {
         ((Beam_Spring_2)obj).marshal(s);
      }
      public Object deepClone(Object orig, int id, uka.transport.DeepClone _helper) throws CloneNotSupportedException {
         try {
            return new Beam_Spring_2((Beam_Spring_2)orig, id, _helper);
         }  catch (java.io.IOException ex) {
            throw (CloneNotSupportedException)new CloneNotSupportedException().initCause(ex);
         }
      }
      public boolean deepCloneReferences(Object orig, Object copy, uka.transport.DeepClone _helper) throws CloneNotSupportedException {
         ((Beam_Spring_2)copy).deepCloneReferences((Beam_Spring_2)orig, _helper);
         return false;
      }
      public Class getType() {
         return Beam_Spring_2.class;
      }
   };
   public uka.transport.TransportDescriptor getTransportDescriptor() {
      return TRANSPORT_DESCRIPTOR;
   }
   private static final int _SIZE = uka.transport.BasicIO.SIZEOF_int + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_boolean + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double;
   public Beam_Spring_2(uka.transport.UnmarshalStream _stream, int _id) throws java.io.IOException, ClassNotFoundException {
      super(_stream, _id);
   }
   public void unmarshal(uka.transport.UnmarshalStream _stream) throws java.io.IOException, ClassNotFoundException {
      super.unmarshal(_stream);
      _stream.request(Beam_Spring_2._SIZE);
      byte[] _buffer = _stream.getBuffer();
      int _pos = _stream.getPosition();
      this.Contact = uka.transport.BasicIO.extractInt(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_int;
      this.D_is_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_boolean;
      this.Material_is_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_boolean;
      this.Factor_is_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_boolean;
      this.Nodes_are_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_boolean;
      this.diameter = uka.transport.BasicIO.extractDouble(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_double;
      this.factor = uka.transport.BasicIO.extractDouble(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_double;
      this.length = uka.transport.BasicIO.extractDouble(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_double;
      this.cross_section_area = uka.transport.BasicIO.extractDouble(_buffer, _pos);
      _pos += uka.transport.BasicIO.SIZEOF_double;
      _stream.accept(Beam_Spring_2._SIZE);
      this.material = (run.Material)_stream.readReference();
      this.internal_contact_element = (run.elements.Contact_Line)_stream.readReference();
      this.temp = (Jama.Matrix)_stream.readReference();
      this.global_m = (Jama.Matrix)_stream.readReference();
      this.m = (Jama.Matrix)_stream.readReference();
      this.force = (Jama.Matrix)_stream.readReference();
      this.velocity = (Jama.Matrix)_stream.readReference();
      this.displacement = (Jama.Matrix)_stream.readReference();
      this.global_moment = (Jama.Matrix)_stream.readReference();
      this.global_force = (Jama.Matrix)_stream.readReference();
      this.local_coordinate_system = (Jama.Matrix)_stream.readReference();
      this.control_node = (run.Node)_stream.readReference();
   }
   public void marshal(uka.transport.MarshalStream _stream) throws java.io.IOException {
      super.marshal(_stream);
      _stream.reserve(Beam_Spring_2._SIZE);
      byte[] _buffer = _stream.getBuffer();
      int _pos = _stream.getPosition();
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Contact);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.D_is_set);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Material_is_set);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Factor_is_set);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Nodes_are_set);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.diameter);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.factor);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.length);
      _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.cross_section_area);
      _stream.deliver(_SIZE);
      _stream.writeReference(this.material);
      _stream.writeReference(this.internal_contact_element);
      _stream.writeReference(this.temp);
      _stream.writeReference(this.global_m);
      _stream.writeReference(this.m);
      _stream.writeReference(this.force);
      _stream.writeReference(this.velocity);
      _stream.writeReference(this.displacement);
      _stream.writeReference(this.global_moment);
      _stream.writeReference(this.global_force);
      _stream.writeReference(this.local_coordinate_system);
      _stream.writeReference(this.control_node);
   }
   public Beam_Spring_2(Beam_Spring_2 _orig, int _id, uka.transport.DeepClone _helper) throws CloneNotSupportedException, java.io.IOException {
      super(_orig, _id, _helper);
      this.Contact = _orig.Contact;
      this.D_is_set = _orig.D_is_set;
      this.Material_is_set = _orig.Material_is_set;
      this.Factor_is_set = _orig.Factor_is_set;
      this.Nodes_are_set = _orig.Nodes_are_set;
      this.diameter = _orig.diameter;
      this.factor = _orig.factor;
      this.length = _orig.length;
      this.cross_section_area = _orig.cross_section_area;
   }
   public void deepCloneReferences(Beam_Spring_2 _orig, uka.transport.DeepClone _helper) throws CloneNotSupportedException {
      super.deepCloneReferences(_orig, _helper);
      this.material = (run.Material)_helper.internalDeepClone(_orig.material);
      this.internal_contact_element = (run.elements.Contact_Line)_helper.internalDeepClone(_orig.internal_contact_element);
      this.temp = (Jama.Matrix)_helper.internalDeepClone(_orig.temp);
      this.global_m = (Jama.Matrix)_helper.internalDeepClone(_orig.global_m);
      this.m = (Jama.Matrix)_helper.internalDeepClone(_orig.m);
      this.force = (Jama.Matrix)_helper.internalDeepClone(_orig.force);
      this.velocity = (Jama.Matrix)_helper.internalDeepClone(_orig.velocity);
      this.displacement = (Jama.Matrix)_helper.internalDeepClone(_orig.displacement);
      this.global_moment = (Jama.Matrix)_helper.internalDeepClone(_orig.global_moment);
      this.global_force = (Jama.Matrix)_helper.internalDeepClone(_orig.global_force);
      this.local_coordinate_system = (Jama.Matrix)_helper.internalDeepClone(_orig.local_coordinate_system);
      this.control_node = (run.Node)_helper.internalDeepClone(_orig.control_node);
   }
   private static int DISABLED = 0;
   private static int BASIC = 1;
   private double cross_section_area;
   private Node control_node;
   private Jama.Matrix local_coordinate_system;
   private double length;
   private Jama.Matrix global_force;
   private Jama.Matrix global_moment;
   private Jama.Matrix displacement;
   private Jama.Matrix velocity;
   private Jama.Matrix force;
   private Jama.Matrix m;
   private Jama.Matrix global_m;
   private Jama.Matrix temp;
   private double factor;
   private double diameter;
   private boolean Nodes_are_set;
   private boolean Factor_is_set;
   private boolean Material_is_set;
   private boolean D_is_set;
   private Contact_Line internal_contact_element;
   private int Contact;
   private Material material;
   public Beam_Spring_2() {
      super();
      run.elements.Beam_Spring_2.this.type = new String("BEAM_STRING_2");
      run.elements.Beam_Spring_2.this.force = new Jama.Matrix(6, 1);
      run.elements.Beam_Spring_2.this.displacement = new Jama.Matrix(6, 1);
      run.elements.Beam_Spring_2.this.velocity = new Jama.Matrix(6, 1);
      run.elements.Beam_Spring_2.this.global_force = new Jama.Matrix(3, 1);
      run.elements.Beam_Spring_2.this.global_moment = new Jama.Matrix(3, 1);
      run.elements.Beam_Spring_2.this.m = new Jama.Matrix(3, 1);
      run.elements.Beam_Spring_2.this.global_m = new Jama.Matrix(3, 1);
      run.elements.Beam_Spring_2.this.temp = new Jama.Matrix(6, 1);
      run.elements.Beam_Spring_2.this.local_coordinate_system = new Jama.Matrix(3, 3);
      run.elements.Beam_Spring_2.this.processed = false;
      run.elements.Beam_Spring_2.this.node = new Node[2];
      run.elements.Beam_Spring_2.this.Contact = run.elements.Beam_Spring_2.DISABLED;
   }
   public void assembleMassMatrix() throws Error {
      this.updateLocalCoordinateSystem();
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element.assembleMassMatrix();
      }
   }
   public void calculateContactForces() {
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element.calculateContactForces();
      }
   }
   public void calculateExternalForces(double currtime) {
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element.calculateExternalForces(currtime);
      }
   }
   public void calculateNodalForces(int integration_point) throws java.lang.Error {
      run.elements.Beam_Spring_2.this.m.set(1, 0, -run.elements.Beam_Spring_2.this.length * run.elements.Beam_Spring_2.this.force.get(2, 0));
      run.elements.Beam_Spring_2.this.m.set(2, 0, run.elements.Beam_Spring_2.this.length * run.elements.Beam_Spring_2.this.force.get(1, 0));
      run.elements.Beam_Spring_2.this.global_force.set(0, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 0) * run.elements.Beam_Spring_2.this.force.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 1) * run.elements.Beam_Spring_2.this.force.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 2) * run.elements.Beam_Spring_2.this.force.get(2, 0));
      run.elements.Beam_Spring_2.this.global_force.set(1, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 0) * run.elements.Beam_Spring_2.this.force.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 1) * run.elements.Beam_Spring_2.this.force.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 2) * run.elements.Beam_Spring_2.this.force.get(2, 0));
      run.elements.Beam_Spring_2.this.global_force.set(2, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 0) * run.elements.Beam_Spring_2.this.force.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 1) * run.elements.Beam_Spring_2.this.force.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 2) * run.elements.Beam_Spring_2.this.force.get(2, 0));
      run.elements.Beam_Spring_2.this.global_moment.set(0, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 0) * run.elements.Beam_Spring_2.this.force.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 1) * run.elements.Beam_Spring_2.this.force.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 2) * run.elements.Beam_Spring_2.this.force.get(5, 0));
      run.elements.Beam_Spring_2.this.global_moment.set(1, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 0) * run.elements.Beam_Spring_2.this.force.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 1) * run.elements.Beam_Spring_2.this.force.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 2) * run.elements.Beam_Spring_2.this.force.get(5, 0));
      run.elements.Beam_Spring_2.this.global_moment.set(2, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 0) * run.elements.Beam_Spring_2.this.force.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 1) * run.elements.Beam_Spring_2.this.force.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 2) * run.elements.Beam_Spring_2.this.force.get(5, 0));
      run.elements.Beam_Spring_2.this.global_m.set(0, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 0) * run.elements.Beam_Spring_2.this.m.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 1) * run.elements.Beam_Spring_2.this.m.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 2) * run.elements.Beam_Spring_2.this.m.get(2, 0));
      run.elements.Beam_Spring_2.this.global_m.set(1, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 0) * run.elements.Beam_Spring_2.this.m.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 1) * run.elements.Beam_Spring_2.this.m.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 2) * run.elements.Beam_Spring_2.this.m.get(2, 0));
      run.elements.Beam_Spring_2.this.global_m.set(2, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 0) * run.elements.Beam_Spring_2.this.m.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 1) * run.elements.Beam_Spring_2.this.m.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 2) * run.elements.Beam_Spring_2.this.m.get(2, 0));
      run.elements.Beam_Spring_2.this.node[0].addInternalForce(run.elements.Beam_Spring_2.this.global_force.times(1));
      run.elements.Beam_Spring_2.this.node[1].addInternalForce(run.elements.Beam_Spring_2.this.global_force.times(-1));
      run.elements.Beam_Spring_2.this.node[0].addInternalMoment(run.elements.Beam_Spring_2.this.global_moment.times(1));
      run.elements.Beam_Spring_2.this.node[1].addInternalMoment(run.elements.Beam_Spring_2.this.global_moment.times(-1));
      run.elements.Beam_Spring_2.this.node[0].addInternalMoment(run.elements.Beam_Spring_2.this.global_m);
      run.elements.Beam_Spring_2.this.node[1].addInternalMoment(run.elements.Beam_Spring_2.this.global_m);
   }
   public void calculateStrain(double timestep, int integration_point) throws java.lang.Error {
      run.elements.Beam_Spring_2.this.length = Math.sqrt((run.elements.Beam_Spring_2.this.node[1].getX_pos() - run.elements.Beam_Spring_2.this.node[0].getX_pos()) * (run.elements.Beam_Spring_2.this.node[1].getX_pos() - run.elements.Beam_Spring_2.this.node[0].getX_pos()) + (run.elements.Beam_Spring_2.this.node[1].getY_pos() - run.elements.Beam_Spring_2.this.node[0].getY_pos()) * (run.elements.Beam_Spring_2.this.node[1].getY_pos() - run.elements.Beam_Spring_2.this.node[0].getY_pos()) + (run.elements.Beam_Spring_2.this.node[1].getZ_pos() - run.elements.Beam_Spring_2.this.node[0].getZ_pos()) * (run.elements.Beam_Spring_2.this.node[1].getZ_pos() - run.elements.Beam_Spring_2.this.node[0].getZ_pos()));
      if (run.elements.Beam_Spring_2.this.length == 0) {
         throw new java.lang.Error("Zero element length for Spring_Beam element nr" + run.elements.Beam_Spring_2.this.number);
      }
      run.elements.Beam_Spring_2.this.temp.set(0, 0, run.elements.Beam_Spring_2.this.node[1].getX_pos() - run.elements.Beam_Spring_2.this.node[1].getX_pos_orig() - (run.elements.Beam_Spring_2.this.node[0].getX_pos() - run.elements.Beam_Spring_2.this.node[0].getX_pos_orig()));
      run.elements.Beam_Spring_2.this.temp.set(1, 0, run.elements.Beam_Spring_2.this.node[1].getY_pos() - run.elements.Beam_Spring_2.this.node[1].getY_pos_orig() - (run.elements.Beam_Spring_2.this.node[0].getY_pos() - run.elements.Beam_Spring_2.this.node[0].getY_pos_orig()) - run.elements.Beam_Spring_2.this.length * 0.5 * (run.elements.Beam_Spring_2.this.node[1].getZ_rot() - run.elements.Beam_Spring_2.this.node[1].getZ_rot_orig() + (run.elements.Beam_Spring_2.this.node[0].getZ_rot() - run.elements.Beam_Spring_2.this.node[0].getZ_rot_orig())));
      run.elements.Beam_Spring_2.this.temp.set(2, 0, run.elements.Beam_Spring_2.this.node[1].getZ_pos() - run.elements.Beam_Spring_2.this.node[1].getZ_pos_orig() - (run.elements.Beam_Spring_2.this.node[0].getZ_pos() - run.elements.Beam_Spring_2.this.node[0].getZ_pos_orig()) + run.elements.Beam_Spring_2.this.length * 0.5 * (run.elements.Beam_Spring_2.this.node[1].getY_rot() - run.elements.Beam_Spring_2.this.node[1].getY_rot_orig() + (run.elements.Beam_Spring_2.this.node[0].getY_rot() - run.elements.Beam_Spring_2.this.node[0].getY_rot_orig())));
      run.elements.Beam_Spring_2.this.temp.set(3, 0, run.elements.Beam_Spring_2.this.node[1].getX_rot() - run.elements.Beam_Spring_2.this.node[1].getX_rot_orig() - (run.elements.Beam_Spring_2.this.node[0].getX_rot() - run.elements.Beam_Spring_2.this.node[0].getX_rot_orig()));
      run.elements.Beam_Spring_2.this.temp.set(4, 0, run.elements.Beam_Spring_2.this.node[1].getY_rot() - run.elements.Beam_Spring_2.this.node[1].getY_rot_orig() - (run.elements.Beam_Spring_2.this.node[0].getY_rot() - run.elements.Beam_Spring_2.this.node[0].getY_rot_orig()));
      run.elements.Beam_Spring_2.this.temp.set(5, 0, run.elements.Beam_Spring_2.this.node[1].getZ_rot() - run.elements.Beam_Spring_2.this.node[1].getZ_rot_orig() - (run.elements.Beam_Spring_2.this.node[0].getZ_rot() - run.elements.Beam_Spring_2.this.node[0].getZ_rot_orig()));
      run.elements.Beam_Spring_2.this.displacement.set(0, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 0) * run.elements.Beam_Spring_2.this.temp.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 0) * run.elements.Beam_Spring_2.this.temp.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 0) * run.elements.Beam_Spring_2.this.temp.get(2, 0));
      run.elements.Beam_Spring_2.this.displacement.set(1, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 1) * run.elements.Beam_Spring_2.this.temp.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 1) * run.elements.Beam_Spring_2.this.temp.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 1) * run.elements.Beam_Spring_2.this.temp.get(2, 0));
      run.elements.Beam_Spring_2.this.displacement.set(2, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 2) * run.elements.Beam_Spring_2.this.temp.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 2) * run.elements.Beam_Spring_2.this.temp.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 2) * run.elements.Beam_Spring_2.this.temp.get(2, 0));
      run.elements.Beam_Spring_2.this.displacement.set(3, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 0) * run.elements.Beam_Spring_2.this.temp.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 0) * run.elements.Beam_Spring_2.this.temp.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 0) * run.elements.Beam_Spring_2.this.temp.get(5, 0));
      run.elements.Beam_Spring_2.this.displacement.set(4, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 1) * run.elements.Beam_Spring_2.this.temp.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 1) * run.elements.Beam_Spring_2.this.temp.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 1) * run.elements.Beam_Spring_2.this.temp.get(5, 0));
      run.elements.Beam_Spring_2.this.displacement.set(5, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 2) * run.elements.Beam_Spring_2.this.temp.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 2) * run.elements.Beam_Spring_2.this.temp.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 2) * run.elements.Beam_Spring_2.this.temp.get(5, 0));
      run.elements.Beam_Spring_2.this.temp.set(0, 0, run.elements.Beam_Spring_2.this.node[1].getX_vel() - run.elements.Beam_Spring_2.this.node[0].getX_vel());
      run.elements.Beam_Spring_2.this.temp.set(1, 0, run.elements.Beam_Spring_2.this.node[1].getY_vel() - run.elements.Beam_Spring_2.this.node[0].getY_vel() - run.elements.Beam_Spring_2.this.length * 0.5 * (run.elements.Beam_Spring_2.this.node[1].getZ_rot_vel() + run.elements.Beam_Spring_2.this.node[0].getZ_rot_vel()));
      run.elements.Beam_Spring_2.this.temp.set(2, 0, run.elements.Beam_Spring_2.this.node[1].getZ_vel() - run.elements.Beam_Spring_2.this.node[0].getZ_vel() + run.elements.Beam_Spring_2.this.length * 0.5 * (run.elements.Beam_Spring_2.this.node[1].getY_rot_vel() + run.elements.Beam_Spring_2.this.node[0].getY_rot_vel()));
      run.elements.Beam_Spring_2.this.temp.set(3, 0, run.elements.Beam_Spring_2.this.node[1].getX_rot_vel() - run.elements.Beam_Spring_2.this.node[0].getX_rot_vel());
      run.elements.Beam_Spring_2.this.temp.set(4, 0, run.elements.Beam_Spring_2.this.node[1].getY_rot_vel() - run.elements.Beam_Spring_2.this.node[0].getY_rot_vel());
      run.elements.Beam_Spring_2.this.temp.set(5, 0, run.elements.Beam_Spring_2.this.node[1].getZ_rot_vel() - run.elements.Beam_Spring_2.this.node[0].getZ_rot_vel());
      run.elements.Beam_Spring_2.this.velocity.set(0, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 0) * run.elements.Beam_Spring_2.this.temp.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 0) * run.elements.Beam_Spring_2.this.temp.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 0) * run.elements.Beam_Spring_2.this.temp.get(2, 0));
      run.elements.Beam_Spring_2.this.velocity.set(1, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 1) * run.elements.Beam_Spring_2.this.temp.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 1) * run.elements.Beam_Spring_2.this.temp.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 1) * run.elements.Beam_Spring_2.this.temp.get(2, 0));
      run.elements.Beam_Spring_2.this.velocity.set(2, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 2) * run.elements.Beam_Spring_2.this.temp.get(0, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 2) * run.elements.Beam_Spring_2.this.temp.get(1, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 2) * run.elements.Beam_Spring_2.this.temp.get(2, 0));
      run.elements.Beam_Spring_2.this.velocity.set(3, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 0) * run.elements.Beam_Spring_2.this.temp.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 0) * run.elements.Beam_Spring_2.this.temp.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 0) * run.elements.Beam_Spring_2.this.temp.get(5, 0));
      run.elements.Beam_Spring_2.this.velocity.set(4, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 1) * run.elements.Beam_Spring_2.this.temp.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 1) * run.elements.Beam_Spring_2.this.temp.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 1) * run.elements.Beam_Spring_2.this.temp.get(5, 0));
      run.elements.Beam_Spring_2.this.velocity.set(5, 0, run.elements.Beam_Spring_2.this.local_coordinate_system.get(0, 2) * run.elements.Beam_Spring_2.this.temp.get(3, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(1, 2) * run.elements.Beam_Spring_2.this.temp.get(4, 0) + run.elements.Beam_Spring_2.this.local_coordinate_system.get(2, 2) * run.elements.Beam_Spring_2.this.temp.get(5, 0));
   }
   public void calculateStress(int integration_point, double timestep) throws java.lang.Error {
      run.elements.Beam_Spring_2.this.material.calculateStressOneDimensional(run.elements.Beam_Spring_2.this.displacement, run.elements.Beam_Spring_2.this.velocity, run.elements.Beam_Spring_2.this.force, timestep);
   }
   public double checkTimestep(double current_timestep) {
      double I1;
      double I2;
      I1 = (run.elements.Beam_Spring_2.this.node[0].getInertia().get(0, 0) + run.elements.Beam_Spring_2.this.node[0].getInertia().get(1, 1) + run.elements.Beam_Spring_2.this.node[0].getInertia().get(2, 2)) / 3.0;
      I2 = (run.elements.Beam_Spring_2.this.node[1].getInertia().get(0, 0) + run.elements.Beam_Spring_2.this.node[1].getInertia().get(1, 1) + run.elements.Beam_Spring_2.this.node[1].getInertia().get(2, 2)) / 3.0;
      return Math.min(current_timestep, run.elements.Beam_Spring_2.this.material.wavespeedOneDimensional(4 * run.elements.Beam_Spring_2.this.node[0].getMass() * run.elements.Beam_Spring_2.this.node[1].getMass() / (run.elements.Beam_Spring_2.this.node[0].getMass() + run.elements.Beam_Spring_2.this.node[1].getMass()), 4 * I1 * I2 / (I1 + I2)));
   }
   public int getNumberOfIntegrationPoints() {
      return 1;
   }
   public Jama.Matrix getForce() {
      return run.elements.Beam_Spring_2.this.force;
   }
   public void parse_Fembic(Token[] param, int lineno, RplVector nodelist, RplVector materiallist, RplVector loadlist) throws java.text.ParseException {
      int nodenumber;
      int i = 0;
      Token[] contact_input;
      while (i < param.length) {
         if (param[i].getw().toUpperCase().equals("NODES") && param[i + 1].getw().toUpperCase().equals("=")) {
            if (!param[i + 2].getw().toUpperCase().startsWith("[") || !param[i + 2].getw().toUpperCase().endsWith("]")) {
               throw new java.text.ParseException("Error, node number definition should be [nodenr,nodenr,nodenr]", lineno);
            }
            try {
               nodenumber = super.getNodeNumber(1, param[i + 2].getw());
               run.elements.Beam_Spring_2.this.node[0] = super.findNode(nodenumber, nodelist);
               nodenumber = super.getNodeNumber(2, param[i + 2].getw());
               run.elements.Beam_Spring_2.this.node[1] = super.findNode(nodenumber, nodelist);
               nodenumber = super.getNodeNumber(3, param[i + 2].getw());
               run.elements.Beam_Spring_2.this.control_node = super.findNode(nodenumber, nodelist);
               i += 3;
               run.elements.Beam_Spring_2.this.Nodes_are_set = true;
            }  catch (IllegalArgumentException e) {
               throw new java.text.ParseException("Error in BeamSpring element\n" + e.getMessage() + "in line ", lineno);
            }
         } else if (param[i].getw().toUpperCase().equals("MATERIAL") && param[i + 1].getw().toUpperCase().equals("=")) {
            try {
               run.elements.Beam_Spring_2.this.material = super.findMaterial(param[i + 2].getw().toUpperCase(), materiallist);
               i += 3;
               run.elements.Beam_Spring_2.this.Material_is_set = true;
            }  catch (IllegalArgumentException e) {
               throw new java.text.ParseException(e.getMessage(), lineno);
            }
         } else if (param[i].getw().toUpperCase().equals("D") && param[i + 1].getw().toUpperCase().equals("=")) {
            run.elements.Beam_Spring_2.this.diameter = param[i + 2].getn();
            i += 3;
            run.elements.Beam_Spring_2.this.D_is_set = true;
         } else if (param[i].getw().toUpperCase().equals("FACTOR") && param[i + 1].getw().toUpperCase().equals("=")) {
            run.elements.Beam_Spring_2.this.factor = param[i + 2].getn();
            i += 3;
            run.elements.Beam_Spring_2.this.Factor_is_set = true;
         } else if (param[i].getw().toUpperCase().equals("CONTACT") && param[i + 1].getw().toUpperCase().equals("=")) {
            if (param[i + 2].getw().toUpperCase().equals("BASIC")) {
               run.elements.Beam_Spring_2.this.Contact = run.elements.Beam_Spring_2.BASIC;
            } else {
               throw new java.text.ParseException("Unrecognized contact parameter", lineno);
            }
            i += 3;
         } else {
            throw new java.text.ParseException("Unknown BeamSpring element parameter ", lineno);
         }
      }
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element = new Contact_Line();
         run.elements.Beam_Spring_2.this.internal_contact_element.setNumber(-1);
         if (run.elements.Beam_Spring_2.this.Factor_is_set) {
            contact_input = new Token[9];
         } else {
            contact_input = new Token[6];
         }
         contact_input[0] = new Token(new String("nodes"));
         contact_input[1] = new Token(new String("="));
         contact_input[2] = new Token(new String("[" + run.elements.Beam_Spring_2.this.node[0].getNumber() + "," + run.elements.Beam_Spring_2.this.node[1].getNumber() + "]"));
         contact_input[3] = new Token(new String("D"));
         contact_input[4] = new Token(new String("="));
         contact_input[5] = new Token(run.elements.Beam_Spring_2.this.diameter);
         if (run.elements.Beam_Spring_2.this.Factor_is_set) {
            contact_input[6] = new Token(new String("factor"));
            contact_input[7] = new Token(new String("="));
            contact_input[8] = new Token(run.elements.Beam_Spring_2.this.factor);
         }
         run.elements.Beam_Spring_2.this.internal_contact_element.parse_Fembic(contact_input, lineno, nodelist, materiallist, loadlist);
      }
   }
   public void parse_Nastran(Token[] param, Token[] param2, int lineno, RplVector nodelist, RplVector materiallist, RplVector loadlist) throws java.text.ParseException {
   }
   public void parse_Gmsh(Token[] param, int lineno, RplVector nodelist, RplVector materiallist, RplVector loadlist) throws java.text.ParseException {
      int i;
      Token[] contact_input;
      run.elements.Beam_Spring_2.this.number = (int)param[0].getn();
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element = new Contact_Line();
         run.elements.Beam_Spring_2.this.internal_contact_element.setNumber(-1);
         if (run.elements.Beam_Spring_2.this.Factor_is_set) {
            contact_input = new Token[9];
         } else {
            contact_input = new Token[6];
         }
         contact_input[0] = new Token(new String("nodes"));
         contact_input[1] = new Token(new String("="));
         contact_input[2] = new Token(new String("[" + run.elements.Beam_Spring_2.this.node[0].getNumber() + "," + run.elements.Beam_Spring_2.this.node[1].getNumber() + "]"));
         contact_input[3] = new Token(new String("D"));
         contact_input[4] = new Token(new String("="));
         contact_input[5] = new Token(run.elements.Beam_Spring_2.this.diameter);
         if (run.elements.Beam_Spring_2.this.Factor_is_set) {
            contact_input[6] = new Token(new String("factor"));
            contact_input[7] = new Token(new String("="));
            contact_input[8] = new Token(run.elements.Beam_Spring_2.this.factor);
         }
         run.elements.Beam_Spring_2.this.internal_contact_element.parse_Fembic(contact_input, lineno, nodelist, materiallist, loadlist);
      }
   }
   public void checkIndata() throws Error {
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC && !run.elements.Beam_Spring_2.this.D_is_set) {
         throw new Error("No Diameter defined for BeamSpring element nr" + run.elements.Beam_Spring_2.this.number);
      }
      if (!run.elements.Beam_Spring_2.this.Nodes_are_set) {
         throw new Error("No nodes defined for BeamSpring element nr" + run.elements.Beam_Spring_2.this.number);
      }
      if (!run.elements.Beam_Spring_2.this.Material_is_set) {
         throw new Error("No Material defined for BeamSpring element nr" + run.elements.Beam_Spring_2.this.number);
      }
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element.checkIndata();
      }
   }
   public boolean hasFailed() {
      return false;
   }
   public String print_Gid(int ctrl, int gpn) {
      String out;
      switch (ctrl) {
      case run.Element.MESH_HEADER: 
         out = new String("MESH \"MeshType" + run.elements.Beam_Spring_2.this.type + "\" Dimension 3 ElemType Linear Nnode 2\n");
         return out;
      
      case run.Element.MESH: 
         out = new String(run.elements.Beam_Spring_2.this.number + "\t" + run.elements.Beam_Spring_2.this.node[0].getNumber() + "\t" + run.elements.Beam_Spring_2.this.node[1].getNumber() + "\n");
         return out;
      
      case run.Element.RESULT_HEADER: 
         out = new String("GaussPoints \"Type" + run.elements.Beam_Spring_2.this.type + "\" ElemType Linear \"MeshType" + run.elements.Beam_Spring_2.this.type + "\"\n");
         out += "Number Of Gauss Points: 1\n";
         out += "Nodes Not Included\n";
         out += "Natural Coordinates: Internal\n";
         out += "End GaussPoints\n";
         return out;
      
      case run.Element.RESULT_SUB_HEADER: 
         out = new String(" 1 2 0 \"Type" + run.elements.Beam_Spring_2.this.type + "\"\n");
         return out;
      
      case run.Element.RESULT_STRESS_LOCAL: 
         out = new String(run.elements.Beam_Spring_2.this.number + " ");
         out += "0.0 \n";
         return out;
      
      case run.Element.RESULT_STRAIN_LOCAL: 
         out = new String(run.elements.Beam_Spring_2.this.number + " ");
         out += "0.0 \n";
         return out;
      
      default: 
         return new String("");
      
      }
   }
   public String print_Fembic(int ctrl, int gpn) {
      String out;
      switch (ctrl) {
      case run.Element.MESH: 
         out = new String(run.elements.Beam_Spring_2.this.number + "\t  nodes = [" + run.elements.Beam_Spring_2.this.node[0].getNumber() + "," + run.elements.Beam_Spring_2.this.node[1].getNumber() + "," + run.elements.Beam_Spring_2.this.control_node.getNumber() + "]\t" + "material = " + run.elements.Beam_Spring_2.this.material.getName() + "\t");
         if (run.elements.Beam_Spring_2.this.D_is_set) out += " D = " + run.elements.Beam_Spring_2.this.diameter;
         if (run.elements.Beam_Spring_2.this.Factor_is_set) out += " factor = " + run.elements.Beam_Spring_2.this.factor;
         if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) out += " contact = BASIC";
         out += "\n";
         return out;
      
      default: 
         return new String("");
      
      }
   }
   public void setInitialConditions() throws Error {
      try {
         run.elements.Beam_Spring_2.this.material = (Material)run.elements.Beam_Spring_2.this.material.copy();
      }  catch (CloneNotSupportedException e) {
         System.err.println("Object cannot clone");
      }
      run.elements.Beam_Spring_2.this.material.setInitialConditions();
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element.setInitialConditions();
      }
   }
   public void updateLocalCoordinateSystem() {
      super.calculateLocalBaseVectors(0, 0, 0, run.elements.Beam_Spring_2.this.node[1].getX_pos() - run.elements.Beam_Spring_2.this.node[0].getX_pos(), run.elements.Beam_Spring_2.this.node[1].getY_pos() - run.elements.Beam_Spring_2.this.node[0].getY_pos(), run.elements.Beam_Spring_2.this.node[1].getZ_pos() - run.elements.Beam_Spring_2.this.node[0].getZ_pos(), run.elements.Beam_Spring_2.this.control_node.getX_pos() - run.elements.Beam_Spring_2.this.node[0].getX_pos(), run.elements.Beam_Spring_2.this.control_node.getY_pos() - run.elements.Beam_Spring_2.this.node[0].getY_pos(), run.elements.Beam_Spring_2.this.control_node.getZ_pos() - run.elements.Beam_Spring_2.this.node[0].getZ_pos(), run.elements.Beam_Spring_2.this.local_coordinate_system);
      if (run.elements.Beam_Spring_2.this.Contact == run.elements.Beam_Spring_2.BASIC) {
         run.elements.Beam_Spring_2.this.internal_contact_element.updateLocalCoordinateSystem();
      }
   }
   public double getFx() {
      return run.elements.Beam_Spring_2.this.force.get(0, 0);
   }
   public double getFy() {
      return run.elements.Beam_Spring_2.this.force.get(1, 0);
   }
   public double getFz() {
      return run.elements.Beam_Spring_2.this.force.get(2, 0);
   }
   public double getMx() {
      return run.elements.Beam_Spring_2.this.force.get(3, 0);
   }
   public double getMy() {
      return run.elements.Beam_Spring_2.this.force.get(4, 0);
   }
   public double getMz() {
      return run.elements.Beam_Spring_2.this.force.get(5, 0);
   }
}
