renamed ensight76FoamExec -> ensightFoamReader for consistency

This commit is contained in:
Mark Olesen
2008-07-22 14:52:57 +02:00
parent 7446cee720
commit 202570dce4
69 changed files with 3 additions and 3 deletions

View File

@ -0,0 +1,2 @@
#!/bin/sh
wmake libso

View File

@ -0,0 +1,3 @@
libuserd.C
LIB = $(FOAM_LIBBIN)/libuserd-foam

View File

@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/browser/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
LIB_LIBS = \
-lOpenFOAM \
-lfiniteVolume \
-llagrangian \
$(PROJECT_LIBS)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,361 @@
README_1.0_to_2.0
=================
This document exists to help those who already have a working user defined
reader (using the 1.0 API) to change it into the 2.0 API format - if desired.
Note that you do not have to update your (1.0 API) user defined reader if it
is already working fine for you.
You should consider it if:
- efficieny gains are needed or
- you need access to complex variables or
- you need access to tensor variables or
- you need multiple timeset capability or
- you want to provide your own "border" elements (as opposed to EnSight's
computation of them)
As an indication of the differences that might be realized in efficency,
consider the following comparison on an unstructured model consisting of:
1,639,058 nodes
7,079,211 elements 240530 tria3
3984 quad4
5927663 tetra4
653 pyramid5
906381 penta6
12 parts
The same model was represented in EnSight6 and EnSight Gold format.
EnSight6 format into: EnSight Gold format into:
------------------------------------ -------------------------
EnSight7.1 |Ensight7.2 |Ensight 7.1 |EnSight7.2 |Ensight7.2
internal |internal |userd reader |internal |userd reader
reader |reader |(API 1.0) |reader |(API 2.0)
| | | |
Time | Mem |Time | Mem |Time | Mem |Time | Mem |Time | Mem
(sec)| (Mb) |(sec)| (Mb) |(sec)| (Mb) |(sec)| (Mb) |(sec)| (Mb)
----------- |----------- |----------- |----------- |-----------
@ part 4.3 27.6 | 3.5 28.4 | 4.0 27.6 | 3.3 8.8 | 3.3 8.9
loader | | | |
| | | |
after 14.0 243.4 |12.8 244.3 |49.8 475.8 | 6.0 211.5 | 6.2 211.6
loading all | | | |
12 parts | | | |
(non-visual) | | | |
| | | |
after 16.8 263.2 |16.0 264.2 |52.8 490.7 | 9.1 236.2 | 9.5 236.2
activate of | | | |
a vector. | | | |
^ ^
/|\ /|\
| |
| |
| |
Compare these two!
Significant is the inefficiency of the 1.0 API, and the fact that the
2.0 API has the same improved efficiency (both in speed and memory) as
the gold internal reader!
Note: Structured data will not show much difference between the two API's,
but it was more efficient initially.
=========================================================
A note on philosophical differences between the two API's:
=========================================================
API 1.0 deals with:
-------------------
-> global coordinate array & corresponding
-> global node id array
-> global nodal variables
-> for each part:
-> local element connectivities (grouped by type) & corresponding
-> local element ids
-> local elemental variables
The element connectivities, within parts, reference the global coordinate
array. If node ids are provided, the element connectivities have to be in
terms of the node ids. If node ids are not provided, the connectivities are in
terms of the (one-based) index number of each node in the global coordinate
array. Thus, node ids are more than labels - they are a part of the
connectivity referencing scheme. Element ids are purely labels.
This API was originally setup to try to make the interface to other codes as
straightforward as possible. Efficiency was not the major consideration.
EnSight must do a fair amount of work to get data provided in the manner
described above into the form that it uses internally. There is mapping that
has to be setup and maintained between the global arrays and the local part
arrays so that updating over time can be accomplished efficiently. There is
hashing that is required in order to deal efficently with node ids.
All of this leads to a considerable amount of temporary memory and processing,
in order to get a model read into EnSight.
API 2.0 deals with:
-------------------
-> for each part:
-> part coordinates & corresponding
-> part node ids
-> part nodal variables
-> part element connectivities (grouped by type) & corresponding
-> part element ids
-> part elemental variables
API 2.0 requires that the coordinates and corresponding nodal variables be
provided per part. This eliminates the global to local mapping with all its
associated temporary memory and processing time. The connectivity of the
elements in each part reference the node indicies of its own (one-based) part
coordinate array. The connectivity of the elements do not reference the nodes
according to node ids. Node ids (and element ids for that matter) are purely
labels for screen display and for query operations within EnSight. This
eliminates the need for node id hashing as a model is read.
The 2.0 API has been created for those needing more efficiency - both in terms
of memory use and speed. The increased efficiency is possible because data is
requested in a manner which more closely represents the way that EnSight
stores and manipulates information internally. The new API requests size
information and allocates the actual internal structures and arrays
accordingly. Pointers to these arrays are passed directly to you in the
routines which gather data, thus eliminating a considerable amount of
temporary memory (and allocation time) that is needed in the old
API. Depending on what you must do to get your data into the form required,
the memory savings and the speed improvement when loading models can be quite
significant!!
Additionally, the ability to handle tensor and complex variables has been
added to the new API, and support for multiple timesets is provided.
------------------------------------------------
So, with that said, if you determine that you want to convert your existing
reader to the new API format, The following may be helpful.
====================
First the Good News! The following routines are identical in both API's!!
==================== ----------------------------------------------------
USERD_bkup
USERD_get_block_coords_by_component
USERD_get_block_iblanking
USERD_get_changing_geometry_status
USERD_get_dataset_query_file_info
USERD_get_element_label_status
USERD_get_name_of_reader
USERD_get_node_label_status
USERD_get_number_of_files_in_dataset
USERD_get_number_of_model_parts
USERD_get_number_of_variables
USERD_set_filenames
USERD_stop_part_building
========================
Second, pretty Good News! The following routines have minor changes,
======================== namely a slight name change and the addition
of arguments related to complex data, constant
(Note, the name changes type, or self contained parts vs global coords.
are needed so both
API's can exist together) The arguments must be added, but depending on
your situation, many might simply be place
holders.
-------------------------------------------------------------------------------
-----------------------------------------------------
A) Changes related to imaginary flag for complex data
=====================================================
If you don't deal with complex variables, simply add
this flag to your argument list and ignore its value.
-----------------------------------------------------
API 1.0 API 2.0
------- -------
USERD_get_constant_value USERD_get_constant_val
( (
int which var int which_var,
int imag_data
) )
USERD_get_description_lines USERD_get_descrip_lines
( (
int which_type, int which_type,
int which_var, int which_var,
int imag_data,
char line1[Z_BUFL], char line1[Z_BUFL],
char line2[Z_BUFL] char line2[Z_BUFL]
) )
USERD_get_variable_value_at_specific USERD_get_var_value_at_specific
( (
int which_var, int which_var,
int which_node_or_elem, int which_node_or_elem,
int which_part, int which_part,
int which_elem_type, int which_elem_type,
int time_step, int time_step,
float values[3] float values[3],
int imag_data
) )
---------------------------------------------------------
B) Changes related to complex data info, and constant type
(and some of the multiple timeset support)
=========================================================
If you don't deal with complex variables, simply add the
arguments for var_complex, var_ifilename, and var_freq
and assign var_complex to be FALSE.
The argument var_contran needs to be added, and set
appropriately if you have constant variables, to indicate
if the constant variable is fixed for all time or varies
over time.
The argument var_timeset needs to be added, and set
appropriately.
---------------------------------------------------------
API 1.0 API 2.0
------- -------
USERD_get_variable_info USERD_get_gold_variable_info
( (
char **var_description, char **var_description,
char **var_filename, char **var_filename,
int *var_type, int *var_type,
int *var_classify int *var_classify,
int *var_complex,
char **var_ifilename,
float *var_freq,
int *var_contran,
int *var_timeset
) )
------------------------------------------------------
C) Changes related to self contained part coordinates
======================================================
The number_of_nodes argument needs to be added and
set for each part. This one is critical for you to do.
------------------------------------------------------
API 1.0 API 2.0
------- -------
USERD_get_part_build_info USERD_get_gold_part_build_info
( (
int *part_numbers, int *part_types,
int *part_types, int *part_types,
char *part_description[Z_BUFL], char *part_description[Z_BUFL],
int *number_of_nodes,
int *number_of_elements[Z_MAXTYPE], int *number_of_elements[Z_MAXTYPE],
int *ijk_dimensions[3], int *ijk_dimensions[3],
int *iblanking_options[6] int *iblanking_options[6]
) )
------------------------------------------------------
D) Changes related to multiple timeset support
======================================================
The timeset_number argument needs to be added for the
following three routines.
The multiple timeset support also includes the change
in B) above for USERD_get_gold_variable_info and the
last three new routines in the third section of this
readme file.
------------------------------------------------------
API 1.0 API 2.0
------- -------
USERD_get_number_of_time_steps USERD_get_num_of_time_steps
( (
void int timeset_number
) )
USERD_get_solution_times USERD_get_sol_times
( (
int timeset_number,
float *solution_times float *solution_times
) )
USERD_set_time_step USERD_set_time_set_and_step
( (
int timeset_number,
int time_step int time_step
) )
------------------------------------------------------
E) Changes related to global_extern.h
======================================================
Be sure to include the updated global_extern.h file that comes
with the EnSight 7.2 release (not the one from previous releases).
=================================================================
Third, deleted and new routines. (Here is where the work lies)
Several old routines are gone. You will have to create the new
routines that replace them. I think you will find in most cases
that your old routines will form the basis of the new routines,
and that it isn't too difficult to provide the information in
the new way.
The detailed specifications for these new routines can be found
in README_USERD_2.0 (or the headers in libuserd.c of the
dummy_gold or ensight_gold readers).
=================================================================
API 1.0 API 2.0
------- -------
These routines: replaced by the single routine:
--------------------------- -------------------------------
USERD_get_block_scalar_values USERD_get_var_by_component
USERD_get_block_vector_values_by_component
USERD_get_scalar_values
USERD_get_vector_values
These global coordinate routines: replaced by part coord routines:
--------------------------------- --------------------------------
USERD_get_global_coords USERD_get_part_coords
USERD_get_global_node_ids USERD_get_part_node_ids
USERD_get_number_of_global_nodes
These part connectivity routines: replaced by part by type routines:
--------------------------------- ----------------------------------
USERD_get_element_connectivities_for_part USERD_get_part_elements_by_type
USERD_get_element_ids_for_part USERD_get_part_element_ids_by_type
These are New Routines
----------------------
(Can be a dummy) -> USERD_exit_routine
(Can be a dummy) -> USERD_get_model_extents
(Required) -> USERD_get_reader_version
multiple timeset releated:
(Required) -> USERD_get_number_timesets
(Required) -> USERD_get_timeset_description
(Required) -> USERD_get_geom_timeset_number
border provided by the reader option:
(Required) -> USERD_get_border_availability
(Can be a dummy) -> USERD_get_border_elements_by_type
transient model allocation efficency:
(Can be a dummy) -> USERD_get_maxsize_info
Possible use with Server-of-Servers:
(Can be a dummy) -> USERD_set_server_number

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
//======================================================================
// backup is not implemented
//======================================================================
int USERD_bkup
(
FILE *archive_file,
int backup_type)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_bkup" << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,13 @@
// Do nothing
void USERD_exit_routine
(
void
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_exit_routine" << endl
<< flush;
#endif
}

View File

@ -0,0 +1,17 @@
// Not used
int USERD_get_border_availability
(
int part_number,
int number_of_elements[Z_MAXTYPE]
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_border_availability for part_number "
<< part_number << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,19 @@
// Not called if USERD_border_availability returns Z_ERR
int USERD_get_border_elements_by_type
(
int part_number,
int element_type,
int **conn_array,
short *parent_element_type,
int *parnet_element_type
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_border_elements_by_type" << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,11 @@
//======================================================================
int USERD_get_changing_geometry_status(void)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_changing_geometry_status" << endl << flush;
#endif
// Choose the most general option
return Z_CHANGE_CONN;
}

View File

@ -0,0 +1,15 @@
//======================================================================
// Not in use
//======================================================================
float USERD_get_constant_val
(
int which_var,
int imag_data
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_constant_val" << endl << flush;
#endif
return 0.0;
}

View File

@ -0,0 +1,8 @@
//======================================================================
// NOT SUPPORTED... yet, if ever!
//======================================================================
int USERD_get_dataset_query_file_info(Z_QFILES *qfiles)
{
// just return OK
return Z_OK;
}

View File

@ -0,0 +1,32 @@
//======================================================================
int USERD_get_descrip_lines
(
int which_type,
int which_var,
int imag_data,
char line1[Z_BUFL],
char line2[Z_BUFL]
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_descrip_lines" << endl
<< flush;
#endif
if (which_type == Z_GEOM)
{
strncpy(line1, meshName, Z_BUFL);
strncpy(line2, "", Z_BUFL);
}
else
{
strncpy(line1, "WHERE IS THIS LINE USED I WONDER???", Z_BUFL);
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_descrip_lines" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,11 @@
//======================================================================
// if TRUE: set in USERD_get_element_ids_for_part
//======================================================================
int USERD_get_element_label_status(void)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_element_label_status" << endl << flush;
#endif
return TRUE;
}

View File

@ -0,0 +1,14 @@
int USERD_get_geom_timeset_number
(
void
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_geom_timeset_number" << endl
<< flush;
#endif
Geom_timeset_number = 1;
return Geom_timeset_number;
}

View File

@ -0,0 +1,151 @@
//======================================================================
// this is based on the current time step.
//======================================================================
int USERD_get_gold_part_build_info
(
int *part_numbers,
int *part_types,
char *part_descriptions[Z_BUFL],
int *number_of_nodes,
int *number_of_elements[Z_MAXTYPE],
int *ijk_dimensions[3],
int *iblanking_options[6]
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_gold_part_build_info" << endl << flush;
#endif
//# include "checkForNewMesh.H"
const cellShapeList& cellShapes = meshPtr->cellShapes();
const cellList& cells = meshPtr->cells();
label nCells = cells.size();
// all parts are unstructured
for (label n = 0; n<Numparts_available; n++)
{
part_numbers[n] = n + 1;
part_types[n] = Z_UNSTRUCTURED;
}
strncpy(part_descriptions[0], meshName, Z_BUFL);
for(label i=0; i<nPatches; i++)
{
word patchName(meshPtr->boundary()[i].name());
strncpy(part_descriptions[i+1], patchName.c_str(), Z_BUFL);
}
label nHex08 = 0;
label nPen06 = 0;
label nPyr05 = 0;
label nTet04 = 0;
label nFaced = 0;
for (label n=0; n<nCells; n++)
{
label nFacesInCell = cells[n].size();
labelList points = cellShapes[n];
if ((nFacesInCell == 6) && (points.size() == 8))
{
nHex08++;
}
else if ((nFacesInCell == 4) && (points.size() == 4))
{
nTet04++;
}
else if (nFacesInCell == 5)
{
if (points.size() == 6)
{
nPen06++;
}
else if (points.size() == 5)
{
nPyr05++;
}
else
{
nFaced++;
}
}
else
{
nFaced++;
}
}
for (label n=0; n < Z_MAXTYPE; n++)
{
for (label i=0; i<Numparts_available; i++)
{
number_of_elements[i][n] = 0;
}
}
number_of_elements[0][Z_TET04] = nTet04;
number_of_elements[0][Z_PYR05] = nPyr05;
number_of_elements[0][Z_HEX08] = nHex08;
number_of_elements[0][Z_PEN06] = nPen06;
number_of_elements[0][Z_NFACED] = nFaced;
/*
Info << "nTet04 = " << nTet04 << endl;
Info << "nPyr05 = " << nPyr05 << endl;
Info << "nHex08 = " << nHex08 << endl;
Info << "nPen06 = " << nPen06 << endl;
Info << "nFaced = " << nFaced << endl;
*/
number_of_nodes[0] = meshPtr->nPoints();
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
for(label i=0; i<nPatches; i++)
{
label nTri03 = 0;
label nQuad04 = 0;
label nPoly = 0;
forAll(bMesh[i], n)
{
label nPoints = bMesh[i][n].size();
if (nPoints == 3)
{
nTri03++;
}
else if (nPoints == 4)
{
nQuad04++;
}
else
{
nPoly++;
}
}
number_of_elements[i+1][Z_TRI03] = nTri03;
number_of_elements[i+1][Z_QUA04] = nQuad04;
number_of_elements[i+1][Z_NSIDED] = nPoly;
number_of_nodes[i+1] = bMesh[i].points().size();
}
if (Numparts_available > nPatches+1)
{
strncpy(part_descriptions[nPatches+1], sprayName.c_str(), Z_BUFL);
number_of_elements[nPatches+1][Z_POINT] = sprayPtr->size();
number_of_nodes[nPatches+1] = sprayPtr->size();
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_gold_part_build_info" << endl << flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,123 @@
//======================================================================
// variable 1 - var[0] , i.e variables are zero based
//======================================================================
int USERD_get_gold_variable_info
(
char **var_description,
char **var_filename,
int *var_type,
int *var_classify,
int *var_complex,
char **var_ifilename,
float *var_freq,
int *var_contran,
int *var_timeset
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_gold_variable_info" << endl
<< flush;
#endif
label offset = Num_variables - nSprayVariables;
// scalars first ...
for (label n=0; n<offset; n++)
{
if (isScalar[var2field[n]])
{
var_type[n] = Z_SCALAR;
var_classify[n] = Z_PER_ELEM;
var_complex[n] = FALSE;
var_timeset[n] = 1;
strncpy
(
var_description[n],
fieldNames[var2field[n]].c_str(),
Z_BUFL
);
}
}
// ... and then vectors
for (label n=0; n<offset; n++)
{
if (isVector[var2field[n]])
{
var_type[n] = Z_VECTOR;
var_classify[n] = Z_PER_ELEM;
var_complex[n] = FALSE;
var_timeset[n] = 1;
strncpy
(
var_description[n],
fieldNames[var2field[n]].c_str(),
Z_BUFL
);
}
}
// ... and tensors (NB! all tensors are treated as asymmetric)
for (label n=0; n<offset; n++)
{
if (isTensor[var2field[n]])
{
var_type[n] = Z_TENSOR9;
var_classify[n] = Z_PER_ELEM;
var_complex[n] = FALSE;
var_timeset[n] = 1;
strncpy
(
var_description[n],
fieldNames[var2field[n]].c_str(),
Z_BUFL
);
}
}
if (Numparts_available > nPatches+1)
{
label Ns = lagrangianScalarNames.size();
for (label n=0; n<Ns; n++)
{
var_type[offset + n] = Z_SCALAR;
var_classify[offset + n] = Z_PER_ELEM;
var_complex[offset + n] = FALSE;
var_timeset[offset + n] = 1;
word name = parcelPrepend + lagrangianScalarNames[n];
strncpy
(
var_description[offset + n],
name.c_str(),
Z_BUFL
);
}
for (label n=0; n<lagrangianVectorNames.size(); n++)
{
var_type[offset + Ns + n] = Z_VECTOR;
var_classify[offset + Ns + n] = Z_PER_ELEM;
var_complex[offset + Ns + n] = FALSE;
var_timeset[offset + Ns + n] = 1;
word name = parcelPrepend + lagrangianVectorNames[n];
strncpy
(
var_description[offset + Ns + n],
name.c_str(),
Z_BUFL
);
}
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_gold_variable_info" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,14 @@
int USERD_get_matf_set_info
(
int *mat_set_ids,
char **mat_set_name
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_matf_set_info" << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,15 @@
int USERD_get_matf_var_info
(
int set_index,
int *mat_ids,
char **mat_desc
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_matf_var_info" << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,104 @@
int USERD_get_maxsize_info
(
int *max_number_of_nodes,
int *max_number_of_elements[Z_MAXTYPE],
int *max_ijk_dimensions[3]
)
{
return Z_ERR;
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_maxsize_info" << endl << flush;
#endif
label maxNPoints = 0;
label maxNParcels = 0;
label nPen06Max = 0;
label nHex08Max = 0;
label nPyr05Max = 0;
label nTet04Max = 0;
Info << "Checking all time steps for EnSight memory allocation purpose. This can take some time." << endl;
for (label t=1; t < TimeList.size(); t++)
{
label nPen06 = 0;
label nHex08 = 0;
label nPyr05 = 0;
label nTet04 = 0;
runTimePtr->setTime(TimeList[t], t);
Info << "Checking time = " << TimeList[t].value() << endl << flush;
const cellShapeList& cells = meshPtr->cellShapes();
label nPoints = meshPtr->nPoints();
label nCells = cells.size();
maxNPoints = max(maxNPoints, nPoints);
for (label n=0; n<nCells;n++)
{
label nFaces = cells[n].nFaces();
labelList points = cells[n];
if ((nFaces == 6) && (points.size() == 8))
{
nHex08++;
}
else if ((nFaces == 5) && (points.size() == 6))
{
nPen06++;
}
else if ((nFaces == 5) && (points.size() == 5))
{
nPyr05++;
}
else if ((nFaces == 4) && (points.size() == 4))
{
nTet04++;
}
}
nPen06Max = max(nPen06Max, nPen06);
nHex08Max = max(nHex08Max, nHex08);
nPyr05Max = max(nPyr05Max, nPyr05);
nTet04Max = max(nTet04Max, nTet04);
if (Numparts_available > 1)
{
// Get the maximum number of spray parcels
// and store it
Cloud<passiveParticle> lagrangian(*meshPtr);
if (lagrangian.size() > nMaxParcels)
{
nMaxParcels = lagrangian.size();
}
}
}
max_number_of_nodes[0] = maxNPoints;
max_number_of_elements[0][Z_HEX08] = nHex08Max;
max_number_of_elements[0][Z_PEN06] = nPen06Max;
max_number_of_elements[0][Z_PYR05] = nPyr05Max;
max_number_of_elements[0][Z_TET04] = nTet04Max;
if (Numparts_available > 1)
{
max_number_of_nodes[1] = maxNParcels;
max_number_of_elements[1][Z_POINT] = maxNParcels;
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_maxsize_info" << endl << flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,15 @@
// Not used. Let EnSight do the job.
int USERD_get_model_extents
(
float extents[6]
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_model_extents" << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,18 @@
//======================================================================
// Setting name in the gui, and specifying one or two input fields
//======================================================================
int USERD_get_name_of_reader
(
char reader_name[Z_MAX_USERD_NAME],
int *two_fields
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_name_of_reader" << endl << flush;
#endif
strncpy(reader_name, readerName, Z_MAX_USERD_NAME);
*two_fields = FALSE;
return Z_OK;
}

View File

@ -0,0 +1,79 @@
int USERD_get_nfaced_conn
(
int part_number,
int *nfaced_conn_array
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_nfaced_conn"
<< ", part_number = " << part_number
<< endl
<< flush;
#endif
if (part_number == 1)
{
label nPoint = 0;
const cellShapeList& cellShapes = meshPtr->cellShapes();
const cellList& cells = meshPtr->cells();
const faceList& faces = meshPtr->faces();
label nCells = cellShapes.size();
for (label n=0; n<nCells; n++)
{
label nFacesInCell = cells[n].size();
labelList points = cellShapes[n];
if ((nFacesInCell == 6) && (points.size() == 8))
{}
else if ((nFacesInCell == 4) && (points.size() == 4))
{}
else if (nFacesInCell == 5)
{
if (points.size() == 6)
{}
else if (points.size() == 5)
{}
else
{
for(label i=0; i<nFacesInCell; i++)
{
label facei = cells[n][i];
label nPoints = faces[facei].size();
for(label j=0; j<nPoints; j++)
{
nfaced_conn_array[nPoint++] = faces[facei][j] + 1;
}
}
}
}
else
{
for(label i=0; i<nFacesInCell; i++)
{
label facei = cells[n][i];
label nPoints = faces[facei].size();
for(label j=0; j<nPoints; j++)
{
nfaced_conn_array[nPoint++] = faces[facei][j] + 1;
}
}
}
}
}
else if (part_number < nPatches+2)
{
}
else
{
return Z_ERR;
}
#ifdef ENSIGHTDEBUG
Info << "Exiting: USERD_get_nfaced_conn" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,74 @@
int USERD_get_nfaced_nodes_per_face
(
int part_number,
int *nfaced_npf_array
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_nfaced_nodes_per_face"
<< ", part_number = " << part_number
<< endl
<< flush;
#endif
if (part_number == 1)
{
const cellShapeList& cellShapes = meshPtr->cellShapes();
const cellList& cells = meshPtr->cells();
const faceList& faces = meshPtr->faces();
label nCells = cellShapes.size();
label nFaced = 0;
for (label n=0; n<nCells; n++)
{
label nFacesInCell = cells[n].size();
labelList points = cellShapes[n];
label nPoints = points.size();
if ((nFacesInCell == 6) && (nPoints == 8))
{}
else if ((nFacesInCell == 4) && (nPoints == 4))
{}
else if (nFacesInCell == 5)
{
if (nPoints == 6)
{}
else if (nPoints == 5)
{}
else
{
for(label i=0; i<nFacesInCell; i++)
{
label facei = cells[n][i];
label nFacePoints = faces[facei].size();
nfaced_npf_array[nFaced++] = nFacePoints;
}
}
}
else
{
for(label i=0; i<nFacesInCell; i++)
{
label facei = cells[n][i];
label nFacePoints = faces[facei].size();
nfaced_npf_array[nFaced++] = nFacePoints;
}
}
}
}
else if (part_number < nPatches+2)
{
return Z_ERR;
}
else
{
return Z_ERR;
}
#ifdef ENSIGHTDEBUG
Info << "Exiting: USERD_get_nfaced_nodes_per_face" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,12 @@
//======================================================================
// if TRUE: set in USERD_get_global_node_ids
//======================================================================
int USERD_get_node_label_status(void)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_node_label_status" << endl << flush;
#endif
return TRUE;
}

View File

@ -0,0 +1,49 @@
int USERD_get_nsided_conn
(
int part_number,
int *nsided_conn_array
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_nsided_conn"
<< ", part_number = " << part_number
<< endl
<< flush;
#endif
if (part_number == 1)
{
Info << "************* EEEEEEEEERRRRRRRRRRRRRRRRRR *************** " << endl << flush;
}
else if (part_number < nPatches+2)
{
//const cellList& cells = meshPtr->cells();
//const faceList& faces = meshPtr->faces();
label patchi = part_number - 2;
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
label np = 0;
forAll(bMesh[patchi], facei)
{
label nPoints = bMesh[patchi][facei].size();
if ((nPoints != 3) && (nPoints != 4))
{
for(label i=0; i<nPoints; i++)
{
nsided_conn_array[np++] = bMesh[patchi][facei][i] + 1;
}
}
}
}
else if (part_number == nPatches+2)
{
return Z_ERR;
}
#ifdef ENSIGHTDEBUG
Info << "Exiting: USERD_get_nsided_conn" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,15 @@
//======================================================================
// don't use multiple time sets...NN
//======================================================================
int USERD_get_num_of_time_steps
(
int timeset_number
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_num_of_time_steps" << endl
<< flush;
#endif
return Num_time_steps;
}

View File

@ -0,0 +1,13 @@
//======================================================================
//
//======================================================================
int USERD_get_number_of_files_in_dataset(void)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_number_of_files_in_dataset" << endl << flush;
#endif
// use 1 insted of 0 which gives an un-necessary warning.
Num_dataset_files = 1;
return Num_dataset_files;;
}

View File

@ -0,0 +1,14 @@
int USERD_get_number_of_material_sets
(
void
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_number_of_material_sets" << endl
<< flush;
#endif
// No materials
return 0;
}

View File

@ -0,0 +1,14 @@
int USERD_get_number_of_materials
(
int set_index
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_number_of_materials" << endl
<< flush;
#endif
// No materials
return 0;
}

View File

@ -0,0 +1,9 @@
int USERD_get_number_of_model_parts(void)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_number_of_model_parts" << endl << flush;
#endif
return Numparts_available;
}

View File

@ -0,0 +1,9 @@
//======================================================================
int USERD_get_number_of_variables(void)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_number_of_variables" << endl << flush;
#endif
return Num_variables;
}

View File

@ -0,0 +1,13 @@
int USERD_get_number_of_timesets
(
void
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_number_of_timesets" << endl
<< flush;
#endif
Num_timesets = 1;
return Num_timesets;
}

View File

@ -0,0 +1,77 @@
// Note: coord_array is 1-based.
int USERD_get_part_coords
(
int part_number,
float **coord_array
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_part_coords" << endl <<
"part_number = " << part_number << endl << flush;
#endif
if (part_number == 1)
{
//# include "checkForNewMesh.H"
const vectorField& points = meshPtr->points();
label nPoints = points.size();
for (label indx=0; indx<nPoints; indx++)
{
coord_array[0][indx+1] = (float)points[indx].x();
coord_array[1][indx+1] = (float)points[indx].y();
coord_array[2][indx+1] = (float)points[indx].z();
}
}
else if (part_number < nPatches+2)
{
//# include "checkForNewMesh.H"
label patchi = part_number-2;
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
const vectorField& points = bMesh[patchi].points();
label nPoints = points.size();
for (label indx=0; indx<nPoints; indx++)
{
coord_array[0][indx+1] = (float)points[indx].x();
coord_array[1][indx+1] = (float)points[indx].y();
coord_array[2][indx+1] = (float)points[indx].z();
}
}
else if (part_number == nPatches+2)
{
label indx = 1;
for
(
Cloud<passiveParticle>::iterator elmnt = sprayPtr->begin();
elmnt != sprayPtr->end();
++elmnt
)
{
coord_array[0][indx] = (float)elmnt().position().x();
coord_array[1][indx] = (float)elmnt().position().y();
coord_array[2][indx] = (float)elmnt().position().z();
indx++;
}
}
else
{
return Z_ERR;
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_part_coords" << endl << flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,162 @@
int USERD_get_part_element_ids_by_type
(
int part_number,
int element_type,
int *elemid_array
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_part_element_ids_by_type" << endl
<< "part_number = " << part_number << endl
<< "element_type = " << element_type << endl << flush;
#endif
if (part_number == 1)
{
const cellShapeList& cellShapes = meshPtr->cellShapes();
const cellList& cells = meshPtr->cells();
label nCells = cells.size();
label nPen06 = 0;
label nHex08 = 0;
label nPyr05 = 0;
label nTet04 = 0;
label nFaced = 0;
if (element_type == Z_HEX08)
{
for (label n=0; n<nCells; n++)
{
label nFaces = cells[n].size();
labelList points = cellShapes[n];
if ((nFaces == 6) && (points.size() == 8))
{
elemid_array[nHex08++] = n + 1;
}
}
}
else if (element_type == Z_PEN06)
{
for (label n=0; n<nCells; n++)
{
label nFaces = cells[n].size();
labelList points = cellShapes[n];
if ((nFaces == 5) && (points.size() == 6))
{
elemid_array[nPen06++] = n + 1;
}
}
}
else if (element_type == Z_PYR05)
{
for (label n=0; n<nCells; n++)
{
label nFaces = cells[n].size();
labelList points = cellShapes[n];
if ((nFaces == 5) && (points.size() == 5))
{
elemid_array[nPyr05++] = n + 1;
}
}
}
else if (element_type == Z_TET04)
{
for (label n=0; n<nCells; n++)
{
label nFaces = cells[n].size();
labelList points = cellShapes[n];
if ((nFaces == 4) && (points.size() == 4))
{
elemid_array[nTet04++] = n + 1;
}
}
}
else if (element_type == Z_NFACED)
{
for (label n=0; n<nCells; n++)
{
label nFaces = cells[n].size();
labelList points = cellShapes[n];
if ((nFaces == 6) && (points.size() == 8))
{}
else if ((nFaces == 5) && (points.size() == 6))
{}
else if ((nFaces == 5) && (points.size() == 5))
{}
else if ((nFaces == 4) && (points.size() == 4))
{}
else
{
elemid_array[nFaced++] = n + 1;
}
}
}
}
else if (part_number < nPatches+2)
{
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
label patchi = part_number - 2;
label nTri03 = 0;
label nQuad04 = 0;
label nPoly = 0;
if (element_type == Z_TRI03)
{
forAll(bMesh[patchi], facei)
{
if (bMesh[patchi][facei].size() == 3)
{
elemid_array[nTri03++] = facei + 1;
}
}
}
else if (element_type == Z_QUA04)
{
forAll(bMesh[patchi], facei)
{
if (bMesh[patchi][facei].size() == 4)
{
elemid_array[nQuad04++] = facei + 1;
}
}
}
else if (element_type == Z_NSIDED)
{
forAll(bMesh[patchi], facei)
{
label nPoints = bMesh[patchi][facei].size();
if ((nPoints != 3) && (nPoints != 4))
{
elemid_array[nPoly++] = facei + 1;
}
}
}
}
else if (part_number == nPatches+2)
{
for (label n=0; n<sprayPtr->size(); n++)
{
elemid_array[n] = n + 1;
}
}
else
{
return Z_ERR;
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_part_element_ids_by_type" << endl << flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,252 @@
int USERD_get_part_elements_by_type
(
int part_number,
int element_type,
int **conn_array
)
{
# ifdef ENSIGHTDEBUG
Info<< "Entering: USERD_get_part_elements_by_type" << nl
<< "part_number = " << part_number << nl
<< "element_type = " << element_type;
if (element_type == Z_HEX08)
{
Info << " Z_HEX08";
}
else if (element_type == Z_PEN06)
{
Info << " Z_PEN06";
}
else if (element_type == Z_PYR05)
{
Info << " Z_PYR05";
}
else if (element_type == Z_TET04)
{
Info << " Z_TET04";
}
else if (element_type == Z_TRI03)
{
Info << " Z_TRI03";
}
else if (element_type == Z_QUA04)
{
Info << " Z_QUA04";
}
else if (element_type == Z_NFACED)
{
Info << " Z_NFACED";
}
else if (element_type == Z_NSIDED)
{
Info << " Z_NSIDED";
}
else
{
Info << " unknown";
}
Info << endl << flush;
# endif
if (part_number == 1)
{
const cellShapeList& cellShapes = meshPtr->cellShapes();
//================================
// hexahedron
//================================
if (element_type == Z_HEX08)
{
const cellModel& hex = *(cellModeller::lookup("hex"));
label nHex08 = 0;
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
if (cellModel == hex)
{
forAll(cellShape, ip)
{
conn_array[nHex08][ip] = cellShape[ip] + 1;
}
nHex08++;
}
}
}
//================================
// pentahedron
//================================
else if (element_type == Z_PEN06)
{
const cellModel& prism = *(cellModeller::lookup("prism"));
label nPen06 = 0;
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
if (cellModel == prism)
{
forAll(cellShape, ip)
{
conn_array[nPen06][ip] = cellShape[ip] + 1;
}
nPen06++;
}
}
}
//================================
// pyramid
//================================
else if (element_type == Z_PYR05)
{
const cellModel& pyr = *(cellModeller::lookup("pyr"));
label nPyr05 = 0;
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
if (cellModel == pyr)
{
forAll(cellShape, ip)
{
conn_array[nPyr05][ip] = cellShape[ip] + 1;
}
nPyr05++;
}
}
}
//================================
// tetrahedron
//================================
else if (element_type == Z_TET04)
{
const cellModel& tet = *(cellModeller::lookup("tet"));
label nTet04 = 0;
forAll(cellShapes, celli)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
if (cellModel == tet)
{
forAll(cellShape, ip)
{
conn_array[nTet04][ip] = cellShape[ip] + 1;
}
nTet04++;
}
}
}
//================================
// polyhedra
//================================
else
{
label nCells = cellShapes.size();
label nFaced = 0;
const cellList cells = meshPtr->cells();
for (label n=0; n<nCells; n++)
{
label nFacesInCell = cells[n].size();
labelList points = cellShapes[n];
if ((nFacesInCell == 6) && (points.size() == 8))
{}
else if ((nFacesInCell == 4) && (points.size() == 4))
{}
else if (nFacesInCell == 5)
{
if (points.size() == 6)
{}
else if (points.size() == 5)
{}
else
{
conn_array[nFaced++][0] = nFacesInCell;
}
}
else
{
conn_array[nFaced++][0] = nFacesInCell;
}
}
}
}
else if (part_number < nPatches+2)
{
label patchi = part_number - 2;
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
label nTri03 = 0;
label nQuad04 = 0;
if (element_type == Z_TRI03)
{
forAll(bMesh[patchi], n)
{
label nPoints = bMesh[patchi][n].size();
if (nPoints == 3)
{
for(label i=0; i<nPoints; i++)
{
label ip = bMesh[patchi][n][i];
conn_array[nTri03][i] = ip + 1;
}
nTri03++;
}
}
}
else if (element_type == Z_QUA04)
{
forAll(bMesh[patchi], n)
{
label nPoints = bMesh[patchi][n].size();
if (nPoints == 4)
{
for(label i=0; i<nPoints; i++)
{
label ip = bMesh[patchi][n][i];
conn_array[nQuad04][i] = ip + 1;
}
nQuad04++;
}
}
}
else if (element_type == Z_NSIDED)
{
label nPoly = 0;
forAll(bMesh[patchi], n)
{
label nPoints = bMesh[patchi][n].size();
if ((nPoints != 3) && (nPoints != 4))
{
conn_array[nPoly++][0] = nPoints;
}
}
}
}
else if (part_number == nPatches+2)
{
for (label n=0; n<sprayPtr->size(); n++)
{
conn_array[n][0] = n + 1;
}
}
else
{
return Z_ERR;
}
# ifdef ENSIGHTDEBUG
Info<< "Leaving: USERD_get_part_elements_by_type" << endl;
# endif
return Z_OK;
}

View File

@ -0,0 +1,60 @@
int USERD_get_part_node_ids
(
int part_number,
int *nodeid_array
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_part_node_ids" << endl
<< "part_number = " << part_number << endl
<< flush;
#endif
if (part_number == 1)
{
for (label indx=0; indx<Num_global_nodes; indx++)
{
nodeid_array[indx] = indx + 1;
}
}
else if (part_number < nPatches+2)
{
label patchi = part_number-2;
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
const vectorField& points = bMesh[patchi].points();
label nPoints = points.size();
for (label indx=0; indx<nPoints; indx++)
{
nodeid_array[indx] = indx + 1;
}
}
else if (part_number == nPatches+2)
{
label indx = 0;
for
(
Cloud<passiveParticle>::iterator elmnt = sprayPtr->begin();
elmnt != sprayPtr->end();
++elmnt
)
{
nodeid_array[indx] = indx + 1;
indx++;
}
}
else
{
return Z_ERR;
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_part_node_ids" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,18 @@
int USERD_get_reader_version
(
char version_number[Z_MAX_USERD_NAME]
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_reader_version" << endl;
#endif
strncpy(version_number, readerVersion, Z_MAX_USERD_NAME);
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_reader_version" << endl;
#endif
return Z_OK;
}

View File

@ -0,0 +1,44 @@
//======================================================================
// Negative values of the time is not allowed in EnSight.
// So for engines, where the time is CAD's we need to correct
// this so that all CAD's are positive. NN
//======================================================================
int USERD_get_sol_times
(
int timeset_number,
float *solution_times
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_sol_times" << endl << flush;
Info << TimeList << endl;
#endif
for (label n=0; n<Num_time_steps;n++)
{
solution_times[n] = TimeList[n+1].value();
}
if (TimeList[1].value() < 0)
{
scalar addCAD = 360.0;
while (TimeList[1].value() + addCAD < 0.0)
{
addCAD += 360.0;
}
for (label n=0; n<Num_time_steps;n++)
{
solution_times[n] += addCAD;
Info << "Time[" << n << "] = " << TimeList[n+1].value()
<< " was corrected to " << solution_times[n] << endl;
}
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_sol_times" << endl << flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,28 @@
int USERD_get_timeset_description
(
int timeset_number,
char timeset_description[Z_BUFL]
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_timeset_description" << endl
<< flush;
#endif
if (TimeList[1].value() < 0)
{
strncpy(timeset_description, "CAD", Z_BUFL);
}
else
{
strncpy(timeset_description, "seconds", Z_BUFL);
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_timeset_description" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,103 @@
int USERD_get_var_by_component
(
int which_variable,
int which_part,
int var_type,
int which_type,
int imag_data,
int component,
float *var_array
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_var_by_component" << endl
<< "which_variable = " << which_variable << endl
<< "which_part = " << which_part << endl
<< "var_type = " << var_type << endl
<< "which_type = " << which_type << endl
<< "component = " << component << endl
<< flush;
#endif
label nVar = which_variable - 1;
Time& runTime = *runTimePtr;
fvMesh& mesh = *meshPtr;
const cellShapeList& cells = mesh.cellShapes();
label nCells = cells.size();
if (var_type == Z_SCALAR)
{
if (which_part == 1)
{
# include "getFieldScalar.H"
}
else if (which_part < nPatches+2)
{
# include "getPatchFieldScalar.H"
}
else if (which_part == nPatches+2)
{
# include "getLagrangianScalar.H"
}
else
{
return Z_ERR;
}
}
else if (var_type == Z_VECTOR)
{
if (which_part == 1)
{
# include "getFieldVector.H"
}
else if (which_part < nPatches+2)
{
# include "getPatchFieldVector.H"
}
else if (which_part == nPatches+2)
{
# include "getLagrangianVector.H"
}
else
{
return Z_ERR;
}
}
else if (var_type == Z_TENSOR9)
{
// all tensor are treated as asymmetric tensors here
if (which_part == 1)
{
# include "getFieldTensor.H"
}
else if (which_part < nPatches+2)
{
# include "getPatchFieldTensor.H"
}
else if (which_part == nPatches+2)
{
return Z_UNDEF;
}
else
{
return Z_ERR;
}
}
else
{
return Z_UNDEF;
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_var_by_component" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,71 @@
//======================================================================
int USERD_get_var_value_at_specific
(
int which_var,
int which_node_or_elem,
int which_part,
int which_elem_type,
int time_step,
float values[3],
int imag_data
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_var_value_at_specific" << endl
<< flush;
#endif
// Not sure if it is 0 or 1 based
label nNode = which_node_or_elem;
label nVar = which_var - 1;
fvMesh& mesh = *meshPtr;
if (nVar < Num_variables - nSprayVariables)
{
Time& runTime = *runTimePtr;
IOobject fieldObject
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (isScalar[nVar])
{
volScalarField scalarField(fieldObject,mesh);
values[0] = scalarField[nNode];
}
else if (isVector[nVar])
{
volVectorField vectorField(fieldObject,mesh);
values[0] = vectorField[nNode].x();
values[1] = vectorField[nNode].y();
values[2] = vectorField[nNode].z();
}
else
{
Info<< "ERROR in USERD_get_variable_value_at_specific. "
<< "No available variable???"
<< endl;
return Z_ERR;
}
}
else
{
Info<< "This functionality is not implemented yet."
<< endl;
return Z_ERR;
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_var_value_at_specific" << endl
<< flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,18 @@
int USERD_load_matf_data
(
int set_index,
int part_id,
int wtyp,
int mat_type,
int *ids_list,
float *val_list
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_load_matf_data" << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,209 @@
//======================================================================
// Setting filenames
//======================================================================
int USERD_set_filenames
(
char filename_1[],
char filename_2[],
char the_path[],
int swapbytes
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_set_filenames" << endl << flush;
#endif
char tmp[100];
label lRoot = strlen(the_path);
label lCase = strlen(filename_1);
bool cleared = false;
while (!cleared)
{
lRoot = strlen(the_path);
lCase = strlen(filename_1);
// remove the last '/' from rootDir
if (the_path[lRoot-1] == '/')
{
the_path[lRoot-1] = (char)NULL;
}
else
{
cleared = true;
}
}
rootDir = the_path;
// the path is pre-pended to filename_1
// 1 is the 'Geometry' : 2 the 'Result' which is null here
// since two_field is FALSE
for (label i=0; i<lCase-lRoot;i++)
{
tmp[i] = filename_1[i+1+lRoot];
}
caseDir = tmp;
if (!dir(rootDir/caseDir))
{
Info<< rootDir/caseDir << " is not a valid directory."
<< endl;
return Z_ERR;
}
// construct the global pointers to the database and mesh
delete meshPtr;
delete runTimePtr;
runTimePtr = new Time
(
Time::controlDictName,
rootDir,
caseDir
);
Time& runTime = *runTimePtr;
meshPtr = new fvMesh
(
IOobject
(
fvMesh::defaultRegion,
runTime.timeName(),
runTime
)
);
// set the available number of time-steps
TimeList = (const instantList&)Foam::Time::findTimes(rootDir/caseDir);
Num_time_steps = TimeList.size() - 1;
nPatches = meshPtr->boundaryMesh().size();
// set the number of fields and store their names
// a valid field must exist for all time-steps
runTime.setTime(TimeList[TimeList.size()-1], TimeList.size()-1);
IOobjectList objects(*meshPtr, runTime.timeName());
fieldNames = (const wordList&)objects.names();
// because of the spray being a 'field' ...
// get the availabe number of variables and
// check for type (scalar/vector/tensor)
label nVar = 0;
wordList scalars = objects.names(scalarName);
for (label n=0; n<fieldNames.size(); n++)
{
bool isitScalar = false;
forAll(scalars,i)
{
if (fieldNames[n] == scalars[i])
{
isitScalar = true;
var2field[nVar++] = n;
}
}
isScalar[n] = isitScalar;
}
wordList vectors = objects.names(vectorName);
for (label n=0; n<fieldNames.size(); n++)
{
bool isitVector = false;
forAll(vectors,i)
{
if (fieldNames[n] == vectors[i])
{
isitVector = true;
var2field[nVar++] = n;
}
}
isVector[n] = isitVector;
}
wordList tensors = objects.names(tensorName);
for (label n=0; n<fieldNames.size(); n++)
{
bool isitTensor = false;
forAll(tensors,i)
{
if (fieldNames[n] == tensors[i])
{
isitTensor = true;
var2field[nVar++] = n;
}
}
isTensor[n] = isitTensor;
}
bool lagrangianNamesFound = false;
label n = 0;
while ((!lagrangianNamesFound) && (n<Num_time_steps))
{
runTime.setTime(TimeList[n+1], n+1);
Cloud<passiveParticle> lagrangian(*meshPtr);
n++;
if (lagrangian.size()>0)
{
lagrangianNamesFound = true;
}
}
IOobject sprayHeader
(
"positions",
runTime.timeName(),
"lagrangian",
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (sprayHeader.headerOk())
{
Info << "[Found lagrangian]" << endl;
delete sprayPtr;
sprayPtr = new Cloud<passiveParticle>(*meshPtr);
IOobjectList objects(*meshPtr, runTime.timeName(), "lagrangian");
lagrangianScalarNames =
(const wordList&)objects.names(sprayScalarFieldName);
lagrangianVectorNames =
(const wordList&)objects.names(sprayVectorFieldName);
isSpray[fieldNames.size()] = true;
nSprayVariables += lagrangianScalarNames.size();
nSprayVariables += lagrangianVectorNames.size();
Num_unstructured_parts++;
}
Current_time_step = Num_time_steps;
runTime.setTime(TimeList[Current_time_step], Current_time_step);
Num_variables = nVar + nSprayVariables;
Numparts_available = Num_unstructured_parts + Num_structured_parts + nPatches;
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_set_filenames" << endl << flush;
#endif
return Z_OK;
}

View File

@ -0,0 +1,12 @@
void USERD_set_server_number
(
int cur_serv,
int tot_serv
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_set_server_number" << endl
<< flush;
#endif
}

View File

@ -0,0 +1,45 @@
//======================================================================
void USERD_set_time_set_and_step
(
int timeset_number,
int time_step
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_set_time_set_and_step" << endl << flush;
#endif
// update the global pointers and variables
// to the current time-step
// at exit time_step < 0
if (time_step >= 0)
{
Time& runTime = *runTimePtr;
Current_time_step = time_step;
// add 1, since the first timestep is 'constant'
if (time_step == 0)
{
runTime.setTime(TimeList[Current_time_step], Current_time_step);
}
else
{
runTime.setTime(TimeList[Current_time_step + 1], Current_time_step + 1);
}
meshPtr->readUpdate();
if (time_step == 0)
{
runTime.setTime(TimeList[Current_time_step + 1], Current_time_step + 1);
}
if (Numparts_available > nPatches+1)
{
delete sprayPtr;
sprayPtr = new Cloud<passiveParticle>(*meshPtr);
}
}
}

View File

@ -0,0 +1,17 @@
int USERD_size_matf_data
(
int set_index,
int part_id,
int wtyp,
int mat_type,
int *matf_size
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_size_matf_data" << endl
<< flush;
#endif
return Z_ERR;
}

View File

@ -0,0 +1,8 @@
// Not in use
void USERD_stop_part_building(void)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_stop_part_building" << endl << flush;
#endif
}

View File

@ -0,0 +1,62 @@
int USERD_get_block_vector_values_by_component
(
int block_number,
int which_vector,
int which_component,
float *vector_array
)
{
return(Z_OK);
}
int USERD_get_block_coords_by_component
(
int block_number,
int which_component,
float *coord_array
)
{
return(Z_OK);
}
int USERD_get_block_iblanking
(
int block_number,
int *iblank_array
)
{
return(Z_OK);
}
int USERD_get_block_scalar_values
(
int block_number,
int which_scalar,
float *scalar_array
)
{
return(Z_OK);
}
int USERD_get_ghosts_in_model_flag( void )
{
return(Z_OK);
}
int USERD_get_ghosts_in_block_flag
(
int block_number
)
{
return(Z_OK);
}
int USERD_get_block_ghost_flags
(
int block_number,
int *ghost_flags
)
{
return(Z_OK);
}

View File

@ -0,0 +1,141 @@
if (nVar >= Num_variables - nSprayVariables)
{
return Z_UNDEF;
}
IOobject fieldObjectPtr
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
{
return Z_UNDEF;
}
IOobject fieldObject
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
volScalarField scalarField
(
fieldObject,
mesh
);
const cellShapeList& cellShapes = meshPtr->cellShapes();
// hexa's
if (which_type == Z_HEX08)
{
const cellModel& hex = *(cellModeller::lookup("hex"));
//const cellModel& wedge = *(cellModeller::lookup("wedge"));
label counter = 1;
for (label celli=0; celli<nCells; celli++)
{
const cellShape& cellShape = cellShapes[celli];
const cellModel& cellModel = cellShape.model();
if (cellModel == hex) // || (cellModel == wedge))
{
var_array[counter++] = scalarField[celli];
}
}
}
// penta's
if (which_type == Z_PEN06)
{
const cellModel& prism = *(cellModeller::lookup("prism"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == prism)
{
var_array[counter++] = scalarField[n];
}
}
}
// pyramids's
if (which_type == Z_PYR05)
{
const cellModel& pyr = *(cellModeller::lookup("pyr"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == pyr)
{
var_array[counter++] = scalarField[n];
}
}
}
// tet's
if (which_type == Z_TET04)
{
const cellModel& tet = *(cellModeller::lookup("tet"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == tet)
{
var_array[counter++] = scalarField[n];
}
}
}
if (which_type == Z_NFACED)
{
const cellList& cells = meshPtr->cells();
label counter = 1;
for (label n=0; n<nCells; n++)
{
const labelList& points = cellShapes[n];
label nFacesInCell = cells[n].size();
if ((nFacesInCell == 6) && (points.size() == 8))
{}
else if ((nFacesInCell == 4) && (points.size() == 4))
{}
else if (nFacesInCell == 5)
{
if (points.size() == 6)
{}
else if (points.size() == 5)
{}
else
{
var_array[counter++] = scalarField[n];
}
}
else
{
var_array[counter++] = scalarField[n];
}
}
}

View File

@ -0,0 +1,142 @@
if (nVar >= Num_variables - nSprayVariables)
{
return Z_UNDEF;
}
IOobject fieldObjectPtr
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
{
return Z_UNDEF;
}
IOobject fieldObject
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
volTensorField tf
(
fieldObject,
mesh
);
const cellShapeList& cellShapes = meshPtr->cellShapes();
// hexa's
if (which_type == Z_HEX08)
{
const cellModel& hex = *(cellModeller::lookup("hex"));
//const cellModel& wedge = *(cellModeller::lookup("wedge"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == hex) // || (cellModel == wedge))
{
# include "tensorConversion.H"
}
}
}
// penta's
if (which_type == Z_PEN06)
{
const cellModel& prism = *(cellModeller::lookup("prism"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == prism)
{
# include "tensorConversion.H"
}
}
}
// pyramids's
if (which_type == Z_PYR05)
{
const cellModel& pyr = *(cellModeller::lookup("pyr"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == pyr)
{
# include "tensorConversion.H"
}
}
}
// penta's
if (which_type == Z_TET04)
{
const cellModel& tet = *(cellModeller::lookup("tet"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == tet)
{
# include "tensorConversion.H"
}
}
}
if (which_type == Z_NFACED)
{
const cellList& cells = meshPtr->cells();
label counter = 1;
for (label n=0; n<nCells; n++)
{
const labelList& points = cellShapes[n];
label nFacesInCell = cells[n].size();
if ((nFacesInCell == 6) && (points.size() == 8))
{}
else if ((nFacesInCell == 4) && (points.size() == 4))
{}
else if (nFacesInCell == 5)
{
if (points.size() == 6)
{}
else if (points.size() == 5)
{}
else
{
# include "tensorConversion.H"
}
}
else
{
# include "tensorConversion.H"
}
}
}

View File

@ -0,0 +1,141 @@
if (nVar >= Num_variables - nSprayVariables)
{
return Z_UNDEF;
}
IOobject fieldObjectPtr
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
{
return Z_UNDEF;
}
IOobject fieldObject
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
volVectorField vectorField
(
fieldObject,
mesh
);
const cellShapeList& cellShapes = meshPtr->cellShapes();
// hexa's
if (which_type == Z_HEX08)
{
const cellModel& hex = *(cellModeller::lookup("hex"));
//const cellModel& wedge = *(cellModeller::lookup("wedge"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == hex) // || (cellModel == wedge))
{
var_array[counter++] = vectorField[n][component];
}
}
}
// penta's
if (which_type == Z_PEN06)
{
const cellModel& prism = *(cellModeller::lookup("prism"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == prism)
{
var_array[counter++] = vectorField[n][component];
}
}
}
// pyramids's
if (which_type == Z_PYR05)
{
const cellModel& pyr = *(cellModeller::lookup("pyr"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == pyr)
{
var_array[counter++] = vectorField[n][component];
}
}
}
// tet's
if (which_type == Z_TET04)
{
const cellModel& tet = *(cellModeller::lookup("tet"));
label counter = 1;
for (label n=0; n<nCells; n++)
{
const cellShape& cellShape = cellShapes[n];
const cellModel& cellModel = cellShape.model();
if (cellModel == tet)
{
var_array[counter++] = vectorField[n][component];
}
}
}
if (which_type == Z_NFACED)
{
const cellList& cells = meshPtr->cells();
label counter = 1;
for (label n=0; n<nCells; n++)
{
const labelList& points = cellShapes[n];
label nFacesInCell = cells[n].size();
if ((nFacesInCell == 6) && (points.size() == 8))
{}
else if ((nFacesInCell == 4) && (points.size() == 4))
{}
else if (nFacesInCell == 5)
{
if (points.size() == 6)
{}
else if (points.size() == 5)
{}
else
{
var_array[counter++] = vectorField[n][component];
}
}
else
{
var_array[counter++] = vectorField[n][component];
}
}
}

View File

@ -0,0 +1,42 @@
// Not sure if this is necessary anymore
nVar -= Num_variables - nSprayVariables;
if (nVar >= 0)
{
word name = lagrangianScalarNames[nVar];
IOField<scalar> s
(
IOobject
(
name,
runTime.timeName(),
"lagrangian",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
if (s.size() != 0)
{
for
(
label n = 0;
n < s.size();
n++
)
{
var_array[n+1] = s[n];
}
}
}
else
{
//Info << "getLagrangianScalar: nVar = " << nVar << endl;
return Z_UNDEF;
}

View File

@ -0,0 +1,54 @@
// Not sure if this is necessary anymore
nVar -= Num_variables - nSprayVariables + lagrangianScalarNames.size();
if (nVar >= 0)
{
word name = lagrangianVectorNames[nVar];
IOField<vector> v
(
IOobject
(
name,
runTime.timeName(),
"lagrangian",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
if (v.size() != 0)
{
for
(
label n = 0;
n < v.size();
n++
)
{
if (component == 0)
{
var_array[n+1] = v[n].x();
}
else if (component == 1)
{
var_array[n+1] = v[n].y();
}
else if (component == 2)
{
var_array[n+1] = v[n].z();
}
}
}
}
else
{
//Info << "getLagrangianVector: nVar = " << nVar << endl;
return Z_UNDEF;
}

View File

@ -0,0 +1,76 @@
label patchi = which_part - 2;
if (nVar >= Num_variables - nSprayVariables)
{
return Z_UNDEF;
}
IOobject fieldObjectPtr
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
{
return Z_UNDEF;
}
IOobject fieldObject
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
volScalarField sf
(
fieldObject,
mesh
);
const scalarField& sfb = sf.boundaryField()[patchi];
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
if (which_type == Z_TRI03)
{
label counter = 1;
for (label facei=0; facei<sfb.size(); facei++)
{
label nPoints = bMesh[patchi][facei].size();
if (nPoints == 3)
{
var_array[counter++] = sfb[facei];
}
}
}
if (which_type == Z_QUA04)
{
label counter = 1;
for (label facei=0; facei<sfb.size(); facei++)
{
label nPoints = bMesh[patchi][facei].size();
if (nPoints == 4)
{
var_array[counter++] = sfb[facei];
}
}
}
if (which_type == Z_NSIDED)
{
label counter = 1;
for (label facei=0; facei<sfb.size(); facei++)
{
label nPoints = bMesh[patchi][facei].size();
if ((nPoints != 3) && (nPoints != 4))
{
var_array[counter++] = sfb[facei];
}
}
}

View File

@ -0,0 +1,76 @@
label patchi = which_part - 2;
if (nVar >= Num_variables - nSprayVariables)
{
return Z_UNDEF;
}
IOobject fieldObjectPtr
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
{
return Z_UNDEF;
}
IOobject fieldObject
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
volTensorField sf
(
fieldObject,
mesh
);
const tensorField& tf = sf.boundaryField()[patchi];
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
if (which_type == Z_TRI03)
{
label counter = 1;
for (label n=0; n<tf.size(); n++)
{
label nPoints = bMesh[patchi][n].size();
if (nPoints == 3)
{
# include "tensorConversion.H"
}
}
}
if (which_type == Z_QUA04)
{
label counter = 1;
for (label n=0; n<tf.size(); n++)
{
label nPoints = bMesh[patchi][n].size();
if (nPoints == 4)
{
# include "tensorConversion.H"
}
}
}
if (which_type == Z_NSIDED)
{
label counter = 1;
for (label n=0; n<tf.size(); n++)
{
label nPoints = bMesh[patchi][n].size();
if ((nPoints != 3) && (nPoints != 4))
{
# include "tensorConversion.H"
}
}
}

View File

@ -0,0 +1,76 @@
label patchi = which_part - 2;
if (nVar >= Num_variables - nSprayVariables)
{
return Z_UNDEF;
}
IOobject fieldObjectPtr
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::NO_READ
);
if (!fieldObjectPtr.headerOk())
{
return Z_UNDEF;
}
IOobject fieldObject
(
fieldNames[var2field[nVar]],
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
volVectorField sf
(
fieldObject,
mesh
);
const vectorField& sfb = sf.boundaryField()[patchi];
const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
if (which_type == Z_TRI03)
{
label counter = 1;
for (label facei=0; facei<sfb.size(); facei++)
{
label nPoints = bMesh[patchi][facei].size();
if (nPoints == 3)
{
var_array[counter++] = sfb[facei][component];
}
}
}
if (which_type == Z_QUA04)
{
label counter = 1;
for (label facei=0; facei<sfb.size(); facei++)
{
label nPoints = bMesh[patchi][facei].size();
if (nPoints == 4)
{
var_array[counter++] = sfb[facei][component];
}
}
}
if (which_type == Z_NSIDED)
{
label counter = 1;
for (label facei=0; facei<sfb.size(); facei++)
{
label nPoints = bMesh[patchi][facei].size();
if ((nPoints != 3) && (nPoints != 4))
{
var_array[counter++] = sfb[facei][component];
}
}
}

View File

@ -0,0 +1,54 @@
//======================================================================
// Global variables
const int maxNames = 1000;
// define the name to be displayed in the window.
static char readerName[] = "OpenFOAM";
static char meshName[] = "cells";
static char readerVersion[] = "2.03";
// everything is one part in foam, except the spray
static int Num_unstructured_parts = 1;
static int Num_structured_parts = 0;
static int Numparts_available = 1;
static int nPatches = 0;
static int Num_timesets = 1;
static int Geom_timeset_number = 1;
static int Num_time_steps = 1;
static int Num_global_nodes = 0;
static int Num_variables = 0;
static int Num_dataset_files = 0;
static int Current_time_step = 0;
static label nSprayVariables = 0;
static label nMaxParcels = 0;
static bool isScalar[maxNames];
static bool isVector[maxNames];
static bool isTensor[maxNames];
static bool isSpray[maxNames];
static word scalarName = "volScalarField";
static word vectorName = "volVectorField";
static word tensorName = "volTensorField";
static word sprayName = "lagrangian";
static word sprayScalarFieldName = "scalarField";
static word sprayVectorFieldName = "vectorField";
static word sprayTensorFieldName = "tensorField";
static word parcelPrepend = "parcel_";
static word pointPrepend = "point_";
static fileName rootDir;
static fileName caseDir;
static instantList TimeList;
static List<word> fieldNames;
static List<word> lagrangianScalarNames;
static List<word> lagrangianVectorNames;
static label var2field[maxNames];
static Time *runTimePtr = 0;
static fvMesh *meshPtr = 0;
static Cloud<passiveParticle> *sprayPtr = 0;

View File

@ -0,0 +1,281 @@
/*--------------------------------------------------------------*/
/* Header file for EnSight External Reader DSO Library Routines */
/*--------------------------------------------------------------*/
/* *************************************************************
* Copyright 1998 Computational Engineering International, Inc.
* All Rights Reserved.
*
* Restricted Rights Legend
*
* Use, duplication, or disclosure of this
* software and its documentation by the
* Government is subject to restrictions as
* set forth in subdivision [(b)(3)(ii)] of
* the Rights in Technical Data and Computer
* Software clause at 52.227-7013.
* *************************************************************
*/
#ifndef GLOBAL_EXTERN_H
#define GLOBAL_EXTERN_H
/*--------------------------------
* Set the reader version define
* (only one can be set at a time)
*--------------------------------*/
#define USERD_API_203
/*----------------------------------------
* Set this appropriately:
* DO_ENSIGHT if using for EnSight itself
* DO_READER if using in a reader
*----------------------------------------*/
#if 1
#define DO_READER
#else
#define DO_ENSIGHT
#endif
/*---------------------------------------*/
/* True/False and Error conditions, etc. */
/*---------------------------------------*/
#define Z_ERR (-1) /*Error return value.*/
#define Z_OK (1) /*Success return value.*/
#define Z_UNDEF (2) /*Undefined return value.*/
#define Z_NOT_IMPLEMENTED (3) /*Routine not implemented*/
/*(currently only checked for */
/* get_var_value_at_specific routine)*/
#ifndef TRUE
# define TRUE (1)
# define FALSE (0)
#endif
#define Z_BUFL (80) /* Typical string length */
#define Z_COMPX (0) /* x component */
#define Z_COMPY (1) /* y component */
#define Z_COMPZ (2) /* z component */
#define Z_STATIC (0) /* static geometry */
#define Z_CHANGE_COORDS (1) /* coordinate changing only */
#define Z_CHANGE_CONN (2) /* conectivity changing */
#define Z_GEOM (0) /* Geometry type */
#define Z_VARI (1) /* Variable type */
#define Z_SAVE_ARCHIVE (0) /* Save archive */
#define Z_REST_ARCHIVE (1) /* Restore archive */
#define Z_MAX_USERD_NAME (20) /* max length of reader name */
#define Z_PER_NODE (4) /* At Nodes Variable classif. */
#define Z_PER_ELEM (1) /* At Elements Variable classif.*/
#define Z_MAX_SETS (300)
#ifndef GLOBALDEFS_H
/*-----------------------------------*/
/* Unstructured coordinate structure */
/*-----------------------------------*/
typedef struct {
float xyz[3];
}CRD;
#endif
/*----------------*/
/* Variable Types */
/*----------------*/
enum z_var_type
{
Z_CONSTANT,
Z_SCALAR,
Z_VECTOR,
Z_TENSOR,
Z_TENSOR9,
MAX_Z_VAR_TYPES
};
/*---------------
* Element Types
*---------------
* If you mess with these, you must also
* change the get_z_maxtype
* to_z_elem_type
* to_int_elem_type routines
* in userd_read.c
*----------------------------------------*/
#if (defined USERD_API_100 || defined USERD_API_200) && defined DO_READER
enum z_elem_types {
Z_POINT, /* 00: 1 node point element */
Z_BAR02, /* 01: 2 node bar */
Z_BAR03, /* 02: 3 node bar */
Z_TRI03, /* 03: 3 node triangle */
Z_TRI06, /* 04: 6 node triangle */
Z_QUA04, /* 05: 4 node quad */
Z_QUA08, /* 06: 8 node quad */
Z_TET04, /* 07: 4 node tetrahedron */
Z_TET10, /* 08: 10 node tetrahedron */
Z_PYR05, /* 09: 5 node pyramid */
Z_PYR13, /* 10: 13 node pyramid */
Z_PEN06, /* 11: 6 node pentahedron */
Z_PEN15, /* 12: 15 node pentahedron */
Z_HEX08, /* 13: 8 node hexahedron */
Z_HEX20, /* 14: 20 node hexahedron */
Z_MAXTYPE
};
#elif defined USERD_API_201 && defined DO_READER
enum z_elem_types {
Z_POINT, /* 00: 1 node point element */
Z_G_POINT, /* 01: 1 node point element (ghost call) */
Z_BAR02, /* 02: 2 node bar */
Z_G_BAR02, /* 03: 2 node bar (ghost cell) */
Z_BAR03, /* 04: 3 node bar */
Z_G_BAR03, /* 05: 3 node bar (ghost cell) */
Z_TRI03, /* 06: 3 node triangle */
Z_G_TRI03, /* 07: 3 node triangle (ghost cell) */
Z_TRI06, /* 08: 6 node triangle */
Z_G_TRI06, /* 09: 6 node triangle (ghost cell) */
Z_QUA04, /* 10: 4 node quad */
Z_G_QUA04, /* 11: 4 node quad (ghost cell) */
Z_QUA08, /* 12: 8 node quad */
Z_G_QUA08, /* 13: 8 node quad (ghost cell) */
Z_TET04, /* 14: 4 node tetrahedron */
Z_G_TET04, /* 15: 4 node tetrahedron (ghost cell) */
Z_TET10, /* 16: 10 node tetrahedron */
Z_G_TET10, /* 17: 10 node tetrahedron (ghost cell) */
Z_PYR05, /* 18: 5 node pyramid */
Z_G_PYR05, /* 19: 5 node pyramid (ghost cell) */
Z_PYR13, /* 20: 13 node pyramid */
Z_G_PYR13, /* 21: 13 node pyramid (ghost cell) */
Z_PEN06, /* 22: 6 node pentahedron */
Z_G_PEN06, /* 23: 6 node pentahedron (ghost cell) */
Z_PEN15, /* 24: 15 node pentahedron */
Z_G_PEN15, /* 25: 15 node pentahedron (ghost cell) */
Z_HEX08, /* 26: 8 node hexahedron */
Z_G_HEX08, /* 27: 8 node hexahedron (ghost cell) */
Z_HEX20, /* 28: 20 node hexahedron */
Z_G_HEX20, /* 29: 20 node hexahedron (ghost cell) */
Z_MAXTYPE
};
#else
enum z_elem_types {
Z_POINT, /* 00: 1 node point element */
Z_G_POINT, /* 01: 1 node point element (ghost call) */
Z_BAR02, /* 02: 2 node bar */
Z_G_BAR02, /* 03: 2 node bar (ghost cell) */
Z_BAR03, /* 04: 3 node bar */
Z_G_BAR03, /* 05: 3 node bar (ghost cell) */
Z_TRI03, /* 06: 3 node triangle */
Z_G_TRI03, /* 07: 3 node triangle (ghost cell) */
Z_TRI06, /* 08: 6 node triangle */
Z_G_TRI06, /* 09: 6 node triangle (ghost cell) */
Z_QUA04, /* 10: 4 node quad */
Z_G_QUA04, /* 11: 4 node quad (ghost cell) */
Z_QUA08, /* 12: 8 node quad */
Z_G_QUA08, /* 13: 8 node quad (ghost cell) */
Z_TET04, /* 14: 4 node tetrahedron */
Z_G_TET04, /* 15: 4 node tetrahedron (ghost cell) */
Z_TET10, /* 16: 10 node tetrahedron */
Z_G_TET10, /* 17: 10 node tetrahedron (ghost cell) */
Z_PYR05, /* 18: 5 node pyramid */
Z_G_PYR05, /* 19: 5 node pyramid (ghost cell) */
Z_PYR13, /* 20: 13 node pyramid */
Z_G_PYR13, /* 21: 13 node pyramid (ghost cell) */
Z_PEN06, /* 22: 6 node pentahedron */
Z_G_PEN06, /* 23: 6 node pentahedron (ghost cell) */
Z_PEN15, /* 24: 15 node pentahedron */
Z_G_PEN15, /* 25: 15 node pentahedron (ghost cell) */
Z_HEX08, /* 26: 8 node hexahedron */
Z_G_HEX08, /* 27: 8 node hexahedron (ghost cell) */
Z_HEX20, /* 28: 20 node hexahedron */
Z_G_HEX20, /* 29: 20 node hexahedron (ghost cell) */
Z_NSIDED, /* 30: n node polygon */
Z_G_NSIDED, /* 31: n node polygon (ghost cell) */
Z_NFACED, /* 32: n faced polyhedron */
Z_G_NFACED, /* 33: n faced polyhedron (ghost cell) */
Z_MAXTYPE
};
#endif
enum z_node_ids_opt
{
Z_NO_NODE_IDS,
Z_ASSIGN_NODE_IDS,
Z_GIVEN_NODE_IDS
};
enum z_element_ids_opt
{
Z_NO_ELEMENT_IDS,
Z_ASSIGN_ELEMENT_IDS,
Z_GIVEN_ELEMENT_IDS
};
/*-------------------------------*/
/* Unstructured/Structured types */
/*-------------------------------*/
enum z_structured_defs
{
Z_UNSTRUCTURED, /* for unstructured part */
Z_STRUCTURED, /* for structured (non-iblanked) part */
Z_IBLANKED, /* for structured iblanked part */
Z_MAXMESHTYPES
};
/*----------------------------*/
/* Structured Iblanking types */
/*----------------------------*/
enum z_iblank_domain
{
Z_EXT, /* Exterior */
Z_INT, /* Interior */
Z_BND, /* Boundary */
Z_INTBND, /* Internal boundary/baffle */
Z_SYM, /* Symmetry surface */
Z_NO_OF_IBLANK_DOMAIN_ITEMS
};
/*-----------------------------------*/
/* Dataset Query file info Structure */
/*-----------------------------------*/
#define Z_MAXFILENP 255 /* Max file name and path.*/
#define Z_MAXTIMLEN 40 /* Max time str length */
#define Z_BUFLEN 82 /* Allocated length of the f_desc strings */
typedef struct {
char name[Z_MAXFILENP];
long sizeb;
char timemod[Z_MAXTIMLEN];
int num_d_lines;
char **f_desc;
} Z_QFILES;
/*-------------------------------------------
* Mixed Material enum
*
* (Must be comparable to material_file_index
* in mat_defs.h of EnSight server)
*--------------------------------------------*/
enum z_material_file_index
{
Z_MAT_INDEX,
Z_MIX_INDEX,
Z_MIX_VALUE,
Z_NUM_MAT_FILES
};
/*----------------------------------------------------------
* For readers, we need to include the prototype header file
*----------------------------------------------------------*/
#if defined DO_READER
#include "global_extern_proto.h"
#endif
/*--------------------------------------------------------------------*/
#endif /*GLOBAL_EXTERN_H*/

View File

@ -0,0 +1,382 @@
/*--------------------------------------------------------------*/
/* Prototype Header file for EnSight External Reader */
/* DSO Library Routines */
/* */
/* intended to be included from global_extern.h only */
/*--------------------------------------------------------------*/
/* *************************************************************
* Copyright 1998 Computational Engineering International, Inc.
* All Rights Reserved.
*
* Restricted Rights Legend
*
* Use, duplication, or disclosure of this
* software and its documentation by the
* Government is subject to restrictions as
* set forth in subdivision [(b)(3)(ii)] of
* the Rights in Technical Data and Computer
* Software clause at 52.227-7013.
* *************************************************************
*/
#ifndef GLOBAL_EXTERN_PROTO_H
#define GLOBAL_EXTERN_PROTO_H
#ifdef WIN32
#define W32IMPORT __declspec( dllimport )
#define W32EXPORT __declspec( dllexport )
#else
#define W32IMPORT extern
#define W32EXPORT extern
#endif
/*----------------------
* Same in All Versions
*----------------------*/
W32IMPORT int
USERD_get_number_of_model_parts( void );
W32IMPORT int
USERD_get_block_coords_by_component(int block_number,
int which_component,
float *coord_array);
W32IMPORT int
USERD_get_block_iblanking(int block_number,
int *iblank_array);
W32IMPORT int
USERD_get_block_scalar_values(int block_number,
int which_scalar,
float *scalar_array);
W32IMPORT int
USERD_get_block_vector_values_by_component(int block_number,
int which_vector,
int which_component,
float *vector_array);
W32IMPORT int
USERD_get_name_of_reader(char reader_name[Z_MAX_USERD_NAME],
int *two_fields);
W32IMPORT int
USERD_get_reader_descrip(char descrip[Z_MAXFILENP]);
W32IMPORT int
USERD_set_filenames(char filename_1[],
char filename_2[],
char the_path[],
int swapbytes);
W32IMPORT int
USERD_get_number_of_files_in_dataset( void );
W32IMPORT int
USERD_get_dataset_query_file_info(Z_QFILES *qfiles);
W32IMPORT int
USERD_get_changing_geometry_status( void );
W32IMPORT int
USERD_get_node_label_status( void );
W32IMPORT int
USERD_get_element_label_status( void );
W32IMPORT int
USERD_get_number_of_variables( void );
W32IMPORT void
USERD_stop_part_building( void );
W32IMPORT int
USERD_bkup(FILE *archive_file,
int backup_type);
/*-----------------------
* For Version 1.000 Only
*-----------------------*/
#if defined USERD_API_100
W32IMPORT int
USERD_get_number_of_global_nodes( void );
W32IMPORT int
USERD_get_global_coords(CRD *coord_array);
W32IMPORT int
USERD_get_global_node_ids(int *nodeid_array);
W32IMPORT int
USERD_get_element_connectivities_for_part(int part_number,
int **conn_array[Z_MAXTYPE]);
W32IMPORT int
USERD_get_element_ids_for_part(int part_number,
int *elemid_array[Z_MAXTYPE]);
W32IMPORT int
USERD_get_vector_values(int which_vector,
int which_part,
int which_type,
float *vector_array);
W32IMPORT int
USERD_get_part_build_info(int *part_id,
int *part_types,
char *part_descriptions[Z_BUFL],
int *number_of_elements[Z_MAXTYPE],
int *ijk_dimensions[3],
int *iblanking_options[6]);
W32IMPORT int
USERD_get_scalar_values(int which_scalar,
int which_part,
int which_type,
float *scalar_array);
W32IMPORT int
USERD_get_variable_info(char **var_description,
char **var_filename,
int *var_type,
int *var_classify);
W32IMPORT int
USERD_get_description_lines(int which_type,
int which_var,
char line1[Z_BUFL],
char line2[Z_BUFL]);
W32IMPORT int
USERD_get_variable_value_at_specific(int which_var,
int which_node_or_elem,
int which_part,
int which_elem_type,
int time_step,
float values[3]);
W32IMPORT float
USERD_get_constant_value(int which_var);
W32IMPORT int
USERD_get_solution_times(float *solution_times);
W32IMPORT void
USERD_set_time_step(int time_step);
W32IMPORT int
USERD_get_number_of_time_steps(void);
#endif
/*----------------------
* New For Version 2.000
*----------------------*/
#if !defined USERD_API_100
W32IMPORT int
USERD_get_part_coords(int part_number,
float **coord_array);
W32IMPORT int
USERD_get_part_node_ids(int part_number,
int *nodeid_array);
W32IMPORT int
USERD_get_part_elements_by_type(int part_number,
int element_type,
int **conn_array);
W32IMPORT int
USERD_get_part_element_ids_by_type(int part_number,
int element_type,
int *elemid_array);
W32IMPORT int
USERD_get_reader_version(char version_number[Z_MAX_USERD_NAME]);
W32IMPORT int
USERD_get_reader_release(char version_number[Z_MAX_USERD_NAME]);
W32IMPORT int
USERD_get_var_by_component(int which_variable,
int which_part,
int var_type,
int which_type,
int complex,
int component,
float *var_array);
W32IMPORT int
USERD_get_maxsize_info(int *max_number_of_nodes,
int *max_number_of_elements[Z_MAXTYPE],
int *max_ijk_dimensions[3]);
W32IMPORT void
USERD_exit_routine( void );
W32IMPORT int
USERD_get_gold_variable_info(char **var_description,
char **var_filename,
int *var_type,
int *var_classify,
int *var_complex,
char **var_ifilename,
float *var_freq,
int *var_contran,
int *var_timeset);
W32IMPORT int
USERD_get_model_extents( float extents[6] );
W32IMPORT int
USERD_get_descrip_lines(int which_type,
int which_var,
int imag_data,
char line1[Z_BUFL],
char line2[Z_BUFL]);
W32IMPORT int
USERD_get_var_value_at_specific(int which_var,
int which_node_or_elem,
int which_part,
int which_elem_type,
int time_step,
float values[3],
int imag_data);
W32IMPORT float
USERD_get_constant_val(int which_var, int imag_data);
W32IMPORT int
USERD_get_geom_timeset_number(void);
W32IMPORT int
USERD_get_number_of_timesets(void);
W32IMPORT int
USERD_get_timeset_description(int timeset_number,
char timeset_description[Z_BUFL]);
W32IMPORT int
USERD_get_sol_times(int timeset_number,
float *solution_times);
W32IMPORT void
USERD_set_time_set_and_step(int timeset_number,
int time_step);
W32IMPORT int
USERD_get_num_of_time_steps(int timeset_number);
W32IMPORT int
USERD_get_border_availability(int part_number,
int number_of_elements[Z_MAXTYPE]);
W32IMPORT int
USERD_get_border_elements_by_type(int part_number,
int element_type,
int **conn_array,
short *parent_element_type,
int *parent_element_num);
W32IMPORT void
USERD_set_server_number(int serv_num,
int tot_servs);
#endif
/*----------------------
* New For Version 2.010
*----------------------*/
#if defined USERD_API_201 || defined USERD_API_202 || defined USERD_API_203
W32IMPORT int
USERD_get_ghosts_in_model_flag( void );
W32IMPORT int
USERD_get_ghosts_in_block_flag(int block_number);
W32IMPORT int
USERD_get_block_ghost_flags(int block_number,
int *ghost_flags);
#endif
/*--------------------------
* Modified at Version 2.030
*--------------------------*/
#if defined USERD_API_201 || defined USERD_API_202
W32IMPORT int
USERD_get_gold_part_build_info(int *part_id,
int *part_types,
char *part_descriptions[Z_BUFL],
int *number_of_nodes,
int *number_of_elements[Z_MAXTYPE],
int *ijk_dimensions[3],
int *iblanking_options[6]);
#endif
#if defined USERD_API_203
W32IMPORT int
USERD_get_gold_part_build_info(int *part_id,
int *part_types,
char *part_descriptions[Z_BUFL],
int *number_of_nodes,
int *number_of_elements[Z_MAXTYPE],
int *ijk_dimensions[9],
int *iblanking_options[6]);
#endif
/*----------------------
* New For Version 2.030
*----------------------*/
#if defined USERD_API_203
W32IMPORT int
USERD_get_number_of_material_sets( void );
W32IMPORT int
USERD_get_matf_set_info(int *mat_set_ids,
char **mat_set_name);
W32IMPORT int
USERD_get_number_of_materials( int set_index );
W32IMPORT int
USERD_get_matf_var_info(int set_index,
int *mat_ids,
char **mat_desc);
W32IMPORT int
USERD_size_matf_data(int set_index,
int part_id,
int wtyp,
int mat_type,
int *matf_size );
W32IMPORT int
USERD_load_matf_data( int set_index,
int part_id,
int wtyp,
int mat_type,
int *ids_list,
float *val_list );
W32IMPORT int
USERD_get_nsided_conn( int part_number,
int *nsided_conn_array );
W32IMPORT int
USERD_get_nfaced_nodes_per_face( int part_number,
int *nfaced_npf_array );
W32IMPORT int
USERD_get_nfaced_conn( int part_number,
int *nfaced_conn_array );
#endif
/*--------------------------------------------------------------------*/
#endif /*GLOBAL_EXTERN_PROTO_H*/

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
libuserd-foam
Description
EnSight library module to read OpenFOAM data directly without translation
It can currently handle most cell types.
See also: README_USERD_2.0
24 Sep 2001: NN - Added support for Ensight API 2.0
02 Sep 2002: NN - Added support for ghost cells
14 Mar 2004: NN - Added patches to the parts
\*---------------------------------------------------------------------------*/
#include <stdio.h>
#include "fvCFD.H"
#include "IOobjectList.H"
#include "Cloud.H"
#include "passiveParticle.H"
#include "fvMesh.H"
#include "cellModeller.H"
#include "globalFoam.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
extern "C"
{
#include "global_extern.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// same API as in 1.0
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "USERD_bkup.H"
#include "USERD_get_name_of_reader.H"
#include "USERD_set_filenames.H"
#include "USERD_get_number_of_model_parts.H"
#include "USERD_get_changing_geometry_status.H"
#include "USERD_get_dataset_query_file_info.H"
#include "USERD_get_element_label_status.H"
#include "USERD_get_node_label_status.H"
#include "USERD_get_number_of_files_in_dataset.H"
#include "USERD_get_number_of_variables.H"
#include "USERD_stop_part_building.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// slightly changed with 2.0 from 1.0
// (to handle complex variables - not used by FOAM anyway)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "USERD_get_constant_val.H"
#include "USERD_get_descrip_lines.H"
#include "USERD_get_var_value_at_specific.H"
#include "USERD_get_gold_variable_info.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// critical changes with 2.0 from 1.0
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "USERD_get_gold_part_build_info.H"
#include "USERD_get_num_of_time_steps.H"
#include "USERD_get_sol_times.H"
#include "USERD_set_time_set_and_step.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// new additions with 2.0 from 1.0
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "USERD_get_var_by_component.H"
#include "USERD_get_part_coords.H"
#include "USERD_get_part_node_ids.H"
#include "USERD_get_part_elements_by_type.H"
#include "USERD_get_part_element_ids_by_type.H"
#include "USERD_exit_routine.H"
#include "USERD_get_model_extents.H"
#include "USERD_get_reader_version.H"
#include "USERD_get_number_timesets.H"
#include "USERD_get_timeset_description.H"
#include "USERD_get_geom_timeset_number.H"
#include "USERD_get_border_availability.H"
#include "USERD_get_border_elements_by_type.H"
#include "USERD_get_maxsize_info.H"
#include "USERD_set_server_number.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// new additions with 2.03 from 2.02
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "USERD_get_number_of_material_sets.H"
#include "USERD_get_matf_set_info.H"
#include "USERD_get_number_of_materials.H"
#include "USERD_get_matf_var_info.H"
#include "USERD_size_matf_data.H"
#include "USERD_load_matf_data.H"
#include "USERD_get_nsided_conn.H"
#include "USERD_get_nfaced_nodes_per_face.H"
#include "USERD_get_nfaced_conn.H"
//**********************************************************************
//======================================================================
// STRUCTURED DATA STUFF - not used in foam
//======================================================================
//**********************************************************************
#include "USERD_structured_data.H"
}
// ************************************************************************ //

View File

@ -0,0 +1,36 @@
if (component == 0)
{
var_array[counter++] = tf[n].xx();
}
else if (component == 1)
{
var_array[counter++] = tf[n].yy();
}
else if (component == 2)
{
var_array[counter++] = tf[n].zz();
}
else if (component == 3)
{
var_array[counter++] = tf[n].xy();
}
else if (component == 4)
{
var_array[counter++] = tf[n].xz();
}
else if (component == 5)
{
var_array[counter++] = tf[n].yz();
}
else if (component == 6)
{
var_array[counter++] = tf[n].yx();
}
else if (component == 7)
{
var_array[counter++] = tf[n].zx();
}
else if (component == 8)
{
var_array[counter++] = tf[n].zy();
}