Integration of AFLR4 for Automated Surface Meshing
AFLR4 integration related tasks are included within
the routines located in the src/aflr4/main/
directory. All of these routines are specific to integration of AFLR4
within a main program or system. They typically serve as simplified APIs of
various startup or I/O tasks. All, except the main program file aflr4.c
have a file name of the form aflr4_main_xxx.c. All of these routines are
referenced only by other routines in the same directory. They are not included
in the AFLR4 library libaflr4.a (or aflr4.lib or AFLR.dll on Windows)
and are instead included in a separate libaflr4_main.a
(or aflr4_main.lib on Windows). Some or all of the aflr4_main_xxx
routines could also be compiled directly with a main program.
Implementation basics
are best obtained by viewing the sequence of calls within the main program. In
any integration of AFLR4 the starting point is to setup integration of external routines for a specific CAD system,
parallel processing, and file I/O. Default call back functions for registering
routines are included in routine aflr4_main_register. It should it be
called before calling other AFLR4routines.
Define flags are used to control which external routines are registered. Alternatively,
you can simply include the contents of this routine in your code.
Register external functions for AFLR4.
void aflr4_main_register(void)
Next, the input
parameters must be set. Multiple choices are available. The input parameters
include parameters that control what AFLR4 does along with the geometry
definition for the given configuration. A reduced set of the most important
parameters are described in the next section on
Integration of AFLR4 for Interactive Use.
It should not be necessary to
set other parameters. They are available only for very specific special case
uses and for completeness. A description of each input parameter is provided on
the AFLR4
Option Details page. Select I/O related input parameters are
described in the following.
- Input_File_Name
Input CAD or discrete geometry definition file case name or full file name.
Specifies either the case name or full file name for the input CAD file or discrete geometry
definition file (surface mesh file).
Note that if only a case name is
specified, then an input CAD file is searched for first. If no suitable CAD
file type is found, then a discrete definition file is searched for.
- Output_Grid_File_Name
Output grid file name or suffix.
Specifies either the full file name or file name suffix for the output grid file.
default=”.meshb”
- Output_File_Flag
Output file flag.
If Output_File_Flag=0, then send all output to standard output or standard error.
If Output_File_Flag=1, then send informational output to both standard output (or standard error) and a file named case_name.program_name.out.
If Output_File_Flag=2, then send maximum informational output to a file named case_name.program_name.out only.
If Output_File_Flag=-1, then send and append informational output to both standard output (or standard error) and a file named case_name.program_name.out.
If Output_File_Flag=-2, then send maximum and append informational output to a file named case_name.program_name.out only.
Error messages will always go to both the file (if any) and standard error.
default=0 min=-2 max=2
Input parameters can be
specified using either the
AFLR4 parameter structure
AFLR4_Param_Struct_Ptr
or an argument vector. The main program provided uses the system command line
argument vector by default. Input parameters in all cases are specified by a
name and a value. Only known parameter names should be specified. Unknown
parameter names will produce an error message and a non-zero return error flag
when
aflr4_main_setup_input_param is called. For all input parameter
methods,
aflr4_main_setup_input_param can be called to do input data and
parameter structure checking and setup along with startup tasks. Note that the
case name used for any output files is derived from the Output_Grid_File_Name. If that is
not set or is only a suffix, then the case name is derived from the Input_File_Name. If neither is set, then the case name must
be directly set using
ug_set_case_name (“case_name”) prior to calling
routine
aflr4_main_setup_input_param.
Do input data and parameter structure setup and checking along with startup tasks using either the program argument vector or the parameter structure.
INT_
aflr4_main_setup_input_param
(char *argv[], int argc, UG_Param_Struct **AFLR4_Param_Struct_Ptr)
- INPUT ARGUMENTS
| Note: |
If argc = 0 then argv is ignored and can be NULL.
AFLR4_Param_Struct_Ptr is used and assumed to be initialized and set.
If argc > 0 then argv is used and assumed to be set.
AFLR4_Param_Struct_Ptr may be NULL on input and will be allocated, initialized, and set. |
| argv |
Program command line argument vector or equivalent. |
| argc |
Program command line argument count or equivalent. |
| AFLR4_Param_Struct_Ptr |
AFLR4 input parameter structure. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
- OUTPUT ARGUMENTS
| Note: |
If argc = 0 then AFLR4_Param_Struct_Ptr may include new parameter values.
It will not be reallocated. |
| AFLR4_Param_Struct_Ptr |
AFLR4 input parameter structure. |
While the main program
provided uses the system command line argument vector, an alternative is to use
the
AFLR4 parameter structure to set all input parameters. An example of
this mode is shown in the test mode routine
aflr4_main_test_mode_input
for test_input_mode=1. In this mode, character
input parameters (Input_File_Name and Output_Grid_File_Name) are set using
ug_set_char_param.
ug_set_char_param (“name_of_param”, “char_param”, AFLR4_Input_Param_Struct);
And, I/O related integer input parameters (Output_File_Flag) are set using
ug_set_int_param.
ug_set_int_param (“name_of_param”, param_value, AFLR4_Input_Param_Struct);
Other input parameters are set in a similar manner and are described in the next section on
Integration of AFLR4 for Interactive Use.
Another mode of setting
the input parameters is to create and set an argument vector with desired input
parameters. An example of this method is shown in the test mode routine
aflr4_main_test_mode_input
for test_input_mode=2. When using an argument vector,
the parameter structure can be setup by
aflr4_main_setup_input_param.
The example shown in
aflr4_main_test_mode_input illustrates how to set
new argument vector entries using
ug_add_new_arg,< i>ug_add_flag_param_arg,
ug_add_int_param_arg,
ug_add_double_param_arg, and
ug_add_char_param_arg
routines. The routine
ug_add_new_arg can be
used to allocate and initialize a new argument vector.
Allocated and initialize a new argument vector or add a new argument to an argument vector.
INT_
ug_add_new_arg (char ***argv, char *new_arg)
- INPUT ARGUMENTS
| argv |
Argument vector. |
| new_arg |
New argument to add to the argument vector.
If new_arg = “allocate_and_initialize_argv" then allocate a new argument vector with one empty argument.
Otherwise set the new_arg string as a new argument vector entry added to the existing argument vector. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
- OUTPUT ARGUMENTS
| argv |
New argument vector. |
After a new argument vector is created the arguments can be added using the following routines.
ug_add_flag_arg (“flag”, argc, argv);
ug_add_int_arg (“name_of_param”, param_value, argc, argv);
ug_add_double_arg (“name_of_param”, param_value, argc, argv);
ug_add_char_arg (“name_of_param”, “char_param”, argc, argv);
Note that if input parameter
checking and startup tasks are not needed, then alternative methods to calling
aflr4_main_setup_input_parammay be used to set the
required
AFLR4 input parameter structure.
In this case,
aflr4_setup_param may be called instead if the argument
vector is directly set and used to set input parameters. If the
AFLR4
input parameter structure is directly set and used to set input parameters,
then no call is needed to either
aflr4_main_setup_input_param or
aflr4_setup_param.
Allocate, initialize and setup the AFLR4 parameter structure.
INT_
aflr4_ setup_ param (INT_ mmsg_setup, INT_ no_aflr2, int argc, char *argv[], UG_Param_Struct **AFLR4_Param_Struct_Ptr)
- INPUT ARGUMENTS
| mmsg_setup |
Setup message flag.
If mmsg_setup = 0 then do not output setup messages
If mmsg_setup = 1 then output setup messages |
| no_aflr2 |
AFLR2 input parameter flag.
If no_aflr2 = 0 then include AFLR2 input parameters.
This should always be set to 0 for usage described above
If no_aflr2 = 1 then do not include AFLR2 input parameters. |
| argc |
Argument count. |
| argv |
Argument vector. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
- OUTPUT ARGUMENTS
| AFLR4_Param_Struct_Ptr |
AFLR4 input parameter structure allocated, initialized
and set with options found in the argument vector. |
Choices are also available for
specifying the input data that defines the configuration geometry. By default,
this data is input and set from a file specified in the input parameters.
Alternatively, other means of setting the data that defines the geometry can be
used, such as another file reader or a geometry creation part of the system in
which
AFLR4 is being integrated. No examples of such are shown in the
main program. For CAD geometry definitions the CAD structure “
model”
must be set with use of an alternative method. And, for discrete definitions “
nbface,
nnode,
idibf,
inibf, and
x”
must be set with use of an alternative method. In default mode,
AFLR4
internally reads and sets CAD or discrete geometry definition data along with
saving it internally using
aflr4_main_data_input.
Read and set CAD or discrete geometry definition data.
INT_
aflr4_main_data_input (UG_Param_Struct *AFLR4_Param_Struct_Ptr)
- INPUT ARGUMENTS
| AFLR4_Param_Struct_Ptr |
AFLR4 input parameter structure. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
If input data is set directly then the geometry definition type must be set directly.
ug_set_int_param ("geom_type", 1, AFLR4_Param_Struct_Ptr); // CAD definition
ug_set_int_param ("geom_type", 2, AFLR4_Param_Struct_Ptr); // discrete definition
Definition data must then be set with either
aflr4_set_ext_cad_data or
dgeom_set_disc_def_data.
Set CAD geometry definition data.
INT_
aflr4_set_ext_cad_data (void *model)
- INPUT ARGUMENTS
| model |
CAD geometry definition data structure. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
Set discrete geometry definition data.
INT_
dgeom_set_disc_def_data (INT_ nbface, INT_ nnode, INT_1D *idibf, INT_3D *inibf, DOUBLE_3D *x)
- INPUT ARGUMENTS
| nbface |
Number of tria-faces for discrete geometry definition. |
| nnode |
Number of nodes/vertices for discrete geometry definition. |
| idibf |
Tria-face surface ID label (nbface+1 in length) for discrete geometry definition. |
| inibf |
Tria-face connectivity (nbface+1 in length) for discrete geometry definition. |
| x |
XYZ coordinates (nnode+1 in length) for discrete geometry definition. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
After all input data is setup, the configuration surface mesh can be generated. Routine
aflr4_setup_and_grid_gen sets up the geometry data, automatic spacing parameters,
and generates a surface mesh for the given input data and geometry configuration
Setup geometry data and automatic spacing parameters and generate complete surface grid for given configuration.
INT_
aflr4_setup_and_grid_gen (UG_Param_Struct *AFLR4_Param_Struct_Ptr);
- INPUT ARGUMENTS
| AFLR4_Param_Struct_Ptr |
AFLR4 input parameter structure. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
- OUTPUT ARGUMENTS
| AFLR4_Input_Param_Struct |
AFLR4 input parameter data structure with possible changes. |
The generated surface mesh and all local parameters are stored internally and can be
output to a file using routine
aflr4_main_data_output.
Write output surface mesh data.
INT_
aflr4_main_data_output (UG_Param_Struct *AFLR4_Param_Struct_Ptr)
- INPUT ARGUMENTS
| AFLR4_Param_Struct_Ptr |
AFLR4 input parameter structure. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred.
|
Note that if the geometry definition is CAD based and aflr4_main_data_output is
not called, then you must directly reset the CAD geometry definition data structure
model using routine
aflr4_cad_geom_reset.
aflr4_cad_geom_reset_attr (AFLR4_Param_Struct_Ptr);
Routine
aflr4_get_def can also be used to retrieve the generated surface mesh.
Get a copy of data arrays for a given surface definition.
INT_
aflr4_get_def (INT_ idef, INT_ noquad, INT_ *nbface, INT_ *nnode, INT_ *nquad, INT_1D **ibcibf, INT_1D **idibf, INT_3D **inibf, INT_4D **iniq, DOUBLE_2D **u, DOUBLE_3D **x)
- INPUT ARGUMENTS
| idef |
ID label for surface definition. |
| noquad |
If there are quad faces and noquad=0 then get them.
If there are quad faces and noquad=1 then replace quad-faces with tria-faces.
If there are no quad faces generated, then noquad is not used. |
- RETURN VALUE
| 0 |
Normal completion without errors. |
| >0 |
An error occurred. |
- OUTPUT ARGUMENTS
| nbface |
Number of tria-faces for generated mesh. |
| nnode |
Number of nodes/vertices for generated mesh. |
| nquad |
Number of quad-faces for generated mesh. |
| ibcibf |
Surface face BC label (nbface+nquad+1 in length) for generated mesh. |
| idibf |
Surface face ID label (nbface+nquad +1 in length) for generated mesh. |
| inibf |
Tria-face connectivity (nbface+1 in length) for generated mesh. |
| iniq |
Quad-face connectivity (nquad+1 in length) for generated mesh. |
| u |
UV coordinates (nnode+1 in length) for generated mesh.
Note that UV coordinates are local to individual surface definitions. For the overall glue-only surface mesh these values are not useful on curves shared between definitions. |
| x |
XYZ coordinates (nnode+1 in length) for generated mesh. |
Note that the ID label input argument in routine
aflr4_get_def for the complete
surface mesh (glue-only composite) can be obtained by the following call.
dgeom_def_get_idef (0, &idef);