OpenFAST
Wind turbine multiphysics simulator
Functions
mapapi.c File Reference

NWTC required functions necessary to hook MAP into FAST. More...

#include "map.h"
#include "maperror.h"
#include "MAP_Types.h"
#include "mapapi.h"
#include "lineroutines.h"
#include "freedata.h"
#include "mapinit.h"
#include "outputstream.h"
#include "numeric.h"
#include "jacobian.h"
#include "residual.h"
Include dependency graph for mapapi.c:

Functions

MAP_EXTERNCALL void map_initialize_msqs_base (MAP_InputType_t *u_type, MAP_ParameterType_t *p_type, MAP_ContinuousStateType_t *x_type, MAP_ConstraintStateType_t *z_type, MAP_OtherStateType_t *other_type, MAP_OutputType_t *y_type, MAP_InitOutputType_t *io_type)
 Initalizes all MAP base types (including some internal state) More...
 
MAP_EXTERNCALL void map_init (MAP_InitInputType_t *init_type, MAP_InputType_t *u_type, MAP_ParameterType_t *p_type, MAP_ContinuousStateType_t *x_type, MAP_DiscreteStateType_t *xd_type, MAP_ConstraintStateType_t *z_type, MAP_OtherStateType_t *other_type, MAP_OutputType_t *y_type, MAP_InitOutputType_t *io_type, MAP_ERROR_CODE *ierr, char *map_msg)
 Initializes the MAP model and allocates memory. More...
 
MAP_EXTERNCALL void map_update_states (float t, int interval, MAP_InputType_t *u_type, MAP_ParameterType_t *p_type, MAP_ContinuousStateType_t *x_type, MAP_DiscreteStateType_t *xd_type, MAP_ConstraintStateType_t *z_type, MAP_OtherStateType_t *other_type, MAP_ERROR_CODE *ierr, char *map_msg)
 Solves the statics problem for the MSQS system and should be called at each time step or vessel displacement. More...
 
MAP_EXTERNCALL void map_calc_output (float t, MAP_InputType_t *u_type, MAP_ParameterType_t *p_type, MAP_ContinuousStateType_t *x_type, MAP_DiscreteStateType_t *xd_type, MAP_ConstraintStateType_t *z_type, MAP_OtherStateType_t *other_type, MAP_OutputType_t *y_type, MAP_ERROR_CODE *ierr, char *map_msg)
 Retrieves the values after the statics problem is solved. More...
 
MAP_EXTERNCALL void map_end (MAP_InputType_t *u_type, MAP_ParameterType_t *p_type, MAP_ContinuousStateType_t *x_type, MAP_DiscreteStateType_t *xd_type, MAP_ConstraintStateType_t *z_type, MAP_OtherStateType_t *other_type, MAP_OutputType_t *y_type, MAP_ERROR_CODE *ierr, char *map_msg)
 Deallocates all memory. More...
 
MAP_EXTERNCALL void map_offset_vessel (MAP_OtherStateType_t *other_type, MAP_InputType_t *u_type, double x, double y, double z, double phi, double the, double psi, char *map_msg, MAP_ERROR_CODE *ierr)
 call this in python: offset_vessel().argtypes = [MapData_Type, MapInput_Type, c_char_p, POINTER(c_int)] angles are radians More...
 
MAP_EXTERNCALL double * map_f_op (MAP_InputType_t *u_type, MAP_ParameterType_t *p_type, MAP_OtherStateType_t *other_type, MAP_OutputType_t *y_type, MAP_ConstraintStateType_t *z_type, MAP_ERROR_CODE *ierr, char *map_msg)
 lib.map_f_op.argtypes = [MapInput_Type, MapData_Type, MapOutnput_Type, c_double, c_char_p, POINTER(c_int)]
 
MAP_EXTERNCALL void map_free_f_op (double *array)
 lib.map_free_f_op.argtypes = [POINTER(c_double)]
 
MAP_EXTERNCALL double ** map_linearize_matrix (MAP_InputType_t *u_type, MAP_ParameterType_t *p_type, MAP_OtherStateType_t *other_type, MAP_OutputType_t *y_type, MAP_ConstraintStateType_t *z_type, double epsilon, MAP_ERROR_CODE *ierr, char *map_msg)
 lib.linearize_matrix.argtypes = [MapInput_Type, MapData_Type, MapOutnput_Type, c_double, c_char_p, POINTER(c_int)]
 
MAP_EXTERNCALL void map_free_linearize_matrix (double **array)
 lib.py_free_linearize_matrix.argtypes = [POINTER(POINTER(c_double))]
 
MAP_EXTERNCALL double * map_plot_x_array (MAP_OtherStateType_t *other_type, int i, int num_points, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL double * map_plot_y_array (MAP_OtherStateType_t *other_type, int i, int num_points, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL double * map_plot_z_array (MAP_OtherStateType_t *other_type, int i, int num_points, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL void map_plot_array_free (double *array)
 
MAP_EXTERNCALL double map_residual_function_length (MAP_OtherStateType_t *other_type, int i, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL double map_residual_function_height (MAP_OtherStateType_t *other_type, int i, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL double map_jacobian_dxdh (MAP_OtherStateType_t *other_type, int i, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL double map_jacobian_dxdv (MAP_OtherStateType_t *other_type, int i, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL double map_jacobian_dzdh (MAP_OtherStateType_t *other_type, int i, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL double map_jacobian_dzdv (MAP_OtherStateType_t *other_type, int i, char *map_msg, MAP_ERROR_CODE *ierr)
 
MAP_EXTERNCALL void map_get_fairlead_force_2d (double *H, double *V, MAP_OtherStateType_t *other_type, int index, char *map_msg, MAP_ERROR_CODE *ierr)
 Returns vertical and horizontal fairlead force along line plane. More...
 
MAP_EXTERNCALL void map_get_fairlead_force_3d (double *fx, double *fy, double *fz, MAP_OtherStateType_t *other_type, int index, char *map_msg, MAP_ERROR_CODE *ierr)
 Returns X, Y, and Z fairlead force in global reference frame. More...
 
MAP_EXTERNCALL int map_size_lines (MAP_OtherStateType_t *other_type, MAP_ERROR_CODE *ierr, char *map_msg)
 
MAP_EXTERNCALL void map_set_summary_file_name (MAP_InitInputType_t *init_type, char *map_msg, MAP_ERROR_CODE *ierr)
 Set the name out the MAP summary output file. More...
 
MAP_EXTERNCALL void map_get_header_string (int *n, char **str_array, MAP_OtherStateType_t *other_type)
 Obtains the variable name array corresponding to the outputs selected in the MAP input file. More...
 
MAP_EXTERNCALL void map_get_unit_string (int *n, char **str_array, MAP_OtherStateType_t *other_type)
 Obtains the units of the outputs passed back to the calling program. More...
 
MAP_EXTERNCALL void set_init_to_null (MAP_InitInputType_t *init_type, char *map_msg, MAP_ERROR_CODE *ierr)
 Fortran binding routine SUBROUTINE MAP_set_initinput_to_null(interf,msg,err) bind(C,name='set_init_to_null')
 
MAP_EXTERNCALL void map_set_sea_depth (MAP_ParameterType_t *p_type, const double depth)
 Set the water depth. More...
 
MAP_EXTERNCALL void map_set_sea_density (MAP_ParameterType_t *p_type, const double rho)
 Set the water density. More...
 
MAP_EXTERNCALL void map_set_gravity (MAP_ParameterType_t *p_type, const double gravity)
 Set the gravitational constant. More...
 
MAP_EXTERNCALL void map_add_cable_library_input_text (MAP_InitInputType_t *init_type)
 
MAP_EXTERNCALL void map_add_node_input_text (MAP_InitInputType_t *init_type)
 
MAP_EXTERNCALL void map_add_line_input_text (MAP_InitInputType_t *init_type)
 
MAP_EXTERNCALL void map_add_options_input_text (MAP_InitInputType_t *init_type)
 
MAP_EXTERNCALL InitializationDataMAP_InitInput_Create (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate InitializationData. More...
 
MAP_EXTERNCALL MAP_InitInputType_tmap_create_init_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_InitInputType_t and InitializationData. More...
 
MAP_EXTERNCALL DomainMAP_OtherState_Create (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate Domain. More...
 
MAP_EXTERNCALL MAP_OtherStateType_tmap_create_other_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_OtherStateType_t and Domain. More...
 
MAP_EXTERNCALL MAP_InitOutputType_tmap_create_initout_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_InitOutputType_t. More...
 
MAP_EXTERNCALL MAP_InputType_tmap_create_input_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_InputType_t. More...
 
MAP_EXTERNCALL MAP_ParameterType_tmap_create_parameter_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_ParameterType_t. More...
 
MAP_EXTERNCALL MAP_ConstraintStateType_tmap_create_constraint_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_ConstraintType_t. More...
 
MAP_EXTERNCALL MAP_OutputType_tmap_create_output_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_OutputType_t. More...
 
MAP_EXTERNCALL MAP_ContinuousStateType_tmap_create_continuous_type (char *map_msg, MAP_ERROR_CODE *ierr)
 Allocate MAP_ContinuousStateType_t. More...
 
MAP_EXTERNCALL int free_init_data (InitializationData *init_data, char *map_msg, MAP_ERROR_CODE *ierr)
 Deallocates the memory space for the init structure. More...
 

Detailed Description

NWTC required functions necessary to hook MAP into FAST.

These functions provide the binding to solve constraints for subsequent time-steps.

Function Documentation

◆ free_init_data()

MAP_EXTERNCALL int free_init_data ( InitializationData init,
char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Deallocates the memory space for the init structure.

Should be called immediately after map_init()

Parameters
initMAP-native initialization data structure. This is distinct from the FAST-framework data structure
map_msgerror string
ierrerror code
Returns
MAP_SAFE if it completes successfully
See also
map_init()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ map_calc_output()

MAP_EXTERNCALL void map_calc_output ( float  t,
MAP_InputType_t u_type,
MAP_ParameterType_t p_type,
MAP_ContinuousStateType_t x_type,
MAP_DiscreteStateType_t xd_type,
MAP_ConstraintStateType_t z_type,
MAP_OtherStateType_t other_type,
MAP_OutputType_t y_type,
MAP_ERROR_CODE *  ierr,
char *  map_msg 
)

Retrieves the values after the statics problem is solved.

This function should be called immediately after map_update_states. Can be called multiple times, but must be called between map_init() and map_end()

Parameters
tcurrent (global) time
u_typeinput type, F2C FAST-native derived type.
p_typeparameter type, F2C FAST-native derived type
x_typecontinuous-state type, F2C FAST-native derived type
nonevoid type. It exists because MAP does not use discrete types (it would fill this place otherwise)
z_typeconstraint-state type, F2C FAST-native derived tpe
other_typeother-state type, F2C FAST-native derived type. This is core structure that houses all internal MAP states that cannot be mapped to Fortran
y_typeoutput type, F2C FAST-native derived type
ierrerror code
map_msgerror string
See also
map_update_states()
Here is the call graph for this function:

◆ map_create_constraint_type()

MAP_EXTERNCALL MAP_ConstraintStateType_t* map_create_constraint_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_ConstraintType_t.

Called to allocate memory for the constraint type. Constraints are variables solved through an algebraic equation. This is fairlead end forces (H and V) and node positions. This function is a necessary call for C and python, but can be ignored for Fortran if the MAP template is followed (that is, ISO C Binding is followed in the mapping of Fortran type and C structures).

Parameters
map_msg,errormessage
ierr,errorcode
Returns
constraint type (equivalent C binding struct)

◆ map_create_continuous_type()

MAP_EXTERNCALL MAP_ContinuousStateType_t* map_create_continuous_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_ContinuousStateType_t.

Called to allocate memory for the coninuous type. Not currently used, but it still is required to be allocated for FAST consistentcy.

Parameters
map_msg,errormessage
ierr,errorcode
Returns
continuous type (equivalent C binding struct)

◆ map_create_init_type()

MAP_EXTERNCALL MAP_InitInputType_t* map_create_init_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_InitInputType_t and InitializationData.

Called to allocate memory for the initialzation data for both the Fortran derived data and internal state data. Following sucessful allocation, initialize_init_type_to_null and initialize_init_data_to_null are both called to nullify data. If not called, memory errors results. This should the first function called when interacting with MAP. This is a necessary function for interaction with python and C based programs

Parameters
map_msg,errormessage
ierr,errorcode
Returns
initialization input type (equivalent C binding struct)
Here is the call graph for this function:

◆ map_create_initout_type()

MAP_EXTERNCALL MAP_InitOutputType_t* map_create_initout_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_InitOutputType_t.

Called to allocate memory for the initialization output type. The only obligation of this struct is to store the program version, necessary for FAST. This function is a necessary call for C and python, but can be ignored for Fortran if the MAP template is followed (that is, ISO C Binding is followed in the mapping of Fortran type and C structures).

Parameters
map_msg,errormessage
ierr,errorcode
Returns
initialization output type (equivalent C binding struct)

◆ map_create_input_type()

MAP_EXTERNCALL MAP_InputType_t* map_create_input_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_InputType_t.

Called to allocate memory for the input type. The program inputs are the fairlead displacement due to the motion of the vessel the cable are attached to. This function is a necessary call for C and python, but can be ignored for Fortran if the MAP template is followed (that is, ISO C Binding is followed in the mapping of Fortran type and C structures).

Parameters
map_msg,errormessage
ierr,errorcode
Returns
input type (equivalent C binding struct)

◆ map_create_other_type()

MAP_EXTERNCALL MAP_OtherStateType_t* map_create_other_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_OtherStateType_t and Domain.

Called to allocate memory for the other states for both the Fortran derived data and internal state data. This is a necessary function for interaction with python and C based programs. The

Parameters
map_msg,errormessage
ierr,errorcode
Returns
other state type (equivalent C binding struct)
Here is the call graph for this function:

◆ map_create_output_type()

MAP_EXTERNCALL MAP_OutputType_t* map_create_output_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_OutputType_t.

Called to allocate memory for the output type. IMPORTANT: this is different from the OutList. Output types are forces at the line fairlead only for lines connecting to the vessel. This function is a necessary call for C and python, but can be ignored for Fortran if the MAP template is followed (that is, ISO C Binding is followed in the mapping of Fortran type and C structures).

Parameters
map_msg,errormessage
ierr,errorcode
Returns
output type (equivalent C binding struct)

◆ map_create_parameter_type()

MAP_EXTERNCALL MAP_ParameterType_t* map_create_parameter_type ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate MAP_ParameterType_t.

Called to allocate memory for the parameter type. Parameters are time-invariant constants, such as gravitational constant. This function is a necessary call for C and python, but can be ignored for Fortran if the MAP template is followed (that is, ISO C Binding is followed in the mapping of Fortran type and C structures).

Parameters
map_msg,errormessage
ierr,errorcode
Returns
parameter type (equivalent C binding struct)

◆ map_end()

MAP_EXTERNCALL void map_end ( MAP_InputType_t u_type,
MAP_ParameterType_t p_type,
MAP_ContinuousStateType_t x_type,
MAP_DiscreteStateType_t xd_type,
MAP_ConstraintStateType_t z_type,
MAP_OtherStateType_t other_type,
MAP_OutputType_t y_type,
MAP_ERROR_CODE *  ierr,
char *  map_msg 
)

Deallocates all memory.

Must be called after map_init(). This is called once.

Parameters
u_typeinput type, F2C FAST-native derived type.
p_typeparameter type, F2C FAST-native derived type
x_typecontinuous-state type, F2C FAST-native derived type
nonevoid type. It exists because MAP does not use discrete types (it would fill this place otherwise)
z_typeconstraint-state type, F2C FAST-native derived tpe
other_typeother-state type, F2C FAST-native derived type. This is core structure that houses all internal MAP states that cannot be mapped to Fortran
y_typeoutput type, F2C FAST-native derived type
ierrerror code
map_msgerror string
See also
map_update_states()

◆ map_get_fairlead_force_2d()

MAP_EXTERNCALL void map_get_fairlead_force_2d ( double *  H,
double *  V,
MAP_OtherStateType_t other_type,
int  index,
char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Returns vertical and horizontal fairlead force along line plane.

Parameters
H,referenceto horizontal fairlead force magnitude
V,referenceto vertical fairlead force magnitude
other_type,otherstate type fortran derived
index,linenumber we are requesting the data for
map_msg,errormessage
ierr,errorcode
See also

◆ map_get_fairlead_force_3d()

MAP_EXTERNCALL void map_get_fairlead_force_3d ( double *  fx,
double *  fy,
double *  fz,
MAP_OtherStateType_t other_type,
int  index,
char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Returns X, Y, and Z fairlead force in global reference frame.

Parameters
fx,referenceto horizontal X fairlead force in global frame
fy,referenceto horizontal Y fairlead force in global frame
fz,referenceto vertical Z fairlead force in global frame
other_type,otherstate type fortran derived
index,linenumber we are requesting the data for
map_msg,errormessage
ierr,errorcode
See also

◆ map_get_header_string()

MAP_EXTERNCALL void map_get_header_string ( int *  n,
char **  str_array,
MAP_OtherStateType_t other_type 
)

Obtains the variable name array corresponding to the outputs selected in the MAP input file.

For example, str_array can be:

       X[2]     H[1]     X[6]     H[3]     X[10]    H[5]     X[14]    H[7]
       
Parameters
nnumber of header blocks. Should be proportional to the number of itms being output to the FAST output file
str_arraythe string being output.
other_typeFortran other state derived type

Example Fortran usage:

! Interface block declaration:
INTERFACE
SUBROUTINE mapextern_map_get_header_string(fc_int, fc_string, fc_other) BIND(C,name='map_get_header_string')
IMPORT
IMPLICIT NONE
INTEGER(KIND=C_INT) :: fc_int
TYPE( MAP_OtherStateType_C ) fc_other
TYPE(C_PTR), DIMENSION(FC_int) :: fc_string
END SUBROUTINE mapextern_map_get_header_string
END INTERFACE
...
! access the function using this subroutine call:
CALL mapextern_map_get_header_string(num_header_str, hdr_str_ptrs, other%C_obj)
Todo:
this should raise and error when count!=n

◆ map_get_unit_string()

MAP_EXTERNCALL void map_get_unit_string ( int *  n,
char **  str_array,
MAP_OtherStateType_t other_type 
)

Obtains the units of the outputs passed back to the calling program.

str_array can be:

       [m]     [N]     [m]     [N]     [m]     [N]     [m]     [N]   
       
Parameters
nnumber of header blocks. Should be proportional to the number of itms being output to the FAST output file
str_arraythe string being output.
other_typeFortran other state derived type

Example Fortran usage:

! Interface block declaration:
INTERFACE
SUBROUTINE mapextern_map_get_unit_string(fc_int, fc_string, fc_other) BIND(C,name='map_get_unit_string')
IMPORT
IMPLICIT NONE
INTEGER(KIND=C_INT) :: fc_int
TYPE(MAP_OtherStateType_C) fc_other
TYPE(C_PTR), DIMENSION(FC_int) :: fc_string
END SUBROUTINE mapextern_map_get_unit_string
END INTERFACE
...
! access the function using this subroutine call:
CALL mapextern_map_get_header_string(num_header_str, unit_str_ptrs, other%C_obj)
Todo:
this should raise and error when count!=n

◆ map_init()

MAP_EXTERNCALL void map_init ( MAP_InitInputType_t init_type,
MAP_InputType_t u_type,
MAP_ParameterType_t p_type,
MAP_ContinuousStateType_t x_type,
MAP_DiscreteStateType_t xd_type,
MAP_ConstraintStateType_t z_type,
MAP_OtherStateType_t other_type,
MAP_OutputType_t y_type,
MAP_InitOutputType_t ioType,
MAP_ERROR_CODE *  ierr,
char *  map_msg 
)

Initializes the MAP model and allocates memory.

Inconsistencies with the input file is reported here. This should only be called once.

Parameters
init_typeinitialization type, F2C FAST-native derived type
u_typeinput type, F2C FAST-native derived type.
p_typeparameter type, F2C FAST-native derived type
x_typecontinuous-state type, F2C FAST-native derived type
nonevoid type. It exists because MAP does not use discrete types (it would fill this place otherwise)
z_typeconstraint-state type, F2C FAST-native derived tpe
other_typeother-state type, F2C FAST-native derived type. This is core structure that houses all internal MAP states that cannot be mapped to Fortran
y_typeoutput type, F2C FAST-native derived type
ioTypeinit-output types, F2C FAST-native derived type
ierrerror code
map_msgerror string
Here is the call graph for this function:

◆ map_initialize_msqs_base()

MAP_EXTERNCALL void map_initialize_msqs_base ( MAP_InputType_t u_type,
MAP_ParameterType_t p_type,
MAP_ContinuousStateType_t x_type,
MAP_ConstraintStateType_t z_type,
MAP_OtherStateType_t other_type,
MAP_OutputType_t y_type,
MAP_InitOutputType_t io_type 
)

Initalizes all MAP base types (including some internal state)

The idea is to set variables to zero and null to prevent seg-faults in the case of early program termination before initialization (MAP_Init) is fully complete. MAP_Init

Parameters
el,opaqueobject used in simclist
See also
map_init()
Returns
Size of CableLibrary structure

◆ MAP_InitInput_Create()

MAP_EXTERNCALL InitializationData* MAP_InitInput_Create ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate InitializationData.

Called by map_create_init_type to allocate memory for the iinitialization data type. The reason why a layer is added to the initialization data is due to Fortran interactions. It is straighforward to pass 1D character arrays between Fortran and C instead of 2D arrays. 2D arrays would make more sense since multiple lines from the MAP input file can be packed in one step. MAP_InitInputType_t in responsible for the 1D arrays. which are passed from Fortran to C. MAP then takes the 1D aray and packs it into InitializationData. This is used to subsequently initialize the model. Structure is free'd by calling MAP_InitInput_Delete.

Parameters
map_msg,errormessage
ierr,errorcode
Returns
instance of the packed initialization strings (different from the FAST-required derived types)
Here is the caller graph for this function:

◆ map_offset_vessel()

MAP_EXTERNCALL void map_offset_vessel ( MAP_OtherStateType_t other_type,
MAP_InputType_t u_type,
double  x,
double  y,
double  z,
double  phi,
double  the,
double  psi,
char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

call this in python: offset_vessel().argtypes = [MapData_Type, MapInput_Type, c_char_p, POINTER(c_int)] angles are radians

lib.map_offset_vessel.argtypes = [MapData_Type, MapInput_Type, c_double, c_double, c_double, c_double, c_double, c_double, c_char_p, POINTER(c_int)]

Angles are in degrees. This routine converts angles from deg to rad Per Fossen (Fossen, Thor I. Guidance and control of ocean vehicles. Vol. 199. No. 4. New York: Wiley, 1994), this matrix converts vector from the body frame to the global reference frame:

R = | cos(ψ)*cos(θ) cos(ψ)*sin(θ)*sin(φ) − sin(ψ)*cos(φ) cos(ψ)*sin(θ)*cos(φ) + sin(ψ)*sin(φ) | | sin(ψ)*cos(θ) sin(ψ)*sin(θ)*sin(φ) + cos(ψ)*cos(φ) sin(ψ)*sin(θ)*cos(φ) − cos(ψ)*sin(φ) | | −sin(θ) cos(θ)*sin(φ) cos(θ)*cos(φ) |

We need to invoke this procedure to move the vessel nodes with body rotations factored:

u_type = x + [R]*r ▲ ▲ ▲ | | | global | | global | local

◆ MAP_OtherState_Create()

MAP_EXTERNCALL Domain* MAP_OtherState_Create ( char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Allocate Domain.

Called by map_create_other_type to allocate memory for the internal state (model) data type. 'Other States', as FAST calls them, are states not fitting a regular role as a parameter, constraint, input, ect. Other states contain information on the line connectivity matrix, how reference to poperties for each line, buoyancy properties of the nodes, ect. Deallocated using interaction with python and C based programs. Structure is free'd by calling MAP_OtherState_Delete.

Parameters
map_msg,errormessage
ierr,errorcode
See also
map_create_other_type()
Returns
instance of the interal model struct (different from the FAST-required derived types)
Here is the caller graph for this function:

◆ map_set_gravity()

MAP_EXTERNCALL void map_set_gravity ( MAP_ParameterType_t p_type,
const double  gravity 
)

Set the gravitational constant.

Should be called before map_init()

Parameters
p_typeparamter type, native C struct MAP_ParameterType_t
grtavitygravitational acceleration [m/s^2]

Example Fortran usage:

INTERFACE
SUBROUTINE MAP_map_set_gravity(interf, fc_val) BIND(C,name='map_set_gravity')
IMPORT
IMPLICIT NONE
TYPE(MAP_ParameterType_C) interf
REAL(C_DOUBLE), VALUE :: fc_val
END SUBROUTINE MAP_map_set_gravity
END INTERFACE
...
! access the function using this subroutine call:
CALL mapextern_map_set_gravity(p%C_obj, g)

◆ map_set_sea_density()

MAP_EXTERNCALL void map_set_sea_density ( MAP_ParameterType_t p_type,
const double  rho 
)

Set the water density.

Should be called before map_init()

Parameters
p_typeparamter type, native C struct MAP_ParameterType_t
rhowater density [kg/m^3]

Example Fortran usage:

INTERFACE
SUBROUTINE mapextern_set_density(interf, fc_val) BIND(C,name='map_set_sea_density')
IMPORT
IMPLICIT NONE
TYPE(MAP_ParameterType_C) interf
REAL(C_DOUBLE), VALUE :: fc_val
END SUBROUTINE mapextern_set_density
END INTERFACE
...
! access the function using this subroutine call:
CALL mapextern_set_density(p%C_obj, rho)

◆ map_set_sea_depth()

MAP_EXTERNCALL void map_set_sea_depth ( MAP_ParameterType_t p_type,
const double  depth 
)

Set the water depth.

Should be called before map_init()

Parameters
p_typeparamter type, native C struct MAP_ParameterType_t
depthwater depth [m]

Example Fortran usage:

INTERFACE
SUBROUTINE mapextern_set_depth(interf, fc_val) BIND(C,name='map_set_sea_depth')
IMPORT
IMPLICIT NONE
TYPE(MAP_ParameterType_C) interf
REAL(C_DOUBLE), VALUE :: fc_val
END SUBROUTINE mapextern_set_depth
END INTERFACE
...
! access the function using this subroutine call:
CALL mapextern_set_depth(p%C_obj, depth)

◆ map_set_summary_file_name()

MAP_EXTERNCALL void map_set_summary_file_name ( MAP_InitInputType_t init_type,
char *  map_msg,
MAP_ERROR_CODE *  ierr 
)

Set the name out the MAP summary output file.

Does not need to be called; the default summary file name is 'outlist.map.sum'.

Parameters
init_typeinitalization type, native C struct InitializationData_t
map_msgMAP error message
ierrMAP error code

Example Fortran usage:

! Interface block declaration:
INTERFACE
SUBROUTINE mapextern_map_set_summary_file_name(fc_init, fc_char, fc_int) BIND(C,name='map_set_summary_file_name')
IMPORT
IMPLICIT NONE
TYPE(MAP_InitInputType_C) fc_init
CHARACTER(KIND=C_CHAR), DIMENSION(*) :: fc_char
INTEGER(KIND=C_INT) :: fc_int
END SUBROUTINE mapextern_map_set_summary_file_name
END INTERFACE
...
! access the function using this subroutine call:
CALL mapextern_map_set_summary_file_name(InitInp%C_obj, ErrMsg, ErrStat)
Todo:
: need to free summary_file_name. This is done in delete_all_init_data(...), should be called in Fortran routines
Here is the call graph for this function:

◆ map_update_states()

MAP_EXTERNCALL void map_update_states ( float  t,
int  interval,
MAP_InputType_t u_type,
MAP_ParameterType_t p_type,
MAP_ContinuousStateType_t x_type,
MAP_DiscreteStateType_t xd_type,
MAP_ConstraintStateType_t z_type,
MAP_OtherStateType_t other_type,
MAP_ERROR_CODE *  ierr,
char *  map_msg 
)

Solves the statics problem for the MSQS system and should be called at each time step or vessel displacement.

Can be called multiple times, but must be called between map_init() and map_end() If the reference to u_type changes, then we have to update the location MAP internal states are pointing to. This is accomplished in the following code. The issue here is when this is called in Fortran:

CALL MAP_CopyInput(u(1), u_interp, MESH_NEWCOPY, ErrStat, ErrMsg)      

u_interp is passed into into the argument for map_update_states(); however, the internal states are not pointing to data in u_interp. We address this below. Note that the initial reference for point_iter is set in set_node_list()

Parameters
tcurrent (global) time
intervalcoupling interval
u_typeinput type, F2C FAST-native derived type.
p_typeparameter type, F2C FAST-native derived type
x_typecontinuous-state type, F2C FAST-native derived type
nonevoid type. It exists because MAP does not use discrete types (it would fill this place otherwise)
z_typeconstraint-state type, F2C FAST-native derived tpe
other_typeother-state type, F2C FAST-native derived type. This is core structure that houses all internal MAP states that cannot be mapped to Fortran
ierrerror code
map_msgerror string
See also
map_calc_output()