Commit e1a8c04a authored by hrchilds's avatar hrchilds
Browse files

Update from June 18, 2003

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@15 18c085ea-50e0-402c-830e-de6fd14e8384
parent 8c679157
......@@ -63,9 +63,10 @@ enum avtMeshType
enum avtGhostType
{
AVT_NO_GHOSTS = 0,
AVT_HAS_GHOSTS, /* 1 */
AVT_MAYBE_GHOSTS /* 2 */
AVT_NO_GHOSTS = 0,
AVT_HAS_GHOSTS, /* 1 */
AVT_CREATED_GHOSTS, /* 2 */
AVT_MAYBE_GHOSTS /* 3 */
};
......
......@@ -265,6 +265,14 @@ avtGenericDatabase::GetOutput(avtDataSpecification_p spec,
spec->TurnZoneNumbersOn();
}
//
// Add node numbers if requested.
//
if (spec->NeedNodeNumbers())
{
CreateOriginalNodes(datasetCollection, domains, src);
}
//
// Add zone numbers if requested.
//
......@@ -1479,6 +1487,52 @@ avtGenericDatabase::AddOriginalCellsArray(vtkDataSet *ds, const int domain)
}
// ****************************************************************************
// Function: AddOriginalNodesArray
//
// Purpose:
// Creates an array of 'original node numbers' to attach to the dataset.
//
// Programmer: Hank Childs
// Creation: June 18, 2003
//
// ****************************************************************************
void
avtGenericDatabase::AddOriginalNodesArray(vtkDataSet *ds, const int domain)
{
if (ds == NULL || ds->GetCellData()->GetArray("avtOriginalCellNumbers"))
{
// DataSet is NULL or array is already created -- return.
return;
}
int timerHandle = visitTimer->StartTimer();
vtkUnsignedIntArray *origNodes = vtkUnsignedIntArray::New();
origNodes->SetName("avtOriginalNodeNumbers");
bool encodeDomains = (domain >= 0 ? true : false);
int nComps = (encodeDomains ? 2 : 1);
origNodes->SetNumberOfComponents(nComps);
int nnodes = ds->GetNumberOfPoints();
origNodes->SetNumberOfTuples(nnodes);
unsigned int *ptr = origNodes->GetPointer(0);
for (int i = 0; i < nnodes; i++)
{
if (encodeDomains)
{
*ptr = domain;
ptr++;
}
*ptr = i;
ptr++;
}
ds->GetPointData()->AddArray(origNodes);
origNodes->Delete();
ds->GetPointData()->CopyFieldOn("avtOriginalNodeNumbers");
visitTimer->StopTimer(timerHandle, "Creating original nodes array");
}
// ****************************************************************************
// Method: avtGenericDatabase::MaterialSelect
//
......@@ -2552,6 +2606,15 @@ avtGenericDatabase::ReadDataset(avtDatasetCollection &ds, vector<int> &domains,
// Also communicate the original zone numbers if we are creating structured
// indices.
//
// Hank Childs, Wed Jun 18 09:34:38 PDT 2003
// Communicate node numbers.
//
// Kathleen Bonnell, Wed Jun 18 17:47:10 PDT 2003
// When telling downstream items that ghost zones are present, use
// AVT_CREATED_GHOSTS to distinguish between those designated by the file
// format (AVT_HAS_GHOSTS) and those created here. (Needed currently so
// that Pick can return the correct cell id and/or coords).
//
// ****************************************************************************
bool
......@@ -2964,6 +3027,28 @@ avtGenericDatabase::CommunicateGhosts(avtDatasetCollection &ds,
}
}
//
// Exchange OriginalNodes Arrays.
//
if (spec->NeedNodeNumbers())
{
vector<vtkDataArray *> nodeNums;
for (j = 0 ; j < doms.size() ; j++)
{
vtkDataSet *ds1 = list[j];
nodeNums.push_back(ds1->GetPointData()->GetArray(
"avtOriginalNodeNumbers"));
}
vector<vtkDataArray *> nodeNumsOut;
nodeNumsOut = dbi->ExchangeIntVector(doms,true,nodeNums);
for (j = 0 ; j < doms.size() ; j++)
{
vtkDataSet *ds1 = ds.GetDataset(j, 0);
ds1->GetPointData()->AddArray(nodeNumsOut[j]);
nodeNumsOut[j]->Delete();
}
}
//
// Exchange OriginalCells Arrays.
//
......@@ -3001,7 +3086,7 @@ avtGenericDatabase::CommunicateGhosts(avtDatasetCollection &ds,
//
avtDatabaseMetaData *md = GetMetaData();
string meshname = md->MeshForVar(spec->GetVariable());
GetMetaData()->SetContainsGhostZones(meshname, AVT_HAS_GHOSTS);
GetMetaData()->SetContainsGhostZones(meshname, AVT_CREATED_GHOSTS);
src->DatabaseProgress(1, 0, progressString);
rv = true;
......@@ -3183,6 +3268,36 @@ avtGenericDatabase::CreateOriginalZones(avtDatasetCollection &ds,
}
// ****************************************************************************
// Method: avtGenericDatabase::CreateOriginalNodes
//
// Purpose:
// Create original nodes array.
//
// Arguments:
// ds The dataset collection.
// src The source object.
//
// Programmer: Hank Childs
// Creation: June 18, 2003
//
// ****************************************************************************
void
avtGenericDatabase::CreateOriginalNodes(avtDatasetCollection &ds,
vector<int> &domains, avtSourceFromDatabase *src)
{
char progressString[1024] = "Creating Original Nodes Array";
src->DatabaseProgress(0, 0, progressString);
for (int i = 0 ; i < ds.GetNDomains() ; i++)
{
AddOriginalNodesArray(ds.GetDataset(i, 0), domains[i]);
src->DatabaseProgress(i, ds.GetNDomains(), progressString);
}
src->DatabaseProgress(1, 0, progressString);
}
// ****************************************************************************
// Method: avtGenericDatabase::CreateStructuredIndices
//
......@@ -3234,7 +3349,6 @@ avtGenericDatabase::CreateStructuredIndices(avtDatasetCollection &dsc,
ds->GetFieldData()->AddArray(orig_dims);
orig_dims->Delete();
AddOriginalCellsArray(ds, -1);
src->DatabaseProgress(i, dsc.GetNDomains(), progressString);
}
src->DatabaseProgress(1, 0, progressString);
......@@ -3270,6 +3384,9 @@ avtGenericDatabase::CreateStructuredIndices(avtDatasetCollection &dsc,
// Use the SIL restriction traverser since SIL restriction routines were
// antiquated.
//
// Hank Childs, Wed Jun 18 09:34:38 PDT 2003
// Added a stage for needing node numbers.
//
// ****************************************************************************
int
......@@ -3329,6 +3446,11 @@ avtGenericDatabase::NumStagesForFetch(avtDataSpecification_p spec)
numStages += 1;
}
if (spec->NeedNodeNumbers())
{
numStages += 1;
}
if (spec->NeedZoneNumbers())
{
numStages += 1;
......
......@@ -135,6 +135,9 @@ class PickVarInfo;
// Jeremy Meredith, Thu Jun 12 09:05:38 PDT 2003
// Added another flag to MaterialSelect.
//
// Hank Childs, Wed Jun 18 09:20:16 PDT 2003
// Added CreateOriginalNodes.
//
// ****************************************************************************
class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
......@@ -190,6 +193,7 @@ class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
vtkDataSet *GetMesh(const char *, int, int, const char *);
void AddOriginalCellsArray(vtkDataSet *, const int);
void AddOriginalNodesArray(vtkDataSet *, const int);
bool PrepareMaterialSelect(const char *, int,
avtSILRestrictionTraverser &,
......@@ -226,6 +230,9 @@ class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
void CreateOriginalZones(avtDatasetCollection &,
std::vector<int> &,
avtSourceFromDatabase *);
void CreateOriginalNodes(avtDatasetCollection &,
std::vector<int> &,
avtSourceFromDatabase *);
void CreateStructuredIndices(avtDatasetCollection &,
avtSourceFromDatabase*);
void UpdateInternalState(int);
......
......@@ -11,6 +11,7 @@
#include <vtkAppendPolyData.h>
#include <vtkDataSet.h>
#include <vtkDataSetMapper.h>
#include <vtkUnsignedIntArray.h>
#include <avtCallback.h>
#include <avtDataTree.h>
......@@ -1483,6 +1484,11 @@ CFindMinimum(avtDataRepresentation &data, void *arg, bool &success)
// Programmer: Hank Childs
// Creation: March 15, 2002
//
// Modifications:
//
// Hank Childs, Wed Jun 18 10:55:48 PDT 2003
// Make use of original zones array if available.
//
// ****************************************************************************
void
......@@ -1507,16 +1513,111 @@ CLocateZone(avtDataRepresentation &data, void *arg, bool &success)
EXCEPTION0(NoInputException);
}
if (args->index >= ds->GetNumberOfCells())
//
// It might be that the original node numbers are saved off. If so, they
// will be the most accurate. If not, assume that the nodes are ordered
// in the same way they were when the data was saved out.
//
int indexToUse = -1;
vtkDataArray *ocn = ds->GetCellData()->GetArray("avtOriginalCellNumbers");
if (ocn == NULL)
{
return;
indexToUse = args->index;
}
vtkCell *cell = ds->GetCell(args->index);
if (cell == NULL)
else
{
return;
vtkUnsignedIntArray *origZone = (vtkUnsignedIntArray *) ocn;
//
// There are two components when we have saved out the domain number
// as well. The domain number is needed in cases where we have created
// ghost zones, for example.
//
if (origZone->GetNumberOfComponents() == 2)
{
//
// If the zone numbering has not changed, then the zone we want
// will still be in the same location. Check to see if this is
// the case. If so, it will allow us to not have to iterate over
// the whole array.
//
int nvals = origZone->GetNumberOfTuples();
int domain = -1;
int index = -1;
if (args->index < nvals)
{
unsigned int *p = origZone->GetPointer(0);
p += 2*args->index;
domain = p[0];
index = p[1];
}
if (domain == args->domain && index == args->index)
{
indexToUse = args->index;
}
else
{
//
// No avoiding it -- look at every zone and try to find a
// match.
//
unsigned int *ptr = origZone->GetPointer(0);
for (int i = 0 ; i < nvals ; i++)
{
int domain = *(ptr++);
int index = *(ptr++);
if (domain == args->domain && index == args->index)
{
indexToUse = i;
break;
}
}
}
}
else
{
//
// The domain numbers are not included. This is very similar to
// the logic above -- so see above for pertinent comments.
//
int nvals = origZone->GetNumberOfTuples();
int index = -1;
if (args->index < nvals)
{
unsigned int *p = origZone->GetPointer(args->index);
index = p[0];
}
if (index == args->index)
{
indexToUse = args->index;
}
else
{
unsigned int *ptr = origZone->GetPointer(0);
for (int i = 0 ; i < nvals ; i++)
{
int index = *(ptr++);
if (index == args->index)
{
indexToUse = i;
break;
}
}
}
}
}
if (indexToUse == -1)
return;
if (indexToUse >= ds->GetNumberOfCells())
return;
vtkCell *cell = ds->GetCell(indexToUse);
if (cell == NULL)
return;
float p[3];
cell->GetParametricCenter(p);
float weights[8] // Assuming no more than 8 vertices in cell.
......@@ -1550,6 +1651,11 @@ CLocateZone(avtDataRepresentation &data, void *arg, bool &success)
// Programmer: Hank Childs
// Creation: March 15, 2002
//
// Modifications:
//
// Hank Childs, Wed Jun 18 10:55:48 PDT 2003
// Make use of original nodes array if available.
//
// ****************************************************************************
void
......@@ -1574,13 +1680,109 @@ CLocateNode(avtDataRepresentation &data, void *arg, bool &success)
EXCEPTION0(NoInputException);
}
if (ds->GetNumberOfPoints() < args->index)
//
// It might be that the original node numbers are saved off. If so, they
// will be the most accurate. If not, assume that the nodes are ordered
// in the same way they were when the data was saved out.
//
int indexToUse = -1;
vtkDataArray *onn = ds->GetPointData()->GetArray("avtOriginalNodeNumbers");
if (onn == NULL)
{
indexToUse = args->index;
}
else
{
vtkUnsignedIntArray *origNode = (vtkUnsignedIntArray *) onn;
//
// There are two components when we have saved out the domain number
// as well. The domain number is needed in cases where we have created
// ghost zones, for example.
//
if (origNode->GetNumberOfComponents() == 2)
{
//
// If the node numbering has not changed, then the node we want
// will still be in the same location. Check to see if this is
// the case. If so, it will allow us to not have to iterate over
// the whole array.
//
int nvals = origNode->GetNumberOfTuples();
int domain = -1;
int index = -1;
if (args->index < nvals)
{
unsigned int *p = origNode->GetPointer(0);
p += 2*args->index;
index = p[1];
}
if (domain == args->domain && index == args->index)
{
indexToUse = args->index;
}
else
{
//
// No avoiding it -- look at every node and try to find a
// match.
//
unsigned int *ptr = origNode->GetPointer(0);
for (int i = 0 ; i < nvals ; i++)
{
int domain = *(ptr++);
int index = *(ptr++);
if (domain == args->domain && index == args->index)
{
indexToUse = i;
break;
}
}
}
}
else
{
//
// The domain numbers are not included. This is very similar to
// the logic above -- so see above for pertinent comments.
//
int nvals = origNode->GetNumberOfTuples();
int index = -1;
if (args->index < nvals)
{
unsigned int *p = origNode->GetPointer(args->index);
index = p[0];
}
if (index == args->index)
{
indexToUse = args->index;
}
else
{
unsigned int *ptr = origNode->GetPointer(0);
for (int i = 0 ; i < nvals ; i++)
{
int index = *(ptr++);
if (index == args->index)
{
indexToUse = i;
break;
}
}
}
}
}
if (indexToUse == -1)
return;
if (ds->GetNumberOfPoints() < indexToUse)
{
return;
}
float p[3];
ds->GetPoint(args->index, p);
ds->GetPoint(indexToUse, p);
args->point[0] = p[0];
args->point[1] = p[1];
args->point[2] = p[2];
......
......@@ -308,6 +308,9 @@ avtDataAttributes::Copy(const avtDataAttributes &di)
// Kathleen Bonnell, Thu Apr 10 10:31:54 PDT 2003
// Merge transform.
//
// Kathleen Bonnell, Wed Jun 18 17:50:20 PDT 2003
// Account for avtGhostType AVT_CREATED_GHOSTS.
//
// ****************************************************************************
void
......@@ -358,6 +361,10 @@ avtDataAttributes::Merge(const avtDataAttributes &da)
{
SetContainsGhostZones(AVT_HAS_GHOSTS);
}
else if (da.GetContainsGhostZones() == AVT_CREATED_GHOSTS)
{
SetContainsGhostZones(AVT_CREATED_GHOSTS);
}
}
else if (GetContainsGhostZones() == AVT_NO_GHOSTS)
{
......
......@@ -56,6 +56,9 @@ using std::vector;
// Jeremy Meredith, Tue Jun 10 13:21:15 PDT 2003
// Added needBoundarySurfaces.
//
// Hank Childs, Wed Jun 18 09:20:16 PDT 2003
// Added needNodes.
//
// ****************************************************************************
avtDataSpecification::avtDataSpecification(const char *var, int ts,
......@@ -63,6 +66,7 @@ avtDataSpecification::avtDataSpecification(const char *var, int ts,
{
mayRequireZones = false;
needZones = false;
needNodes = false;
useGhostZones = true;
needInternalSurfaces = false;
needBoundarySurfaces = false;
......@@ -122,12 +126,16 @@ avtDataSpecification::avtDataSpecification(const char *var, int ts,
// Jeremy Meredith, Tue Jun 10 13:21:24 PDT 2003
// Added needBoundarySurfaces.
//
// Hank Childs, Wed Jun 18 09:20:16 PDT 2003
// Added needNodes.
//
// ****************************************************************************
avtDataSpecification::avtDataSpecification(const char *var, int ts, int ch)
{
mayRequireZones = false;
needZones = false;
needNodes = false;
useGhostZones = true;
needInternalSurfaces = false;
needBoundarySurfaces = false;
......@@ -317,6 +325,7 @@ avtDataSpecification::operator=(const avtDataSpecification &spec)
mayRequireZones = spec.mayRequireZones;
useGhostZones = spec.useGhostZones;
needZones = spec.needZones;
needNodes = spec.needNodes;
needInternalSurfaces = spec.needInternalSurfaces;
needBoundarySurfaces = spec.needBoundarySurfaces;
needValidFaceConnectivity = spec.needValidFaceConnectivity;
......@@ -379,6 +388,9 @@ avtDataSpecification::operator=(const avtDataSpecification &spec)
// Jeremy Meredith, Tue Jun 10 13:21:40 PDT 2003
// Compare needBoundarySurfaces.
//
// Hank Childs, Wed Jun 18 09:20:16 PDT 2003
// Compare needNodes.
//
// ****************************************************************************
bool
......@@ -407,6 +419,11 @@ avtDataSpecification::operator==(const avtDataSpecification &ds)
return false;
}
if (needNodes != ds.needNodes)
{
return false;
}
if (mayRequireZones != ds.mayRequireZones)
{
return false;
......
......@@ -138,6 +138,13 @@ class PIPELINE_API avtDataSpecification
void TurnZoneNumbersOff(void)
{ needZones = false; };
bool NeedNodeNumbers(void)
{ return needNodes; };
void TurnNodeNumbersOn(void)
{ needNodes = true; };
void TurnNodeNumbersOff(void)
{ needNodes = false; };
bool MayRequireZones(void)
{ return mayRequireZones; };
void SetMayRequireZones(bool val)
......@@ -179,6 +186,7 @@ class PIPELINE_API avtDataSpecification
std::vector<CharStrRef> secondaryVariables;
bool needZones;
bool needNodes;
bool mayRequireZones;
bool useGhostZones;
bool needInternalSurfaces;
......
......@@ -136,6 +136,9 @@ avtLocateCellQuery::PostExecute(void)
// Removed calculation of tolerance, and passing of that value to FindCell
// methods. No longer use tolerance when calculating fudgedIsect.
//
// Kathleen Bonnell, Wed Jun 18 17:52:45 PDT 2003
// Always use OriginalCellsArray if present.
//
// ****************************************************************************