1 package run.elements; 2 import run.*; 3 4 import java.util.Hashtable; 5 6 public class Rod_2 extends Element implements uka.patch.Patchable, uka.transport.Transportable { createPatch(Object _copy, uka.patch.PatchOutput po)7 public void createPatch(Object _copy, uka.patch.PatchOutput po) throws java.io.IOException { 8 Rod_2 copy = (Rod_2)_copy; 9 super.createPatch(copy, po); 10 if (po.writeDiff(this.Contact, copy.Contact)) copy.Contact = this.Contact; 11 if (po.writeDiff(this.Friction_is_set, copy.Friction_is_set)) copy.Friction_is_set = this.Friction_is_set; 12 if (po.writeDiff(this.Factor_is_set, copy.Factor_is_set)) copy.Factor_is_set = this.Factor_is_set; 13 if (po.writeDiff(this.Material_is_set, copy.Material_is_set)) copy.Material_is_set = this.Material_is_set; 14 if (po.writeDiff(this.Nodes_are_set, copy.Nodes_are_set)) copy.Nodes_are_set = this.Nodes_are_set; 15 if (po.writeDiff(this.D_is_set, copy.D_is_set)) copy.D_is_set = this.D_is_set; 16 if (po.writeDiff(this.friction, copy.friction)) copy.friction = this.friction; 17 if (po.writeDiff(this.factor, copy.factor)) copy.factor = this.factor; 18 if (po.writeDiff(this.initial_cross_section_area, copy.initial_cross_section_area)) copy.initial_cross_section_area = this.initial_cross_section_area; 19 if (po.writeDiff(this.initial_length, copy.initial_length)) copy.initial_length = this.initial_length; 20 if (po.writeDiff(this.diameter, copy.diameter)) copy.diameter = this.diameter; 21 if (po.writeDiff(this.cross_section_area, copy.cross_section_area)) copy.cross_section_area = this.cross_section_area; 22 copy.internal_contact_element = this.internal_contact_element = (run.elements.Contact_Line)po.writeDiff(this.internal_contact_element, copy.internal_contact_element); 23 copy.dstrain = this.dstrain = (Jama.Matrix)po.writeDiff(this.dstrain, copy.dstrain); 24 copy.force = this.force = (Jama.Matrix)po.writeDiff(this.force, copy.force); 25 copy.stress = this.stress = (Jama.Matrix)po.writeDiff(this.stress, copy.stress); 26 copy.strain = this.strain = (Jama.Matrix)po.writeDiff(this.strain, copy.strain); 27 copy.inertia = this.inertia = (Jama.Matrix)po.writeDiff(this.inertia, copy.inertia); 28 copy.local_coordinate_system = this.local_coordinate_system = (Jama.Matrix)po.writeDiff(this.local_coordinate_system, copy.local_coordinate_system); 29 copy.material = this.material = (run.Material)po.writeDiff(this.material, copy.material); 30 } applyPatch(Object _copy, uka.patch.PatchInput pi)31 public void applyPatch(Object _copy, uka.patch.PatchInput pi) throws java.io.IOException, ClassNotFoundException { 32 Rod_2 copy = (Rod_2)_copy; 33 super.applyPatch(copy, pi); 34 if (pi.hasDiff()) copy.Contact = this.Contact = pi.getDiffAsInt(); 35 if (pi.hasDiff()) copy.Friction_is_set = this.Friction_is_set = pi.getDiffAsBoolean(); 36 if (pi.hasDiff()) copy.Factor_is_set = this.Factor_is_set = pi.getDiffAsBoolean(); 37 if (pi.hasDiff()) copy.Material_is_set = this.Material_is_set = pi.getDiffAsBoolean(); 38 if (pi.hasDiff()) copy.Nodes_are_set = this.Nodes_are_set = pi.getDiffAsBoolean(); 39 if (pi.hasDiff()) copy.D_is_set = this.D_is_set = pi.getDiffAsBoolean(); 40 if (pi.hasDiff()) copy.friction = this.friction = pi.getDiffAsDouble(); 41 if (pi.hasDiff()) copy.factor = this.factor = pi.getDiffAsDouble(); 42 if (pi.hasDiff()) copy.initial_cross_section_area = this.initial_cross_section_area = pi.getDiffAsDouble(); 43 if (pi.hasDiff()) copy.initial_length = this.initial_length = pi.getDiffAsDouble(); 44 if (pi.hasDiff()) copy.diameter = this.diameter = pi.getDiffAsDouble(); 45 if (pi.hasDiff()) copy.cross_section_area = this.cross_section_area = pi.getDiffAsDouble(); 46 if (pi.hasDiff()) copy.internal_contact_element = this.internal_contact_element = (run.elements.Contact_Line)pi.getDiffAsObject(); 47 if (pi.hasDiff()) copy.dstrain = this.dstrain = (Jama.Matrix)pi.getDiffAsObject(); 48 if (pi.hasDiff()) copy.force = this.force = (Jama.Matrix)pi.getDiffAsObject(); 49 if (pi.hasDiff()) copy.stress = this.stress = (Jama.Matrix)pi.getDiffAsObject(); 50 if (pi.hasDiff()) copy.strain = this.strain = (Jama.Matrix)pi.getDiffAsObject(); 51 if (pi.hasDiff()) copy.inertia = this.inertia = (Jama.Matrix)pi.getDiffAsObject(); 52 if (pi.hasDiff()) copy.local_coordinate_system = this.local_coordinate_system = (Jama.Matrix)pi.getDiffAsObject(); 53 if (pi.hasDiff()) copy.material = this.material = (run.Material)pi.getDiffAsObject(); 54 } descendReferences(uka.patch.ReferenceConsumer c)55 public void descendReferences(uka.patch.ReferenceConsumer c) throws java.io.IOException { 56 super.descendReferences(c); 57 c.descend(this.internal_contact_element); 58 c.descend(this.dstrain); 59 c.descend(this.force); 60 c.descend(this.stress); 61 c.descend(this.strain); 62 c.descend(this.inertia); 63 c.descend(this.local_coordinate_system); 64 c.descend(this.material); 65 } filterReferences(uka.patch.ReferenceFilter f)66 public void filterReferences(uka.patch.ReferenceFilter f) { 67 super.filterReferences(f); 68 this.internal_contact_element = (run.elements.Contact_Line)f.filter(this.internal_contact_element); 69 this.dstrain = (Jama.Matrix)f.filter(this.dstrain); 70 this.force = (Jama.Matrix)f.filter(this.force); 71 this.stress = (Jama.Matrix)f.filter(this.stress); 72 this.strain = (Jama.Matrix)f.filter(this.strain); 73 this.inertia = (Jama.Matrix)f.filter(this.inertia); 74 this.local_coordinate_system = (Jama.Matrix)f.filter(this.local_coordinate_system); 75 this.material = (run.Material)f.filter(this.material); 76 } 77 public static final uka.transport.TransportDescriptor TRANSPORT_DESCRIPTOR = new uka.transport.TransportDescriptor(){ 78 public Object unmarshalReference(uka.transport.UnmarshalStream s, int id) throws java.io.IOException, ClassNotFoundException { 79 return new Rod_2(s, id); 80 } 81 public boolean unmarshal(Object obj, uka.transport.UnmarshalStream s) throws ClassNotFoundException, java.io.IOException { 82 ((Rod_2)obj).unmarshal(s); 83 return false; 84 } 85 public void marshalReference(Object obj, uka.transport.MarshalStream s) throws java.io.IOException { 86 ((Rod_2)obj).marshalReference(s); 87 } 88 public void marshal(Object obj, uka.transport.MarshalStream s) throws java.io.IOException { 89 ((Rod_2)obj).marshal(s); 90 } 91 public Object deepClone(Object orig, int id, uka.transport.DeepClone _helper) throws CloneNotSupportedException { 92 try { 93 return new Rod_2((Rod_2)orig, id, _helper); 94 } catch (java.io.IOException ex) { 95 throw (CloneNotSupportedException)new CloneNotSupportedException().initCause(ex); 96 } 97 } 98 public boolean deepCloneReferences(Object orig, Object copy, uka.transport.DeepClone _helper) throws CloneNotSupportedException { 99 ((Rod_2)copy).deepCloneReferences((Rod_2)orig, _helper); 100 return false; 101 } 102 public Class getType() { 103 return Rod_2.class; 104 } 105 }; getTransportDescriptor()106 public uka.transport.TransportDescriptor getTransportDescriptor() { 107 return TRANSPORT_DESCRIPTOR; 108 } 109 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_boolean + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double + uka.transport.BasicIO.SIZEOF_double; Rod_2(uka.transport.UnmarshalStream _stream, int _id)110 public Rod_2(uka.transport.UnmarshalStream _stream, int _id) throws java.io.IOException, ClassNotFoundException { 111 super(_stream, _id); 112 } unmarshal(uka.transport.UnmarshalStream _stream)113 public void unmarshal(uka.transport.UnmarshalStream _stream) throws java.io.IOException, ClassNotFoundException { 114 super.unmarshal(_stream); 115 _stream.request(Rod_2._SIZE); 116 byte[] _buffer = _stream.getBuffer(); 117 int _pos = _stream.getPosition(); 118 this.Contact = uka.transport.BasicIO.extractInt(_buffer, _pos); 119 _pos += uka.transport.BasicIO.SIZEOF_int; 120 this.Friction_is_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 121 _pos += uka.transport.BasicIO.SIZEOF_boolean; 122 this.Factor_is_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 123 _pos += uka.transport.BasicIO.SIZEOF_boolean; 124 this.Material_is_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 125 _pos += uka.transport.BasicIO.SIZEOF_boolean; 126 this.Nodes_are_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 127 _pos += uka.transport.BasicIO.SIZEOF_boolean; 128 this.D_is_set = uka.transport.BasicIO.extractBoolean(_buffer, _pos); 129 _pos += uka.transport.BasicIO.SIZEOF_boolean; 130 this.friction = uka.transport.BasicIO.extractDouble(_buffer, _pos); 131 _pos += uka.transport.BasicIO.SIZEOF_double; 132 this.factor = uka.transport.BasicIO.extractDouble(_buffer, _pos); 133 _pos += uka.transport.BasicIO.SIZEOF_double; 134 this.initial_cross_section_area = uka.transport.BasicIO.extractDouble(_buffer, _pos); 135 _pos += uka.transport.BasicIO.SIZEOF_double; 136 this.initial_length = uka.transport.BasicIO.extractDouble(_buffer, _pos); 137 _pos += uka.transport.BasicIO.SIZEOF_double; 138 this.diameter = uka.transport.BasicIO.extractDouble(_buffer, _pos); 139 _pos += uka.transport.BasicIO.SIZEOF_double; 140 this.cross_section_area = uka.transport.BasicIO.extractDouble(_buffer, _pos); 141 _pos += uka.transport.BasicIO.SIZEOF_double; 142 _stream.accept(Rod_2._SIZE); 143 this.internal_contact_element = (run.elements.Contact_Line)_stream.readReference(); 144 this.dstrain = (Jama.Matrix)_stream.readReference(); 145 this.force = (Jama.Matrix)_stream.readReference(); 146 this.stress = (Jama.Matrix)_stream.readReference(); 147 this.strain = (Jama.Matrix)_stream.readReference(); 148 this.inertia = (Jama.Matrix)_stream.readReference(); 149 this.local_coordinate_system = (Jama.Matrix)_stream.readReference(); 150 this.material = (run.Material)_stream.readReference(); 151 } marshal(uka.transport.MarshalStream _stream)152 public void marshal(uka.transport.MarshalStream _stream) throws java.io.IOException { 153 super.marshal(_stream); 154 _stream.reserve(Rod_2._SIZE); 155 byte[] _buffer = _stream.getBuffer(); 156 int _pos = _stream.getPosition(); 157 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Contact); 158 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Friction_is_set); 159 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Factor_is_set); 160 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Material_is_set); 161 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.Nodes_are_set); 162 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.D_is_set); 163 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.friction); 164 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.factor); 165 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.initial_cross_section_area); 166 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.initial_length); 167 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.diameter); 168 _pos = uka.transport.BasicIO.insert(_buffer, _pos, this.cross_section_area); 169 _stream.deliver(_SIZE); 170 _stream.writeReference(this.internal_contact_element); 171 _stream.writeReference(this.dstrain); 172 _stream.writeReference(this.force); 173 _stream.writeReference(this.stress); 174 _stream.writeReference(this.strain); 175 _stream.writeReference(this.inertia); 176 _stream.writeReference(this.local_coordinate_system); 177 _stream.writeReference(this.material); 178 } Rod_2(Rod_2 _orig, int _id, uka.transport.DeepClone _helper)179 public Rod_2(Rod_2 _orig, int _id, uka.transport.DeepClone _helper) throws CloneNotSupportedException, java.io.IOException { 180 super(_orig, _id, _helper); 181 this.Contact = _orig.Contact; 182 this.Friction_is_set = _orig.Friction_is_set; 183 this.Factor_is_set = _orig.Factor_is_set; 184 this.Material_is_set = _orig.Material_is_set; 185 this.Nodes_are_set = _orig.Nodes_are_set; 186 this.D_is_set = _orig.D_is_set; 187 this.friction = _orig.friction; 188 this.factor = _orig.factor; 189 this.initial_cross_section_area = _orig.initial_cross_section_area; 190 this.initial_length = _orig.initial_length; 191 this.diameter = _orig.diameter; 192 this.cross_section_area = _orig.cross_section_area; 193 } deepCloneReferences(Rod_2 _orig, uka.transport.DeepClone _helper)194 public void deepCloneReferences(Rod_2 _orig, uka.transport.DeepClone _helper) throws CloneNotSupportedException { 195 super.deepCloneReferences(_orig, _helper); 196 this.internal_contact_element = (run.elements.Contact_Line)_helper.internalDeepClone(_orig.internal_contact_element); 197 this.dstrain = (Jama.Matrix)_helper.internalDeepClone(_orig.dstrain); 198 this.force = (Jama.Matrix)_helper.internalDeepClone(_orig.force); 199 this.stress = (Jama.Matrix)_helper.internalDeepClone(_orig.stress); 200 this.strain = (Jama.Matrix)_helper.internalDeepClone(_orig.strain); 201 this.inertia = (Jama.Matrix)_helper.internalDeepClone(_orig.inertia); 202 this.local_coordinate_system = (Jama.Matrix)_helper.internalDeepClone(_orig.local_coordinate_system); 203 this.material = (run.Material)_helper.internalDeepClone(_orig.material); 204 } 205 private static int DISABLED = 0; 206 private static int BASIC = 1; 207 private double cross_section_area; 208 private Material material; 209 private Jama.Matrix local_coordinate_system; 210 private double diameter; 211 private double initial_length; 212 private Jama.Matrix inertia; 213 private Jama.Matrix strain; 214 private Jama.Matrix stress; 215 private Jama.Matrix force; 216 private Jama.Matrix dstrain; 217 private double initial_cross_section_area; 218 private double factor; 219 private double friction; 220 private boolean D_is_set; 221 private boolean Nodes_are_set; 222 private boolean Material_is_set; 223 private boolean Factor_is_set; 224 private boolean Friction_is_set; 225 private Contact_Line internal_contact_element; 226 private int Contact; Rod_2()227 public Rod_2() { 228 super(); 229 this.type = new String("ROD_2"); 230 this.inertia = new Jama.Matrix(3, 3); 231 this.force = new Jama.Matrix(3, 1); 232 this.stress = new Jama.Matrix(6, 1); 233 this.strain = new Jama.Matrix(6, 1); 234 this.dstrain = new Jama.Matrix(6, 1); 235 this.local_coordinate_system = new Jama.Matrix(3, 3); 236 this.processed = false; 237 this.node = new Node[2]; 238 this.Contact = run.elements.Rod_2.BASIC; 239 } assembleMassMatrix()240 public void assembleMassMatrix() throws IllegalArgumentException { 241 double mass; 242 this.initial_cross_section_area = Math.PI * this.diameter * this.diameter / 4; 243 this.cross_section_area = this.initial_cross_section_area; 244 if (this.cross_section_area <= 0) { 245 throw new IllegalArgumentException("Error in rod element " + this.number + ", Cross section area is zero or negative"); 246 } 247 this.initial_length = java.lang.Math.sqrt((this.node[0].getX_pos() - this.node[1].getX_pos()) * (this.node[0].getX_pos() - this.node[1].getX_pos()) + (this.node[0].getY_pos() - this.node[1].getY_pos()) * (this.node[0].getY_pos() - this.node[1].getY_pos()) + (this.node[0].getZ_pos() - this.node[1].getZ_pos()) * (this.node[0].getZ_pos() - this.node[1].getZ_pos())); 248 mass = this.material.getDensity() * this.cross_section_area * this.initial_length; 249 if (mass <= 0) { 250 throw new IllegalArgumentException("Error in rod element " + this.number + ". Element mass is zero or negative.\nElement length: " + this.initial_length + " Material density: " + this.material.getDensity()); 251 } 252 this.node[0].addMass(mass / 2.0); 253 this.node[1].addMass(mass / 2.0); 254 this.inertia.set(0, 0, Math.max(mass * this.diameter * this.diameter / 8, mass * this.initial_length * this.initial_length / 12)); 255 this.inertia.set(1, 1, this.inertia.get(0, 0)); 256 this.inertia.set(2, 2, this.inertia.get(0, 0)); 257 this.inertia.set(1, 0, 0); 258 this.inertia.set(2, 0, 0); 259 this.inertia.set(0, 1, 0); 260 this.inertia.set(0, 2, 0); 261 this.inertia.set(2, 1, 0); 262 this.inertia.set(1, 2, 0); 263 this.node[0].addInertia(this.inertia); 264 this.node[1].addInertia(this.inertia); 265 if (this.Contact == run.elements.Rod_2.BASIC) { 266 this.internal_contact_element.assembleMassMatrix(); 267 } 268 } calculateContactForces()269 public void calculateContactForces() { 270 if (this.Contact == run.elements.Rod_2.BASIC) { 271 this.internal_contact_element.calculateContactForces(); 272 } 273 } calculateExternalForces(double currtime)274 public void calculateExternalForces(double currtime) { 275 if (this.Contact == run.elements.Rod_2.BASIC) { 276 this.internal_contact_element.calculateExternalForces(currtime); 277 } 278 } calculateNodalForces(int integration_point, double timestep)279 public void calculateNodalForces(int integration_point, double timestep) { 280 Jama.Matrix global_force; 281 this.force.set(0, 0, this.stress.get(0, 0) * this.cross_section_area); 282 this.force.set(1, 0, 0); 283 this.force.set(2, 0, 0); 284 global_force = this.local_coordinate_system.transpose().times(this.force); 285 this.node[0].addInternalForce(global_force.times(1)); 286 this.node[1].addInternalForce(global_force.times(-1)); 287 } calculateStrain(double timestep, int integration_point)288 public void calculateStrain(double timestep, int integration_point) { 289 double xpos1; 290 double ypos1; 291 double zpos1; 292 double xpos2; 293 double ypos2; 294 double zpos2; 295 double new_length; 296 xpos1 = this.node[0].getX_pos(); 297 ypos1 = this.node[0].getY_pos(); 298 zpos1 = this.node[0].getZ_pos(); 299 xpos2 = this.node[1].getX_pos(); 300 ypos2 = this.node[1].getY_pos(); 301 zpos2 = this.node[1].getZ_pos(); 302 new_length = java.lang.Math.sqrt((xpos2 - xpos1) * (xpos2 - xpos1) + (ypos2 - ypos1) * (ypos2 - ypos1) + (zpos2 - zpos1) * (zpos2 - zpos1)); 303 this.dstrain.set(0, 0, Math.log(1 + (new_length - this.initial_length) / this.initial_length) - this.strain.get(0, 0)); 304 this.cross_section_area = this.initial_cross_section_area * this.initial_length / new_length; 305 } calculateStress(int integration_point, double timestep)306 public void calculateStress(int integration_point, double timestep) { 307 this.material.calculateStressOneDimensional(this.strain, this.dstrain, this.stress, timestep); 308 } checkTimestep(double current_timestep)309 public double checkTimestep(double current_timestep) { 310 double timestep; 311 double critical_length; 312 double xpos1; 313 double ypos1; 314 double zpos1; 315 double xpos2; 316 double ypos2; 317 double zpos2; 318 xpos1 = this.node[0].getX_pos(); 319 ypos1 = this.node[0].getY_pos(); 320 zpos1 = this.node[0].getZ_pos(); 321 xpos2 = this.node[1].getX_pos(); 322 ypos2 = this.node[1].getY_pos(); 323 zpos2 = this.node[1].getZ_pos(); 324 critical_length = java.lang.Math.sqrt((xpos2 - xpos1) * (xpos2 - xpos1) + (ypos2 - ypos1) * (ypos2 - ypos1) + (zpos2 - zpos1) * (zpos2 - zpos1)); 325 timestep = critical_length / this.material.wavespeedOneDimensional(0.0, 0.0); 326 return Math.min(0.9 * timestep, current_timestep); 327 } getI1()328 private double getI1() { 329 return this.inertia.get(0, 0); 330 } getI2()331 private double getI2() { 332 return this.inertia.get(1, 1); 333 } getI3()334 private double getI3() { 335 return this.inertia.get(2, 2); 336 } getNumberOfIntegrationPoints()337 public int getNumberOfIntegrationPoints() { 338 return 1; 339 } getForce()340 public double getForce() { 341 return this.force.get(0, 0); 342 } parse_Fembic(Token[] param, int lineno, RplVector nodelist, RplVector materiallist, RplVector loadlist, Hashtable nodetable)343 public void parse_Fembic(Token[] param, int lineno, RplVector nodelist, RplVector materiallist, RplVector loadlist, Hashtable nodetable) throws java.text.ParseException { 344 int nodenumber; 345 int i = 0; 346 Token[] contact_input; 347 while (i < param.length) { 348 if (param[i].getw().toUpperCase().equals("NODES") && param[i + 1].getw().toUpperCase().equals("=")) { 349 if (!param[i + 2].getw().toUpperCase().startsWith("[") || !param[i + 2].getw().toUpperCase().endsWith("]")) { 350 throw new java.text.ParseException("Error, node number definition should be [nodenr,nodenr]", lineno); 351 } 352 try { 353 nodenumber = super.getNodeNumber(1, param[i + 2].getw()); 354 this.node[0] = super.findNode(nodenumber, nodetable); 355 nodenumber = super.getNodeNumber(2, param[i + 2].getw()); 356 this.node[1] = super.findNode(nodenumber, nodetable); 357 i += 3; 358 this.Nodes_are_set = true; 359 } catch (IllegalArgumentException e) { 360 throw new java.text.ParseException("Error in Rod_2 element\n" + e.getMessage() + "in line ", lineno); 361 } 362 } else if (param[i].getw().toUpperCase().equals("MATERIAL") && param[i + 1].getw().toUpperCase().equals("=")) { 363 try { 364 this.material = super.findMaterial(param[i + 2].getw().toUpperCase(), materiallist); 365 i += 3; 366 this.Material_is_set = true; 367 } catch (IllegalArgumentException e) { 368 throw new java.text.ParseException(e.getMessage(), lineno); 369 } 370 } else if (param[i].getw().toUpperCase().equals("D") && param[i + 1].getw().toUpperCase().equals("=")) { 371 this.diameter = param[i + 2].getn(); 372 i += 3; 373 this.D_is_set = true; 374 } else if (param[i].getw().toUpperCase().equals("FACTOR") && param[i + 1].getw().toUpperCase().equals("=")) { 375 this.factor = param[i + 2].getn(); 376 i += 3; 377 this.Factor_is_set = true; 378 } else if (param[i].getw().toUpperCase().equals("FRICTION") && param[i + 1].getw().toUpperCase().equals("=")) { 379 this.friction = param[i + 2].getn(); 380 i += 3; 381 this.Friction_is_set = true; 382 } else if (param[i].getw().toUpperCase().equals("CONTACT") && param[i + 1].getw().toUpperCase().equals("=")) { 383 if (param[i + 2].getw().toUpperCase().equals("OFF")) { 384 this.Contact = run.elements.Rod_2.DISABLED; 385 } else { 386 throw new java.text.ParseException("Unrecognized contact parameter", lineno); 387 } 388 i += 3; 389 } else { 390 throw new java.text.ParseException("Unknown Rod element parameter ", lineno); 391 } 392 } 393 if (this.Contact == run.elements.Rod_2.BASIC) { 394 this.internal_contact_element = new Contact_Line(); 395 this.internal_contact_element.setNumber(-1); 396 i = 6; 397 if (this.Factor_is_set) i += 3; 398 if (this.Friction_is_set) i += 3; 399 contact_input = new Token[i]; 400 contact_input[0] = new Token(new String("nodes")); 401 contact_input[1] = new Token(new String("=")); 402 contact_input[2] = new Token(new String("[" + this.node[0].getNumber() + "," + this.node[1].getNumber() + "]")); 403 contact_input[3] = new Token(new String("D")); 404 contact_input[4] = new Token(new String("=")); 405 contact_input[5] = new Token(this.diameter); 406 i = 6; 407 if (this.Factor_is_set) { 408 contact_input[i] = new Token(new String("factor")); 409 contact_input[i + 1] = new Token(new String("=")); 410 contact_input[i + 2] = new Token(this.factor); 411 i += 3; 412 } 413 if (this.Friction_is_set) { 414 contact_input[i] = new Token(new String("friction")); 415 contact_input[i + 1] = new Token(new String("=")); 416 contact_input[i + 2] = new Token(this.friction); 417 i += 3; 418 } 419 this.internal_contact_element.parse_Fembic(contact_input, lineno, nodelist, materiallist, loadlist, nodetable); 420 } 421 } checkIndata()422 public void checkIndata() throws IllegalArgumentException { 423 if (!this.D_is_set) { 424 throw new IllegalArgumentException("No Diameter defined for Rod element nr" + this.number); 425 } 426 if (!this.Nodes_are_set) { 427 throw new IllegalArgumentException("No nodes defined for Rod element nr" + this.number); 428 } 429 if (!this.Material_is_set) { 430 throw new IllegalArgumentException("No Material defined for Rod element nr" + this.number); 431 } 432 if (this.Contact == run.elements.Rod_2.BASIC) { 433 this.internal_contact_element.checkIndata(); 434 } 435 } checkIfFailed()436 public void checkIfFailed() { 437 if (!this.material.failureStrainIsSet() && !this.material.failureStressIsSet()) { 438 this.failed = false; 439 return; 440 } 441 if (this.material.failureStressIsSet()) { 442 if (this.stress.get(0, 0) > this.material.getFailureStress()) { 443 this.failed = true; 444 return; 445 } 446 } 447 if (this.material.failureStrainIsSet()) { 448 if (this.strain.get(0, 0) > this.material.getFailureStrain()) { 449 this.failed = true; 450 return; 451 } 452 } 453 this.failed = false; 454 } print_Gid(int ctrl, int gpn)455 public String print_Gid(int ctrl, int gpn) { 456 String out; 457 switch (ctrl) { 458 case run.Element.MESH_HEADER: 459 out = new String("MESH \"MeshType" + this.type + "\" Dimension 3 ElemType Linear Nnode 2\n"); 460 return out; 461 462 case run.Element.MESH: 463 out = new String(this.number + "\t" + this.node[0].getNumber() + "\t" + this.node[1].getNumber() + "\n"); 464 return out; 465 466 case run.Element.RESULT_HEADER: 467 out = new String("GaussPoints \"Type" + this.type + "\" ElemType Linear \"MeshType" + this.type + "\"\n"); 468 out += "Number Of Gauss Points: 1\n"; 469 out += "Nodes Not Included\n"; 470 out += "Natural Coordinates: Internal\n"; 471 out += "End GaussPoints\n"; 472 return out; 473 474 case run.Element.RESULT_SUB_HEADER: 475 out = new String(" 1 2 0 \"Type" + this.type + "\"\n"); 476 return out; 477 478 case run.Element.RESULT_STRESS_LOCAL: 479 out = new String(this.number + " "); 480 out += this.stress.get(0, 0) + "\n"; 481 return out; 482 483 case run.Element.RESULT_STRAIN_LOCAL: 484 out = new String(this.number + " "); 485 out += this.strain.get(0, 0) + "\n"; 486 return out; 487 488 default: 489 return new String(""); 490 491 } 492 } print_Fembic(int ctrl, int gpn)493 public String print_Fembic(int ctrl, int gpn) { 494 String out; 495 switch (ctrl) { 496 case run.Element.MESH: 497 out = new String(this.number + "\t nodes = [" + this.node[0].getNumber() + "," + this.node[1].getNumber() + "]\t" + "D = " + this.diameter + "\t" + "material = " + this.material.getName() + "\t"); 498 if (this.Factor_is_set) out += " factor = " + this.factor; 499 if (this.Friction_is_set) out += " friction = " + this.friction; 500 if (this.Contact == run.elements.Rod_2.DISABLED) out += " contact = OFF"; 501 out += "\n"; 502 return out; 503 504 default: 505 return new String(""); 506 507 } 508 } setInitialConditions()509 public void setInitialConditions() throws IllegalArgumentException { 510 try { 511 this.material = (Material)this.material.copy(); 512 } catch (CloneNotSupportedException e) { 513 System.err.println("Object cannot clone"); 514 } 515 this.material.setInitialConditions(); 516 if (this.Contact == run.elements.Rod_2.BASIC) { 517 this.internal_contact_element.setInitialConditions(); 518 } 519 } updateLocalCoordinateSystem()520 public void updateLocalCoordinateSystem() { 521 this.calculateLocalBaseVectors(0, 0, 0, this.node[1].getX_pos() - this.node[0].getX_pos(), this.node[1].getY_pos() - this.node[0].getY_pos(), this.node[1].getZ_pos() - this.node[0].getZ_pos(), this.node[1].getZ_pos() - this.node[0].getZ_pos(), this.node[0].getX_pos() - this.node[1].getX_pos(), this.node[1].getY_pos() - this.node[0].getY_pos(), this.local_coordinate_system); 522 if (this.Contact == run.elements.Rod_2.BASIC) { 523 this.internal_contact_element.updateLocalCoordinateSystem(); 524 } 525 } deActivate()526 public void deActivate() { 527 super.deActivate(); 528 if (this.internal_contact_element != null) this.internal_contact_element.deActivate(); 529 } 530 } 531