Commit 911a960c authored by hrchilds's avatar hrchilds
Browse files

Update from May 25, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@476 18c085ea-50e0-402c-830e-de6fd14e8384
parent e49aa64c
......@@ -520,10 +520,13 @@ DebugStream::close()
// Ignore SIGPIPE because it can defeat our mechanisms for detecting when
// we lose a connection to a component.
//
// Jeremy Meredith, Tue May 17 11:20:51 PDT 2005
// Allow disabling of signal handlers.
//
// ****************************************************************************
void
DebugStream::Initialize(const char *progname, int debuglevel)
DebugStream::Initialize(const char *progname, int debuglevel, bool sigs)
{
switch (debuglevel)
{
......@@ -541,18 +544,21 @@ DebugStream::Initialize(const char *progname, int debuglevel)
break;
}
if (sigs)
{
#if !defined(_WIN32)
signal(SIGQUIT, signalhandler_core);
signal(SIGTRAP, signalhandler_core);
signal(SIGSYS, signalhandler_core);
signal(SIGBUS, signalhandler_core);
signal(SIGPIPE, SIG_IGN);
signal(SIGQUIT, signalhandler_core);
signal(SIGTRAP, signalhandler_core);
signal(SIGSYS, signalhandler_core);
signal(SIGBUS, signalhandler_core);
signal(SIGPIPE, SIG_IGN);
#endif
signal(SIGILL, signalhandler_core);
signal(SIGABRT, signalhandler_core);
signal(SIGFPE, SIG_IGN);
signal(SIGSEGV, signalhandler_core);
signal(SIGTERM, signalhandler_exit);
signal(SIGINT, signalhandler_exit);
signal(SIGILL, signalhandler_core);
signal(SIGABRT, signalhandler_core);
signal(SIGFPE, SIG_IGN);
signal(SIGSEGV, signalhandler_core);
signal(SIGTERM, signalhandler_exit);
signal(SIGINT, signalhandler_exit);
}
}
......@@ -44,6 +44,9 @@
// Change the DebugStreamBuf member to be a pointered value instead of
// a referenced value so that it works with the MIPSpro compiler.
//
// Jeremy Meredith, Tue May 17 11:20:51 PDT 2005
// Allow disabling of signal handlers.
//
// ****************************************************************************
class MISC_API DebugStream : public ostream
......@@ -55,7 +58,7 @@ class MISC_API DebugStream : public ostream
operator bool() {return enabled;};
void open(const char *progname);
void close();
static void Initialize(const char *, int);
static void Initialize(const char *, int, bool=true);
private:
class DebugStreamBuf : public streambuf
{
......
......@@ -138,10 +138,13 @@ NewHandler(void)
// Hank Childs, Tue Jun 1 11:47:36 PDT 2004
// Removed atexit call, since that is buggy with gcc.
//
// Jeremy Meredith, Tue May 17 11:20:51 PDT 2005
// Allow disabling of signal handlers.
//
// ****************************************************************************
void
Init::Initialize(int &argc, char *argv[], int r, int n, bool strip)
Init::Initialize(int &argc, char *argv[], int r, int n, bool strip, bool sigs)
{
int i, debuglevel = 0;
#if defined(_WIN32)
......@@ -218,7 +221,7 @@ Init::Initialize(int &argc, char *argv[], int r, int n, bool strip)
// Initialize the debug streams and also add the command line arguments
// to the debug logs.
DebugStream::Initialize(progname, debuglevel);
DebugStream::Initialize(progname, debuglevel, sigs);
for(i = 0; i < argc; ++i)
debug1 << argv[i] << " ";
debug1 << endl;
......
......@@ -30,11 +30,15 @@ typedef void (*ErrorFunction)(void *, const char *);
// Mark C. Miller, Tue Mar 8 18:06:19 PST 2005
// Added ComponentNameToID and ComponentIDToName
//
// Jeremy Meredith, Wed May 25 13:24:24 PDT 2005
// Added ability to disable custom signal handlers.
//
// ****************************************************************************
namespace Init
{
MISC_API void Initialize(int &argc, char *argv[], int r=0, int n=1, bool strip=true);
MISC_API void Initialize(int &argc, char *argv[], int r=0, int n=1,
bool strip=true, bool sigs=true);
MISC_API void Finalize();
MISC_API void SetComponentName(const char *);
MISC_API const char * GetExecutableName();
......
......@@ -56,6 +56,14 @@ extern "C"
#define VISIT_OWNER_SIM 0
#define VISIT_OWNER_VISIT 1
/* Cell Types */
#define VISIT_CELL_BEAM 0
#define VISIT_CELL_TRI 1
#define VISIT_CELL_QUAD 2
#define VISIT_CELL_TET 3
#define VISIT_CELL_PYR 4
#define VISIT_CELL_WEDGE 5
#define VISIT_CELL_HEX 6
typedef struct VisIt_DataArray
{
......@@ -182,12 +190,25 @@ typedef struct VisIt_RectilinearMesh
typedef struct VisIt_UnstructuredMesh
{
/* FILL IN */
int ndims;
int nnodes;
int nzones;
int firstRealZone;
int lastRealZone;
VisIt_DataArray xcoords;
VisIt_DataArray ycoords;
VisIt_DataArray zcoords;
int connectivityLen;
VisIt_DataArray connectivity;
} VisIt_UnstructuredMesh;
typedef struct VisIt_PointMesh
{
/* FILL IN */
int dummy;
} VisIt_PointMesh;
typedef struct VisIt_MeshData
......@@ -230,6 +251,7 @@ typedef struct VisIt_MaterialData
typedef struct VisIt_SpeciesData
{
/* FILL IN */
int dummy;
} VisIt_SpeciesData;
typedef struct VisIt_CurveData
......
......@@ -535,6 +535,9 @@ avtSimV1FileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
// Jeremy Meredith, Wed May 11 10:56:01 PDT 2005
// Added ghost zone support.
//
// Jeremy Meredith, Wed May 25 14:38:35 PDT 2005
// Added unstructured mesh support.
//
// ****************************************************************************
vtkDataSet *
avtSimV1FileFormat::GetMesh(int domain, const char *meshname)
......@@ -557,6 +560,10 @@ avtSimV1FileFormat::GetMesh(int domain, const char *meshname)
case VISIT_MESHTYPE_CURVILINEAR:
{
VisIt_CurvilinearMesh *cmesh = vmesh->cmesh;
if (!cmesh)
return NULL;
//
// Create the VTK objects and connect them up.
//
......@@ -651,6 +658,10 @@ avtSimV1FileFormat::GetMesh(int domain, const char *meshname)
case VISIT_MESHTYPE_RECTILINEAR:
{
VisIt_RectilinearMesh *rmesh = vmesh->rmesh;
if (!rmesh)
return NULL;
//
// Create the VTK objects and connect them up.
//
......@@ -753,6 +764,188 @@ avtSimV1FileFormat::GetMesh(int domain, const char *meshname)
return rgrid;
}
break;
case VISIT_MESHTYPE_UNSTRUCTURED:
{
VisIt_UnstructuredMesh *umesh = vmesh->umesh;
if (!umesh)
return NULL;
if (umesh->connectivity.dataType != VISIT_DATATYPE_INT)
{
EXCEPTION1(ImproperUseException,
"Connectivity array must be ints.");
}
vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
vtkPoints *points = vtkPoints::New();
ugrid->SetPoints(points);
points->Delete();
//
// Populate the coordinates.
//
int npts = umesh->nnodes;
points->SetNumberOfPoints(npts);
float *pts = (float *) points->GetVoidPointer(0);
if (umesh->xcoords.dataType == VISIT_DATATYPE_FLOAT)
{
for (int i=0; i<npts; i++)
{
pts[i*3 + 0] = umesh->xcoords.fArray[i];
pts[i*3 + 1] = umesh->ycoords.fArray[i];
if (umesh->ndims==3)
pts[i*3 + 2] = umesh->zcoords.fArray[i];
else
pts[i*3 + 2] = 0;
}
}
else if (umesh->xcoords.dataType == VISIT_DATATYPE_DOUBLE)
{
for (int i=0; i<npts; i++)
{
pts[i*3 + 0] = umesh->xcoords.dArray[i];
pts[i*3 + 1] = umesh->ycoords.dArray[i];
if (umesh->ndims==3)
pts[i*3 + 2] = umesh->zcoords.dArray[i];
else
pts[i*3 + 2] = 0;
}
}
else
{
EXCEPTION1(ImproperUseException,
"Coordinate arrays must be float or double.\n");
}
int celltype_npts[10];
celltype_npts[VISIT_CELL_BEAM] = 2;
celltype_npts[VISIT_CELL_TRI] = 3;
celltype_npts[VISIT_CELL_QUAD] = 4;
celltype_npts[VISIT_CELL_TET] = 4;
celltype_npts[VISIT_CELL_PYR] = 5;
celltype_npts[VISIT_CELL_WEDGE] = 6;
celltype_npts[VISIT_CELL_HEX] = 8;
int celltype_idtype[10];
celltype_idtype[VISIT_CELL_BEAM] = VTK_LINE;
celltype_idtype[VISIT_CELL_TRI] = VTK_TRIANGLE;
celltype_idtype[VISIT_CELL_QUAD] = VTK_QUAD;
celltype_idtype[VISIT_CELL_TET] = VTK_TETRA;
celltype_idtype[VISIT_CELL_PYR] = VTK_PYRAMID;
celltype_idtype[VISIT_CELL_WEDGE] = VTK_WEDGE;
celltype_idtype[VISIT_CELL_HEX] = VTK_HEXAHEDRON;
vtkIdTypeArray *nlist = vtkIdTypeArray::New();
nlist->SetNumberOfValues(umesh->connectivityLen);
vtkIdType *nl = nlist->GetPointer(0);
vtkUnsignedCharArray *cellTypes = vtkUnsignedCharArray::New();
cellTypes->SetNumberOfValues(umesh->nzones);
unsigned char *ct = cellTypes->GetPointer(0);
vtkIntArray *cellLocations = vtkIntArray::New();
cellLocations->SetNumberOfValues(umesh->nzones);
int *cl = cellLocations->GetPointer(0);
int numCells = 0;
int offset = 0;
while (offset < umesh->connectivityLen)
{
int celltype = umesh->connectivity.iArray[offset];
int vtktype = celltype_idtype[celltype];
int nelempts = celltype_npts[celltype];
*ct++ = vtktype;
*nl++ = nelempts;
for (int j=0; j<nelempts; j++)
{
*nl++ = umesh->connectivity.iArray[offset+1+j];
}
numCells++;
*cl++ = offset;
offset += nelempts+1;
}
if (numCells != umesh->nzones)
{
EXCEPTION1(ImproperUseException,
"Number of zones and length of connectivity "
"array did not match!");
}
vtkCellArray *cells = vtkCellArray::New();
cells->SetCells(umesh->nzones, nlist);
nlist->Delete();
ugrid->SetCells(cellTypes, cellLocations, cells);
cellTypes->Delete();
cellLocations->Delete();
cells->Delete();
int firstCell = umesh->firstRealZone;
int lastCell = umesh->lastRealZone;
if (firstCell == 0 && lastCell == 0 )
{
debug5 << "Cannot tell if ghost zones are present because "
<< "min_index & max_index are both zero!" << endl;
}
else if (firstCell < 0 || firstCell >= numCells ||
lastCell < 0 || lastCell >= numCells ||
firstCell > lastCell)
{
// bad min or max index
debug5 << "Invalid min/max index for determining ghost zones: "
<< "\n\tnumCells: " << numCells
<< "\n\tfirstRealZone: " << firstCell
<< "\n\tlastRealZone: " << lastCell << endl;
}
else if (firstCell != 0 || lastCell != numCells -1)
{
int i;
vtkUnsignedCharArray *ghostZones = vtkUnsignedCharArray::New();
ghostZones->SetName("avtGhostZones");
ghostZones->SetNumberOfTuples(numCells);
unsigned char *tmp = ghostZones->GetPointer(0);
for (i = 0; i < firstCell; i++)
{
//
// ghostZones at the begining of the zone list
//
unsigned char val = 0;
avtGhostData::AddGhostZoneType(val,
DUPLICATED_ZONE_INTERNAL_TO_PROBLEM);
*tmp++ = val;
}
for (i = firstCell; i <= lastCell; i++)
{
//
// real zones
//
*tmp++ = 0;
}
for (i = lastCell+1; i < numCells; i++)
{
//
// ghostZones at the end of the zone list
//
unsigned char val = 0;
avtGhostData::AddGhostZoneType(val,
DUPLICATED_ZONE_INTERNAL_TO_PROBLEM);
*tmp++ = val;
}
ugrid->GetCellData()->AddArray(ghostZones);
ghostZones->Delete();
ugrid->SetUpdateGhostLevel(0);
}
return ugrid;
}
break;
default:
EXCEPTION1(ImproperUseException,
"Only curvilinear meshes are currently supported.\n");
......@@ -981,6 +1174,10 @@ avtSimV1FileFormat::GetMaterial(int domain, const char *varname)
// Jeremy Meredith, Thu Apr 28 18:00:32 PDT 2005
// Added true data array structures in place of raw array pointers.
//
// Jeremy Meredith, Wed May 25 14:37:58 PDT 2005
// Added ability to have separate types for x/y values. Added support
// for integer X's.
//
// ****************************************************************************
vtkDataSet *
......@@ -999,26 +1196,50 @@ avtSimV1FileFormat::GetCurve(const char *name)
int npts = cd->len;
pts->SetNumberOfPoints(npts);
if (cd->x.dataType == VISIT_DATATYPE_FLOAT)
float *xpts = new float[npts];
if (cd->x.dataType == VISIT_DATATYPE_INT)
{
for (int j=0; j<npts; j++)
xpts[j] = cd->x.iArray[j];
}
else if (cd->x.dataType == VISIT_DATATYPE_FLOAT)
{
for (int j=0; j<npts; j++)
xpts[j] = cd->x.fArray[j];
}
else if (cd->x.dataType == VISIT_DATATYPE_DOUBLE)
{
for (int j=0; j<npts; j++)
xpts[j] = cd->x.dArray[j];
}
else
{
EXCEPTION1(ImproperUseException, "Curve coordinate arrays "
"must be float, double, or int in X.\n");
}
if (cd->y.dataType == VISIT_DATATYPE_FLOAT)
{
for (int j=0; j<npts; j++)
{
pts->SetPoint(j, cd->x.fArray[j], cd->y.fArray[j], 0);
pts->SetPoint(j, xpts[j], cd->y.fArray[j], 0);
}
}
else if (cd->x.dataType == VISIT_DATATYPE_DOUBLE)
else if (cd->y.dataType == VISIT_DATATYPE_DOUBLE)
{
for (int j=0; j<npts; j++)
{
pts->SetPoint(j, cd->x.dArray[j], cd->y.dArray[j], 0);
pts->SetPoint(j, xpts[j], cd->y.dArray[j], 0);
}
}
else
{
EXCEPTION1(ImproperUseException,
"Curve coordinate arrays must be float or double.\n");
"Curve coordinate arrays must be float or double in Y.\n");
}
delete[] xpts;
FreeDataArray(cd->x);
FreeDataArray(cd->y);
......
......@@ -226,9 +226,12 @@ Engine *Engine::Instance()
// but I needed a separate PAR_ProcessInput method that used the same
// buffer connection.
//
// Jeremy Meredith, Tue May 17 11:20:51 PDT 2005
// Allow disabling of signal handlers.
//
// ****************************************************************************
void
Engine::Initialize(int *argc, char **argv[])
Engine::Initialize(int *argc, char **argv[], bool sigs)
{
#ifdef PARALLEL
......@@ -247,10 +250,10 @@ Engine::Initialize(int *argc, char **argv[])
//
// Initialize error logging
//
Init::Initialize(*argc, *argv, PAR_Rank(), PAR_Size());
Init::Initialize(*argc, *argv, PAR_Rank(), PAR_Size(), true, sigs);
#else
xfer = new Xfer;
Init::Initialize(*argc, *argv);
Init::Initialize(*argc, *argv, 0,1, true, sigs);
#endif
Init::SetComponentName("engine");
......
......@@ -96,6 +96,9 @@ class ProcessAttributes;
// Jeremy Meredith, Mon Apr 4 15:59:49 PDT 2005
// Added methods to control a simulation from VisIt.
//
// Jeremy Meredith, Wed May 18 16:50:59 PDT 2005
// Allow disabling of signal handlers.
//
// ****************************************************************************
class Engine
......@@ -105,7 +108,7 @@ class Engine
static Engine *Instance();
// Initialization routines
void Initialize(int *argc, char **argv[]);
void Initialize(int *argc, char **argv[], bool sigs);
void Finalize(void);
bool ConnectViewer(int *argc, char **argv[]);
void SetUpViewerInterface(int *argc, char **argv[]);
......
......@@ -36,6 +36,9 @@
// Jeremy Meredith, Wed May 11 09:17:44 PDT 2005
// Forced the RESTRICTED load balancer mode.
//
// Jeremy Meredith, Wed May 25 13:25:45 PDT 2005
// Disabled our own signal handlers.
//
// ****************************************************************************
void *get_engine()
......@@ -47,7 +50,7 @@ void *get_engine()
int initialize(void *e, int argc, char *argv[])
{
Engine *engine = (Engine*)(e);
engine->Initialize(&argc, &argv);
engine->Initialize(&argc, &argv, false);
return 1;
}
......
......@@ -202,6 +202,9 @@
// Hank Childs, Sun Mar 6 08:56:30 PST 2005
// Remove call to LoadBalancer::ForceStatic. This is now the default.
//
// Jeremy Meredith, Tue May 17 11:20:51 PDT 2005
// Allow disabling of signal handlers for the engine library.
//
// ****************************************************************************
int
......@@ -210,7 +213,7 @@ main(int argc, char *argv[])
Engine *engine = Engine::Instance();
// Do some pre-connect initialization
engine->Initialize(&argc, &argv);
engine->Initialize(&argc, &argv, true);
// Try to connect to the viewer
if (engine->ConnectViewer(&argc, &argv))
......
......@@ -7,11 +7,11 @@
SIMSER=sim
SIMPAR=psim
SIMSRC=sim.c VisItV1.c simconnection.c
SIMSRC=sim.c VisItControlInterface_V1.c simconnection.c
SIMSEROBJ=$(SIMSRC:.c=.o)
SIMPAROBJ=$(SIMSRC:.c=_par.o)
CPPFLAGS=@CPPFLAGS@ -I. -I../include/visit
CPPFLAGS=@CPPFLAGS@ -I. -I../include -I../include/visit
SERLIBS=
PARLIBS=@MPI_LIBS@
......
This diff is collapsed.
#ifndef VisItV1_H
#define VisItV1_H
#ifndef VISIT_CONTROL_INTERFACE_V1_H
#define VISIT_CONTROL_INTERFACE_V1_H
/* ****************************************************************************
// File: VisItV1.h
// File: VisItControlInterfave_V1.h
//
// Purpose:
// Abstraction of VisIt Engine wrapper library. Handles the
// grunt work of actually connecting to visit that must be done
// outside of the VisItEngine DLL.
// 1) setting up a non-blocking listen socket
// 2) writing a .sim file
// 3) opening the VisItEngine .so and retrieving the functions from it
// 4) accepting an incoming socket connection
// 5) removing the .sim file when the program exits
//
// Programmer: Jeremy Meredith
// Creation: April 4, 2005
......@@ -22,20 +17,26 @@
extern "C" {
#endif
void VisItSetBroadcastIntFunction(int (*)(int *, int));
void VisItSetBroadcastStringFunction(int (*)(char *, int, int));
void VisItSetParallel(int);
void VisItSetParallelRank(int);
void VisItSetDirectory(char *);
void VisItSetOptions(char *);
int VisItSetupEnvironment(void);
int VisItInitializeSocketAndDumpSimFile(const char *name,
const char *comment,
const char *path,
const char *inputfile);
int VisItDetectInput(int blocking, int consoledesc);
int VisItAttemptToCompleteConnection(void);
void VisItInitializeSocketAndDumpSimFile(char *name,
char *comment,
char *path,
char *inputfile);
int VisItGetListenSocket(void);
int VisItGetEngineSocket(void);
int VisItProcessEngineCommand(void);
void VisItAddLibraryPaths(int argc, char *argv[]);
void VisItDisconnect(void);
void VisItTimeStepChanged(void);
void VisItSetupEnvironment(void);
void VisItSetSlaveProcessCallback(void(*)());
void VisItSetCommandCallback(void(*)(const char*,int,float,const char*));
int VisItProcessEngineCommand(void);
void VisItTimeStepChanged(void);
void VisItDisconnect(void);
char *VisItGetLastError();
#ifdef __cplusplus
}
......
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>