C_GetDiffractionOutput

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 Nh The wave headings as specified in the environment data. Nh, the number of wave headings, can be obtained using the "NumberOfWaveHeadings" data name.
dotFrequencies double Nf The wave frequencies as specified in the environment data. Nf, the number of wave periods or frequencies, can be obtained using the "NumberOfPeriodsOrFrequencies" data name.
dotAngularFrequencies double Nf The same information as dotFrequencies, but reported as angular frequencies.
dotPeriods double Nf The same information as dotFrequencies, but reported as periods.
dotPeriodsOrFrequencies double Nf 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 Nb The values are the hydrostatic results for each included body. Nb is the number of included bodies specified in the body data. This can be obtained using the "NumberOfIncludedBodies" data name.
dotAddedMass double Nf, Ndof, Ndof The frequency dependent added mass matrices. Ndof is the total number of degrees of freedom, equal to 6Nb.
dotInfiniteFrequencyAddedMass double Ndof, Ndof The infinite frequency added mass matrix.
dotDamping double Nf, Ndof, Ndof The frequency dependent damping matrices.
dotLoadRAOsHaskind TComplex Nh, Nf, Ndof The load RAOs calculated by the Haskind method.
dotLoadRAOsDiffraction TComplex Nh, Nf, Ndof The load RAOs calculated by the diffraction method.
dotDisplacementRAOs TComplex Nh, Nf, Ndof The displacement RAOs
dotMeanDriftHeadingPairs double[2] Nmh The pairs of headings for which mean drift results are reported. The value of Nmh can be inferred from the required size of the output, see below.
dotQTFHeadingPairs double[2] Nqh The pairs of headings for which QTF results are reported. The value of Nqh can be inferred from the required size of the output, see below.
dotQTFFrequencies double[3] Nqf 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. Nqf can be inferred from the required size of the output, see below.
dotQTFAngularFrequencies double[3] Nqf The same information as dotQTFFrequencies, but reported as angular frequencies.
dotQTFPeriods double[3] Nqf The same information as dotQTFFrequencies, but reported as periods.
dotQTFPeriodsOrFrequencies double[3] Nqf 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 Nmh, Nf, Ndof The mean drift loads, calculated by the pressure integration method.
dotMeanDriftLoadControlSurface TComplex Nmh, Nf, Ndof The mean drift loads, calculated by the control surface method.
dotMeanDriftLoadMomentumConservation TComplex Nmh, Nf, 6 The mean drift loads, calculated by the momentum conservation method.
dotFieldPointPressure TComplex Nh, Nf, Nfp The field point pressures. Nfp, the number of field points, can be obtained using the "NumberOfFieldPoints" data name.
dotFieldPointRAO TComplex Nh, Nf, Nfp The field point RAOs.
dotFieldPointVelocity TComplex[3] Nh, Nf, Nfp The field point velocities.
dotFieldPointRAOGradient TComplex[3] Nh, Nf, Nfp The field point RAO gradients.
dotPanelCount int 1 The number of panels, Np, for which panel results are available.
dotPanelGeometry TDiffractionPanelGeometry Np The panel geometry information of the panels for which panel results are available. Np is the number of panels, obtained using the dotPanelCount output type.
dotPanelPressure TComplex Nh, Nf, Np The panel pressures.
dotPanelPressureDiffraction TComplex Nh, Nf, Np The contributions from the diffraction potential to panel pressure.
dotPanelPressureRadiation TComplex Ndof, Nf, Np The contributions from the radiation potentials to panel pressure.
dotPanelVelocity TComplex[3] Nh, Nf, Np The panel velocities.
dotPanelVelocityDiffraction TComplex[3] Nh, Nf, Np The contributions from the diffraction potential to panel velocity.
dotPanelVelocityRadiation TComplex[3] Ndof, Nf, Np The contributions from the radiation potentials to panel velocity.
dotQuadraticLoadFromPressureIntegration TComplex Nqh, Nqf, Ndof The quadratic load results calculated by the pressure integration method.
dotQuadraticLoadFromControlSurface TComplex Nqh, Nqf, Ndof The quadratic load results calculated by the control surface method.
dotDirectPotentialLoad TComplex Nqh, Nqf, Ndof The potential load results calculated by the direct method.
dotIndirectPotentialLoad TComplex Nqh, Nqf, Ndof The potential load results calculated by the indirect method.
dotExtraRollDamping double Nb The extra roll damping calculated to meet a target percentage of critical.
dotRollDampingPercentCritical double Nf, Nb 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 Nmh 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.