Commit a1548a6b authored by hrchilds's avatar hrchilds

Update from May 25, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@248 18c085ea-50e0-402c-830e-de6fd14e8384
parent 6bd4e550
......@@ -164,6 +164,9 @@ typedef struct {
// Jeremy Meredith/Hank Childs, Tue Mar 23 12:26:55 PST 2004
// Add file format as a data member.
//
// Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
// Added virtual QueryZoneCenter, defined here so derived types don't
// have to.
// ****************************************************************************
class DATABASE_API avtDatabase
......@@ -205,6 +208,9 @@ class DATABASE_API avtDatabase
virtual bool FindElementForPoint(const char *, const int,
const int, const char *, float[3], int &)
{ return false; } ;
virtual bool QueryZoneCenter(const std::string &, const int,
const int, const int, float[3] )
{ return false; } ;
virtual void GetDomainName(const std::string &, const int ts,
const int dom, std::string &) {;};
......
......@@ -5818,3 +5818,43 @@ avtGenericDatabase::GetDomainName(const std::string &varName, const int ts,
}
}
}
// ****************************************************************************
// Method: avtGenericDatabase::QueryZoneCenter
//
// Purpose:
// Gets the geometric center of a zone.
//
// Arguments:
// var The variable to use in searching the database.
// dom The domain to use in searching the database.
// zoneId The zone number to use in searching the database.
// ts The timestep to use in searching the database.
// coord A place to store the zone center.
//
// Returns: True if query is a success, false otherwise.
//
// Programmer: Kathleen Bonnell
// Creation: May 25, 2004
//
// ****************************************************************************
bool
avtGenericDatabase::QueryZoneCenter(const string &varName, const int dom,
const int zoneId, const int ts, float coord[3])
{
string meshName = GetMetaData(ts)->MeshForVar(varName);
vtkDataSet *ds = GetMeshDataset(meshName.c_str(), ts, dom, "_all");
bool rv = false;
if (ds)
{
vtkCell *cell = ds->GetCell(zoneId);
float parametricCenter[3];
float weights[28];
int subId = cell->GetParametricCenter(parametricCenter);
cell->EvaluateLocation(subId, parametricCenter, coord, weights);
rv = true;
}
return rv;
}
......@@ -178,6 +178,9 @@ class PickVarInfo;
// Hank Childs, Fri Apr 9 09:02:57 PDT 2004
// Calculate material indices directly from the material for that timestep.
//
// Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
// Add QueryZoneCenter.
//
// ****************************************************************************
class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
......@@ -347,6 +350,8 @@ class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
const bool, const bool,
std::vector<std::string> &,
std::vector<std::string> &);
virtual bool QueryZoneCenter(const std::string &, const int,
const int, const int, float[3]);
void AssociateBounds(vtkDataSet *);
void ScaleMesh(vtkDataSet *);
......
......@@ -530,3 +530,30 @@ avtSourceFromDatabase::GetDomainName(const std::string &var, const int ts,
{
database->GetDomainName(var, ts, dom, domName);
}
// ****************************************************************************
// Method: avtSourceFromDatabase::QueryZoneCenter
//
// Purpose: A query to find the geometric center of a zone.
//
// Arguments:
// var The variable to use in searching the database.
// dom The domain to use in searching the database.
// zone The zone to use in searching the database.
// ts The timestep to use in searching the database.
// coord A place to store the zone center.
//
// Returns: True if the query was successful, false otherwise.
//
// Programmer: Kathleen Bonnell
// Creation: May 25, 2004
//
// ****************************************************************************
bool
avtSourceFromDatabase::QueryZoneCenter(const std::string &var, const int dom,
const int zone, const int ts, float coord[3])
{
return database->QueryZoneCenter(var, dom, zone, ts, coord);
}
......@@ -63,6 +63,9 @@ class PickAttributes;
// Kathleen Bonnell, Mon Dec 22 14:39:30 PST 2003
// Add GetDomainName method.
//
// Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
// Add QueryZoneCenter method.
//
// ****************************************************************************
class DATABASE_API avtSourceFromDatabase : public avtTerminatingDatasetSource
......@@ -85,6 +88,8 @@ class DATABASE_API avtSourceFromDatabase : public avtTerminatingDatasetSource
void InvalidateZones(void);
void DatabaseProgress(int, int, const char *);
virtual void Query(PickAttributes *);
virtual bool QueryZoneCenter(const std::string &, const int, const int,
const int, float[3]);
virtual bool FindElementForPoint(const char *, const int,
const int, const char *, float[3], int &);
virtual void GetDomainName(const std::string &, const int,
......
......@@ -647,3 +647,25 @@ avtExpressionEvaluatorFilter::GetDomainName(const std::string &var, const int ts
GetInput()->GetQueryableSource()->GetDomainName(var, ts, dom, domName);
}
// ****************************************************************************
// Method: avtExpressionEvaluatorFilter::QueryZoneCenter
//
// Purpose:
// Passes this request on to the queryable source.
//
// Programmer: Kathleen Bonnell
// Creation: May 25, 2004
//
// Modifications:
//
// ****************************************************************************
bool
avtExpressionEvaluatorFilter::QueryZoneCenter(const std::string &var,
const int dom, const int zone, const int ts, float c[3])
{
return GetInput()->GetQueryableSource()->
QueryZoneCenter(var, dom, zone, ts, c);
}
......@@ -41,6 +41,9 @@
// Moved inlined constructor and destructor definitions to .C files
// because certain compilers have problems with them.
//
// Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
// Added QueryZoneCenter.
//
// ****************************************************************************
class EXPRESSION_API avtExpressionEvaluatorFilter
......@@ -60,6 +63,8 @@ public:
virtual bool FindElementForPoint(const char *, const int,
const int, const char *, float[3], int &);
virtual bool QueryZoneCenter(const std::string&, const int,
const int, const int, float[3]);
virtual void GetDomainName(const std::string &, const int,
const int , std::string &);
......
// ************************************************************************* //
// avtQueryableSource.h //
// avtQueryableSourcy.h //
// ************************************************************************* //
#ifndef AVT_QUERYABLE_SOURCE_H
......@@ -33,6 +33,9 @@ class PickAttributes;
// Moved inlined constructor and destructor definitions to .C files
// because certain compilers have problems with them.
//
// Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
// Add virtual method 'QueryZoneCenter'.
//
// ****************************************************************************
class PIPELINE_API avtQueryableSource : virtual public avtDataObjectSource
......@@ -47,6 +50,8 @@ class PIPELINE_API avtQueryableSource : virtual public avtDataObjectSource
const int, const char*, float[3], int &)=0;
virtual void GetDomainName(const std::string&, const int,
const int, std::string&)=0;
virtual bool QueryZoneCenter(const std::string&, const int,
const int, const int, float[3])=0;
};
......
......@@ -56,6 +56,10 @@ typedef void (*InitializeProgressCallback)(void *, int);
//
// Kathleen Bonnell, Mon Dec 22 14:48:57 PST 2003
// Added virtual method GetDomainName.
//
// Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
// Add virtual method 'QueryZoneCenter'.
//
// ****************************************************************************
class PIPELINE_API avtTerminatingSource : virtual public avtQueryableSource
......@@ -97,6 +101,9 @@ class PIPELINE_API avtTerminatingSource : virtual public avtQueryableSource
{ return false;};
virtual void GetDomainName(const std::string &, const int,
const int, std::string &) {;};
virtual bool QueryZoneCenter(const std::string &, const int,
const int, const int, float[3])
{ return false;};
protected:
avtMetaData *metadata;
......
......@@ -300,6 +300,10 @@ avtMapper::GetDrawable(void)
// Hank Childs, Thu Mar 18 16:02:27 PST 2004
// Do not create actors and mappers for empty datasets.
//
// Hank Childs, Tue May 25 13:30:16 PDT 2004
// Allow display lists of 250,000 polygons or more again, since the display
// list generation was made much faster by breaking it into chunks.
//
// ****************************************************************************
void
......@@ -351,7 +355,7 @@ avtMapper::SetUpMappers(void)
mappers[i] = CreateMapper();
vtkDataSet *ds = InsertFilters(children[i], i);
mappers[i]->SetInput(ds);
if (ds->GetNumberOfCells() > 250000 || immediateMode)
if (immediateMode)
{
mappers[i]->ImmediateModeRenderingOn();
}
......
......@@ -76,6 +76,9 @@
# I changed the list of libraries that need to be linked so we can prebind
# the library on MacOS X.
#
# Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
# Added avtZoneCenterQuery.
#
##############################################################################
@SET_MAKE@
......@@ -125,7 +128,8 @@ Queries_src= \
Queries/avtTotalVolumeQuery.C \
Queries/avtVariableQuery.C \
Queries/avtVariableSummationQuery.C \
Queries/avtWeightedVariableSummationQuery.C
Queries/avtWeightedVariableSummationQuery.C \
Queries/avtZoneCenterQuery.C
CPPFLAGS=@COMPONENT_CPPFLAGS@ @CPPFLAGS@
......
......@@ -24,6 +24,7 @@
#include <avtVariableQuery.h>
#include <avtVariableSummationQuery.h>
#include <avtWeightedVariableSummationQuery.h>
#include <avtZoneCenterQuery.h>
#include <QueryAttributes.h>
......@@ -115,6 +116,9 @@ avtQueryFactory::Instance()
// Hank Childs, Tue Apr 13 12:50:51 PDT 2004
// Allow for surface area to have multiple aliases.
//
// Kathleen Bonnell, Tue May 25 16:16:25 PDT 2004
// Added Zone center query.
//
// ****************************************************************************
......@@ -249,6 +253,10 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
query = new avtOriginalDataNumNodesQuery();
}
}
else if (qname == "Zone Center")
{
query = new avtZoneCenterQuery();
}
return query;
}
......
// ************************************************************************* //
// avtZoneCenterQuery.C //
// ************************************************************************* //
#include <avtZoneCenterQuery.h>
#include <avtTerminatingSource.h>
#include <avtSILRestrictionTraverser.h>
#include <vector>
#include <snprintf.h>
#include <avtParallel.h>
#ifdef PARALLEL
#include <mpi.h>
#endif
using std::vector;
using std::string;
// ****************************************************************************
// Method: avtZoneCenterQuery constructor
//
// Programmer: Kathleen Bonnell
// Creation: May 25, 2004
//
// Modifications:
//
// ****************************************************************************
avtZoneCenterQuery::avtZoneCenterQuery() : avtDatasetQuery()
{
}
// ****************************************************************************
// Method: avtZoneCenterQuery destructor
//
// Programmer: Kathleen Bonnell
// Creation: May 25, 2004
//
// Modifications:
//
// ****************************************************************************
avtZoneCenterQuery::~avtZoneCenterQuery()
{
}
// ****************************************************************************
// Method: avtZoneCenterQuery::PerformQuery
//
// Purpose:
// Perform the requested query.
//
// Programmer: Kathleen Bonnell
// Creation: May 25, 2004
//
// Modifications:
//
// ****************************************************************************
void
avtZoneCenterQuery::PerformQuery(QueryAttributes *qA)
{
queryAtts = *qA;
Init();
UpdateProgress(0, 0);
bool singleDomain = false;
intVector dlist;
avtDataSpecification_p dspec =
GetInput()->GetTerminatingSource()->GetFullDataSpecification();
dspec->GetSIL().GetDomainList(dlist);
if (dlist.size() == 1 && dspec->UsesAllDomains())
{
singleDomain = true;
}
int blockOrigin = GetInput()->GetInfo().GetAttributes().GetBlockOrigin();
int cellOrigin = GetInput()->GetInfo().GetAttributes().GetCellOrigin();
int dim = GetInput()->GetInfo().GetAttributes().GetSpatialDimension();
int domain = qA->GetDomain() - blockOrigin;
int zone = qA->GetElement() - cellOrigin;
int ts = qA->GetTimeStep();
string var = qA->GetVariables()[0];
float coord[3] = {0., 0., 0.};
domain = (domain < 0 ? 0 : domain);
zone = (zone < 0 ? 0 : zone);
avtSILRestrictionTraverser trav(querySILR);
trav.GetDomainList(dlist);
int success = 0;
//
// See if any processor is working with this domain.
//
intVector dAllProc;
trav.GetDomainListAllProcs(dAllProc);
bool domainUsed = false;
for (int j = 0; j < dAllProc.size() && !domainUsed; j++)
{
if (dAllProc[j] == domain)
domainUsed = true;
}
avtTerminatingSource *src = GetInput()->GetTerminatingSource();
if (domainUsed)
{
for (int i = 0; i < dlist.size() && !success; ++i)
{
if (dlist[i] == domain)
{
success = (int)src->QueryZoneCenter(var, domain, zone, ts, coord);
}
}
}
else if (PAR_Rank() == 0)
{
success = (int)src->QueryZoneCenter(var, domain, zone, ts, coord);
}
#ifdef PARALLEL
int myRank, numProcs;
MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
if (myRank == 0)
{
MPI_Status stat, stat2;
int good;
for (int i = 1; i < numProcs; i++)
{
MPI_Recv(&good, 1, MPI_INT, MPI_ANY_SOURCE,
MPI_ANY_TAG, MPI_COMM_WORLD, &stat);
if (good)
{
MPI_Recv(coord, 3, MPI_FLOAT, stat.MPI_SOURCE, MPI_ANY_TAG,
MPI_COMM_WORLD, &stat2);
success = good;
}
}
}
else
{
MPI_Send(&success, 1, MPI_INT, 0, myRank, MPI_COMM_WORLD);
if (success)
{
MPI_Send(coord, 3, MPI_FLOAT, 0, myRank, MPI_COMM_WORLD);
}
return;
}
#endif
char msg[120];
if (success)
{
if (singleDomain)
{
if (dim == 2)
{
SNPRINTF(msg, 120, "The center of zone %d is (%g, %g).",
qA->GetElement(), coord[0], coord[1]);
}
else
{
SNPRINTF(msg, 120, "The center of zone %d is (%g, %g, %g).",
qA->GetElement(), coord[0], coord[1], coord[2]);
}
}
else
{
string domainName;
src->GetDomainName(var, ts, domain, domainName);
if (dim == 2)
{
SNPRINTF(msg, 120, "The center of zone %d (%s) is (%g, %g).",
qA->GetElement(), domainName.c_str(),
coord[0], coord[1]);
}
else
{
SNPRINTF(msg, 120, "The center of zone %d (%s) is (%g, %g, %g).",
qA->GetElement(), domainName.c_str(),
coord[0], coord[1], coord[2]);
}
}
doubleVector c;
c.push_back((double)coord[0]);
c.push_back((double)coord[1]);
c.push_back((double)coord[2]);
qA->SetResultsValue(c);
}
else
{
if (singleDomain)
{
SNPRINTF(msg, 120, "The center of zone %d could not be determined.",
qA->GetElement());
}
else
{
string domainName;
src->GetDomainName(var, ts, domain, domainName);
SNPRINTF(msg, 120, "The center of zone %d (%s) could not be determined.",
qA->GetElement(), domainName.c_str());
}
}
qA->SetResultsMessage(msg);
UpdateProgress(1, 0);
}
// ************************************************************************* //
// avtZoneCenterQuery.h //
// ************************************************************************* //
#ifndef AVT_ZONECZENTER_QUERY_H
#define AVT_ZONECZENTER_QUERY_H
#include <query_exports.h>
#include <avtDatasetQuery.h>
// ****************************************************************************
// Class: avtZoneCenterQuery
//
// Purpose:
// This is a dataset query that returns the coordintes of a zone's center.
//
// Programmer: Kathleen Bonnell
// Creation: May 25, 2004
//
// Modifications:
//
// ****************************************************************************
class QUERY_API avtZoneCenterQuery : public avtDatasetQuery
{
public:
avtZoneCenterQuery();
virtual ~avtZoneCenterQuery();
virtual const char *GetType(void) { return "avtZoneCenterQuery"; };
virtual const char *GetDescription(void)
{ return "Getting zone center."; };
virtual void PerformQuery(QueryAttributes *);
virtual bool OriginalData(void) { return true; };
protected:
virtual void Execute(vtkDataSet*, const int){;};
};
#endif
......@@ -61,6 +61,11 @@ static void WriteByteStreamToSocket(NonBlockingRPC *, Connection *,
// Initial connection timeout of 5 minutes (300 seconds)
#define INITIAL_CONNECTION_TIMEOUT 60
// convenient MPI message tags
#define CELL_COUNT_TAG 0x0
#define SEND_DATA_TAG 0x1
#define DATAOBJ_SIZE_TAG 0x2
#define DATAOBJ_DATA_TAG 0x3
// ****************************************************************************
// Constructor: Engine::Engine
......@@ -903,11 +908,32 @@ WriteByteStreamToSocket(NonBlockingRPC *rpc, Connection *vtkConnection,
// Hank Childs, Fri Mar 19 21:20:12 PST 2004
// Use a helper routine (that's more efficient) to write to a socket.
//
// Mark C. Miller, Mon May 24 18:36:13 PDT 2004
// Added arguments to support checking of scalable threshold is exceeded
// Modified communication algorithm to have each processor handshake with
// UI proc and check if ok before actually sending data. When scalable
// threshold is exceeded, UI proc tells everyone to stop sending data.
//
// ****************************************************************************
void
Engine::WriteData(NonBlockingRPC *rpc, avtDataObjectWriter_p &writer)
Engine::WriteData(NonBlockingRPC *rpc, avtDataObjectWriter_p &writer,
bool respondWithNull, int scalableThreshold, bool* scalableThresholdExceeded,
int currentTotalGlobalCellCount, int* currentNetworkGlobalCellCount)
{
#ifdef PARALLEL
//
// When respond with null is true, this routine still has an obligation
// to recieve the dummied-up data tree from each processor, regardless of
// whether or not the scalable threshold has been exceeded. So, we capture
// that fact in the 'sendDataAnyway' bool. Likewise, when scalableThreshold