UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

Object-oriented software development in structural engineering Elbury, Kevin M. 1992

You don't seem to have a PDF reader installed, try download the pdf

Item Metadata

Download

Media
ubc_1992_spring_eldbury_kevin.pdf [ 4.29MB ]
[if-you-see-this-DO-NOT-CLICK]
Metadata
JSON: 1.0050472.json
JSON-LD: 1.0050472+ld.json
RDF/XML (Pretty): 1.0050472.xml
RDF/JSON: 1.0050472+rdf.json
Turtle: 1.0050472+rdf-turtle.txt
N-Triples: 1.0050472+rdf-ntriples.txt
Original Record: 1.0050472 +original-record.json
Full Text
1.0050472.txt
Citation
1.0050472.ris

Full Text

OBJECT-ORIENTED SOFTWARE DEVELOPMENTIN STRUCTURAL ENGINEERINGbyKEVIN MICHAEL ELBURYB.A.Sc. (Civil), The University of British Columbia, 1990A THESIS SUBMITTED IN PARTIAL FULFILLMENT OFMASTER OF APPLIED SCIENCEinTHE FACULTY OF GRADUATE STUDIESDepartment of Civil EngineeringWe accept this thesis as conformingto the required standardTHE UNIVERSITY OF BRITISH COLUMBIAAPRIL, 1992© Kevin Michael Elbury, 1992In presenting this thesis in partial fulfilment of the requirements for an advanceddegree at the University of British Columbia, I agree that the Library shall make itfreely available for reference and study. I further agree that permission for extensivecopying of this thesis for scholarly purposes may be granted by the head of mydepartment or by his or her representatives. It is understood that copying orpublication of this thesis for financial gain shall not be allowed without my writtenpermission.(Signature)Department of C t v,, Ev6-4 The University of British ColumbiaVancouver, CanadaDate /2k-p_i. L._ 30^1 44 Z.DE-6 (2/88)AbstractThe recent emergence of the object-oriented paradigm has created a very powerfulmethodology to aid software developers in the creation of complex applications. This technologyis quite common in fields such as computer science and computer engineering but still remainsrelatively unexplored in more traditional disciplines such as Civil Engineering. The paradigmenforces several basic necessities required by complex, modern software applications. These includemanagement of complexity, data modelling, information hiding, software reusability, and softwareevolution.The purpose of this thesis is to give an overview of the object-oriented paradigm. Thisdiscussion includes a review of the necessary requirements of an object-oriented language. This isfollowed by the presentation of a software diagramming notation which can aid in the data modellingand design of a software system before coding is started. Also presented is a discussion on thepragmatics of object-oriented development.A universal structural analysis preprocessor called "Cross Link" is developed by the author todemonstrate the application of the object paradigm. Cross Link is intended to provide a unified,easy to use, graphical preprocessing environment that can be used as a front end for any type offinite element analysis programme or CADD package. This is achieved through the implementationof a powerful macro programming language which allows users to manipulate the finite elementdatabase in many different ways.Table of ContentsAbstract^ iiTable of Contents^ iiiTable of Figures ivAcknowledgements vii1 INTRODUCTION^ 12 THE SOFTWARE LIFE CYCLE^ 32.1 Structured and Object-Oriented Development^ 43 BACKGROUND ON OBJECT -ORIENTED (00) SYSTEMS^83.1 Framework of an 00 System^ 8Encapsulation^ 9Classification 10Flexible Sharing 12Interpretation 143.2 The Booch 00 Design Notation^ 15The Process^ 16Class Diagrams 17Object Diagrams 193.3 Pragmatics of Object-Oriented Development^ 21Generalization and Specialization^21Designing for Reuse^ 234 CROSS LINK:A UNIVERSAL STRUCTURAL ANALYSIS PREPROCESSOR ^264.1 Requirements^ 27Overview 27Preprocessor Requirements^ 294.2 Application Framework 30The Zinc Interface Library 304.3 Implementation^ 35The Structure Framework^ 36Controllers 38The Macro Language 40Interfacing the Macro Language with other Applications ^434.4 A Sample Session in Cross Link^ 44Exporting a Structure to the ANSYS Finite Element Programme^534.5 Extending Cross Link^ 58Recognition of the Physical and Finite Element Models^ 58Extending the Macro Language^ 625 CONCLUSIONS^ 646 REFERENCES 65APPENDIX ACROSS LINK MACRO LANGUAGE FUNCTION REFERENCE ^67BIOGRAPHICAL INFORMATIONTable of FiguresFigure 1.Cross Link as a Universal Structural Analysis Preprocessor ^ 2Figure 2.The Five Phases of the Waterfall Life Cycle ^ 3Figure 3.Top-Down or Structured Software Development 5Figure 4.The Three Concepts of Object -Oriented Programming^ 6Figure 5.The Multidimensional View of an Object Oriented System 8Figure 6.Classification using Classes and Inheritance ^ 11Figure 7.Polymorphism and the Class Hierarchy 13Figure 8.The Object Design Model for the Booch Notation^ 16Figure 9.The Class Category Icon^ 18Figure 10.The Class Icon^ 18Figure 11.The Class Relationship Icon^ 18Figure 12.The Class Template^ 19Figure 13.The Operation Template 19Figure 14.The Object Icon^ 20Figure 15.The Object Relationship Icons^ 20Figure 16.The Object Visibility Symbols 20Figure 17.The Object Template^ 21Figure 18.The Object Message Template^ 21Figure 19.A Class Hierarchy for an Editor Class 22Figure 20.Revised Editor Class to Enhance Code Reusability^ 23Figure 21.Reusability Using Subclassing or Construction. 24Figure 22.^ 28Sample Objects Supported by the Preprocessor- iv -Figure 23.The Stages of Structural Analysis and Design^ 29Figure 24.The UI LIST and UI ELEMENT Generic Classes31Figure 25.The Zinc Interface Library Class Diagram^ 32Figure 26.A Partial ZIL Window Object Hierarchy34Figure 27.A Standard Window Created by ZIL^34Figure 28.The Cross Link User Interface35Figure 29.The Cross Link Application and Utilities^ 36Figure 30.The Structure Window and Structure Object Framework^ 37Figure 31.Cross Link Object Diagram^37Figure 32.Cross Link Node Controller Object Diagram^ 38Figure 33.Layout of the BOB Macro Language Compiler and Interpreter^ 40Figure 34.Example Tokens Returned Generated by the Lexical Scanner41Figure 35.Example Bytecodes produced by the Bytecode Compiler^ 41Figure 36.Macro to Add Two Numbers^42Figure 37.Resulting Bytecodes from Figure 3642Figure 38.Internal Function for the BOB Sin() Library Function ^ 44Figure 39.The Example Frame to be Modelled using Cross Link 45Figure 40.The Cross Link Editing Environment^ 46Figure 41.Setting the Structure Limits^ 47Figure 42.Setting the Structure Display Options ^ 48Figure 43.Placement of the Column Node Points 49Figure 44.Generation of Nodes and Elements for Top and Bottom Chords^50Figure 45.Final Placement of Nodes and Elements^ 51- v -Figure 46.Placing Node Boundary Conditions^ 52Figure 47.Setting Element Fixity^53Figure 48.Running a BOB Macro56Figure 49.Resulting ANSYS Frame Data File^57Figure 50.Example Frame Exported to the ANSYS Programme^ 58Figure 51.The Physical and Finite Element Structural Models59Figure 52.Alternate Implementation of Element Container^ 60Figure 53.Extending the Assembly Class for Design61AcknowledgementsI would like to take this opportunity to thank the many people who have helped me incompleting this thesis under the Professional Partnership Programme. I extend my gratitude to Mr.Bill Kendrick, P.Eng., Chief Engineer at Canron Inc., and Mr. Dave Halliday, P.Eng., SpecialProjects Manager at Coast Steel Fabricators Ltd. I also thank Mr. David Lo, P.Eng., for hiscontribution to this thesis, Mr Manfred Frank, P.Eng., and Mr. Phil Sullivan, P.Eng., for theirpractical perspectives on the steel fabrication business. Finally, I thank Dr. Siegfried F. Stiemer andDr. Helmut P. Prion, my graduate advisors, for the valuable support and guidance they providedfor me.Kevin M. Elbury1 INTRODUCTIONSoftware development often involves the process of mapping or decomposing a complexproblem space into modules that are ordered and simplified. The success of this mapping is oftendetermined by the methodology used to analyze and design the "building blocks" that will solve theproblem. Recent advances in development tools that support the object-oriented paradigm are nowgiving the software developers the ability to create complex software applications that excel overtraditional techniques in modelling a problem space. As engineers, we naturally deal with complexitythrough the classification and decomposition of concepts into hierarchial or tree-like formations.The object-oriented development process follows in a manner very similar to this so it may be arguedthat the paradigm is well suited as a development tool for complex engineering applications.Early observations also indicate that object-oriented software is far more economical toproduce than software developed using traditional procedural approaches such as StructuredDesign. This is mostly due to the large amount of code that can be reused both inside and acrossapplications. Object-oriented software also tends to be much more adaptable and easier to maintainas programme requirements change because of features such as encapsulation, inheritance andinformation hiding. The purpose of this thesis is, firstly, to provide an overview of object-orientedprinciples in a language independent manner and secondly, to explain the object-orienteddevelopment of structural engineering software application.The second chapter of this thesis introduces the software life cycle, a process orientedprocedure which most software follows as it is developed. Two different development paradigmsare presented: Structured Development and Object-Oriented Development. Different types ofknowledge representation are presented and compared with the two paradigms and it is concludedthat the structured paradigm follows an algorithmic approach which places the data being modelledsecondary to the procedure. Conversely, the object-oriented paradigm follows a more data-centeredapproach whereby entities are recognized as objects that have both state and behavior.The third chapter outlines the four principles an object-oriented language must support inorder to be classified as "object-oriented". These include encapsulation, classification, flexiblesharing and interpretation. Also presented is an brief overview of the Booch Design Notation which-1-is a diagramming technique developed to aid designers in the creation of software designspecifications. Finally, some practical considerations in object-oriented development are discussed,including classification and designing for reusability. AutoCAD(DXF)UserDefinedANSYSPlane 2.0Figure 1.Cross Link as a Universal Structural Analysis PreprocessorThe fourth and final chapter looks at the design and implementation of Cross Link, a universalstructural analysis preprocessor. Developed using object-oriented techniques, the application allowsstructural analysts to generate finite element models for any type of analysis programme, designutility or CADD (Computer Aided Drafting and Design) application using an easy to use, integratedenvironment (Figure 1). The preprocessor supports two editing modes. The first, an interactivedrawing mode, lets the analyst draw a structure on the display and perform all usual editing operationssuch as moving, resizing and setting boundary conditions on nodes and elements. The second editingmode, driven by a powerful macro programming language, allows users to write macros to manipulatethe structure database in many different ways. For example, macros can be developed to enhanceexisting editing features, perform automated mesh generation or design parametric structures (ie.a truss with variable span and depth etc.). Most importantly though, the macro facility provides ameans for a two way link (import and export) to any type of analysis programme, providing theanalysis programme's file format is known. As an example, two macros (for import and export) aredeveloped that bridge Cross Link with the ANSYS finite element programme.-2-AnalysisDesignTesting4.166 " Ne./..fedWAVAW.,IntegrationCoding2 THE SOFTWARE LIFE CYCLEThe process model used in software engineering formalizes the phases of the software lifecycle to make each more visible. The most general process model is that of the Waterfall Life Cycle,proposed by Royce (1970) (Figure 2). Based on this model, a multitude of specialized paradigms)have evolved that attempt to provide better models of some of the various aspects of the softwaredevelopment process. However, the waterfall life cycle model remains the most widely acceptedprocess model used in software development. The five phases of the cycle include: Analysis, Design,Coding, Testing and Integration. [18]Figure 2.The Five Phases of the Waterfall Life Cycle.Phase 1: AnalysisThe analysis phase establishes the software system services and constraints throughconsultation with the users and developers of the system. Generally, the goal is to "build avocabulary of the problem domain" 2. This involves identification or invention of tangibleobjects, roles, events, interactions and procedures. The result of this process is a "Software1 Other paradigms include Exploratory Programming, Prototyping and Formal Transformations [18]2 Booch, Grady. Object-Oriented Design. pg. 141 [3].-3-Requirements Document" that must be readable by both users and developers. Popularanalysis techniques include Structured Analysis (SA), Object-Oriented Analysis (00A),Domain Analysis and Entity-Relationship Modelling [3,6,18].Phase 2: DesignUsing the "Requirements Document", design proceeds with the specification of softwarecomponents and associated functionalities. The results of design are usually presented in away that allows for easy transformation into a computer code. Several design techniques exist;correct selection depends on the type of analysis used. The two most common are StructuredDesign and Object-Oriented Design.Phase 3- 5: Coding, Testing and IntegrationUsing the design documents, the problem is coded into the computer using a programminglanguage suitable to the type of analysis and design performed. Testing of each module in thesystem is then performed according to the specifications in the Requirements Document.This phase is followed by integration whereby all modules and programme units are tested asa whole, again according to Requirements Document specifications.2.1 Structured and Object -Oriented DevelopmentThis section introduces the two popular software development paradigms, one establishedand one emerging. These are the Structured Development and Object-Oriented developmentparadigms. Of the different software development paradigms that have evolved over the past 30years, Structured Development (SD) has come forth as an efficient software development technique.Dale and Orshalick describe SD as (Figure 3):'A design methodology that works from an abstract functional description ofa problem (top) to a detailed solution (bottom); a heirarchial approach toproblem solving that divides a problem into functional sub-problemsrepresented by modules...The design consisting of a hierarchy of separatemodules with lower level modules containing greater detail than higher levelmodules."3However, within the past 15 years, progression of the Object-Oriented (00) developmentparadigm has progressed to the point that it can now be called a formal software development3 Dale, Nell. and Orshalick, David. Introduction to PASCAL and Structured Design, p. A50 [7].-4-TOP ABSTRACT Level 2"fBOTTOM•PARTICULARFigure 3.Structured or Top-Down Software Development.technique. Being a formal technique, every phase in the development life cycle fully supports theparadigm. The 00 model views a system as an assembly of objects, each capable of enveloping itsown state and behavior. Objects use messages to communicate with other objects. Classes providea template that describes the behavior of an object and the inheritance mechanism allows a class tobe specialized from existing classes (Figure 4). Fundamentally, the 00 paradigm addresses the issuesof code reusability, information hiding and software evolution.Structured and Object-Oriented development have evolved essentially from the differingprocesses humans use to classify knowledge. Loy breaks this classification into two categories:structural representation and functional representation [11]. The structural paradigm organizesknowledge into entities that have both state and services with the services having secondaryimportance over the state (the Object Oriented paradigm). The functional paradigm, on the otherhand, represents knowledge as an algorithm or procedure. Conversely, functional knowledge placesthe procedure primary and the data secondary (the Structured paradigm). Recognition of thesediffering representations of knowledge has lead to hybrid analysis and design techniques that bringtogether the advantages of the structural and functional approaches [8].- 5 -• - . . • ' - • '. . ..... • • ..CIRCLE .;-^•^- •CIRCLE :-.(--00 SQUARE- . . . . • • . • •ShapeCircle RectangleFil edCircleFilledRectangleIObject MessagesClassesFigure 4.The Three Concepts of Object-Oriented Programming.It is interesting to note the process in which software development occurs using either of thetwo paradigms. The Structured Development approach is to "divide and conquer". High level orabstract properties of the system are identified and broken down into lower level components.Programme coding then begins with implementation of the low level components, eventually endingin coding at a high level. In this way, analysis and design usually occur top-down and implementation,bottom-up. Thus, any changes made in analysis and design are much more difficult to implement atthe coding stage.In object-oriented development, the goal is to identify the major objects or entities in thesystem. From these, one abstracts as many properties as possible common to all objects. These formthe abstract classes which are the foundation of the system. Programme coding then begins withimplementation of the abstract classes. The more specialized classes are then implemented usingthe inheritance mechanism which allows the behavior encapsulated in the parent class(es) to beshared with derived classes. Thus in the object-oriented paradigm, development occurs in the same-6-order in which the classes are abstracted. This makes the process of analysis, design and coding muchmore synchronized than that of Structured Development. In this way, it becomes much easier toreturn to any phase in the process life cycle and make modifications as more is learnt about thesystem.ObjectAcive ObjectClassesPrototypesStatic BindingDynamic BindingStatic TypingStatic Binding:luta .PolymorphismSubciassingOverloadingPrototyping3 BACKGROUND ON OBJECT-ORIENTED (00) SYSTEMS3.1 Framework of an 00 SystemThe framework of an object-oriented (00) system is built around a multidimensional viewof the object paradigm. These dimensions are viewed as the fundamental principles of objectorientation that provide the basic building blocks for dealing with complexity in software systems.The principles allow most of the object-oriented developments to date to be classified in a coherentand unified manner, thus allowing for objective evaluation of the many different techniquesavailable. The features found in any given 00 language can be classified into the following principlesof object orientation:• Encapsulation• Classification• Flexible Sharing• Interpretation [2]Figure 5.The multidimensional model of an object-oriented system. Within each dimension there existsseveral different solution techniques.-8-Shown in Figure 5 is the generalized framework (principles) of an 00 system. Each principlelists a series of different techniques that have been used in various languages to apply the principle.Thus, by looking at a particular technique, the framework enables a connection to be made betweenit and its associated principle. Following is a brief discussion of the principles of 00 systems alongwith some of the more common associated techniques 4.EncapsulationEncapsulation (also referred to as information hiding) provides a method of grouping togetherthe various properties5 associated with an identifiable entity in the system into one logical unit (anobject). Access to the object is provided via its interface, which defines the protocol users of theobject use to communicate (ie. the object's external view). On the other hand, the implementationof an object is the set of properties that only the object itself knows about (ie. the internal view).Snyder describes encapsulation as:"...a technique for minimizing interdependencies among separately writtenmodules by defining strict external interfaces. The external interface of amodule serves as the contract between module and clients. If clients dependonly on the external interface, the module can be re-implemented withoutaffecting any clients, as long as the implementation supports the same externalinterface." [17]Object-Oriented languages achieve encapsulation via two techniques: passive objects andactive objects.Passive and Active ObjectsIn class based languages, passive objects signify the importance of structural organizationof objects. In general, passive objects represent state; this state can only be changed wheninstructed by other objects.In contrast to class based languages, actor languages are mainly concerned not with thestructural organization of objects, but with the "communication structure of interacting4 It is important to note that most object-oriented languages support any or all of the following principles.This leads to a popular question demanded of many so-called object-oriented languages: Is it reallyobject-oriented?5 The term property collectively represents the both the state (ie. Member variables) and operations (ie.Member functions) associated with an object.-9-processes"6. This is achieved via active objects. Active objects differ from passive objects in thatthey encompass their own thread of control. While passive objects can only undergo changes instate when explicitly acted upon, active objects can show behavior without being operated onby another object. Active objects are of direct importance in concurrent or multi-taskingcomputer systems and will likely become more significant as more computers gain multi-taskingcapability.ClassificationClassification is a higher level approach to encapsulation. Instead of grouping togetherproperties of an entity into an object, classification works to group together objects with commonproperties. Given that various combinations of classification can be formed in a given system, onemust determine exactly how to classify them. Should objects be classified according to particularattributes (ie. Color, shape) or according to the operations performed by objects (ie. Read, write)?Some common methods of classification are discussed below.ClassesA class is a template from which objects can be created. It is based on the grouping togetherof state descriptors and methods for the object. The inheritance mechanism allows one class toacquire, modify or extend the behavior of another class. The result of inheritance is a classhierarchy which is useful for capturing redundant behavior in a particular group of classes (Figure6).Class relationships are usually expressed using any one of three basic principles:generalization, aggregation or association 7. Generalization denotes the "kind of relationshipamongst classes. For example, a highrise is a kind of building. Secondly, aggregation usuallydenotes the "part of relationship amongst classes. Here, a storey is not considered a kind ofbuilding but a part of a highrise. Thirdly, association expresses some type of connotativeconnection amongst otherwise unrelated classes. As an example, an earthquake may govern thedesign of a highrise building but in no way can it be considered dependent class of building.6 Blair, Gordon et. AL, Object Oriented Languages, Systems and Applications, p.62 [2].7 Booch, Grady. Object Oriented Design. p.96 [3]- 10 -RectangleACircleFilledCircleA IFilledRectangle•Orty1.7lhgtwid•(x ,v) PointFigure 6.Classification using classes and inheritance. Inheritance allows classes to evolve from simple toadvanced.Some consider class based systems to be the most restricted form of classification becauseconstruction of a given class hierarchy is sometimes difficult due to the many different (andcorrect) combinations that may be possible [2]. Despite this, class based systems (ie. C++,Smalltalk, CLOS) are currently most popular in object-oriented computing. Moreover, this styleof object orientation solves some of the more pragmatic problems of software development,mainly in the areas of code reusability and program evolution.PrototypesAlongside classes, prototypes provide a second form of classification. A prototyperepresents the "default behavior for a concept, and new objects can re-use part of the knowledgestored in the prototype by saying how the new object differs from the prototype" [14]. Objectsin a prototypical system use the mechanism of delegation to send messages to prototypes thatrepresent general knowledge (in general, any object can serve as a prototype). Similar to classbased systems, prototypes also support behavior sharing but in a fundamentally different manner.Objects that share knowledge with a prototype are constructed using an extension objectwhich contains a list of prototypes which can be shared and a personal definition of the objectthat gives it a unique identity. When an extension object receives a message, it first attempts torespond to the message using its personal part. If this is unsuccessful, it then forwards (delegates)the message to its prototypes.Flexible Sharing00 systems generally distinguish between two types of techniques, the first being those whichsupport classification and the second being those which support flexible behavior sharing. Thetechniques discussed in this section enhance behavior sharing and evolution in an 00 system.PolymorphismPolymorphism is one of the most characteristic features of an object-oriented system. Itis defined as "the ability of behavior to have an interpretation over more than one class" 8.Polymorphism represents a shift towards the modelling of common behaviorisms amongst agroup of objects. For example, in the class hierarchy shown in Figure 7, every class exhibits aDraw() and Erase() function. Users of any one of these classes can generically send a Draw()or Erase() message to the object and be guaranteed that the it will behave appropriately. If aDraw() message were sent to an instance of class FilledCircle, the Draw() function defined forfilled circle may fill the circle and then call the Draw() function for the Circle class to draw thecircle's outline.8 Blair, Gordon. et al. Object Oriented Languages, Systems and Applications, pp. 35,116. [2]- 12 -PointDraw()Erase()Print()Draw()Erase()CircleDraw()Erase()A dRectangleFilledRectangleDraw()Erase()Figure 7.A class hierarchy for the representation of some geometric shapes. Sending the Draw() messageto an instance of any of these classes will elicit a uniform response.Subclassing (Inheritance)Subclassing or inheritance incorporates the behavior of one class into another. The newclass is called the subclass of the parent or superclass. Through the process of subclassing, aspecialization of a class is created that allows existing code to be easily re-used, modified andextended.A subclass may be specialized in several ways: extension, re-definition, or restriction [2].Using extension a new method is added to the subclass. By using re-definition as a specializationtechnique, the subclass maintains the same interface as the parent class but some part of theimplementation may be re-coded. Restrictive specialization allows the subclass to inherit onlya subset of the methods of the parent class.Draw()Erase()CircleOverloadingOverloading permits methods in a class hierarchy to use the same name but to overloadthe meaning. Overloading is actually another form of polymorphism. In the example shown inFigure 7, the Draw() message is an example of an overloaded method (meaning it has a differentimplementation depending on where it is in the hierarchy).InterpretationThe principle of interpretation determines exactly how the techniques of flexible sharing arebe implemented, specifically at the point where a program is compiled or interpreted into machinelanguage. The issues of interpretation generally involve the concepts of type checking and binding.When a compiler performs type checking, it determines whether operations are supported by aparticular object or type and whether type inconsistencies will result (ie. can a string be added toan integer?). When a compiler performs binding, it tries to locate the correct implementation of amethod (which may lie within another superclass). The issue is when to perform typing and binding:compile time (a static process) or run-time (a dynamic process).Binding: Static or Dynamic?As a direct consequence of inheritance, classes no longer contain all information aboutthe class in a central location because of the line of superclasses that may exist before it. Thus,binding ensures that the correct method is attached to an object. Binding may be achieved eitherstatically or dynamically.In static or early binding, methods are bound to objects at compile time. This type ofbinding relies on the compiler to build a table of class-method relationships and embed calls tomethods directly into the code. Static binding has the advantage of no runtime overhead to findthe correct method to attach to the object. An additional advantage is that failed bindings (ie.a method that may not exist) are caught at compile time and not at runtime.Conversely, dynamic or late binding allows methods to be attached to objects at run-time.This offers the advantage of increased flexibility but the disadvantage of possible failed bindings(ie. a method does not exist) at runtime. Dynamic binding is a requirement if an object-orientedlanguage is to support polymorphism.- 14 -Typing: Static or Dynamic?In addition to binding, typing determines whether specified operations are supported byan object and whether type inconsistencies will occur as a result. Like binding, this may be doneat either compile time or runtime.Static typing offers the advantage of entrapment all type errors before program executionbegins. This is because all variables and expressions are explicitly bound to a type at compiletime. However, this does impose restrictions on the language. Conversely, dynamic typingensures correctness of type at runtime. This offers more flexibility for the language but alsocreates extra runtime overhead and burden for the programmer because error trapping facilitiesmust be provided when type inconsistencies do occur (this would never happen in a staticly typedsystem).3.2 The Booch 00 Design NotationSeveral object-oriented design notations exist today. Most common are the EVB, HOOD(Hierarchial Object-Oriented Design) and OOSD (Object-Oriented Structured Design) notations[2,8]. However, Booch's OOD notation is the most common in North America (HOOD is mostcommon in Europe). The purpose of any design notation is to decompose a complex system intosmaller subsystems which are more easily approachable. Additionally, a notation should address theissues of data abstraction, information hiding and responsiveness to change (in the future) [2,3].This section looks in particular at using the Booch Notation in software design. This design methodis attractive because not only is it language independent but can be easily adapted into a CASE(Computer Aided Software Engineering) tool (the notation is to clumsy to use by hand) 9.The Booch notation is based on the Object Model shown in Figure 8 [3]. The Object Modelviews a software system from several different perspectives. These perspectives include the logicalview, the physical view, static semantics and dynamic semantics. The logical view looks at how classesare decomposed and interact with each other while the physical view looks more closely at hardwareissues such as where certain classes are defined and implemented and which processes will be9 The Rose CASE Tool by Rational Systems fully supports the Booch design notation.-15-Dynamic SemanticsStatic SemanticsLogical ViewPhysical ViewBooch NotationFigure 8.The Object Design Model forms the basis of the Booch Design Notation.performed by what processor (in a concurrent system). In the Booch Notation, class diagrams andobject diagrams are used to design and present the physical view of the system. Module diagramsand process diagrams are used to design and present the physical view of the system.The four diagrams listed so far generally describe static processes that are time independent(ie. a snapshot of the system at on instance in time). These are representations of the static semanticsof the system. The dynamic semantics of the system describe the time ordering of events (such asmessage passing). These semantics are designed and presented using state transition diagrams andthe timing diagrams.The purpose of this section is to provide a brief overview of some of the diagrams used in thenotation - in particular, class diagrams and object diagrams. The complete specification of the BoochDesign Notation can be found in reference [3].The ProcessThe general approach using the Booch Design is a five step method. Blair et. al describe thisdevelopment using the following steps 10:(1) identify the objects and their attributes(2) identify the operations required by each object10 Blair, Gordon et Al., Object-Oriented Languages, Systems and Applications. pp.206-207 [2].- 16 -(3) establish the visibility of each object relative to other objects(4) establish an interface to each object(5) implement the objectsThe first step, the identification of objects and their attributes, is probably the most difficultstage in the process because of the multitude of different and correct groupings that may exist in aproblem space. Booch suggests identification of key attributes based on the nouns used to describethe problem space.Identification of the operations suffered by and required of each object establishes the staticand dynamic semantics of the object. At this stage it is important to look at the operations requiredof an object because it enforces decoupling of objects from one another. The third step, to establishobject visibility, determines the static dependencies required amongst objects. In other words, onedetermines what objects see and are seen by a given object.The establishment of the interface to an object determines the protocol for which objects cancommunicate amongst themselves. The interface forms the boundary between the internal andexternal view (implementation) of an object. The final step involves implementation of the objectwhereby a representation of each object or class of objects is chosen.Class DiagramsClass diagrams are used to present the class structure (hierarchial information), itsspecification, and its relationship with other classes. Class diagrams are built using several differenticons and templates. These include:• Class Category Icon• Class Icon• Class Relationship Icon• Class Template• Operation TemplateClass Category IconBecause class diagrams can sometimes get very large, the class category can be used toorganize them into meaningful blocks. The class category is used to represent only the highest- 17 -levels of abstraction in the class diagram and thus gives only an overview of the generalarchitecture of the system (Figure 9). Generally, every component in a class category diagramis a high level reference to a class diagram or another class category.nameFigure 9.The Class Category Icon.Class IconThe class icon, shown in Figure 10, represents a class in a class diagram. The class nameis enclosed within the dashed line. The dashed line is used to show that clients of the class operateon instances of the class (IE. objects) and not the class itself.• class name. •' - . . . - " • . -Figure 10.The Class Icon.ox^x uses interface7"------"iolA uses implementation^ io.^Inherits0 zero^--),.. instantiates1 one• zero or more+ one or more? zero or onen nFigure 11.Class Relationship Icons and Cardinality.Class Relationship IconThe class relationship icon shown in Figure 11, displays the various relationships that mayexist amongst classes. These include the using, inheritance and instantiation relationships. Usingrelationships employ a double line with a circle placed by the class that uses the other class. Ifthe circle is filled, the implementation of the class is being used; if not filled, its interface is beingused. Circles can be placed on both ends of the icon in instances where there is a two wayrelationship.-18-Two numbers can be placed on the icon to indicate cardinality, the number of objectsaffected by the relationship. For example, a container class would have one instance, but manyobjects in the container so the cardinality here would be 1 to n. If the cardinality is 1 to 1, is isnot placed on the icon Inheritance relationships are shown using a single solid line with thearrow always pointing to the parent class (superclass).Class Templates and Operation TemplateThe class template provides the detailed documentation of each class in the system (Figure12). The information presented is generally an amalgamation of all the other class diagrams.Class templates provide descriptive narrations of the class, inheritance information, classinterface and implementation, and descriptions of operations the class perform. Obviously, theclass template can become very detailed so it may only be used later on in the analysis/designstage. Additionally, it is not necessary to use all the fields within the template; only the onescapture the important design decisions. The operation template is a spin-off of the class template.The operation template is used to specifically describe the operations (member functions)performed by the class (Figure 13).Name:Documentation:Visibility:Cardinality:Hierarchy:Superclasses:Metaclass:Generic Parameters:Interface/Implementation:Uses:Fields:Operations:Finite State:Concurrency:Space Complexity:Persistence:identifiertextexported/private/imported0/1/nclass namesclass namelist of parameterslist class nameslist fieldlist operationsstate transition diagramsequential/blocking/activetextpersistent/transitoryName:Documentation:Category:Qualification:Formal Parameters:Result:Preconditions:Action:Postconditions:Exceptions:Concurrency:Time complexity:Space complexity:identifiertexttexttextlist of declarationsclass nameobject diagramobject diagramobject diagramlist of exceptionssequential /guarded / concurrent/multipletexttextFigure 12.^ Figure 13.The Class Template.^ The Operation Template.Object DiagramsObject diagrams are used to explain objects and their relationships in the logical design of thesystem. While class diagrams describe the static semantics, object diagrams describe the dynamicsemantics of a design. However, the two are closely related since an object is an instance of a class- 19 -and both adhere to the same sets of operations. The difference is "class diagrams document the keyabstraction in the system, and object diagrams highlight the important mechanisms to manipulatethese abstractions"[3]. An object diagram is completed using the following icons and templates:• Object Icon• Object Relationship Icon• Object Template• Message TemplateObject Icon and Object Relationship IconThe object icon in Figure 14 is similar to the class icon except a solid line is used to drawthe boundary of the object.Figure 14.The Object Icon.list of messageslabelinside systemoutside systemFigure 15.The Object Relationship Icons.The object relationship icon shows the flow of messages between objects using lines(Figure 15). A solid line represents a relationship amongst two objects inside the system and agrey line provides a method to document the relationship between the object and any objectsoutside the software application. Figure 16 shows several detailed icons can be placed at theends of the object relationship icons to express visibility between objects.P parametershared parameterfieldF^shared fieldFigure 16.The Object Visibility Symbols.Object and Message TemplatesAs with the class template, the object template provides more detailed information aboutthe object, specifically on the class of the object and its persistence qualities (Figure 17).Name:^identifier^ Operation:^operation nameDocumentation: text Documentation:^textClass:^class name Frequency:^aperiodic / periodicPersistence:^persistent / static / dynamic^Synchronization:^simple / synchronous / balking / timeout/asynchronousFigure 17. Figure 18.The Object Template.^ The Object Message Template.Object message templates document the individual messages an object may send to otherobjects (Figure 18). This template is generally only used to document time critical operations.3.3 Pragmatics of Object-Oriented DevelopmentLike any other development paradigm, object orientation has its own set of problems, mostlyin the area of classification. As already discussed, a large part of the 00 analysis and design processlies in the area of classification - the discovery and invention of key abstractions and their interactions.Most inexperienced designers encounter problems in mapping a complex problem space intosomething ordered. In class based systems, the class hierarchy is the result of this mapping. However,in most instances, a wide variety of solutions may exist in the creation of a class hierarchy becauseof many different classification criteria.- 21 -.^• • • • •. •^. •^•^• •^• •^.Field•(abstract)StringField^-.Data validated charact4r•by character• IntegerField • •Data validated characteirby character•DateField ••Data validated characterby character• •^'Generalization and SpecializationOne of the main objectives in building a class hierarchy is to maximize code reusability. Thisis sometimes done by embedding generic behavior into a base class for use by all derived classes.An example presented by Duntemann [9] shows some of the shortfalls of this philosophy. Theexample involves implementation of an abstract class called Field which would enable editing ofdifferent types of values (a string field, a data field, or an integer field). The Field class takes careof operations that every field requires. This would include painting a title for the field and indicatingthe field is active but exclude the actual editing of a value. Derived from Field would be the classesthat perform the actual editing of the value. Operations in the derived class would include movingthe cursor within the field, ensuring that only numbers are only typed into an integer field or deletingcharacters from the field. The derived classed may include a StringField, anlntegerField or aDateField(Figure 19). It is evident, however, that there is a great deal of code duplication (three times),particularly for processes such as moving the cursor in the field and formatting characters read fromthe keyboard.Figure 19.A class hierarchy for an editing class to edit strings, integers and dates.Shown in Figure 20, is an alternate proposal for editing different values. This arrangement isbuilt on the the premise that a string class can handle all input and when completed, need only beverified by the child class (DataField or IntegerField). Thus, most of the code used to perform allediting operations is written only once. The problem with this arrangement is that data validationis only performed after the user presses the enter key. A user editing an integer value would be- 22 -. • • • . • • •^. • • • •IntegerFieldData validated aftercarriage return••• •• • . •^. .DateFleldData validated aftercarriage return.^. •• • .^. • • • • • . 'permitted to enter an alphabetic character into the field but would only be informed of the errorafter pressing the Enter key. In the first arrangement (Figure 19), this scenario would never arisebecause the code that reads the keyboard is customized to that particular type of field. This highlightsa problem that will often be encountered in differient situations. That is, there is a trade-off betweencode reusability (and therefore programme size) and getting the desired behavior from a class.. • • • - • • • .. • - • -StringField^•• Data validated after^•• carriage return•Figure 20.Revised implementation to enhance code reusability. All editing is performed in StringField andvalidation is performed by the subclasses.Duntemann refers to this problem as the case of distribution versus extension. In the firstscenario, most of the behavior of the class is distributed throughout many subclasses with littleembedded in the abstract class. In contrast, the second approach builds a fully functional base classwhich is then extended to support any required variations.Designing for ReuseObject-oriented programming promises to increase programmer productivity throughsoftware reusability through use of the techniques of encapsulation and inheritance. Two differentapproaches can be used in designing a system to maximize reusability. These are the subclassingapproach or the construction approach [20]. In order to compare the two concepts, consider theexample of a container class used to hold a list of strings. Assume that a generic container class,Container, holds generic objects that must be derived from the generic class Object.- 23 -. ...•^•^•^•Container....- • .• ..^...^...• • • ...• • • • .Object...." • . • •• • ...• - •Object. . •• - • • .^• - - ..^..Container•• -^• - •StringContainer.• .........•StringContainer .•Subclassing Approach Construction Approach Figure 21.Reusability using the Subclassing Approach or the Construction Approach.The Subclassing ApproachThe subclassing approach derives StringContainer from Container so that StringContainer,is given complete access to the interface and implementation of Container. Operations for addingor removing objects from Container need not be defined in StringContainer since they are alreadydefined in Container and are be called directly. This is desirable from both reusability andflexibility points of view. On the other hand, subclassing may not be the best alternative insituations where the preceding hierarchy is very large. Here, the large number of methods thatare inherited become difficult to manage (since one picks up both interface and implementation).Additionally, information that was cautiously hidden in the implementation part of the classsuddenly becomes accessible to a derived class (that maybe should not have that access), thusdefeating the whole concept of interface and implementation. The subclassing approach shouldonly be used in instances where the class to be derived is really a subtype of the parent class.The Construction ApproachUsing the construction approach, the StringContainer is implemented as a derived classof Object. Included in StringContainer is a field which references (uses) the interface to Container.Unlike the subclassing approach, StringContainer now requires methods to be declared tointerface with Container (ie. to Add or Remove a string from Container). This approach isbeneficial from a maintainability point of view since it only uses the interface to Container andis thus more resilient to any future modifications made in Container. However, many times theinterface to the reference class (Container) is insufficient and the designer is forced to use thesubclassing approach simply to gain access to a particular method hidden in the implementationpart of the class. Additionally, the construction approach requires implementation of additionalinterface methods to perform operations such as adding and removing strings from the container(if inheritance were used, these methods are automatically included in the derived classesinterface).4 CROSS LINK: A UNIVERSAL STRUCTURAL ANALYSIS PREPROCESSORIn the past, analysts using computer aided structural analysis programmes have had to workat an unnecessarily low level of detail. A typical analysis session would start with a paper sketch ofthe structure to be analyzed. On this sketch, the analyst would identify all node points and elements.Nodes and elements would be numbered in some particular sequence. From this sketch, the analystwould proceed to enter the data defining the node points and elements into a data file, its formatdependent on the analysis programme being used. If the structure being analyzed requires theresources of several different analysis programmes, most times the data would have to be manuallyre-entered each time. Additionally, since most design offices now use some form of CADD(Computer Aided Drafting and Design), analysis data must be re-entered into the CADDprogramme for final detailing. Not only is this unproductive, but it also allows for more errors.Throughout the whole analysis procedure, the analyst often expends unnecessary time and energyhaving to remember correct file formats and maintain correct numbering and connectivity sequencesfor nodes and elements. Instead of concentrating on the problem at hand, the analyst has to worryabout small details that can easily be taken care of by preprocessing software. Clearly, there is aneed for structural analysis preprocessing software that allows for intuitive, high level modeldefinition along with a facility that allows the model to be transferred between different analysisand CADD programmes.The Cross Link Universal Structural Analysis Preprocessor, provides a graphical editingenvironment that allows structural engineers to perform preprocessing without becoming distractedwith small details. Using the mouse, the analyst has the capability of draw a structure on the displayand then use a host of tools to perform editing operations to manipulate the structure. Cumbersomedata file formats or node and element numbering schemes no longer need the attention they havereceived in the past. Cross Link also addresses the data transfer issue between alternate analysisand CADD programmes ( and is hence called Universal). This been solved via the use of a uniquemacro programming language. Because the macro language has the capability to manipulate theinternal database kept by Cross Link, its uses are limitless:• Automated parametric structure definition,• Mesh generation and refinement,- 26 -• Enhanced editing capabilities such as alignment and transformation,• Design modules and,• Import/Export of data in any format (Binary and ASCII).The purpose of this chapter is to introduce and discuss some of the software design issues inCross Link with particular emphasis on the data modelling aspects. This will be concluded with atour through Cross Link including the use of the macro programming language.4.1 RequirementsOverviewA software application is required to create and edit a graphical model of a structure whichis then used in a numerical analysis programme to analyze deflections and stresses due to loadsapplied to the structure. Typically, the graphical model is composed of nodes and elements whichdefine key locations and components of the structure. Node points are defined by some spatialcoordinates and a code to represent allowable degrees of freedom. Springs may be applied to nodepoints to model semi-rigid support points and can be applied to the same degrees of freedom as thenode (x, y and rotational for a 2-D problem). Point loads can also be applied to node points in thesame directions as springs. Since springs and loads are not common to every node, they are consideredseparate entities to the node.Elements are used to model load carrying members in the structure. In the specification ofan element, reference is usually made the lower and upper node numbers, a fixity code and theelements geometric properties (ie. cross sectional area, moment of inertia). An element cannothave zero length or be composed of two identical node points. Elements may also contain loads inthe form of an offset point load and/or a uniformly distributed load (UDL). The UDL may bespecified with either x,y components or as perpendicular to the element.Several other types of elements are often used in analysis. One general type is the plateelement, used to model surfaces. These elements are typically composed of a variable number ofnodes (typically 3 to 8) defined by a particular numbering sequence. Although it is not required thatthese elements be supported in this specification, it is expected that the application will later beextended to support them.- 27 -(b)(c)Figure 22.(a) Nodes points with loads and springs.(b) Beam element with UDL and offset point load(c) Some plate elementsA session inside the editor would consist of describing the geometry of the structure, assigningpreliminary cross sections to the elements, setting node/element boundary conditions and placingsprings and loads on the structure. After saving the structure to a file with a format compatible withthe analysis being performed, an analysis would be completed to calculate deflections and stresses.The results of the analysis would then be viewed inside a post-processor. At this stage, coderequirement checks would be completed to ensure structural components are correctly designed.The user then proceeds back to the preprocessor to make the required changes to the structure andthe cycle is repeated again (Figure 23).Resize membersRefine meshAlternate structuralsystemPreprocessing- geometric model- boundary and loadingconditionsAnalysis- calculate displacements- calculate stressesPostprocessing- code check on stressesand deflectionsFigure 23.The stages of Structural Analysis and Design.Preprocessor RequirementsThe first objective of the preprocessor is that it be used as tool for taking a structural conceptand rapidly developing a design prototype. Hence its power will be in its inherent ability to quicklygenerate a model and perform basic editing such as moving or re-sizing components, changingboundary conditions or creating loading cases.The second objective is that the preprocessor provide a generic link with other analysisprogrammes. This link must be user defined to allow complete flexibility in communication betweenthe preprocessor and the desired application. The advantages offered by such a feature are twofold.Firstly, this will allow analysts to do prototyping in a single environment regardless of the type ofanalysis programme being used. Secondly, the information gap between engineer and draftspersonwill likely be bridged due to the preprocessor's ability to import and export data via any CADDdrawing interchange standard (ie. DXF or IGES). The first version of the preprocessor shouldprovide support for the following structural components:- 29 -• Nodes with plane translations and rotations• 2-D beam elements with fixity control• Nodal springs and point loads• Element loads - UDL and offset point loadsBasic tools should be provided to add, delete, re-size and move components within a userdefined coordinate system.4.2 Application FrameworkFrom the requirements presented in the previous section, we may proceed to discuss someof the software implementation details. At this stage, let's look at the application framework for theCross Link package. The application framework provides a library of highly flexible, pre-writtenfunctions to manage the interface between application and user, thus allowing developers toconcentrate on problems specific to the application. In this case, a commercial software packagecalled the Zinc Interface Library (ZIL), was selected [21]. This particular library was chosen becauseit was the first GUI (Graphical User Interface) based library written using object-orientedtechniques since the introduction of the Borland C+ + compiler. Additionally, the library iscompletely portable between DOS and Microsoft Windows.The Zinc Interface LibraryThe purpose of the application framework is to provide an easy to use, customizable userinterface to an application. Because ZIL is object-oriented, customization and modification can beachieved quite easily by simply deriving new classes from the existing framework. ZIL has threeimportant classes that form the engine of the library. These are the display manager, the eventmanager and the window manager. Along with the these, the window class (UIW_WINDOW) andthe window object class (UI_WINDOW_OBJECT) are also important in programme development.Before the role of each of these classes is explained, the foundation of the ZIL library must beexplained.Generic ClassesAll of the generic classes in ZIL are built around the concept of the container. A containersis a linked lists which is capable of holding many different types of objects. The only requirementfor an object to be registered in a container is that it must be derived from some common class.All containers in ZIL are built from the generic base class, UL LIST and objects to be placed- 30 -in the container must all be derived from the UI ELEMENT base class. In this configuration,_the container class maintains pointers to the first and last objects in the list and theUL ELEMENT objects provide pointers to the next and previous objects in the list (Figure 24). UI_LIST UI_ELEMENT'sFirst ^PI FirstObject Next,PreviousLast^ IObject^II Object^ILastObject 1Figure 24.The UI LIST and UI ELEMENT generic classes._^_A UI LIST object acts as a manager for a group of objects. Its basic functions include_insertion and deletion of objects to and from the list. Additionally, the manager can traverse thelist and send messages to each object. All classes within ZIL are derived from either the UL LISTclass or the UL ELEMENT class (Figure 25).- .^. - •^•. • • .^• •U I_D ISPLAYUI_LIST• . , • •Ul_WINDOW-' • . . " • •.^. .UI_WINDOVi •. MANAGER. UI DOS TEXT •. bISPLAY• . . • • . • •• •^•UI^ 'OBJECT. . •^. . •• • • . .•UI_ELEMENT• .^•• .^.•^•^•^-• 111_11GI GRAPHICS '• DISPLAY• .^•^• •. . ..UI_MS WINDOWS '.^DISPLAY^. •• • . . •^• . • •Figure 25.The Zinc Interface Library Class Diagram.The Display ManagerThe purpose of the display manager (UIDISPLAY) is to encapsulate all displayinput/output to provide a consistent application to hardware interface that is easily portable toother environments11. The first role of the display manager is to provide an interface betweenthe software application and any hardware devices such as printers or video displays. The displaymanager also acts as a container for all object regions on the display. Whenever an object (ie.a window) is added to the window manager (discussed below), the window manager registersthe region with the display manager. The window manager and the display manager then work11 ZIL is packaged with several display managers that support the following environments: DOS text mode,DOS graphics mode, and Microsoft Windows. By simply changing the display manager the applicationports seamlessly to other environments.- 32 -together to determine the areas of all objects in the region list that should be displayed (forfeatures such as overlapped windows). They also determine which objects are affected by eventssuch as mouse clicks.The Event ManagerThe event manager (ULEVENT_MANAGER) is a container class for all devices(UI DEVICE) attached to the system. UI DEVICE objects (or anything derived from a_^ _UI DEVICE) usually provide the communication medium between the user and the application_and are generally responsible for generating events. Example devices include the mouse, thekeyboard, a serial port, or a timer. The purpose of the event manager is to poll all of the devicesthat is holds, looking for events such mouse or keyboard actions. When an event is generated,the event manager informs the window manager of the type of event that occurred. The windowmanager then tries to determine which object on the display to dispatch the event to.The Window ManagerThe window manager (UI_WINDOW_MANAGER) is a container class for all windowobjects. Window objects include windows (UIW_WINDOW) and any objects (discussed below)associated with the window (ie. title bar, borders etc.). The window manager class provides theinterface between the event manager and any window objects on the display. In other words,the window manager receives events from the event manager then dispatches them to theappropriate window objects.Windows and Window ObjectsThe UI_ WINDOW_ OBJECT class is an abstract class from which all useable objects suchas buttons and icons in ZIL are derived from (Figure 26). In ZIL, window objects are eitherused to enhance the appearance and behavior of a window or they are used as data fields in awindow. This feature is very elegant because it allows the behavior and appearance of the windowto be dynamically created and easily customized. Additionally, code size is smaller because onlythe features that are required are added. Trying to include every window feature provided byZIL in one data structure or class would not only result in a very inefficient (speed and size)window, but would also be very difficult to maintain. With this dynamic system, each windowobject is only responsible for itself which results in very easily maintainable objects.- 33 -U1W_INTEGER ..• - • '^' •UIW_REAL• •^' • •^•. ,^• .1.11W_MAXIMth.^BUTTON , •• •^•. UIW_POP_UP •• ITEM^•....... . UIW_TITLE •^AWILMINIMIZE. BUTTON^•• • • • • • • ••.UI_WINDOW_•OBJECT•^•^• •^•^' ..USER DEFINED-. OBJECTS •• .^.^. • •, • • .UIW_NUMBER.•., •^. •UIW_ICON^UIW_BORDER.r Til tUIPtatin.133REIPS.01,131111111,..../Irlar.13£.1.1RnSt.ttirly,X Grid Spacing: 11400V Grid Spacing: 11400X Origin:V Origin:1010 Display Grid() Vas 0Points.?No^1r=MI aanca 1 I Halo I11111/11,43MMAAM,F,J10.0.4.1.1SaftratilStRARRI.IesrASULINIftfirSSSLAXIASLFigure 26.A partial ZIL window object class hierarchy.For example, the window shown in Figure 27 is built from several window objects thatallow the window to exhibit a wide variety of behavior. The system button (top left corner), whenpressed, opens a menu with options to expand the window to full screen or shrink it to an icon,close it or restore it to its original size. The border object allows the window to be re-sized andthe title object not only displays the window title but allows the window to be moved whendragged with the mouse.Figure 27.A standard window created by ZIL.- 34 -The radio buttons (Display Grid Points) show another unique feature of the window class.The radio button class is also a window class (RADIO CONTROL) which can be placed withinanother window (added to it). The RADIO_CONTROL class corresponds to the area aroundthe two radio buttons (RADIO BUTTON class) and its responsibility is to ensure that whenone button is selected that the other is unselected. The RADIO _ BUTTON objects then receivemessages from the RADIO_CONTROL to display themselves as selected or unselected.4.3 ImplementationThis section briefly describes how the different features of Cross Link have been interfacedwith the Zinc Interface Library using the C+ + programming language. It also discusses theimplementation of the Cross Link Macro Language that enable users to' modify and customize theoperation of Cross Link in many different ways. Detailed internal documentation on Cross Linkcan be found in reference [10].Menu BarElls Edit &lettings hacro pools &laStructureWindow.^• C^\..sil._ I Mt, •,) C:, ME^Ws 1^ Km^T(5600.0 : 4200.0)•Tools0riliiix0T ,,, •.^.^.^.^.qt.4-4P:-.0-ff::*.:',...^,...^%,:^\ i /^.:.:^...-*:^/ .. • /1"*.t.:..^4^.X1^ .I"^• I Match Nlndow^ 1 i I t^". ^k Tool BoxWatch WindowFigure 28.The Cross Link User Interface.- 35 -AnalysisModulePostprocessor :Spreadsheet :ApplicationCross LinkUtilitiesMenu BarTool BoxMacroLanguageStructureDatabaseExternal UtilitiesShown in Figure 28 is the Cross Link user interface. It is composed of four windows: the menubar, the tool box, the watch window and the structure window. These features along with otherutilities are also presented in Figure 29. The menu bar provides basic services for Cross Link includingoptions to read and write the database to file, set drawing parameters such as the coordinate systemlimits, grid points and snap points. The menu bar also contains options to execute user macros, runexternal applications and obtain help. The tool box contains six icons that let the user select anappropriate editing mode. The watch window is a utility used by the macro language that allowsmacro programmers to write useful macro results to the display. Most importantly, the structurewindow, which is the engine of the preprocessor, provides the interface between the user and thedatabase.Figure 29.The Cross Link Application and UtilitiesThe Structure FrameworkFigure 30 shows the class diagram for the structure framework (using the Booch designnotation). The four important classes to recognize in this diagram are the UIW_STRUCTUREclass, the STRUCTURE class, the SO_NODE_CONTROL class and theSO ELEMENT CONTROL class. Referring to Figure 28, the UIW_STRUCTURE classcorresponds to the structure window and the STRUCTURE class corresponds to the interior border- 36 -. -WI_WINDOW OBJECT. .. - - . • ' ' - -- - , . . . _ - -• .,^ . , UIW_STRUCTURE .0^(:) STRUCTUREUIW WINDOW 2• - . , - - . - 'SO_  NODE CONTROL •. .^• - - . •• •• . . . . . ..' .ELEMENT CONTROL' ..^ ,- • . . ' - - - -in the structure window. The structure database, which provides storage facilities for nodes andelements, is represented by the two node and element controllers. As already mentioned, thestructure window and the structure object provide the interface between all utilities (ie. the menubar or the macro language) and the structure database. In other words, utilities never communicatedirectly with the database.' Ul_WINDOW_MANAGER 'Figure 30.The structure window and structure object framework (using the Booch Notation).In order to demonstrate how the system works, consider the Booch object diagram shown inFigure 31. Shown on the diagram are six objects: a menu bar object (aMenuBar), a tool box object(aToolBox), a structure window object (aStructureWmdow) and two controllers (aElementControland allodeControl) 12. The two messages displayed on the diagram correspond to a user using thenode tool to set the degrees of freedom on some selected nodes (SetDOF) and the using theEdit...Delete menu option to erase some selected nodes (DelectObjects). Following the SetDOFmessage, it is sent to the aStructureWmdow object who in turn dispatches it to the aStructure object.12 Container-type objects can be represented in the Booch notation with a series of smallerobject icons placed inside the container icon.- 37 -4SetDOFI DeleteObjectsDeleteObjects\aStructureWindo SetDOFDeleteObjects \DeleteObjectsSetDOFaToolBoxallodeControllerThe aStructure object then sends the message to the allodeController object which sends the SetDOFmessage to all selected allode objects. To erase all selected objects, the DeleteObjects message isdispatched in a similar manner except this time, the message is also sent to the aElementControllerobject.Figure 31.Cross Link Object Diagram.ControllersThe structure database is represented using the SO_NODE_CONTROL and theSO ELEMENT CONTROL controllers (Figure 32). Controllers provide a powerful, high levelmethod of organizing information. Generally, it is not a requirement of the controller to know thetype of objects stored in the container as long as the stored objects abide by the common messageprotocol defined by the controller. For example, it is perfectly acceptable for a controller to hold anode object and an element object as long as the objects know what type of messages they canreceive from the controller. In this implementation however, two controllers were used. Each onewas customized specifically for the type of objects that would be contained.UIW WINDOW.^-^- SO GRAPHIC CONTROL^•-^-' -•INtISTRUCTURE •• •so_NooLcoNTRol.SO_NODE^SO_LOAD^•.^- . SO_SPRING^•.^.^-Ul WINDOW_OBJECT^SO_GRAPHIC.^.Figure 32.Implementation of the SO_NODE_CONTROL class and the SO NODE class. TheSO ELEMENT CONTROL and SO ELEMENT classes are similar.Storing the nodes and elements in separate containers was done for efficiency reasons. Withstructures that consume a large amount of time in displaying themselves, a user has the option tosuppress display of a given object (ie. nodes, elements or loads) in order to increase the overallprogramme efficiency. For example, when the flag is set to suppress the display of nodes, a drawmessage sent to both controllers is only accepted by the element controller. In a single controllerimplementation however, there is no way of filtering a message and sending it to a particular groupof objects such as elements. This is because the controller now has to iterate through the completecontainer and for each object, either blindly send the message or determine if it is a candidate forthe message.illBOB SourceFileThe Macro LanguageThe Cross Link Macro Language (BOB) is a powerful object-oriented programming languagethat can be used by end users of Cross Link [1]. Through a set of callable library functions that accessthe Cross Link kernel, users can write macros to manipulate Cross Link in many different ways.Appendix A gives and overview of the language and also provides a complete listing of the macrolibrary functions.The macro language is implemented using three modules, the lexical scanner, the bytecodecompiler and the bytecode interpreter, which are shown below (Figure 33).tokenLexical^—0-^BytecodeScanner get token^Compilerr\Data DictionarytStackBytecodeInterpretersp -to-4-stk_bottomFigure 33.Layout of the BOB Macro Language Compiler and Interpreter.The Lexical ScannerThe purpose of the lexical scanner is to scan a macro file and parse it into tokens whichare fed into the bytecode compiler. The lexical scanner does not perform syntax checking butit must distinguish between language keywords and operators (ie. class, if, else, nil, > =, = ) andvariables in order to send the correct token to the bytecode compiler (Figure 34).Bytecodes/essassgsasens+ i p 4.4-stk_top- 40 -T_INTEGERT_FLOATT_STRINGT EOILET_IFT ANDT_NEWinteger value (12)floating point value (1.234)string value ("ab123.0")equal (==)less than or equal to operation (<-.)begin an if statementlogical AND (&&)new keywordFigure 34.Some example token values returned by the lexical scanner.The Bytecode CompilerThe bytecode compiler calls the lexical scanner to parse the source file and then using itsdefined syntax rules, converts these tokens into a series of bytecodes 'Which are later interpretedusing the bytecode interpreter (Figure 35). The compiler also builds a data dictionary where allvariables, functions, class definitions and class implementations are stored. This dictionary isreferenced to using the gererated bytecodes. There is a class of possible syntax errors that arenot trapped by the compiler and therefore must be located by the interpreter. These errors arisebecause of the fact that the language is typeless. Being typeless, any variables defined within amacro are not required to be explicitly declared as integers, floats or strings (variable types areset when an assignment is made to the variable - ie. x = 123.1; sets the type of x to a float).Therefore, the compiler cannot check for incorrect operations such as adding an integer to astring because this is unknown at compile time. If the language were typed, type syntax couldbe checked by the compiler.OP_PUSHOP_ADDOP_DIVOP_GEOP_SETOP CALLpush nil onto the stackadd the top two stack entriesdivide the two top stack entriesperform "greater than or equal to" on two top entriesset the value of a variablecall a functionFigure 35.Some example bytecodes (or opcodes) produced by the bytecode compiler.The compiler-interpreter arrangement has some advantages over a straight interpreterarrangement (such as BASIC) where syntax checking, compilation and execution are allperformed in one pass. Not only is programme execution much faster (because language syntaxis verified by the compiler) but development of a runtime-only system that does not include the- 41 -compiler could also be implemented. This would allow a compiled macro to be written to a filewhere it could later be retrieved and executed using the interpreter (the compiler could bepackaged as a separate application). This feature would offer a significant speed advantage ininstances where macros are never modified and do not require compilation every time they areexecuted.The Bytecode InterpreterThe bytecode interpreter executes the series of bytecodes that are built by the bytecodecompiler to create a running application. It is also responsible for the verification of typecorrectness at run-time.To show how the bytecode interpreter uses the stack when interpreting bytecodes,consider the macro shown in Figure 36 which adds two numbers together. Shown in Figure 37are the bytecodes (opcodes) created by the bytecode compiler.main(;i,j,k)^ TSPACE 03PUSHi = 2.0; LIT ; 2.0j = 4.0; TSET 02k = i + j;^ LIT ;4.0TSET 01TREF 02PUSHTREF 01ADDTSET 00 ; kRETURNFigure 36.^ Figure 37.Macro to add two numbers.^Resulting bytecode instructions execute the functionmain() in Figure 36.The interpreter uses a stack as a temporary storage facility for intermediate operationsand values (Figure 33). The stack pointer (sp) is used to point to different slots on the stack. Inthe example programme, the TSPACE opcode allocates three temporary slots onto the top ofthe stack which are used the three local variables i, j and k. A PUSH opcode is then executedto push a slot onto the stack, followed by a LIT opcode which sets the value of the new slot tothe value 2.0. Next, a TSET opcode sets the value of the variable i to the current value pointedto by the stack pointer (2.0). The same LIT-TSET sequence is also performed for the assignmentto variable j. The TREF opcode then pushes a slot onto the stack and sets the value of this slotto the value of variable i and the same is done for variable j. The ADD opcode is then executed- 42 -which adds the value pointed to by the stack pointer (j) with the value contained in the next slotabove the stack pointer. The result is then stored in the slot above the stack pointer and theTSET opcode is issued to set the value of variable k to this value. The RETURN opcode thenindicates execution of the function is complete.Interfacing the Macro Language with other ApplicationsThe macro language supports two different types of callable functions. The first is any functionwhich is declared in a macro file (ie. a subroutine). The second type of callable function, specifiedby a developer of the system, is called an internal or library function. As part of the compilerinitialization routine, a set of library functions can be added to the data dictionary (a storagedictionary for all macro variables and internal functions) which can then be executed from within aBOB macro. These internal functions are written in C and have to be compiled into the application'sexecutable file.Programming the internal functions requires minimal understanding of thecompiler/interprete operation. The external function is written to accept one parameter in thefunction call, the number of arguments passed in the BOB function. For example, consider the BOBlibrary function Sin (value), which calculates the sine of value. Shown in Figure 38 is the equivalentC function that calculates the sine and returns the result back to the interpreter. Allone need toknow in order to add a library function to the language is the state of the stack right before theexternal function is called. The interpreter will push all the parameters passed to the function ontothe stack (in this case only value) so the internal function need only check that the parametersnumber of parameters were passed and that they are of the correct type (obviously, value can onlybe of type integer or float). Once the parameter type is verified, it can be extracted from the stackand the calculation can be performed. In order to pass the result back to the interpreter, the stackpointer must be incremented by the number of arguments in the function. After the stack increment,the result will be placed on the stack where the interpreter will insure it is assigned to the correctvariable.Using this method, a full complement of functions can be developed to interface BOB withfunctions and data that are internal to the application. This creates a very high level of flexibility// init functions - initialize the internal functionsvoid init_functions()C// add the BOB Sin() function using a pointer to the sine functionadd_function("Sin",sine);I/ sine calculates the sine of a valuestatic int sine(int argc)Cfloat value, retval;// make sure only 1 parameter was passed by BOB.argcount(argc,1);// ensure the parameter has the correct typeif(!type(O,DT_INTEGER) && !type(O,DT_FLOAT))badtype(0,DT_NUMERIC);// perform the calculationif(type(0,DT_INTEGER))(value^sp(O].v.v_integer;retval = sin(vatue); // call a function to do the calculationelse if(type(O,DT_FLOAT))Cvalue = sp(07.v.v_float;retval = sin(value);// increment the stack pointer by the number of params passed (1)sp += argc;// set the value pointed to by sp to the return value of sinset_floataspI0],retval);return(0);Figure 38.The internal function to calculate the sine of the BOB Sin() function.because, with the proper interface to the kernel of the application, it is possible to shift much of theprogramming from internal development to external development which can be done by end usersof the application.4.4 A Sample Session in Cross LinkThe purpose of this section is to provide a tour through CLUSAP. In the example, a modelof the frame shown in Figure 39 will be developed. Then using the macro language, the frame willbe exported to the ANSYS finite element programme for final analysis.Start the Cross Link programme by typingxlink<enter> at the DOS command line. If this isnot the first editing session, any structure that was edited in another session will automatically beloaded. A screen similar to that shown in Figure 40 should appear. The preprocessor environmentconsists of four windows on the display: the Menu Bar, the Tool Window, the Watch Window andthe Structure Window. The Menu Bar contains menu options to open and save files, set environment- 44 -0LI)Ofull momentconnection req'dfull momentconnection req'd//.{/fassume full moment transfer betwenweb members and chord14 CP 2000 28 000Figure 39.The Example Frame to be Modelled using Cross Link.parameters, run macros and obtain help. The Tool Window contains six icons or tools that determinethe editing mode. The Structure Window is the window where the structure is displayed and edited.Finally, the Watch Window is used as an output facility for the macro language. Macro developerscan use this window display information for users of the macro or use it as a debugging facility (byprinting variable values to the window).- 45 -En... Last lettings nacre, Loomis Haloa^ (Untitled)^ 4^1 Teelsi(0.0, 0.0) Zo —0Node Tool• -^•^- •^Element- Tool^-.^.^.^. .^'^•^'^'Spring' Tobl. ..^.^. .^Point.^Lo.ad . Tool^.• •^•^-^ •^4 .^•^•^UDL • ToolProperty Tool.^.^.^-^•^•^ •111111 .,,pi pp11481IJ^.^IWatch Windom^ 1 4 I 1. L1 ,^ ,rFigure 40.The Cross Link Preprocessor Editing Environment.The first step in a session is to set up a coordinate system and a grid sustem. To do this selectSettings...Limits from the menu and enter the minimum and maximum coordinates of the frame(allowing for some margin space) in the dialogue box (Figure 41). To set the grid size, selectSettings...Grid and enter 500 (mm) for the x and y grid spacings. The Settings...Display option canbe used to set some of the structure display options on the screen. In this case, select the display ofnodes and node numbers, and element and element numbers (Figure 42).^r ToolsHelm, Iaancst 1 IJ^ Watch Window(Untitled)(1000.0 : 6500.0)=I a mc zu a al^mu IN I ^Mininun x coordinate: 1-2000Minimum w coordinate: 1-2000Maximum x coordinate: 128000Maximum w coordinate: 118000 1 4 10rtFile Edit tettinws near° Ioola UeloFigure 41.Setting the Structure Limits.The preprocessor is now ready to begin definition of the frame. This will proceed with thedefinition of the node points, then the elements and their properties and finally any boundaryconditions (both node and element). To place nodes, select the node tool from the Tools windowusing the left mouse button. Move over the structure window and click the right mouse button tomake it current (the window title bar will highlight). Now, using the left mouse button, add the nodepoints for the two columns (Figure 43). The F9 key can be used to toggle the snap-to-grid option(the coordinate display will tell you if it is on or off). Similarily, F8 will toggle the grid display. If youwish to zoom into a region of the structure to place the nodes, drag the mouse with the right buttonpressed over the area you wish to zoom. To return to the previous view, click on the Zp ('ZoomPrevious') button.- 47 -(Untitled) ToolsI 4' 1ms(11500.0 : 18000.0)Eile Edit tettings nacro Davis HelpWatch Window 4 1 t0NEaA.0-r riI aanbel I I Help I— Display OptionsED Nodes 11 Node numbersEgiElements^Element numbersElSprings Spring stiffnessesLoads Load values1^Figure 42.Setting the Structure Display Options.Next, select Edit...Generate to generate a line of nodes for the top and bottom chords (Figure44). The node generator contains options to control node placement at the beginning and endingcoordinates and optional element generation (with or without properties attached). For the bottomchord, start node generation at (0,8500) and end at (28000,8500) using 14 elements. Do not includegeneration of the first and last nodes because Cross Link will automatically look at these coordinatesfor a node to connect an element to.4 I tHatch WindowTools0iii(12000.0 : 11000.0)(Untitled)0602^4^1^File Edit lettings nacre Lools helpFigure 43.Placement of the Column Node Points.For the top left hand chord, start at (0,10000), stop at (14000,11500) and generate 7 elements.This time, include generation of the last node. For the top right hand chord, start at (14000,11500),stop at (28000,10000) and again generate 7 elements. Do not specify generation of the first and lastnodes this time since they already exist. Placement of the remaining web elements can now beperformed using the element tool. Select the element tool with the left mouse button, move overthe frame and select the first node for an element. A rubber-banded element will follow the mousecursor until the second node point for the element is selected. Element selection is continuous untilyou press the <Escape> key. Figure 45 shows the fmal frame model with all nodes and elementsplaced.Eile Edit lettings Macro tools UelPw^I• (Untitled)^ I iitt Tools(26000.0 ^■^Automatic Nodc Gcmcvatiom^...^1^t ^Start Point:^End Paint:-^ Zn E) ^... ^...^ .c.,6V.,.a1/4\alx = 10^1 ^X = (28000^Iu . )8500^I^.W = 0500 i ^Generate n Elements: ...i4;n =^114^1 EliSI,, AV7O' .20 0* — Generation OptionsGenerate first nodeGenerate last nodeGenerate elementsN Use current  property settingsa^Use current fixity settings^ez..5Wx oAL.0[^ay.^IgAirvmel ^I^Help-   %T., ,,:,,4^- Ilt, rillill• I^ Watch Window^ 1 1 1t11Figure 44.Automatic Generator of Nodes and Elements for Top and Bottom Chords.Now you can place the boundary conditions. Start by selecting the two column support nodesby dragging the mouse with the left button held down. Eight selector icons will appear on the displayencompassing the selected objects. The selector icons can perform two operations when the mouseis moved over top of them and then dragged (a different mouse cursor appears when the mouse isover a selector). Dragging a selector icon with the left mouse button down will increase the box sizein order to add or remove objects from the selection set. Dragging a selector icon with the right mousebutton down will move all selected objects. The F4 key can also be used to add or remove elementsfrom the selection set. The default selection criterion is to select all elements inside and crossingthe selector box (the region inside the eight icons). Pressing F4 once will then proceed to selectonly elements completely inside the selector box. Pressing F4 yet again will proceed to select allelements crossing the selector box.- 50 -Eile Edit lettings ffeero tools Hello,-^• (Untitled)^ 4^t Toole(12500.0 : 6500.0) Zia EDas.25^*RI ... a-i27 '' -^29 --^2s^22 ^4 23^a - ..0^AD^''''.-^ ''^.1, '''^CD- --- CO ---- - 400 ^31^320?.... 1,p-4e1 ^(!),,,,^-i- -,„ ^.--,-. i^,.-^ „A) ----- -.*^06 Cir..'"- i,s^. •' ,ell --412^-4..;6 2' -, (V..---408^c:4113^40:4 ^6.0 ^®16 ^17 ^40 ^,Isr .  45■.01 4. .ALO-I- ini-..-Z.1^ Watch Window^ 4^t^-Figure 45.Final placement of Nodes and Elements.With the two column support points selected, select the node tool with the right mouse button.A window will appear that will display all possible nodal constraints (Figure 46). Select the iconrepresenting a node with no translational or rotational degrees of freedom. Cross Link will proceedto set the boundary conditions on all selected nodes.The frame geometry is now complete. If element releases are required for any elements, selectthe elements and then select the element tool using the right mouse button (The spring tool, thepoint load tool and the UDL tool all behave in a similar manner). A window will open presentingthe available release options for an element (Figure 47). The convention for placing releases isbased on the element's high and low node numbers. Note that the elements are displayed as dottedlines when they do not have properties assigned to them. In order to set the element properties,select the desired elements and select the property tool with the right mouse button. A window willprompt you to enter the required properties for the selected elements.- 51 -File Edit Settings nacro Laois halo■^1 (Untitled)^ F 4 I 1 f Too(29500.0 : 9500.0)EDIP I^ 01^ AA ^.__.^.P0(i)2 '''..-6L::-45_.;:::49.: ()10...:...22........?A...?±...*K--4F-1:-.;(07....-*Fs-.03?. ....4P. • • ...30 31Ill ^4;9'6:^: 411'44i2 ^_.i. (ifig  ,:iiii .4jili 40'45i ,,._.[ . ^i■ ^ •  ^IIIlg. 1 of= ciA. 0I' I-1III  IIII^■ 11111111, iJ^.^I Watch Window^ ) 4 Ii ^rFigure 46.Placing Node Boundary Conditions. Constraints are placed by selecting the node tool with the rightmouse button. The selected nodes (below) will be affected by the selection.Elle edit lettings Macro 'polo Halo.^ .J^■^I(Untitled)^ I 4^Et - Tools(25500.0 : 17500.0) ZoED0--01^2   El:(i)?-----F5`---*F1,•^• l' ,.....^24 :^1 :'--..!8...:: 40. •::619:2p........at. ^2.7^2B .1^.'219-..^30 ^31^32 ..4102.-t-- 4:1>^• -t.^-^•• Ar.. ... 407.^1,....rl....___403^.0^436I^'-... ^...-^; ii- •^i iis.:^. ii- ..^, iii. : I ii.-.^: 5 eai  1 r ^it?' )41:4111 4_... 0^ i ^(9^w^t1ge ^ Ws ciA. 01' r11^ '1111111111iJ .^IWatch Window^ 1 4Itlin .Figure 47.Setting Element Fixity. Element fixity is specified by selecting the element tool with the right mousebutton.Exporting a Structure to the ANSYS Finite Element ProgrammeIn order to export a structure to the ANSYS finite element programme, a macro must bewritten to extract the node and element data from the Cross Link database and to write it to anASCII file in a format readable by ANSYS. Nodes are specified in an ANSYS data file using the Ncommand which has the following syntax:N,nodenumber,x_coordinate,y_coordinate[,z_coordinate]Elements are specified using the E command. The ANSYS E command automatically takescare of the element numbering so its syntax is:E,lo_node_number,hi_node_numberNodal boundary conditions are placed using the D command. Its syntax is:- 53 -D,node_number,dof,displacement [„„dof2,dof3where:dof, dofl and dof3 can be either UX,UY or ROTZ,displacement = 0.0For simplification, we will assume that only the node, element and boundary conditioninformation must be provided for ANSYS. To start, using an ASCII editor open a file called'ansys.bob'. Three functions are required to write the nodes, the elements and the boundaryconditions to a file. The first function will be called writeNodes(). It takes one parameter, the filehandle, and is specified as follows (review Appendix A for an overview of the BOB programminglanguage and the Cross Link library functions):// writeNodes - writes all node information to filewriteNodes(file;nodeNumber,x,y)nodeNumber = NodeFirst();while(nodeNumber)(x = NodeGetX(nodeNumber);y = NodeGetY(nodeNumber);fwrite(file,"N,",nodeNumber, 11,11,x,11,11,y,11\n"); \\ '\n' is linefeednodeNumber = NodeNext();To extract the nodes, a call is first made to the NodeFirst() function which returns the numberof the first node in the node database or nil if there are no nodes. The x and y coordinates areobtained using the NodeGet?() function. The fwrite 0 function is then used to write the informationto file in an ANSYS compatible format (note thatfwrite 0 can take a variable number of parameters).The NodeNext() function is then called to get the next node in the database. This is all performedinside a while loop until NodeNext() returns a value of nil.The function writeElements() can be implemented using a procedure identical to writeNodes()except this time the two nodes points for the element are required. These are obtained using theElementGet??Node 0 functions:// writeElements - writes all node information to filewriteElements(file;elementNumber,loNumber,hiNumber)CelementNumber = ElementFirst();while(elementNumber)(loNumber = ElementGetLoNode(elementNumber);hiNumber = ElementGetHiNode(elementNumber);fwrite(file, "E,", loNumber, 11,11, hiNumber, "\n");- 54 -elementNumber = ElementNext();To write the node boundary conditions, the node database must be traversed again, this timeto retrieve the degree of freedom (dot) code for each node (using NodeGetD0F0). This code iscompared with a set of constants which represent each allowable degree of freedom for a node. Forexample, the constant ID _101 represents a node with no allowable x translations or z rotations. Thevalue of ID 101 is 5 which is obtained from the binary representation 101. Hence logical operators(such as a bitwise OR [ I ]) can be used on the dof code to determine if a particular dof is free or not.For example, to set the x dof in an existing code (which may or may not have the code set) the dofcan be OR'd with the ID 100 code (ie. dof = dof I ID 100). The writeBoundwyCond() function isimplemented as follows:writeBoundaryCond(file;nodeNumber,dof)num = NodeFirst();while(num)(// get the node degree of freedomdof = NodeGetD0F(num);if(dof == ID_100)fwrite(file,"D,",num,",UX,0.0\n");else if(dof == ID 110)fwrite(file,"- 0,",num,",UX,0.0„„UY\n");else if(dof == ID 111)fwrite(file,"D,",num,",UX,0.0„„UY,ROTZ\n"):else if(dof == ID 101)fwrite(file,"D,",num,",UX,0.0„„ROTZ\n");else if(dof == ID_001)fwrite(file,"D,",num,",ROTZ,0.0\n");else if(dof == mom)fwrite(file,"0,",num,",UY,0.0\n");else if(dof == ID 011)fwrite(file,"0,",num,",UY,0.0„„ROTZ\n");num = NodeNext();All three functions along with the following required main() function are placed in the sameASCII file (main() usually appears first). The main() function will open the ANSYS ASCII datafile (harded coded to be 'test.dat') and call the three functions to write the node, elements andboundary conditions respectively:main(;filehandle)// open a file (test.dat) for writingfilehandle = fopen("test.dat", "w");// write the nodes, elements and BC'swriteNodes(filehandle);writeElements(filehandle);writeBoundaryCond(filehandle);- 55 -// close the filefclose(filehandle);File Edit Eettines Macro tools Help1(Untitled>^111T1- Tools( 0400 _0 :^11200_0)MI E)• .^..^.^.••^1188BEW-8888888 Extutu,^m_iuty^filiL.._.38888881,188388E4188888-38868138888388EBB88883a8tO888803111.888 , AsuFile nano: 1ANS-OUT.BOB^1.^.^.• •^••.^..^.Directors: C:NXLINKNMACROSFiles:^Directories: C9.41r,:;:iANS-IN.BOBANS-OUTDEMO.BOBERASE.BOB1;1. .C A:^][^B:^]C^C:^31111X 0JL.T. ,0PREWAR^I ca---1^I^I^11° 11) I• I^ Watch Window^ 4^t l1^ r, .Figure 48.Running a Macro in Cross Link.Let's return back to the frame problem. The 'ansys.bob' macro can be run from Cross Linkby selecting the Macro...Run macro menu option which will present a listing of all macro files (*.bob)in the current directory. Select the ansys.bob file and then the OK button (Figure 48). The framewill be written to the file 'test.dat' which is presented in Figure 49. Shown in Figure 50 is the frameas interpreted by the ANSYS preprocessor, PREP7.Listed in Appendix A is a more complete ANSYS file export macro (ANS-OUT.BOB) whichcomments the data file and also includes a dialog box to get the name of the destination data file.Also presented is a listing for a macro to import a commented ANSYS data file (ANS-IN.BOB).Basicly, this macro uses the fread 0 function to read in a line of data from a file and the token()function is used to parse the fields from the string. It takes a two parameters; the first is the string- 56 -N,^1,N,^2,N,^3,0.0000, 0.00000.0000, 8500.00000.0000, 10000.0000E,^2,E,^7,E, 8,789E, 7, 20E, 8, 20E, 8, 21N, 4, 28000.0000, 0.0000E,^9, 10 E,^9,^21N, 5, 28000.0000, 8500.0000E, 10, 11 E, 9, 22N, 6,28000.0000, 10000.0000 E, 11, 12 E, 10, 22N, 7, 2000.0000, 8500.0000 E, 12, 13 E, 10, 23N, 8, 4000.0000, 8500.0000 E, 13, 14 E, 11,^23N, 9, 6000.0000, 8500.0000 E, 14, 15 E, 11,^24N, 10, 8000.0000, 8500.0000 E, 15, 16 E, 12, 24N, 11, 10000.0000, 8500.0000 E, 16, 17 E, 12,^25N, 12, 12000.0000, 8500.0000 E, 17, 18 E, 13,^25N, 13, 14000.0000, 8500.0000 E, 18, 19 E, 13, 26N, 14, 16000.0000, 8500.0000 E, 5, 19 E, 13, 27N, 15, 18000.0000, 8500.0000 E, 1, 2 E, 14, 27N, 16, 20000.0000, 8500.0000 E, 2, 3 E, 14, 28N, 17, 22000.0000, 8500.0000 E, 3, 7 E, 15, 28N, 18, 24000.0000, 8500.0000 E,^3, 20 E, 15, 29N, 19, 26000.0000, 8500.0000 E, 20, 21 E, 16, 29N, 20, 2000.0000, 10214.2861 E, 21, 22 E, 16, 30N, 21, 4000.0000,^10428.5713 E, 22, 23 E, 17, 30N, 22, 6000.0000, 10642.8574 E, 23, 24 E, 17, 31N, 23, 8000.0000,^10857.1426 E, 24, 25 E, 18, 31N, 24, 10000.0000,^11071.4287 E, 25, 26 E, 18, 32N, 25, 12000.0000,^11285.7139 E, 26, 27 E, 19, 32N, 26, 14000.0000,^11500.0000 E, 27, 28 E, 6,^19N, 27, 16000.0000,^11285.7139 E, 28, 29 E, 5, 6N, 28, 18000.0000,^11071.4287 E, 29, 30 E, 4, 5N, 29, 20000.0000,^10857.1426 E, 30, 31 D, 1,UX,0.0,,,,UY,ROTZN, 30, 22000.0000, 10642.8574 E, 31, 32 D, 4,UX,0.0,,,,UY,ROTZN,^31, 24000.0000,^10428.5713 E, 6, 32N,^32, 26000.0000,^10214.2861Figure 49.The resulting ANSYS data file for the frame.to parse and the second is a string listing all possible field delimters in the string (the ANSYS delimiteris a comma [,]). The first call to token() returns the first parameter in the string. To parse theremainder of the string, successive calls are made to token with no string passed (ie. tok =token(0,delimiter)) until the nil is returned. Thestrcmp 0 and val() functions can be used to comparea string and convert it to a number respectively.offina.0111111LiturminANSYS 4.4UNIV VERSIONMAR 23 199010:34:2RFRET'? ELEMENTSTYPE NIIMBC SYMBOLSZU =1DIST=n400XF =14000YF =5750 Cross Link to ANSYS TransferFigure 50.Example Frame Exported to the ANSYS Programme.4.5 Extending Cross LinkSeveral modifications could be made to Cross Link's editing environment and macro language.This section discusses some alterations that could be done to enhance the editing capabilities andalso extend the preprocessor to a postprocessor.Recognition of the Physical and Finite Element ModelsCurrently, a shortfall with the preprocessor is the fact that analysts still have to describe astructural model in terms of nodes and elements. No feature is yet provided to model a completestructural component such as a continuous beam, as a single entity and still recognize that it iscomposed of multiple nodes and elements. Structural analysis is performed at a level closer to thefinite element model rather than the physical model (Figure 51). Clearly, an alternate data modellingtechnique is required that recognizes the requirements of the physical model and the finite elementmodel. The physical model is most intuitive for structure description because it explains the structure- 58 -1PREPROCESSING MODELPHYSICAL MODELFINITE ELEMENT MODELin terms of it structural components (ie. beam, column, slab). The finite element model provides amethod of discretizing the physical model into data which is then used in forming the mathematicalmodel of the structure.Figure 51.The Physical and Finite Element Structural ModelsTo move from the finite element based model and back towards the physical model,modifications have to be made in the way nodes and elements are currently represented. Shown inFigure 52 is an alternate implementation of the element container which has been renamed to anassembly container, SO_ASSEMBLY CONTAINER. The assembly container now holds assemblyobjects (SO_ASSEMBLY) which are container classes that model both the physical and finiteelement views of "vector type" elements such as beam and columns or "area type" elements such asslabs and walls. As shown in the figure, the assembly object will always contain, at the least, oneelement (SO _ELEMENT) which would represent the physical view of the structural component(the beam or column). Finite elements could then be added to the container (as SO _ELEMENT's)- 59 -but would be distinguished from the corresponding physical model element. Numerous other objectssuch as custom components or custom sub-assemblies (which are again container classes) can alsobe added to the assembly to model loads, boundary conditions or section table objects. Everycomponent and sub-assembly in the assembly container has to behave according to a commonmessage protocol defined by the container. Sub-assembly components could also define a messageprotocol to communicate object with the sub-assembly container.^..... ^. ...SO_GRAPHIC_CONTROL . ..^Generic container^'class• . •^•^•. . . .. . . .. . . . . . .., . . . .. .^ . ..... .. . . ..SO_ASSEMSLY_CONTROL^1^•^Cy. SO_ASSEMILY^' . i^+contain ., oft.. for 0__________^Container class for 0^SO_ELEMENT• assembly objects assembly components•• '' . „ . . . • . . . •. • • • - . , • "CUSTOMCOMPONENTS• • .^. •^. • •CUSTOM• SUR-ASSEMILIES•• •• •• • •^•Figure 52.Alternate Implementation of the Element Container. The element container is now called anassembly container.For users of the application, most structural modelling would occur on the physical modellevel. However, a user would also have the ability to enter into a finite element model mode whichwould allow assemblies to be selected and discretized into finite elements. Returning to the physicalmodel, all finite elements would disappear. An editing operation such as moving an assembly wouldoccur on the physical model level; all finite elements would automatically be moved (so instead ofselecting 10 elements representing one continuous beam or assembly, the user would select oneassembly).• . „^. • ' • . • •- 60 -gusset plateobject point load object...------distributed load objectA......-- shear connectionobjectthe assembly objectN section objectmoment connectionobjectThe concept of an assembly container that holds sub-assemblies and components could ideallyserve as an extension of the preprocessor to a design programme (Figure 53). Objects such asconnections or web stiffeners could be added to an assembly container to create detailed assemblies.Using polymorphism, generic messages such as DesignYourself would be dispatched from theassembly container to all objects. The objects in the container would then respond to a messagesuch as this and proceed to design themselves. Because of the two way interaction between thecontainer and the object, the object would also have the capability to query the container for requireddesign information. For example, a moment connection object may query the assembly object toobtain the design moment and shear for the connection.Figure 53.Extending Assemblies for Postprocessing and DesignThe benefits of this approach must be emphasized. Firstly, this model recognizes the needsof the end user of the system - a compromise in modelling capability between the physical and finiteelement views. Secondly, all assemblies, sub-assemblies and components are developed anddebugged as separate entities, each adhering to the interface-implementation concept. This resultsin a set of objects that should be more resilient to changes made in the system. Finally, assembliesnow have a very dynamic appearance because of the ability to modify and enhance behavior simplyby adding components. Future objects can easily be implemented as long as they adhere to themessage protocol defined by the assembly container.- 61 -Extending the Macro LanguageImplementation of the aforementioned assembly concept would require modifications to theinterface between the macro language and the Cross Link kernel. This is mainly because thecontainers are now nonhomogenous because they can hold many different types of objects. Theexisting implementation exploits the fact that the node and element containers are homogeneous.For example, the BOB library functions ElementFirstOlElementNext0 (see Appendix A) are usedto traverse the element container by initializing and incrementing an internal pointer. Both functionsreturn an integer value representing the current element number.// example function to print all element fixity codesPrintFixity( ; elementNumber,fixity)C// get the first element •elementNumber = ElementFirst();while(elementNumber)(fixity ElementGetFixity(elementNumber);print("Element ",elementNumber,"^",fixity);// get the next element in the listelementNumber = ElementNext();}Clearly, the above system used to manipulate the element container could not work adequatelyin an assembly container based system. Functions such as ElementFirst() and ElementNext() couldstill be implemented but the internal representation of the assembly container would not be fullyaccessible to macro users. Really, a macro user should have the ability to edit the contents of anyobject in the container. A feature such as this could be implemented using the class mechanismsupported by the macro language. Pre-built classes could be designed into the language that wouldallow duplication of the objects data and provide a set of methods within the class to manipulatethe data. Additional language keywords could also be created to allow determination of class types(in the existing implementation of the macro language, classes do not know their type). For example,an assembly container may be manipulated with a macro in the following way:// get the first object in the containerobject = AssemblyFirst()while(object)(// compare the object string typeif(type(object,"Assembly"))(subObject = ObjectFirst(object);while(subObject)C// look for element objectsif(type(subObject,"SO_ELEMENT"))f// we've got an element stored in the assemblyelementNum = subObject->Number();print("Found element number ",elementNum);- 62 -else if (type(subObject,"SO_PROPERTY"))(// we've get a property object in the assemblyInertia = subObject->GetInertia();Area = subObject->GetArea();subObject = ObjectNext(object);)// get the next object in the containerobject = AssemblyNext();Here, the ElementFirstOlElementNext0 functions have been replaced by theAssemblyFirstOlAssemblyNext0 functions. These functions now return a handle which nowrepresents a reference to any type of object stored in the container. A special language keyword,type, is then used to determine the class type of the object. The functions ObjectFirstOlObjectNext(),which take an object as a parameter, can then be used to determine the contents in an assemblyobject. The above example looks only for element (SO_ELEMENT) and property(SO PROPERTY) objects. Once the object's type is determined, member functions that areinternally attached to the object can be used to manipulate the object.5 CONCLUSIONSThis thesis has examined the use of object-oriented programming techniques in thedevelopment of engineering applications. The paradigm is very well suited to large, complex softwareapplications where issues such as encapsulation, code reusability, portability and maintainability areimportant. These aforementioned features can be implemented using conventional paradigms suchas structured programming, but only through programmer discipline. For example, most procedurallanguages provide only very limited support in the language syntax for concepts such as informationhiding. Conversely, object-oriented languages imbed concepts such as information hiding rulesdirectly into the language syntax and let the compiler provide the enforcement. Consequentially,software becomes more reliable and programmers become more productive because the compileris now used as a more active tool in the development process.Cross Link, a universal structural analysis preprocessor, provides an easy to use, interactiveediting environment that, through the use of a macro programming language, links bi-directionallywith any structural analysis programme. The unique macro facility also gives end users the excitingability to customize the preprocessor to their own requirements, thus providing unprecedentedflexibility. Conceivably, the macro language could also be used to provide an electronic link betweenstructural design and drafting. Traditionally, this communication link is done through hand drawnsketches; engineers describe the geometry of a structure in their analysis and design programmes,produce a sketch of the final product and then pass this on to drafting personnel. These people thenhave to re-enter the information back into a CADD programme for final detailing. Cross Link couldbe used to provide a smoother, more effective communication link between engineer and draftsman.The link may be simple as a wire frame model or as complex as a fully detailed and dimensionedframe. Features such as these could be implemented using a drawing exchange standard such asIGES or DXF.6 REFERENCES[1] Betz, David. Your Own Tiny Object-Oriented Language. Dr. Dobb's Journal, September1991, pp.26-33.[2] Blair, Gordon. et al. 1991. Object-Oriented Languages, Systems and Applications.Reading, London:Pitman Publishing[3] Booch, Grady. Object Oriented Development IEEE Transactions on SoftwareEngineering, Volume 12, Number 2, February 1986, pp.211-221.[4] Booch, Grady. 1991. Object Oriented Design With Applications. CA:BenjaminCummings.[5] Borland International Inc. 1990. Turbo C+ + Programmer's-Guide.[6] Coad, Peter. And Yourdon, Edward. 1990. Object Oriented Analysis. NJ:Prentice Hall.[7] Dale, Nell. and Orshalick, David. 1983. Introduction to PASCAL and Structured Design.MA:D.C. Heath and Company[8] Dupont, G. et al. A Functional and Object-Oriented Design Approach, FourthInternational Conference on Computer Aided Software Engineering, December 1990,pp. 356-372.[9] Duntemann, Jeff. Structured Programming. Dr. Dobb's Journal, May 1990, pp.141-145[10] Elbury, Kevin M. Source Code for the Cross Link Universal Structural AnalysisPreprocessor. 1992, University of British Columbia, Vancouver, B.C., Canada.[11] Hoy, Patrick. A Comparison of Object-Oriented and Structured Development Methods.ACM SIGSOFT, Volume 15,Number 1, January 1990, pp.44-48.[12] LaLonde, Wiif R. and Pugh, John R. Specialization, Generalization and Inheritance:Teaching Objectives Beyond Data Structures and Data Types, SIGPLAN Notices,Volume 20, Number 8, August 1985, pp.88-92.[13] Lee. H.S. and Arora, J.S. Object-Oriented Programming for Engineering Applications.Engineering With Computers. Volume 7, 1991, pp.225-235.[14] Lieberman, Henry. Using Prototypical Objects to Implement Shared Behaviour in ObjectOriented Systems. Proceedings of the Conference on Object-Oriented ProgrammingSystems, Languages and Applications (00PSLA '86). 1986, pp. 214-223.[15] Mullin, Mark. 1989. Object Oriented Program Design. Reading, MA:Addison-Wesley.[16] Pascoe, Geoffrey A. Elements of Object Oriented Programming. Byte, Volume 11,Number 8. August 1986, pp.139-144.- 65 -[17] Snyder, A. Encapsulation and Inheritance in Object Oriented Programming Languages.Proceedings of the Conference on Object-Oriented Programming Systems, Languagesand Applications (00PSLA '86). 1986, pp. 38-45.[18] Sommerville, Ian. 1989. Software Engineering. Reading, MA:Addison-Wesley.[19] Stroustrup, Bjarne. 1986. The C+ + Programming Language. Reading,MA:Addison-Wesley.[20] Taenzer, David., Murthy, Ganti and Podar, Sunil. Problems in Object-Oriented SoftwareReuse. Proceedings of the Third European Conference on Object-OrientedProgramming (ECOOP 89). 1989. pp.25-38[21] Zinc Interface Library Programmer's Reference (Version 2.0), Zinc SoftwareIncorporated, Pleasant Grove, Utah.APPENDIX ACROSS LINK MACRO LANGUAGEFUNCTION REFERENCECross LinkMacro LanguageFunction ReferencebelCross Link^ Programmer's ReferenceTable of Contents1 THE CROSS LINK MACRO LANGUAGE^ 711.1 Basics^ 711.2 Variables and Expressions^ 72Data Types 72Expressions^ 731.3 Program Control Statements^ 741.4 Objects and Classes 752 CROSS LINK PROGRAMMER'S REFERENCE^ 772.1 Programming Constants^ 772.2 Input / Output Functions 79fclose()^ 79fopen() 80fread() 81fwrite()^ 82getc() 82putc() 83print()^ 832.3 Math Functions^ 84abs() 84acos ( ) / asin ( ) / atan ( )^ 84atan2()^ 85cos() / sin() / tan()^ 85exp() 85hypot()^ 86log() / log10() 86pow() / pow10()^ 87sqrt()^ 872.4 String Functions 88strcmp() 88token()^ 89val() 902.5 Cross Link System Functions^ 91SetGrid()^ 91New() 92Prompt() 93PromptYesNo()^ 94Repaint() 95SetLimits() 95Speaker()^ 962.6 Node Functions 97NodeErase() 97-71-Cross Link^ Programmer's ReferenceNodeFirst() / NodeNext()NodeGetDOF() / NodeSetDOF()NodeGetX() / NodeGetY()NodeHigh()NodePut()NodeSelect()NodeSelected()NodeSetX() / NodeSetY()NodeToggleSelect()NodeUnSelect()2.7 Element FunctionsElementErase()ElementFirst() / ElementNext()ElementGetFixity() / ElementSetFixity()ElementGetLoNode() / ElementGetHiNode()ElementSetProp()ElementHigh()ElementPut()ElementSelect()ElementSelected()ElementToggleSelect()ElementUnSelect()3 EXAMPLE APPLICATIONS3.1 Demonstration Program3.2 ANSYS File TransfersANS-IN.BOBANS-OUT.BOB9899100100101102102103103104105105105106107108108109110110111111112112114114117Cross Link^ Programmer's Reference1 THE CROSS LINK MACRO LANGUAGEThe BOB macro language is a weakly typed, object oriented programming language that users of theCross Link Preprocessor have access to within an editing session. The uses of the language are limitless:importing/exporting data files, manipulating the Cross Link node and element databases,  and parametricstructure definition to name a few.BOB has several features that make it unique as a programming language. It contains flavours ofC, C+ + and LISP although its syntax is almost identical that of C. Being object oriented, it supportsclass definitions and inheritance. In a weakly typed language, basic data types such as integer numbers,floating point numbers and character strings are never explicitly typed by the programmer as integers,floats, or strings. This is advantageous since it makes the language more flexible and easier to use.1.1 BasicsThe basic program unit inside a BOB program is the function. Every BOB program requiresa function called main() that must exist somewhere in the program file. A functions can take anynumber of parameters and perform operations on those parameters. The function may directlymodify the values passed into it or it may only use them for calculations. Functions also have theability to return a value. Hence a call to a function usually appears as an assignment.main( ; x, x_squared)x = 5;4x squared = Square(x); // call the Square() function// Function: Square(z)// - returns the square of zSquare(z ; tmp)^// note x is a parmeter, tmp is a local variabletmp = z * z;^// calculate the square...return(tmp);)Figure 1.A BOB program to calculate the square of a number. The function Square does thecalculation.From the example program in Figure 1, several observations can be made:-73-Cross Link^ Programmer's Reference• The function main() has two local variables, x and x squared which aredeclared after the semicolon in declaration of main().• Any function must enclose all of its associated code in curly braces {}.• A semicolon (;) ends every line in which there is an assignment.• The Square() function takes one parameter, x (declared as z).• The Square() function has one local variable, imp, declared after thesemicolon in the function definition.• The Square() function returns the value of x * x.• Program comments are place by preceding the comment with two slashes1.2 Variables and ExpressionsData TypesAs mentioned in the introduction, BOB is an untyped language. Thus as a user of BOB, youare not required to explictly declare the type of any variable. However, you must be aware of thebasic internal representation of data types in order to use the language correctly. When a variableis declared, its default data type is type nil. Only when an assignment is made to the variable, is itstype set.Shown in Figure 2 is an example program emphasising BOB's internal treadment of datatypes. From this example we can make the following observations:• Variables are of type nil before they they are used.• In Part A, i and j are typed as integers because no decimal point appears inthe number 2 or 5. The result of the integer division, 5 / 2, is 2.Cross Link^ Programmer's Referencemain( ;i,j,k)// Part A: Division using integersi = 5;^// represented as integerj = 2;k = i / j;^// result is 2// Part B: Dividision using floats (deimals)= 5.0;^// represented as floatj = 2.; // also represents as floatk = i / j;^// result is k = 2.5Figure 2.A BOB program used to compare calculations using integers and floating point (decimal)numbers.• In Part B, the variables i and j change type from integer to floating point(legal in BOB) as indicated by the decimal point (2.0). Here the result isdifferent: 5.0 / 2.0 = 2.5.• If the division involved a floating point number (ie i = 5.0) and an integer(ie. j = 2.0) the result would a float (k = 2.5).• The above rules are applicable to all other basic mathematical operations.ExpressionsListed in Figure 3 are the basic expressions supported by BOB. Since all of these expressionare a subset of the C programming language, instructions and examples on their use can be foundin any C programming reference (ignore anything to do with pointers).-75-<expression> II <expression><expression> && <expression><expression> I <expression>1<expression> - <expression><expression> & <expression><expression> == <expression><expression> I= <expression><expression> < <expression><expression> <= <expression><expression> >_ <expression><expression> > <expression><expression> « <expression><expression> » <expression>logical ORlogical ANDbitwise ORbitwise XORbitwise ANDequal tonot equal toless thanless than or equal togreater than or equal togreater thanshift leftshift right<expression> + <expression><expression> - <expression><expression> * <expression><expression> / <expression><expression> % <expression>plusminusmultiplydivideremainder-<expression>!<expression><expression>++<expression>--<expression><lvalue>++<lvalue>--unary minuslogical negation (NOT)bitwise negationpreincrementpredecrementpost incrementpostdecrementCross Link^ Programmer's Reference<expression>,<expression>^ comma expression<lvalue> = <expression> assignment<lvalue> += <expression>^ assign sum<lvalue> -= <expression> assign difference<lvalue> *. <expression> assign product<lvalue> 1= <expression>^ assign quotient<test-expression> ? <true-expression> : <false-expression>conditional operatorFigure 3.Operations supported by BOB. An <lvalue> is a left hand side value meaning the variable mustbe able to have the result of an expression assigned to it.1.3 Program Control StatementsBOB contains all the program control statements of the C language (except for the switchstatement). Listed in Figure 4 are the four program control statements used by BOB.Cross Link^ Programmer's Referenceif( <test-expression> )<then-statement>[else<else-statement> ]uhile(<test-expression>)<body-statement>do <body-statement>uhile(test-expression);for(<init-expression>;<test-expression>;<increment-expression>)<body-expression>break;continue;return(<result-expression>);Figure 4.Program control statements supported by BOB.1.4 Objects and ClassesBOB supports class definitions and single inheritance. A class can be used to combine bothdata (called member data) and the functions (called member functions) that operate on that datainto a single entity. Generally a complete class system includes two components. The first is the classtemplate which defines the member data and the member functions of the class. Using inheritance,classes are able to inherit the member data and functions of other classes in order to extend or modifythem. The second component of a class system is the implementation or definition of the memberfunctions. These are coded outside of the class template; they look like regular functions except thefunction name is preceded by the class to which the function belongs. However, member data appearsglobal to the member functions so member data is never passes as an argument to a member functions.The syntax for class definition is shown in Figure 5.The class definition serves as a template for the physical definition of an object; an object isan instance of a class. An object is instantiated using the new operator. Member functions withinthe object are then referenced using the -> operator. However, all member data in a class definitionis private so it cannot be referenced using the -> operator. Therefore, member data is typicallyreferenced by users of the object via members functions that set or retrieve the value of memberdata. Figure 6 shows the syntax for creating objects and accessing them.-77-Cross Link^ Programmer's ReferenceClass Definition: class <class-name> [: <base-class-name>]C<member-definition><member-definition>where <member-definition> is any/all of the following:<variable-name>;static <variable-name>;Ounction-name>((formal-argument-list>1);static Ounction-name>((<formal-argument-list>l );Member Function Definition: <class-name>::<member-function>([<argument-list> ; <temporary-argument-list>])C<statements>Figure 5.Class definition syntax.Object Creation: <object-name> = new <class-name>((<constructor-arguments>3);Object Access: <object-name>-><function-name>((<arguments>1)<object-name>-><data-name>;Figure 6.Object creation and access syntax.Every object usually has a constructor as one of its member functions. Constructors have thesame name as the class and are used for initialization on any member data. They are automaticallycalled when an object is instantiated using the new keyword. Figure 7 shows an exampleimplementation of a class system to represent a point in space.// The Point class definitionclass PointCx,y;Point(x,y);Move(dx,dy);GetX();GetY();// the coordinates of the point// Constructor// move the point// get the data-78-Cross Link^ Programmer's Reference// ConstructorPoint::Point(a_x,a_y)x = a_x;Y = a_Y;// move the point a distance (dx,dy)Point::Move(dx,dy)Cx += dx;y += dy;// get the x and y coordinates of pointPoint::GetX()Creturn x;Point::GetY()Creturn y;)// Example implementation of a Point classmain( ; aPoint, x)C// instantiate a Point object at (0,0)aPoint = new Point(0.0,0.0); // constructor is automatically called// offset the point a distance of (10.0,10.0);aPoint->Move(10.0,10.0);// inquire about its coordinatesx = aPoint->GetX();Figure 7.Example implementation of class Point.-79-Cross Link^ Programmer's Reference2 CROSS LINK PROGRAMMER'S REFERENCE2.1 Programming ConstantsSeveral constants are pre-coded into to the system. These are listed in the following table:Name Value CommentsTRUEFALSE01Generally used as a return valuefrom some functions.PI 3.14159265ID 000ID 001ID 011ID 111ID 101ID 100ID 010N/A These are node degree of freedomcodes used by NodeGetD0F0,NodeSetDOF() and NodePut()ID_FFID_PPID_FPID_PFN/A These are element fixity codes usedby^ElementGetFixity(),ElementSetFixity(),^andElementPut().Cross Link^ Programmer's Reference2.2 Input / Output Functionsfclose()Synopsisfclose(file)file - file handleRemarksfclose() closes the file associated with the file handle file.Exampleoutputfile = fopen("test.dat","rb");fctose(outputfite);Cross Link^ Programmer's Referencefopen0Synopsisfopen(fname,mode)fname - the file namemode^- the access mode for the fileRemarksUse fopen to perform I/O to a file. fopen() returns the handle to the file frame opened. Validmodes are any combination of the following access modes and file translation modes:Access Modes for File I/OString^Interpretation"r"^Open file for read only operations"w"^Open a new file for writing. Existing contents will be overwritten.iiai,^Open a file for appending."r +"^Open an existing file for read and write operations. Error it the filedoes not exist.,,w+t,^Create a file and open it for reading and writing."a +"^Create a file and open it for reading and writing.File Translation Modes for File 1/0Mode^Interpretation"b"^File is opened in binary mode. Every character is read as is withoutthe changes described below."t"^File is opened in translated mode subject to the following:1. Carriage Return-Line Feed combinations on input aretranslated to single linefeeds.2. During input, the Ctrl-Z character is interpreted as the EOFcharacter.Example-82-Cross Link^ Programmer's Reference// open test.dat for writing tooutfile = fopen("test.dat 11,H0);fwrite(outfile,"This file is called test.dat");fread0Synopsisfread(file)file- file handle (see fopen())RemarksUse fread to read a line from file. The line is read until a newline character (\n) is encountered.The maximum line length is limited to 255 characters.If there are no errors, fread() returns the the string read; otherwise it returns nil.Example// program to print the file test.dat to the watch windowmain( ; file, string)(// open test.dat for readingfile = fopen("test.dat","r");// read the first linestring = fread(file);while(string)(print(string);string = fread(file);))-83-Cross Link^ Programmer's Referencefwrite()Synopsisfwrite(file,...)file- the file handle (see fopen())RemarksUse fwrite to write data to a file. Numeric values are automatically padded with a blank spaceon the left hand side. Floating point numbers are output to four decimal point accuracy.Additional characters can be used to control output:\n^- new line character\t^- insert a tab characterExample// open test.dat for writing tooutfile = fopen("test.dat 11,110);// write some text and add to Line feedsfwrite(outfile,"\tThis file is called test.dat\n\n");getc()Synopsisgetc(fhandle)fhandle - the file handleRemarksUse getc() to read the next character from the file associated with fhandle. The functionreturns -1 when the end of file is reached.Example// read a character from filechar = getc(file);print("Read the char: ",char," from file.");Cross Link^ Programmer's Referenceputc()Synopsisputc(char,thandle)RemarksUse putc() to write the character char to the file associated with (handle.Example// write a character to fileputc("a",file);print()Synopsisprint(...)RemarksUse print() to print information to the Watch Window inside Cross-Link. Print takes anynumber of data types and is capable of distinguishing between different data types. Thisfunction is useful for debugging and displaying information to the user.Exampleprint(ncount," nodes selected");Cross Link^ Programmer's Reference2.3 Math Functionsabs()Synopsisabs(number)number^- the numberRemarksabs() returns the absoulute value of number.Examplevalue = -10.3454value = abs(value); // value = 10.3454acos() / asin() / atan()Synopsisacos(x)asin(x)at an(x)RemarksUse acos(), asino, atano to compute the arc cosine, arc sine and arc tangent of argument x.For acos() and asin(), x must be between -1 and 1. The returned angle is in RADIANS.Exampleangle = acos(0.5); // angle = P1/3Cross Link^ Programmer's Referenceatan2()Synopsisatan2(y,x)Remarksatan2() returns the arc tangent of y/x in radians.Exampleangle = atan2(y,x);cos() / sin() / tan()Synopsiscos(theta)sin(theta)tan(theta)RemarksUse cos(), sin(), and tan() to compute the cosine, sine and tangent of angle theta (inRADIANS)Examplevat = cos(PI); // yal = -1exp()Synopsisexp(x)RemarksUse exp() to calculate the exponential of x.Exampleeyal = exp(10.345);-87-Cross Link^ Programmer's Referencehypot()Synopsishypot(x,y)RemarksUsehypot() to compute the length of the hypotenuse of a right angle triangle given the lengthof both sides, x and y.Examplelength = hypot(3.0,4.0);^// length = 5.0log() / log10()Synopsislog(x)log10(x)RemarksUse loge and log10() to calculate the natural logarithm and logarithm to the base 10respectively of argument x.Exampley = log(2.0); // t = 0.693147Cross Link^ Programmer's Referencepow() / pow10()Synopsispow(x,y)pow10(z)RemarksUsepow() to calculate the value of x raised to the power of y. Usepow100 to raise 10 to thepower of z.Examplex = pow10(2);^// x = 100.0y = pow(2,4);^// y = 16.0sqrt()Synopsissqrt(x)RemarksUse sqrt0 to compute the square root of value x. If x is less than zero an error will occur;Exampley = sqrt(abs(-2.0);^// y = 1.414Cross Link^ Programmer's Reference2.4 String Functionsstrcmp()Synopsisstrcmp(stringl,string2)strcmp (stringl ,string2,n)stringl^- the strings to be comparedstring2n^- number of characters to compareRemarksThe first function compares stringl and string2 lexigraphically. The second function comparesthe first n characters of stringl and string2. Both functions are case sensitive.strcmp () returns a number less than, equal to, or greater than 0, depending on whether stringlis less than, equal to, or greater than string2, respectively.Exampleif(strcmp(token,"Node") == 0)print("The token is a 'Node'");if(strcmp("Kevin Etbury","KevinEtbury",5) == 0)print("First 5 characters are the same!);Cross Link^ Programmer's Referencetoken()Synopsistoken(string,delimiter)stringdelimiterRemarks- the number- a string containing the delimiting charactersUse the token() function to parse the records out of a delimited string. The first argument,string, is a character string containing all the delimited tokens. The second string, delimiter, isa string describing the set of characters that delimit the tokens.In general the token() function must be called several times to completely parse string. Thefirst call to token() includes the complete string that requires parsing. Subsequent call totoken() must pass 0 as the first parameter to indicate that parsing is still to be done on the oldstring. However, every call still requires the delimiter string (which can be changed betweencalls).token() returns nil when there are no more records to parse.Example// parse each of the records from a string containing the// following format (ANSYS Node command)://^N,node_num,x,y,z//delimiter^11,11;^ // delimiter is a commastring = "N,12,123.4,232.23,0.0";// initialize the token parserstrtok = token(string,delimiter);// check the first token to see if it is a node stringif(strcmp(strtok,"N")C// get the node numberstrtok = token(0,delimiter);num = val(strtok);// get the x, y and z coordinatesstrtok = token(0,delimiters);x = val(strtok);strtok = token(0,delimiters);y = val(strtok);strtok = token(0,delimiters);z = val(strtok);-91-Cross Link^ Programmer's Referenceval()Synopsisval (string)string - the number in string formRemarksUse the val 0 function to convert string to a numeric value. If string contains any non-numericcharacters, val() returns nil, otherwise val() returns the numeric value.Examplenunber = val("123.23");number = val(flab123");// nunber = 123.23// number = nilCross Link^ Programmer's Reference2.5 Cross Link System FunctionsSetGridSynopsisSetGrid(grid_x, grid_y, x_origin, y_origin, snapflag, gridflag)grid x^- the x direction grid spacinggrid_y^- the y direction grid spacingx_origin^- the x_origin of the gridy_origin^- the y_origin of the gridsnapflag^- snap-to-grid flag (TRUE/FALSE)gridflag^- grid display flag (TRUE/FALSE)RemarksThe SetGrid() function is used to set the grid parameters.Example// set up grid with snaps off and grid display offSetLimits(0,0,15000,10000);snapflag = FALSE;gridflag = TRUE;SetGrid(1000, 1000,0,0,snapflag,gridflag);Cross Link^ Programmer's ReferenceNew()SynopsisNew()RemarksUse New() to reset a structure by erasing all nodes and elements. Any work not saved will belost.Examplemain()C1/ start with a clean structureNew();SetLimits(0,0,15000,1000);)-94-r 18121.1.11.4.11186.1,1141.14,,,k1.7 V .14 .111{114,1,ANSYS Vile Import__Cross Link^ Programmer's ReferencePrompt()SynopsisPrompt(title,prompt,value)title - the title for the dialogue boxprompt^- the prompt string placed within the boxvalue^- the initial value to be edited (integer, float or string)RemarksPrompt() opens a dialog box centered on the screen. The diaglog box consists of a title barwith title, a prompt string, a value editor and an OK button. The parameter value must beinitialized (type nil is not supported) with the type of value you wish to edit (ie. string, integeror decimal number) before it is passed into this function.Prompt() returns the new value entered by the user.Examplemain()Cfilename = "test.dat"string = Prompt("ANSYS Fite Import... ","Import ANSYS filename: ",filename);// edit an integer valueintval = 1;intval = Prompt("Example Integer Editor","Enter an integer: ",intval);-95-88.nrisysReplace existing structure?Imp 1 Ho^ICross Link^ Programmer's ReferencePromptYesNo()SynopsisPromptYesNo(title,prompt)title - the title for the dialogue boxprompt^- the prompt string placed within the boxRemarksPromptYesNo() opens a dialog box to retrieve a Yes or No answer from the user. The diaglogbox consists of a title bar with title, a prompt string, a Yes button and a No button.PromptYesNo() returns the TRUE if the Yes button was pressed or FALSE if the No buttonwas pressed.Examplemain()// do we want to run the macro with a new structure?ans = PromptYesNo("ANSYS Fite Inport...","Replace existing structure?");if(ans == TRUE)New();^// erase the existing structure...-96-Cross Link^ Programmer's ReferenceRepaint()SynopsisRepaint()RemarksRepaint() redisplays the contents of the structure database. Only items selected in theSettings... Display will be displayed.Example// add a node and redisplay the structureNodePut(NodeHigh(),1000,2000,ID000);Redisplay();SetLimits()SynopsisSetLimits(left,bottom,right,top);RemarksUse SetLimits() to set the current structure limits. The limits are defined as the minimumarea required to fit a structure on the screen. Cross Link will provide a viewport with at leastthe specified limits However, in order to maintain an aspect ratio of 1:1 the x or y limits mayneed to be internally adjusted. These adjusted limits are referred to as 'extents' and are storedseparately from the structure limits. Note that grids will only be drawn on the specified limits.Example// define Limits big enough to hold a 10m wide by 20m high structureSetLimits(-1000,-1000,12000,22000);-97-Cross Link^ Programmer's ReferenceSpeaker()SynopsisSpeaker()RemarksUse Speaker() to sound the speaker on your computer. This is useful for debugging programsExample// select a node - make some noise if we can't find iferr = NodeSelect(num);if(err == nil)(Speaker();print("Can't find node ",num);-98-Cross Link^ Programmer's Reference2.6 Node FunctionsNodeErase()SynopsisNodeErase()NodeErase(num)num - node number to eraseRemarksThe first function removes all selected nodes from the node database. The second functionerases node num from the node database. Both functions will additionally remove any pointloads, springs and elements attached to the node.Example// erase the last node in the databasenum = NodeHigh() - 1;retval = NodeErase(num);if(retval == nil)print("Node number ",num,"does not exist!");elseprint("Node number ",nun, "deleted");Cross Link^ Programmer's ReferenceNodeFirst() / NodeNext()SynopsisNodeFirst()NodeNext()RemarksNodeFirst() returns the number of the first node in the node database. It is generally used inconjunction with the NodeNext() function to traverse the node database and performoperations on individual nodes. NodeFirst() returns nil if there are no nodes in the nodedatabase.Example// function to erase nodes that are NOT selectedMyErase(,num)(num = NodeFirst();^// get the first node in the databasewhile(num != nil)(if(!NodeSelected(num))NodeErase(nun);// get the next 'nun' in the databasenun = NodeNext();))Cross Link^ Programmer's ReferenceNodeGetDON) / NodeSetD0F()SynopsisNodeGetDOF(num)NodeSetDOF(num,dof)num - node number to getdof - node dof codeRemarksNodeGetDOF 0 returns the degree of freedom code for node num.NodeSetDOF 0 sets the degree of freedom of node num. See NodePut() for a description ofthese codes.Examplemain()(// change all pinned nodes to fixed nodesModifyD0F(ID_110,1D_111);)// function to change all nodes with dof lold_dof' with 'new_dofModifyD0F(old_dof, new_dof; num, dof)(num = NodeFirst();while(num != nil)(if(NodeGetDof(nun) == old_dof)NodeSetDof(num,new_dof);nun = NodeNext(); // proceed to next number))-101-Cross Link^ Programmer's ReferenceNodeGetX() / NodeGetY()SynopsisNodeGetX(num)NodeGetY(num)num - node to getRemarksNodeGet?() returns the x or y coordinate of node num or returns nil if node num does notexist.Example// function to calculate the distance between two nodesLength(num1,num2; dx, dy)Cdx = NodeGetX(num1) - NodeGetX(num2);dy = NodeGetY(num1) - NodeGetY(num2);length = hypot(dx,dy);return(length);NodeHigh()SynopsisNodeHigh()RemarksNodeHigh() returns the number of the next available node number.Example// add a node but find out the next number we can usenum = NodeHigh();NodePut(num,100,1200,ID_000);Cross Link^ Programmer's ReferenceNodePut()SynopsisNodePut(num,x,y,dof)num - the node numberx,y - the x and y coordinatesdof - the dof code numberRemarksNodePut places a node at the specified x,y coordinates with a dof degrees of freedom.Allowable dof codes are global variables set by the system. A code is specified by 'ID_' alongwith the x,y and rotational degrees of freedom represented by ones and zeros with 1 = freeand 0 = fixed. Allowable codes are:ID_000 - free jointID_001 - 0 rotation jointID 011ID 111 - fully fixed jointID 100ID 110 - pinned jointID 101If node num already exists in the node database, Cross Link will update the existing nodeparameters with the supplied values.Example// generate a parabolic Line of nodesk = 0.00005;for(x=0.0, x <= 10000; x += 500)(^// space nodes at 500num = NodeHigh();y = k * x * x;NodePut(num,x,y,1D_000);^// ID_000 is a system variableCross Link^ Programmer's ReferenceNodeSelect()SynopsisNodeSelect(num)NodeSelect(left,bottom,right,top)RemarksThe first function selects node num. The second function selects ALL nodes defined by a boxwith coordinates (leftbottom) to (righ4top). NodeSelect() returns the number of nodesselected. Use the NodeSelected() function to determine if a node is selected.Example// select all nodes within (100,100) to (500,800)count = NodeSelect(100,100,500,1000);print(count," nodes selected");NodeSelected()SynopsisNodeSelected(num)num - node number to inquire aboutRemarksNodeSelected returns TRUE if node num is selected and FALSE if node num is not selected.Exampleif(NodeSelected(num) == TRUE)print("Node ",nun, "is selected");Cross Link^ Programmer's ReferenceNodeSetX() / NodeSetY()SynopsisNodeSetX(num,x_coordinate);NodeSetY(num,y_coordinate);RemarksNodeSetX and NodeSetY are used to set the x and y coordinates of num respectively. Bothreturn TRUE if succesful and FALSE if not.Example// set the x coordinate on node 12num = 12;ret = NodeSetX(num,10500.0);NodeToggleSelect()SynopsisNodeToggleSelect()RemarksNodeToggleSelect() runs through the whole node database and toggles selected andunselected nodes.Example// delete all nodes except for number 5 and 7NodeSelect(5);NodeSelect(7);NodeToggleSelect(); // flip selected/unselected nodesNodeErase();-105-Cross Link^ Programmer's ReferenceNodeUnSelect()SynopsisNodeUnSelect()RemarksNodeUnSelect() unselects all selected nodes in the node database.Example// unselect all unselecded nodesNodeUnSelect();Cross Link^ Programmer's Reference2.7 Element FunctionsElementErase()SynopsisElementErase()ElementErase (num)RemarksThe first function erases all selected elements. The second function erases element num. Thereturn value for this function is TRUE if successful of FALSE if num does not exist.Example// erase all selected elementsret = ElementErase();ElementFirst() / ElementNext()SynopsisElementFirst()ElementNext()RemarksElementFirst() returns the number of the first node in the node database. It is generally usedin conjunction with the ElementNext() function to traverse the element database and performoperations on individual elements. Both functions return nil when there are no more elementsin the element database.Example// traverse the element databaseelement = ElementFirst();while(element)(// perform any required operations on each elementelement = ElementNext();-107-Cross Link^ Programmer's ReferenceElementGetFixity() / ElementSetFixity()SynopsisElementGetFixity(num)ElementSetFixity(fix_code)ElementSetFixity(num,fix_code)RemarksElementGetFixity returns the fixity code for element num.ElementSetFixity sets the fixity code for an element. If the first is used, all selected elementsare affected. If the second is used, only element num is affected (if it exists).See ElementPut() for list of fix _code's.Example// set all selected elements to pin-pinElementSetFixity(ID_PP);Cross Link^ Programmer's ReferenceElementGetLoNode() / ElementGetHiNode()SynopsisElementGetLoNode(el_num)ElementGetHiNode(elnum)RemarksElementGetLoNode returns the lower node number of element el_num.ElementGetHiNode returns the higher node number of element el_num.Both return nil is el num does not exist.Example// function to erase all elements that are attached to node 'nun'Spc_Erase(num; el_numo tonode,hinode)C// run through the element databaseel_num = Elementfirst();while(el_num != nil)(Londe = ElementGetLoNode(el_num);hinode = EtementGetHiNode(el_num);// do we have a match??if(lonode == nun)ElementErase(el_num);else if(hinode == nun)EtementErase(el_num);// get the next elementelnum = EtementNext();Cross Link^ Programmer's ReferenceElementSetProp0SynopsisElementSetProp(A,Av,I)ElementSetProp(el_num,A,Av,I)el_num^- the element numberA^- the Area of element el_ num (returned)Av - the Shear Area of element el_num (returned)I^- the Moment of Inertia of el num (returned)RemarksElementSetProp() sets the sectional properties for the element. The first function set thesection properties of all selected elements. The second function sets the section propertiesfor element elnum.ExampleElementSetProp(el_num,A,Av,1);ElementHigh()SynopsisElementHigh()RemarksElementHigh() returns the number of the next available element number.Example// add an element but find out the next number we can usenum = ElementHigh();ElementPut(num,lonode,hinode,1D_FF);-110-Cross Link^ Programmer's ReferenceElementPut()SynopsisElementPut(el_el_numlonodehinodecodeRemarks- reference number for the element- the lower node number- the high node number- the fixity codenum,lonode,hinode,code)ElementPut add an element to the element database. The lonode and hinode numbers mustalready exist. The fixity codes precode into the system as follows:ID -PP- lonode Pinned, hinode PinnedID -FP- lonode Fixed, hinode PinnedID -PF- lonode Pinned, hinode FixedID FF- lonode Fixed, hinode FixedExample// generate parabolic line of nodes and elementsParabola(dx,dy,num1,num2,elnum)num1 = NodeHigh();// place the starting nodeNodePut(num1,0,0,ID_000);// generate the line at increments of 1000for(dx=1000.0; dx <= 11000.0; dx += 1000.)(num2 = NodeHigh();dy = 0.00008 * dx * dx;NodePut(num2,dx,dy,ID_000);// get the next available element number and add the elementelnum = ElementHigh();ElementPut(elnum,num1,num2,ID_FF);num1 = num2;Cross Link^ Programmer's ReferenceElementSelect()SynopsisElementSelect(el_num)ElementSelect(left,bottom,right,top)RemarksElementSelect selects an element. The first function selects an element by its number, el _num.The second function selects any elements inside a box with coordinates (left,bottom) to(right, top).ExampleElementSelect(1000,1000,5000,10000);ElementSelected()SynopsisElementSelected(el_num)RemarksElementSelected returns TRUE if if element el num is selected of FALSE otherwise.Example// see if element 12 is selectedif(ElementSelected(12) == TRUE)print("Element 12 is selected");elseprint("Element 12 is NOT selected");Cross Link^ Programmer's ReferenceElementToggleSelect()SynopsisElementToggleSelect()RemarksElementToggleSelect toggles selected and unselected elements in the element database.Example// erase element all UNselected elements using ToggleSelect()ElementToggleSelect();ElementErase();ElementUnSelect()SynopsisElementUnSelect()RemarksElementUnSelect unselects all selected elements in the element database.Example// unselect all the elementsElementUnSelect();-113-Cross Link^ Programmer's Reference3 EXAMPLE APPLICATIONSFollowing is the BOB source code for two sample applications3.1 Demonstration Program// ^// File:^DEMO.BOB// Description:^Demo of the BOB programming Language// Written By:^KME// Date:^Decenber 15, 1991//// Copyright (c) 1992, by Kevin Michael Elbury// ^main()C// start with a clean structureNew();print("Cross Link Demo Program - (demo.bob)");// set up the grid and limitsSetGrid(1000,1000,0,0,TRUE,TRUE);SetLimits(-1000,-1000,15000,12000);// perfom the demostrationCircle(3000.,5000.,3000.,20);SineWave(8000,5000,14000,5000,2000);// update the displayRepaint();// Circle()// %% Creates a circle out of node and elements with origin at x,y//Circle(x,y,radius,points; i,num1,num2,elnum,dx,dy,dt,theta,start)Cstart = num1 = NodeHigh();^// rememeber the first nodenum2 = 0;i=1;theta = dt = 2.0 * PI / points;NodePut(num1,x+radius,y,ID_000);while(i<points)ftheta = dt * i;dx = x + radius * cos(theta);dy = y + 1.30 * radius * sin(theta);I++;num2 = NodeHigh();NodePut(num2,dx,dy,ID_000);// get the next element numberelnum = ElementHigh();ElementPut(elnum,num1,num2,ID_FF);num1 = num2;)// add the elementElementPut(ElementHigh(),num2,start,ID_FF);Repaint();-114-Cross Link^ Programmer's Reference// SineWave()// X% Creates a sine wave out of node and elements with origin at xo,y0//^and ending at xf,yf. Amplitude of wave is A.//SineWave(xo,yo,xf,yf,A;num1,num2,spc,w,i,di,dx,dy)num1 = num2 = 0;di = 80;spc = (xf - xo)/ di;w = 12 * PI / (xf-xo);num1 = NodeHigh();NodePut(numl,xo,yo,ID_000);i = 1;dx = xo;while(dx < xf)(dx = xo + i * spc;dy = yo + A * sin(w * i * spc);I++;num2 = NodeHigh();NodePut(num2,dx,dy,ID_000);elnum = EtementHigh();ElementPut(elnum,num1,num2,ID_FF);num1 = num2;)-115-Cross Link^ Programmer's Reference3.2 ANSYS File TransfersANS-IN.BOBThe following program provides limited file compatability with the ANSYS finite element program.// ^// File:^ANS-IN.BOB// Description:^Imports an ANSYS script file into Cross Link// Written By:^KME// Date:^January 14, 1992//// Copyright (c) 1992, by Kevin Michael Elbury// ^main(; filename,line,tok,dx,dy)f// set this to the ANSYS file you wish to importfilename = "test.dat";delimit = ","; // field delimiter is a comma - global varfile = fopen(filename,"r");// read in first line and get the first token in the string...line = fread(file);tok = token(line,delimit);max_x = max_y = 3.4 * pow10(-38.0);^// smallest floating point number possiblemin_x = min_y = 3.4 * pow10(38.0);^// Largest ...// compare first tokenwhile(line)Cif(strcmp(tok,"N") == 0)readNode();else if(stromp(tok,"E") == 0)readElement();else if(strcmp(tok,"0") == 0)readBoundaryCond();elseprint("Ignoring command: ",tok);// read and tokenize next lineline = fread(file);if(line)tok = token(line,delimit););// add 30% margin to limitsdx = max_x - min_x;dy = max_y - min_y;dx *= 0.30;dy *= 0.30;minx -= dx;max_x += dx;min_y -= dy;max_y += dy;SetLimits(min_x,min_y,max_x,max_y);Repaint();// readNode()// %% continues parsing the ANSYS 'N'ode command and adds the node//^to the node database//// Format://^N,node_num,x_coord,y_coord//-116-Cross Link^ Programmer's ReferencereadNode( ;num,x,y)C// get the next token string and convert it to a numbernun = val(token(0,delimit));x = val(token(0,delimit));y = val(token(0,delimit));// add the node to the data baseNodePut(num,x,y,ID_000);// evaluate structure limitsmax_x = (x > max_x ? x : max_x);max_y = (y > max_y ? y : max_y);min_x = (x < min_x ? x : min_x);min_y = (y < min_y ? y : min_y);// readElement()// %% continues parsing the ANSYS 'E'Lement command//// Format://^E,lonode_num,hinode_num//readElement( ;Ionode,hinode,num)C// get the next token string and convert it to a numberlonode = val(token(0,delimit));hinode = val(token(0,delimit));num = ElementHigh();// add the node to the data baseElementPut(num,lonode,hinode,ID_FF);// readBoundaryCond()// %% Parses the ANSYS 'D'isplacement command .//^and sets the degrees of freedom on the associated nodes//// Format://^D,node_num,UX,disp(„„UY,ROTZ]//readBoundaryCond(;num,disp,dof,tok)C// get the next token string and convert it to a numbernun = val(token(0,delimit));tok = token(0,delimit);if(strcmp(tok,"UX") == 0)dof = ID_100;else if(strcmp(tok,"UY") == 0)dof = ID_010;else if(stromp(tok,"ROTZ") == 0)dof = ID_001;elseprint("Error: No support for dof - ",tok," on node ",nun);disp = val(token(0,delimit));if(disp > 0.0)print("Warning: Displacment > 0 on node ",num);// read in the rest of the degrees of freedomtok = token(0,delimit);while(tok)(if(strcmp(tok,"UX") == 0)dof = dof 1 ID_100;^/ bitwise .OR to add additional dofelse if(strcmp(tok,"UY") == 0)dof = dof 1 ID_010;-117-Cross Link^ Programmer's Referenceelse if(strcmp(tok,"ROTZ") == 0)dof^dof I ID 001;elseprint("Error: No support for dof - ",tok," on node ",num);tok = token(0,delimit);// add the node to the data baseNodeSetD0F(num,dof);Cross Link^ Programmer's ReferenceANS-OUT.BOB// ^// File:^ANS-OUT.BOB// Description:^Exports a Cross Link structure to ANSYS// Written By:^KME// Date:^January 14, 1992//// Copyright (c) 1992, by Kevin Michael Elbury// ^main(;file)Cfile = fopen("test.dat","w");// write a file header, go directly to PREP?fwrite(file,"! ^ \n");fwrite(file,"! - Cross Link to ANSYS Transfer -\n");fwrite(file,"!  \n");fwrite(file,"/PREP7\n");fwrite(file,"/TITLE Cross Link to ANSYS Transfer\n");// dump the data to 'file'writeNodes(file);writeElements(file);writeBoundaryCond(file);// close the filefclose(file);Speaker();)// writeNodes()// X% Extracts all node info from the database and dump to file in ANSYS format//// Format://^N,node_num,x_coord,y_coordwriteNodes(file;num,x,y)Cprint("Writing nodes...");fwrite(file,"! ^\n");fwrite(file,"! ***Node Data\n");fwrite(file,"! \n");nun = NodeFirst();while(num)Cx = NodeGetX(num);y = NodeGetY(nun);fwrite(file,"N,",num,",",x,",",y,"\n");nun = NodeNext();// writeElements()// X% Extracts all element info from the database and dump to file in ANSYS format//// Format://^EFlonode_nuv,hinode_nun//writeElements(file;num,lo,hi)Cprint("Writing elements...");fwrite(file,"! ^ \n");fwrite(file,"! ***Element Data\n");fwrite(file,"!  \n");nun = ElementFirst();-119-Cross Link^ Programmer's Referencewhile(num)(lo = ElementGetLoNode(num);hi = ElementGetHiNode(num);fwrite(file,"E,u,lo,li,u,hi,"\n");num = ElementNext();// readBoundaryCond()// %X Scans node database and extracts any boundary conditions in ANSYS format//// Format://^D,node_num,UX,disp(„„UY,ROTZ1 - (] optional//writeBoundaryCond(file;num,dof)Cprint("Writing BC's...");fwrite(file,"! ^ \nu);fwrite(file,"! ***Boundary Conditions \n");fwrite(file,"! \nu);num = NodeFirst();while(num)(dof = NodeGetD0F(num);if(dof == ID_100)fwrite(file,"D,u,num,H,UX,0.0\n");if(dof == 1D_110)fwrite(file,"0,",num,u,UX,0.0,„,UY\n");else if(dof == 1D_111)fwrite(file,"D,",num,",UX,0.0„„UY,ROTZ\n");else if(dof == ID_101)fwrite(file,flD,",num,u,UX,O.0„„ROTZ\n");else if(dof == 1D_001)fwrite(file,"0,",num,",ROTZ,0.0\n");else if(dof == 10_010)fwrite(file,"D,",num,",UY,0.0\n");else if(dof == 1D_011)fwrite(filefuD,u,num,H,UY,0.0,„,ROTZ\n");num = NodeNext();-120-

Cite

Citation Scheme:

    

Usage Statistics

Country Views Downloads
Canada 7 0
China 5 4
India 3 0
United States 2 2
Tanzania 2 3
Russia 1 0
United Kingdom 1 0
Algeria 1 0
Japan 1 0
City Views Downloads
Unknown 7 8
Surrey 6 0
Beijing 5 0
Ashburn 2 0
Chennai 1 0
Victoria 1 0
Tokyo 1 0

{[{ mDataHeader[type] }]} {[{ month[type] }]} {[{ tData[type] }]}
Download Stats

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.831.1-0050472/manifest

Comment

Related Items