|
|
Native external function examples: Line stress external result |
This topic is intended to be read in conjunction with the main external function documentation, and the example source code.
This ZIP file contains all of the native external function examples, with each example contained in the appropriately named sub-folder.
This example uses the track calculation feature of the bend stiffness variable data source to provide a custom line stress component result. The track calculation feature allows an external function access to a line node's instantaneous calculation data without incurring the performance expense of having to implement bend stiffness within the external function. The external function is specified as a tracking function in the bend stiffness data source on the variable data form.
The custom stress component result calculated by this example allows the user to specify tension and curvature stress factors as well as the component angle.
The OrcaFlex data file for this example is LineStressExternalResult.dat. The model is very simple, a fifty segment line connected to a vessel. The line type uses a variable Bend stiffness called Stiffness1 which is a simple Curvature/Bend Moment table, but has an associated external function called Line Stress Factors. In turn, Line Stress Factors is used to call the external function LineStressExternalResult in the LineStressExternalResult.dll.
Initialisation consists of instantiating a data class called CNodeHalfSegmentData. This data class instance gives the external function a persistent store for recording instantaneous curvature values for use during the calculation. We also use this data class to store away some calculated values that remain constant for the duration of the simulation. ArcLength is the arc length along the line associated with this instance of the external function and SegmentIn is a bool that is true if we are the external function instance associated with the in side of the segment. The initialisation function is called twice for each segment, once for the in half and then again for the out half.
The eaFinalise action is called for each external function instance (twice for each segment – in and out) where we delete the CNodeHalfSegmentData instance created during eaInitialise action.
The eaTrackCalculation action is called once per log interval, but before the calls to eaLogResultCreate/eaLogResultDestroy. This action is passed the instantaneous data for the half segment in the info.InstantaneousCalculationData field. The incoming or outgoing curvature at our associated node is saved within this action.
In the eaRegisterResults action our single result is registered when the helper function RegisterResult is called. We supply the result name, External Stress, the units to appear in OrcaFlex and an ID which OrcaFlex uses to refer to this result. Although this method will be called once for each instance, OrcaFlex only permits unique result IDs and ignores duplicate registrations.
In the eaLogResultCreate action we query the model to obtain the wall tension at the half segment arc length. The accumulated curvature and wall tension data are logged with OrcaFlex by setting the info.lpLogData and info.lpLogDataLength fields to point to a temporary LogResult structure. This allocated LogResult memory is deleted within the eaLogResultDestroy action.
Results are also made available from our dynamic positioning external function example. In that code, the allocation of memory was managed only in initialise and finalise actions, so the log result actions could be a little simpler. If results are of particular interest, refer also to that example.
When requesting this result from OrcaFlex, the user can specify stress concentration factors for tension and curvature, and an angular position. These parameters are passed into the eaDeriveResult action in the info.lpObjectExtra.ExternalResultText property.
The external result text is expected to be a valid JSON string, and parsing that string is done using a library that you can find in the included source files for this example.
The parameter text specifying a tension and stress factor of 10 and 250e3 respectively with a theta of 30 degrees would be represented in the external result text as:
{"w": 10, "c": 250e3, "t": 30}
An externally calculated result variable can be consumed by the OrcaFlex fatigue module. This allows you to define a bespoke stress result variable in your external function and let OrcaFlex calculate and collate fatigue damage.
An example of this can be found in the fatigue file ExternallyCalculatedStress.ftg. In order to carry out the fatigue analysis you need to create a load case simulation file. This is based on LineStressExternalResult.dat and so you will need to generate a dynamic OrcaFlex simulation file based on that data file.
Once you have generated the simulation file, open the .ftg file in the OrcaFlex fatigue module. Note that the damage calculation data is set to externally calculated stress. This is the setting that determines that an external results variable will be used.
Now switch to the Components page. This is very similar to the input data for stress factor fatigue. Indeed, the form of our external result was chosen so that we can compare against the built-in stress factor fatigue option.
The stress result data item is External Stress, i.e. the name of our external result variable. The component name data item is used to specify the external result text. In our example file this is:
{"w": 10, "c": 250e3, "t": %theta%}
This text is parsed as JSON, in the same way as described above. However, note that we use the special symbol %theta% rather than specifying a fixed value. The reason being that OrcaFlex extracts multiple stress results, at different circumferential points, at each arc length along the line. When OrcaFlex calls the external function it replaces %theta% with the true theta value, in degrees, and then calls the eaDeriveResult action.
You can now calculate the fatigue for this input data and view results just as you would for any other OrcaFlex damage calculation.
Now switch the Damage Calculation to Stress factors. Note that the data has been setup to match that which we used for externally calculated stress. The tension stress factor is 10 and the curvature stress factor is 250e3. You can calculate fatigue now and confirm that the results are the same as we obtained using externally calculated stress.
One final point to make is that fatigue analysis is one of the most demanding calculations that OrcaFlex performs. Using externally calculated stress can lead to slower performance of the fatigue calculation.