C_GetDiffractionOutput

dummy link for benefit of anchor linked from external source

Call C_GetDiffractionOutput to obtain the results of a diffraction calculation.

void C_GetDiffractionOutput(

TOrcFxAPIHandle DiffractionHandle,

int OutputType,

int *lpOutputSize,

void *lpOutput,

int *lpStatus

);

Parameters

DiffractionHandle (IN)

The diffraction handle returned by C_CreateDiffraction.

OutputType (IN)

Specifies which type of output is obtained. The available output types are listed below.

lpOutputSize (IN/OUT)

Points to a variable containing the output buffer size. On input this must be set to the size of output buffer provided by the caller in lpOutput. On output the function sets this variable to the required size of the output buffer.

If the results are not available, usually because the calculation data meant they have not been calculated, the output size is set to 0.

lpOutput (OUT)

Pointer to the output buffer, which is allocated by the caller. To determine the required size of the output buffer, make two calls C_GetDiffractionOutput:

int OutputSize = 0;

int Status;

C_GetDiffractionOutput(DiffractionHandle, OutputType, &OutputSize, NULL, &Status);

unsigned char *lpOutput = new unsigned char[OutputSize];

C_GetDiffractionOutput(DiffractionHandle, OutputType, &OutputSize, lpOutput, &Status);

// use lpOutput

delete[] lpOutput;

Note that, for the sake of brevity, error checking has been omitted from the above code.

lpStatus (OUT)

Points to a variable in which the status result for the function call will be returned.

Remarks

Output format

The output is a multidimensional array, in row-major order. Each output type is listed in the table below, together with the array base type and dimensions.

Output type Base type Dimensions          Description / notes
dotHeadings double $N_h$ The wave headings as specified in the environment data. $N_h$, the number of wave headings, can be obtained using the "NumberOfWaveHeadings" data name.
dotFrequencies double $N_f$ The wave frequencies as specified in the environment data. $N_f$, the number of wave periods or frequencies, can be obtained using the "NumberOfPeriodsOrFrequencies" data name.
dotAngularFrequencies double $N_f$ The same information as dotFrequencies, but reported as angular frequencies.
dotPeriods double $N_f$ The same information as dotFrequencies, but reported as periods.
dotPeriodsOrFrequencies double $N_f$ The same information as dotFrequencies, but reported as periods, frequencies or angular frequencies. Whether the values are periods, frequencies or angular frequencies is determined by the environment data waves are referred to by.
dotHydrostaticResults TDiffractionBodyHydrostaticInfo $N_b$ The values are the hydrostatic results for each included body. $N_b$ is the number of included bodies specified in the body data. This can be obtained using the "NumberOfIncludedBodies" data name.
dotAddedMass double $N_f$, $N_\textrm{dof}$, $N_\textrm{dof}$ The frequency dependent added mass matrices. $N_\textrm{dof}$ is the total number of degrees of freedom, equal to 6$N_b$.
dotInfiniteFrequencyAddedMass double $N_\textrm{dof}$, $N_\textrm{dof}$ The infinite frequency added mass matrix.
dotDamping double $N_f$, $N_\textrm{dof}$, $N_\textrm{dof}$ The frequency dependent damping matrices.
dotLoadRAOsHaskind TComplex $N_h$, $N_f$, $N_\textrm{dof}$ The load RAOs calculated by the Haskind method.
dotLoadRAOsDiffraction TComplex $N_h$, $N_f$, $N_\textrm{dof}$ The load RAOs calculated by the diffraction method.
dotDisplacementRAOs TComplex $N_h$, $N_f$, $N_\textrm{dof}$ The displacement RAOs
dotMeanDriftHeadingPairs double[2] $N_{mh}$ The pairs of headings for which mean drift results are reported. The value of $N_{mh}$ can be inferred from the required size of the output, see below.
dotQTFHeadingPairs double[2] $N_{qh}$ The pairs of headings for which QTF results are reported. The value of $N_{qh}$ can be inferred from the required size of the output, see below.
dotQTFFrequencies double[3] $N_{qf}$ The frequencies at which QTF results are reported. The first two values are a pair of wave frequencies. The third value is either the difference frequency or the sum frequency associated with the first two values. $N_{qf}$ can be inferred from the required size of the output, see below.
dotQTFAngularFrequencies double[3] $N_{qf}$ The same information as dotQTFFrequencies, but reported as angular frequencies.
dotQTFPeriods double[3] $N_{qf}$ The same information as dotQTFFrequencies, but reported as periods.
dotQTFPeriodsOrFrequencies double[3] $N_{qf}$ The same information as dotQTFFrequencies, but reported as periods, frequencies or angular frequencies. Whether the values are periods, frequencies or angular frequencies is determined by the environment data waves are referred to by.
dotMeanDriftLoadPressureIntegration TComplex $N_{mh}$, $N_f$, $N_\textrm{dof}$ The mean drift loads, calculated by the pressure integration method.
dotMeanDriftLoadControlSurface TComplex $N_{mh}$, $N_f$, $N_\textrm{dof}$ The mean drift loads, calculated by the control surface method.
dotMeanDriftLoadMomentumConservation TComplex $N_{mh}$, $N_f$, 6 The mean drift loads, calculated by the momentum conservation method.
dotFieldPointPressure TComplex $N_h$, $N_f$, $N_{fp}$ The field point pressures. $N_{fp}$, the number of field points, can be obtained using the "NumberOfFieldPoints" data name.
dotFieldPointRAO TComplex $N_h$, $N_f$, $N_{fp}$ The field point RAOs.
dotFieldPointVelocity TComplex[3] $N_h$, $N_f$, $N_{fp}$ The field point velocities.
dotFieldPointRAOGradient TComplex[3] $N_h$, $N_f$, $N_{fp}$ The field point RAO gradients.
dotPanelCount int 1 The number of panels, $N_p$, for which panel results are available.
dotPanelGeometry TDiffractionPanelGeometry $N_p$ The panel geometry information of the panels for which panel results are available. $N_p$ is the number of panels, obtained using the dotPanelCount output type.
dotPanelPressure TComplex $N_h$, $N_f$, $N_p$ The panel pressures.
dotPanelPressureDiffraction TComplex $N_h$, $N_f$, $N_p$ The contributions from the diffraction potential to panel pressure.
dotPanelPressureRadiation TComplex $N_\textrm{dof}$, $N_f$, $N_p$ The contributions from the radiation potentials to panel pressure.
dotPanelVelocity TComplex[3] $N_h$, $N_f$, $N_p$ The panel velocities.
dotPanelVelocityDiffraction TComplex[3] $N_h$, $N_f$, $N_p$ The contributions from the diffraction potential to panel velocity.
dotPanelVelocityRadiation TComplex[3] $N_\textrm{dof}$, $N_f$, $N_p$ The contributions from the radiation potentials to panel velocity.
dotPanelPotentialInfiniteFrequencyRadiation double $N_\textrm{dof}$, $N_p$ The velocity potential, per panel, of the infinite-frequency radiation potentials.
dotQuadraticLoadFromPressureIntegration TComplex $N_{qh}$, $N_{qf}$, $N_\textrm{dof}$ The quadratic load results calculated by the pressure integration method.
dotQuadraticLoadFromControlSurface TComplex $N_{qh}$, $N_{qf}$, $N_\textrm{dof}$ The quadratic load results calculated by the control surface method.
dotDirectPotentialLoad TComplex $N_{qh}$, $N_{qf}$, $N_\textrm{dof}$ The potential load results calculated by the direct method.
dotIndirectPotentialLoad TComplex $N_{qh}$, $N_{qf}$, $N_\textrm{dof}$ The potential load results calculated by the indirect method.
dotExtraRollDamping double $N_b$ The extra roll damping calculated to meet a target percentage of critical.
dotRollDampingPercentCritical double $N_f$, $N_b$ The total roll damping expressed as a percentage of the critical damping coefficient.

Dimensions

Unless an alternative method is documented above, the dimensions should be inferred from the required array size. For example, consider the dotMeanDriftHeadingPairs output type. The value of $N_{mh}$ can be inferred like this:

int OutputSize = 0;

int Status;

C_GetDiffractionOutput(DiffractionHandle, dotMeanDriftHeadingPairs, &OutputSize, NULL, &Status);

int Nmh = OutputSize / sizeof(double[2]);

Note that, for the sake of brevity, error checking has been omitted from the above code.

Dimensions for output types with struct base types

Output types that are arrays of struct require special consideration. Because these structs may be extended in future release, your code should account for that possibility if it is to be compatible with future releases of the OrcFxAPI DLL.

The output types that are subject to such considerations are dotHydrostaticResults and dotPanelGeometry. For these output types you must find the array length ($N$) as documented in the output format table, and the required array size ($S$). The struct size can then be determined as $S / N$. For example (again with error checking omitted):

int OutputSize = 0;

int Status;

C_GetDiffractionOutput(DiffractionHandle, dotHydrostaticResults, &OutputSize, NULL, &Status);

int Nb;

C_GetDataInteger(DiffractionHandle, L"NumberOfIncludedBodies", -1, &Nb, &Status);

int StructSize = OutputSize / Nb;

if (StructSize < sizeof(TDiffractionBodyHydrostaticInfo))

// incompatible version, handle error

 

unsigned char *lpOutput = new unsigned char[OutputSize];

C_GetDiffractionOutput(DiffractionHandle, dotHydrostaticResults, &OutputSize, lpOutput, &Status);

for (int i = 0; i < Nb; i++) {

TDiffractionBodyHydrostaticInfo* lpItem = static_cast<TDiffractionBodyHydrostaticInfo*>(lpOutput[i * StructSize]);

// use *lpItem

}

delete[] lpOutput;

See also

C_TranslateDiffractionOutput.