[MOAB-dev] r3516 - MOAB/trunk
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Sun Jan 31 11:55:42 CST 2010
Author: tautges
Date: 2010-01-31 11:55:42 -0600 (Sun, 31 Jan 2010)
New Revision: 3516
Modified:
MOAB/trunk/ReadCCMIO.cpp
MOAB/trunk/ReadCCMIO.hpp
Log:
Adding ability to read and tag material sets.
Modified: MOAB/trunk/ReadCCMIO.cpp
===================================================================
--- MOAB/trunk/ReadCCMIO.cpp 2010-01-31 14:57:45 UTC (rev 3515)
+++ MOAB/trunk/ReadCCMIO.cpp 2010-01-31 17:55:42 UTC (rev 3516)
@@ -33,7 +33,19 @@
* FieldData
* Processor ...
-
+ * MaterialType (CCMIOReadOptstr in readexample)
+ * constants (see readexample)
+ * lagrangian data (CCMIOReadLagrangianData)
+ * vertices label (CCMIOEntityDescription)
+ * restart info: char solver[], iteratoins, time, char timeUnits[], angle
+ * (CCMIOReadRestartInfo, kCCMIORestartData), reference data?
+ * phase:
+ * field: char name[], dims, CCMIODataType datatype, char units[]
+ * dims = kCCMIOScalar (CCMIOReadFieldDataf),
+ * kCCMIOVector (CCMIOReadMultiDimensionalFieldData),
+ * kCCMIOTensor
+ * MonitoringSets: num, name (CellSet, VertexSet, BoundarySet, BlockSet, SplineSet, CoupleSet)
+ * CCMIOGetProstarSet, CCMIOReadOpt1i,
*/
enum DataType { kScalar, kVector, kVertex, kCell, kInternalFace, kBoundaryFace,
@@ -45,6 +57,13 @@
static int const kVertOffset = 2;
static int const kCellInc = 4;
+#define CHKERR(a, b) \
+ {if (MB_SUCCESS != a) {if (b) readMeshIface->report_error(b); return a;}}
+
+#define CHKCCMERR(a, b) \
+ {if (kCCMIONoErr != a) {if (b) readMeshIface->report_error(b); return MB_FAILURE;}}
+
+
MBReaderIface* ReadCCMIO::factory( MBInterface* iface )
{ return new ReadCCMIO( iface ); }
@@ -125,32 +144,165 @@
CCMIOError error = kCCMIONoErr;
CCMIOOpenFile(&error, file_name, kCCMIORead, &rootID);
- if (kCCMIONoErr != error) {
- readMeshIface->report_error("Problem opening file.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Problem opening file.");
// get the file state
MBErrorCode rval = get_state(rootID, problemID, stateID);
- if (MB_SUCCESS != rval) return MB_FAILURE;
+ CHKERR(rval,NULL);
// get processors
std::set<CCMIOSize_t> procs;
rval = get_processors(stateID, processorID, procs);
- if (MB_SUCCESS != rval) return MB_FAILURE;
+ CHKERR(rval,NULL);
std::set<CCMIOSize_t>::iterator sit;
+ MBRange new_ents, *new_ents_ptr = NULL;
+ if (file_set) new_ents_ptr = &new_ents;
+
for (sit = procs.begin(); sit != procs.end(); sit++) {
- rval = read_processor(stateID, processorID, *sit);
- if (MB_SUCCESS != rval) return MB_FAILURE;
+ rval = read_processor(stateID, problemID, processorID, *sit, new_ents_ptr);
+ CHKERR(rval,NULL);
}
+
+ // load some meta-data
+ rval = load_metadata(rootID, problemID, file_set);
+ CHKERR(rval,NULL);
+
+ // now, put all this into the file set, if there is one
+ if (file_set) {
+ rval = mbImpl->add_entities(*file_set, new_ents);
+ CHKERR(rval, "Failed to add new entities to file set.");
+ }
return rval;
}
-MBErrorCode ReadCCMIO::read_processor(CCMIOID stateID, CCMIOID processorID, CCMIOSize_t proc)
+MBErrorCode ReadCCMIO::load_metadata(CCMIOID rootID, CCMIOID problemID,
+ const MBEntityHandle *file_set)
{
+ // Read the simulation title.
CCMIOError error = kCCMIONoErr;
+ MBErrorCode rval = MB_SUCCESS;
+ CCMIONode rootNode;
+
+ if (kCCMIONoErr == CCMIOGetEntityNode(&error, rootID, &rootNode)) {
+ char *name = NULL;
+ CCMIOGetTitle(&error, rootNode, &name);
+
+ if (NULL != name && strlen(name) != 0) {
+ // make a tag for it and tag the read set
+ MBTag simname;
+ rval = mbImpl->tag_get_handle("SimulationName", simname);
+ if (MB_TAG_NOT_FOUND == rval) {
+ rval = mbImpl->tag_create("SimulationName", strlen(name), MB_TAG_SPARSE,
+ MB_TYPE_OPAQUE, simname, NULL);
+ CHKERR(rval, "Simulation name tag not found or created.");
+ }
+ MBEntityHandle tag_set = (NULL != file_set ? *file_set : 0);
+ rval = mbImpl->tag_set_data(simname, &tag_set, 1, name);
+ CHKERR(rval, "Problem setting simulation name tag.");
+
+ }
+ if (name) free(name);
+ }
+
+ rval = load_matset_data(problemID);
+ CHKERR(rval, NULL);
+
+ return rval;
+}
+
+MBErrorCode ReadCCMIO::load_matset_data(CCMIOID problemID)
+{
+ // make sure there are matsets
+ if (newMatsets.empty()) return MB_SUCCESS;
+
+ // ... walk through each cell type
+ CCMIOSize_t i = CCMIOSIZEC(0);
+ CCMIOID next;
+ std::vector<char> mtype_name;
+ CCMIOError error = kCCMIONoErr;
+ MBTag matNameTag = 0, matPorosityTag = 0, matSpinTag = 0, matGroupTag = 0;
+ MBErrorCode rval = create_matset_tags(matNameTag, matPorosityTag,
+ matSpinTag, matGroupTag);
+ CHKERR(rval, NULL);
+
+ while (CCMIONextEntity(NULL, problemID, kCCMIOCellType, &i, &next)
+ == kCCMIONoErr) {
+ int csize, mindex, idum;
+
+ CCMIOGetEntityIndex(&error, next, &mindex);
+ assert(mindex > 0 && mindex <= (int)newMatsets.size()+1);
+ mindex--;
+
+ // do Id first, since it should be set to something to identify set as a matset
+ if (kCCMIONoErr != CCMIOReadOpti(NULL, next, "MaterialId", &idum))
+ idum = mindex + 1;
+ MBEntityHandle dum_ent = newMatsets[mindex];
+ rval = mbImpl->tag_set_data(mMaterialSetTag, &dum_ent, 1, &idum);
+ CHKERR(rval, "Failed to set material set id tag.");
+
+ // MaterialType
+ if (kCCMIONoErr == CCMIOReadOptstr(NULL, next, "MaterialType", &csize, NULL)) {
+ mtype_name.resize(csize+1, '\0');
+ CCMIOReadOptstr(&error, next, "MaterialType", &csize, &mtype_name[0]);
+
+ rval = mbImpl->tag_set_data(matNameTag, &dum_ent, 1, &mtype_name[0]);
+ CHKERR(rval, "Failed to set matNameTag.");
+
+ }
+
+ // porosity
+ if (kCCMIONoErr == CCMIOReadOpti(NULL, next, "PorosityId", &idum)) {
+ rval = mbImpl->tag_set_data(matPorosityTag, &dum_ent, 1, &idum);
+ CHKERR(rval, "Failed to set matPorosityTag.");
+
+ }
+
+ // Spin
+ if (kCCMIONoErr == CCMIOReadOpti(NULL, next, "SpinId", &idum)) {
+ rval = mbImpl->tag_set_data(matSpinTag, &dum_ent, 1, &idum);
+ CHKERR(rval, "Failed to set matSpinTag.");
+
+ }
+
+ // group
+ if (kCCMIONoErr == CCMIOReadOpti(NULL, next, "GroupId", &idum)) {
+ rval = mbImpl->tag_set_data(matGroupTag, &dum_ent, 1, &idum);
+ CHKERR(rval, "Failed to set matGroupTag.");
+ }
+ }
+
+ return MB_SUCCESS;
+}
+
+MBErrorCode ReadCCMIO::create_matset_tags(MBTag &matNameTag, MBTag &matPorosityTag,
+ MBTag &matSpinTag, MBTag &matGroupTag)
+{
+ MBErrorCode rval = mbImpl->tag_create("MaterialName", NAME_TAG_SIZE, MB_TAG_SPARSE, MB_TYPE_OPAQUE,
+ matNameTag, NULL, true);
+ CHKERR(rval, "Failed to create matNameTag.");
+
+ rval = mbImpl->tag_create("MaterialPorosity", sizeof(int), MB_TAG_SPARSE, MB_TYPE_INTEGER,
+ matPorosityTag, NULL, true);
+ CHKERR(rval, "Failed to create matPorosityTag.");
+
+ rval = mbImpl->tag_create("MaterialSpin", sizeof(int), MB_TAG_SPARSE, MB_TYPE_INTEGER,
+ matSpinTag, NULL, true);
+ CHKERR(rval, "Failed to create matSpinTag.");
+
+ rval = mbImpl->tag_create("MaterialGroup", sizeof(int), MB_TAG_SPARSE, MB_TYPE_INTEGER,
+ matGroupTag, NULL, true);
+ CHKERR(rval, "Failed to create matGroupTag.");
+
+ return MB_SUCCESS;
+}
+
+MBErrorCode ReadCCMIO::read_processor(CCMIOID stateID, CCMIOID problemID,
+ CCMIOID processorID, CCMIOSize_t proc,
+ MBRange *new_ents)
+{
+ CCMIOError error = kCCMIONoErr;
MBErrorCode rval;
bool has_solution = true;
CCMIOID verticesID, topologyID, solutionID;
@@ -165,91 +317,157 @@
CCMIOReadProcessor(&error, processorID, &verticesID, &topologyID, NULL, NULL);
if(kCCMIONoErr == error)
hasSolution = false;
- else {
- readMeshIface->report_error("Couldn't get vertices and topology.");
- return MB_FAILURE;
- }
+ else CHKERR(MB_FAILURE, "Couldn't get vertices and topology.");
}
- MBRange verts;
// vert_map fields: s: none, i: gid, ul: vert handle, r: none
//TupleList vert_map(0, 1, 1, 0, 0);
TupleList vert_map;
rval = read_vertices(proc, processorID, verticesID, topologyID,
- solutionID, has_solution, verts, vert_map);
- if (MB_SUCCESS != rval) return rval;
+ solutionID, has_solution, new_ents, vert_map);
+ CHKERR(rval, NULL);
- rval = read_cells(proc, processorID, verticesID, topologyID,
- solutionID, has_solution, vert_map);
+ rval = read_cells(proc, problemID, verticesID, topologyID,
+ solutionID, has_solution, vert_map, new_ents);
+ CHKERR(rval, NULL);
return rval;
}
-MBErrorCode ReadCCMIO::read_cells(CCMIOSize_t proc, CCMIOID processorID,
+MBErrorCode ReadCCMIO::read_cells(CCMIOSize_t proc, CCMIOID problemID,
CCMIOID verticesID, CCMIOID topologyID,
CCMIOID solutionID, bool has_solution,
- TupleList &vert_map)
+ TupleList &vert_map, MBRange *new_ents)
{
- CCMIOID cellsID, mapID;
- CCMIOError error = kCCMIONoErr;
-
- // get the cells entity and number of cells
- CCMIOSize_t num_cells;
- CCMIOGetEntity(&error, topologyID, kCCMIOCells, 0, &cellsID);
- CCMIOEntitySize(&error, cellsID, &num_cells, NULL);
-
- // read the cell types and gid map
- std::vector<int> cell_gids(GETINT32(num_cells)), cell_types(GETINT32(num_cells));
- CCMIOReadCells(&error, cellsID, &mapID, NULL,
- CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
- // this reads the cellids from the map.
- CCMIOReadMap(&error, mapID, &cell_gids[0],
- CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
- if (kCCMIONoErr != error) {
- readMeshIface->report_error("Couldn't read cells or cell id map.");
- return MB_FAILURE;
- }
-
// read the faces.
// face_map fields: s:forward/reverse, i: cell id, ul: face handle, r: none
+ MBErrorCode rval;
#ifdef TUPLE_LIST
TupleList face_map(1, 1, 1, 0, 0);
#else
TupleList face_map;
SenseList sense_map;
#endif
- MBErrorCode rval = read_all_faces(topologyID, vert_map, face_map
+ rval = read_all_faces(topologyID, vert_map, face_map
#ifndef TUPLE_LIST
- , sense_map
+ , sense_map
#endif
- );
-
+ , new_ents);
+ CHKERR(rval, NULL);
+
// now construct the cells; sort the face map by cell ids first
#ifdef TUPLE_LIST
rval = face_map.sort(1);
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Couldn't sort face map by cell id.");
- return MB_FAILURE;
- }
+ CHKERR(rval, "Couldn't sort face map by cell id.");
#endif
- MBRange new_cells;
+ std::vector<MBEntityHandle> new_cells;
rval = construct_cells(face_map,
#ifndef TUPLE_LIST
sense_map,
#endif
vert_map, new_cells);
- if (MB_SUCCESS != rval) return rval;
+ CHKERR(rval, NULL);
+ if (new_ents) {
+ MBRange::iterator rit = new_ents->end();
+ std::vector<MBEntityHandle>::reverse_iterator vit;
+ for (vit = new_cells.rbegin(); vit != new_cells.rend(); vit++)
+ rit = new_ents->insert(rit, *vit);
+ }
+ rval = read_gids_and_types(problemID, topologyID, new_cells);
+ CHKERR(rval, NULL);
+
return MB_SUCCESS;
}
+MBErrorCode ReadCCMIO::read_gids_and_types(CCMIOID problemID,
+ CCMIOID topologyID,
+ std::vector<MBEntityHandle> &cells)
+{
+ // get the cells entity and number of cells
+ CCMIOSize_t num_cells;
+ CCMIOError error = kCCMIONoErr;
+ CCMIOID cellsID, mapID;
+ CCMIOGetEntity(&error, topologyID, kCCMIOCells, 0, &cellsID);
+ CCMIOEntitySize(&error, cellsID, &num_cells, NULL);
+
+ // check the number of cells against how many are in the cell array
+ if (num_cells != (int)cells.size())
+ CHKERR(MB_FAILURE, "Number of cells doesn't agree.");
+
+ // read the gid map and set global ids
+ std::vector<int> cell_gids(GETINT32(num_cells));
+ CCMIOReadCells(&error, cellsID, &mapID, NULL,
+ CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
+ CCMIOReadMap(&error, mapID, &cell_gids[0],
+ CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
+ CHKCCMERR(error, "Couldn't read cells or cell id map.");
+
+ MBErrorCode rval = mbImpl->tag_set_data(mGlobalIdTag, &cells[0],
+ cells.size(), &cell_gids[0]);
+ CHKERR(rval, "Couldn't set gids tag.");
+
+ // now read cell types; first get the number of different types, so we can make material
+ // sets
+ int num_matsets = 0;
+ CCMIOSize_t dum = CCMIOSIZEC(0);
+ // if we don't have a problem description, return
+ if (!CCMIOIsValidEntity(problemID)) return MB_SUCCESS;
+
+ // get the number of cells
+ CCMIOID next;
+ while (kCCMIONoErr == CCMIONextEntity(NULL, problemID, kCCMIOCellType, &dum, &next))
+ num_matsets++;
+
+ // create the matsets
+ for (int i = 0; i < num_matsets; i++) {
+ MBEntityHandle matset;
+ rval = mbImpl->create_meshset(MESHSET_SET, matset);
+ CHKERR(rval, "Couldn't create material set.");
+ newMatsets.insert(matset);
+ }
+
+ // read in cell types and use to assign cells to matsets; reuse cell_gids
+ CCMIOReadCells(&error, cellsID, NULL, &cell_gids[0],
+ CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
+ CHKCCMERR(error, "Trouble reading cell types.");
+
+ // check min/max
+ int min = *(std::min_element(cell_gids.begin(), cell_gids.end())),
+ max = *(std::max_element(cell_gids.begin(), cell_gids.end()));
+ if (1 != min || num_matsets != max) CHKERR(MB_FAILURE, "Wrong range for cell types.");
+
+ if (min == max && num_matsets == 1) {
+ // no streaming necessary, all elements are in this set
+ rval = mbImpl->add_entities(newMatsets[0], &cells[0], cells.size());
+ CHKERR(rval, "Trouble adding cells to matset.");
+ }
+ else {
+ // now stream through cell types, gather cells for each type, add to matsets
+ MBRange mcells;
+ for (int i = 1; i <= num_matsets; i++) {
+ mcells.clear();
+ // go backwards, since it's more efficient when adding to the end of a range
+ for (int j = num_cells-1; j >= 0; j--)
+ if (cell_gids[j] == i) mcells.insert(cells[j]);
+
+ rval = mbImpl->add_entities(newMatsets[i-1], mcells);
+ CHKERR(rval, "Trouble adding cells to matset.");
+
+ }
+ }
+
+ return MB_SUCCESS;
+}
+
+
MBErrorCode ReadCCMIO::construct_cells(TupleList &face_map,
#ifndef TUPLE_LIST
SenseList &sense_map,
#endif
TupleList &vert_map,
- MBRange &new_cells)
+ std::vector<MBEntityHandle> &new_cells)
{
std::vector<MBEntityHandle> facehs;
std::vector<int> senses;
@@ -269,11 +487,11 @@
senses.push_back(face_map.get_short(inext));
}
#else
- std::map<int,std::vector<MBEntityHandle> >::iterator fmit;
- std::map<int,std::vector<int> >::iterator smit;
- for (fmit = face_map.begin(), smit = sense_map.begin();
- fmit != face_map.end(); fmit++, smit++) {
+ std::map<int,std::vector<MBEntityHandle> >::iterator fmit;
+ std::map<int,std::vector<int> >::iterator smit;
+ for (fmit = face_map.begin(), smit = sense_map.begin();
+ fmit != face_map.end(); fmit++, smit++) {
// pull out face handles bounding the same cell
facehs.clear();
int this_id = (*fmit).first;
@@ -284,7 +502,7 @@
tmp_rval = create_cell_from_faces(facehs, senses, cell);
if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
else {
- new_cells.insert(cell);
+ new_cells.push_back(cell);
// tag cell with global id
tmp_rval = mbImpl->tag_set_data(mGlobalIdTag, &cell, 1, &this_id);
if (MB_SUCCESS != tmp_rval) rval = tmp_rval;
@@ -315,21 +533,15 @@
(MBQUAD == this_type && facehs.size() != 6) ||
(MBQUAD != this_type && MBTRI != this_type)) {
rval = mbImpl->create_element(MBPOLYHEDRON, &facehs[0], facehs.size(), cell);
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Couldn't make polyhedron.");
- return MB_FAILURE;
- }
- else return MB_SUCCESS;
+ CHKERR(rval, "Couldn't make polyhedron.");
+ return rval;
}
// try tet and hex elements; get connectivity of first face
std::vector<MBEntityHandle> verts;
rval = mbImpl->get_connectivity(&facehs[0], 1, verts);
+ CHKERR(rval, "Couldn't get connectivity.");
bool match = false;
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Couldn't get connectivity.");
- return MB_FAILURE;
- }
// reverse connectivity if sense is forward, since base face always points
// into entity
@@ -341,13 +553,12 @@
// get the 4th vertex through the next tri
const MBEntityHandle *conn; int conn_size;
rval = mbImpl->get_connectivity(facehs[1], conn, conn_size, true, &storage);
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Couldn't get connectivity.");
- return MB_FAILURE;
- }
+ CHKERR(rval, "Couldn't get connectivity.");
int i = 0;
while (std::find(verts.begin(), verts.end(), conn[i]) != verts.end() && i < conn_size) i++;
- if (conn_size == i) return MB_FAILURE;
+ if (conn_size == i)
+ CHKERR(MB_FAILURE, "Didn't find apex vertex.");
+
match = true;
this_type = MBTET;
}
@@ -369,48 +580,37 @@
// get q1, which shares 2 vertices with q0
std::copy(facehs.begin(), facehs.end(), mb_range_inserter(tmp_faces));
rval = mbImpl->get_adjacencies(&verts[0], 2, 2, false, tmp_faces);
- if (MB_SUCCESS != rval || tmp_faces.size() != 2) {
- readMeshIface->report_error("Couldn't get adj face.");
- return MB_FAILURE;
- }
+ if (MB_SUCCESS != rval || tmp_faces.size() != 2)
+ CHKERR(MB_FAILURE, "Couldn't get adj face.");
tmp_faces.erase(facehs[0]);
MBEntityHandle q1 = *tmp_faces.begin();
// get other 2 verts of q1
rval = mbImpl->get_connectivity(&q1, 1, tmp_verts);
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Couldn't get adj verts.");
- return MB_FAILURE;
- }
+ CHKERR(rval, "Couldn't get adj verts.");
tmp_verts.erase(verts[0]); tmp_verts.erase(verts[1]);
// get q2
std::copy(facehs.begin(), facehs.end(), mb_range_inserter(tmp_faces));
rval = mbImpl->get_adjacencies(tmp_verts, 2, false, tmp_faces);
- if (MB_SUCCESS != rval || tmp_faces.size() != 2) {
- readMeshIface->report_error("Couldn't get adj face.");
- return MB_FAILURE;
- }
+ if (MB_SUCCESS != rval || tmp_faces.size() != 2)
+ CHKERR(MB_FAILURE, "Couldn't get adj face.");
tmp_faces.erase(q1);
MBEntityHandle q2 = *tmp_faces.begin();
// get verts in q2
rval = mbImpl->get_connectivity(&q2, 1, storage);
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Couldn't get adj vertices.");
- return MB_FAILURE;
- }
+ CHKERR(rval, "Couldn't get adj vertices.");
+
// get verts in q1 opposite from v[1] and v[0] in q0
MBEntityHandle v0 = 0, v1 = 0;
rval = mtu.opposite_entity(q1, verts[1], v0);
rval = mtu.opposite_entity(q1, verts[0], v1);
- if (!v0 || !v1) {
- readMeshIface->report_error("Trouble finding opposite vertices.");
- return MB_FAILURE;
- }
+ if (!v0 || !v1)
+ CHKERR(MB_FAILURE, "Trouble finding opposite vertices.");
+
// offset of v0 in q2, then rotate and flip
unsigned int ioff = std::find(storage.begin(), storage.end(), v0) - storage.begin();
- if (4 == ioff) {
- readMeshIface->report_error("Trouble finding offset.");
- return MB_FAILURE;
- }
+ if (4 == ioff)
+ CHKERR(MB_FAILURE, "Trouble finding offset.");
+
if (storage[(ioff+1)%4] != v1) {
std::reverse(storage.begin(), storage.end());
ioff = std::find(storage.begin(), storage.end(), v0) - storage.begin();
@@ -423,24 +623,22 @@
match = true;
this_type = MBHEX;
}
- if (!match) return MB_FAILURE;
+ if (!match)
+ CHKERR(MB_FAILURE, "Couldn't find vertices for hex.");
- // now make the element
+ // now make the element
rval = mbImpl->create_element(this_type, &verts[0], verts.size(), cell);
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("create_element failed.");
- return MB_FAILURE;
- }
+ CHKERR(rval, "create_element failed.");
return MB_SUCCESS;
}
-
+
MBErrorCode ReadCCMIO::read_all_faces(CCMIOID topologyID, TupleList &vert_map,
TupleList &face_map
#ifndef TUPLE_LIST
,SenseList &sense_map
#endif
-)
+ , MBRange *new_faces)
{
CCMIOSize_t index = CCMIOSIZEC(0);
CCMIOID faceID;
@@ -472,11 +670,8 @@
#ifndef TUPLE_LIST
, sense_map
#endif
- );
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Trouble reading boundary faces.");
- return MB_FAILURE;
- }
+ , new_faces);
+ CHKERR(rval, "Trouble reading boundary faces.");
}
// now get internal faces
@@ -486,11 +681,8 @@
#ifndef TUPLE_LIST
, sense_map
#endif
- );
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Trouble reading internal faces.");
- return MB_FAILURE;
- }
+ , new_faces);
+ CHKERR(rval, "Trouble reading internal faces.");
return rval;
}
@@ -501,12 +693,10 @@
#ifndef TUPLE_LIST
,SenseList &sense_map
#endif
- )
+ , MBRange *new_faces)
{
- if (kCCMIOInternalFaces != bdy_or_int && kCCMIOBoundaryFaces != bdy_or_int) {
- readMeshIface->report_error("Face type isn't boundary or internal.");
- return MB_FAILURE;
- }
+ if (kCCMIOInternalFaces != bdy_or_int && kCCMIOBoundaryFaces != bdy_or_int)
+ CHKERR(MB_FAILURE, "Face type isn't boundary or internal.");
CCMIOSize_t num_faces;
CCMIOError error = kCCMIONoErr;
@@ -517,10 +707,7 @@
CCMIOSize_t farray_size = CCMIOSIZEC(0);
CCMIOReadFaces(&error, faceID, bdy_or_int, NULL, &farray_size, NULL,
CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
- if (kCCMIONoErr != error) {
- readMeshIface->report_error("Trouble reading face connectivity length.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Trouble reading face connectivity length.");
// allocate vectors for holding farray and cells for each face; use new for finer
@@ -532,14 +719,11 @@
CCMIOID mapID;
CCMIOReadFaces(&error, faceID, bdy_or_int, &mapID, NULL,
farray, CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
- if (kCCMIONoErr != error) {
- readMeshIface->report_error("Trouble reading face connectivity.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Trouble reading face connectivity.");
std::vector<MBEntityHandle> face_handles(GETINT32(num_faces), 0);
MBErrorCode rval = make_faces(farray, vert_map, face_handles);
- if (MB_SUCCESS != rval) return rval;
+ CHKERR(rval, NULL);
// read face cells and make tuples
int *face_cells;
@@ -547,10 +731,7 @@
else face_cells = farray;
CCMIOReadFaceCells(&error, faceID, bdy_or_int, face_cells,
CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
- if (kCCMIONoErr != error) {
- readMeshIface->report_error("Trouble reading face cells.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Trouble reading face cells.");
int *tmp_ptr = face_cells;
for (int i = 0; i < num_faces; i++) {
@@ -571,19 +752,23 @@
// now read & set face gids, reuse face_cells 'cuz we know it's big enough
CCMIOReadMap(&error, mapID, face_cells, CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
- if (kCCMIONoErr != error) {
- readMeshIface->report_error("Trouble reading face gids.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Trouble reading face gids.");
rval = mbImpl->tag_set_data(mGlobalIdTag, &face_handles[0], face_handles.size(), face_cells);
- if (MB_SUCCESS != rval) {
- readMeshIface->report_error("Couldn't set face global ids.");
- return MB_FAILURE;
- }
+ CHKERR(rval, "Couldn't set face global ids.");
+ // ok, now sort face handles, and add to range
+ std::sort(face_handles.begin(), face_handles.end());
+ if (new_faces) {
+ MBRange::iterator rit = new_faces->end();
+ for (std::vector<MBEntityHandle>::reverse_iterator vit = face_handles.rbegin();
+ vit != face_handles.rend(); vit++)
+ rit = new_faces->insert(rit, *vit);
+ }
+
return MB_SUCCESS;
}
+
MBErrorCode ReadCCMIO::make_faces(int *farray,
TupleList &vert_map,
@@ -630,26 +815,20 @@
MBErrorCode ReadCCMIO::read_vertices(CCMIOSize_t proc, CCMIOID processorID, CCMIOID verticesID,
CCMIOID topologyID, CCMIOID solutionID, bool has_solution,
- MBRange &verts, TupleList &vert_map)
+ MBRange *verts, TupleList &vert_map)
{
CCMIOError error = kCCMIONoErr;
// pre-read the number of vertices, so we can pre-allocate & read directly in
CCMIOSize_t nverts = CCMIOSIZEC(0);
CCMIOEntitySize(&error, verticesID, &nverts, NULL);
- if(kCCMIONoErr != error) {
- readMeshIface->report_error("Couldn't get number of vertices.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Couldn't get number of vertices.");
// get # dimensions
CCMIOSize_t dims;
float scale;
CCMIOReadVerticesf(&error, verticesID, &dims, NULL, NULL, NULL, CCMIOINDEXC(0), CCMIOINDEXC(1));
- if(kCCMIONoErr != error) {
- readMeshIface->report_error("Couldn't get number of dimensions.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Couldn't get number of dimensions.");
// allocate vertex space
MBEntityHandle node_handle = 0;
@@ -661,10 +840,7 @@
std::vector<double> tmp_coords(GETINT32(dims)*GETINT32(nverts));
CCMIOReadVerticesd(&error, verticesID, &dims, &scale, &mapID, &tmp_coords[0],
CCMIOINDEXC(0), CCMIOINDEXC(0+nverts));
- if(kCCMIONoErr != error) {
- readMeshIface->report_error("Trouble reading vertex coordinates.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Trouble reading vertex coordinates.");
// copy interleaved coords into moab blocked coordinate space
int i = 0, threei = 0;
@@ -685,15 +861,12 @@
}
// put new vertex handles into range
- verts.insert(node_handle, node_handle+nverts);
+ if (verts) verts->insert(node_handle, node_handle+nverts);
// pack vert_map with global ids and handles for these vertices
std::vector<int> gids(GETINT32(nverts));
CCMIOReadMap(&error, mapID, &gids[0], CCMIOINDEXC(kCCMIOStart), CCMIOINDEXC(kCCMIOEnd));
- if(kCCMIONoErr != error) {
- readMeshIface->report_error("Trouble reading vertex global ids.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Trouble reading vertex global ids.");
#ifdef TUPLE_LIST
vert_map.resize(GETINT32(nverts));
for (i = 0; i < GETINT32(nverts); i++) {
@@ -733,10 +906,7 @@
CCMIONextEntity(&error, rootID, kCCMIOProblemDescription,
&i, &problemID);
}
- if (kCCMIONoErr != error) {
- readMeshIface->report_error("Couldn't find state.");
- return MB_FAILURE;
- }
+ CHKCCMERR(error, "Couldn't find state.");
return MB_SUCCESS;
}
@@ -754,175 +924,6 @@
/*
// ****************************************************************************
-// Method: avtCCMFileFormat::GetIDsForDomain
-//
-// Purpose:
-// Gets nodes for state, processor, vertices, topology and solution that can
-// be used to query attributes for variables and meshes.
-//
-// Arguments:
-//
-// Returns:
-//
-// Note:
-//
-// Programmer: Brad Whitlock
-// Creation: Mon Aug 6 09:10:29 PDT 2007
-//
-// Modifications:
-//
-// ****************************************************************************
-
-bool
-avtCCMFileFormat::GetIDsForDomain(int dom,
- CCMIOID &processor, CCMIOID &vertices, CCMIOID &topology,
- CCMIOID &solution, bool &hasSolution)
-{
- const char *mName = "avtCCMFileFormat::GetIDsForDomain: ";
-
- // Try and get the requested processor.
- int proc = dom;
- bool ret = (
- CCMIONextEntity(NULL, GetState(), kCCMIOProcessor, &proc, &processor) ==
- kCCMIONoErr);
- if(ret)
- {
- hasSolution = true;
- ccmErr = kCCMIONoErr;
- // Try and read the vertices, topology, and solution ids for this
- // processor.
- CCMIOReadProcessor(&ccmErr, processor, &vertices, &topology, NULL,
- &solution);
- if(ccmErr != kCCMIONoErr)
- {
- // That didn't work. (Maybe no solution). See if we can at least
- // get the vertices and processor.
- ccmErr = kCCMIONoErr;
- CCMIOReadProcessor(&ccmErr, processor, &vertices, &topology, NULL,
- NULL);
- if(ccmErr == kCCMIONoErr)
- hasSolution = false;
- else
- ret = false;
- }
- }
-
- return ret;
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::GetFaces
-//
-// Purpose: Reads the face info.
-//
-// Arguments:
-// faceID The ID of the face entity.
-// faceType The type of faces (internal or boundary).
-// nFaces How many faces are in the entity.
-// cellIDMap Used to map cell IDs to indices
-// vertexIDMap Used to map vertex IDs to indices
-// minSize Min num verts in a face
-// maxSize Max num verts in a face
-// ci A place to store the face info, must be allocated by
-// calling method.
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 5, 2007
-//
-// Modifications:
-// Kathleen Bonnell, Thu Mar 6 09:21:02 PST 2008
-// Removed unused variable.
-//
-// Dave Bremer, Fri Apr 4 16:29:49 PDT 2008
-// Fixed a bug in which cell and vertex ids were mistaken for 1-based
-// indices.
-// ****************************************************************************
-
-void
-avtCCMFileFormat::GetFaces(CCMIOID faceID, CCMIOEntity faceType,
- unsigned int nFaces, const IDMap &cellIDMap,
- const IDMap &vertexIDMap,
- int &minSize, int &maxSize, CellInfoVector &ci)
-{
- if (faceType != kCCMIOInternalFaces && faceType != kCCMIOBoundaryFaces)
- {
- debug1 << "avtCCMFileFormat::GetFaces encountered an internal error"
- << endl;
- return;
- }
- int getFacesTimer = visitTimer->StartTimer();
- CCMIOID mapID;
- unsigned int nCells = 0, size = 0;
- //intVector faces;
- intVector faceNodes, faceCells;
-
- // Determine the size of the faceNodes array, which is of the
- // form n1, v1, v2, ...vn1, n2, v1, v2, ... vn2, )
- CCMIOReadFaces(&ccmErr, faceID, faceType, NULL, &size, NULL,
- kCCMIOStart, kCCMIOEnd);
- faceNodes.resize(size);
- //faces.resize(nFaces);
- if (faceType == kCCMIOInternalFaces)
- faceCells.resize(nFaces*2);
- else
- faceCells.resize(nFaces);
- CCMIOReadFaces(&ccmErr, faceID, faceType, &mapID, NULL,
- &faceNodes[0], kCCMIOStart, kCCMIOEnd);
- CCMIOReadFaceCells(&ccmErr, faceID, faceType, &faceCells[0],
- kCCMIOStart, kCCMIOEnd);
- //CCMIOReadMap(&ccmErr, mapID, &faces[0], kCCMIOStart, kCCMIOEnd);
-
- unsigned int pos = 0;
- for (unsigned int i = 0; i < nFaces; ++i)
- {
- FaceInfo newFace;
- //newFace.id = faces[i];
- if (faceType == kCCMIOInternalFaces)
- {
- newFace.cells[0] = faceCells[i*2];
- newFace.cells[1] = faceCells[i*2+1];
- }
- else
- {
- newFace.cells[0] = faceCells[i];
- }
- int nVerts = faceNodes[pos];
-
- if (nVerts < minSize)
- minSize = nVerts;
- if (nVerts > maxSize)
- maxSize = nVerts;
-
- for (unsigned int j = 0; j < nVerts; ++j)
- {
- newFace.nodes.push_back( vertexIDMap.IDtoIndex(faceNodes[pos+1+j]) );
- }
- // cell ids are 1-origin, so must subract 1 to get the
- // correct index into the CellInfoVector
- if (faceType == kCCMIOInternalFaces)
- {
- int c0 = cellIDMap.IDtoIndex(newFace.cells[0]);
- int c1 = cellIDMap.IDtoIndex(newFace.cells[1]);
-
- ci[c0].faceTypes.push_back(1);
- ci[c0].faces.push_back(newFace);
- ci[c1].faceTypes.push_back(2);
- ci[c1].faces.push_back(newFace);
- }
- else
- {
- int c0 = cellIDMap.IDtoIndex(newFace.cells[0]);
-
- ci[c0].faceTypes.push_back(0);
- ci[c0].faces.push_back(newFace);
- }
- pos += faceNodes[pos] +1;
- }
- visitTimer->StopTimer(getFacesTimer, "GetFaces");
-}
-
-// ****************************************************************************
// Method: avtCCMFileFormat::PopulateDatabaseMetaData
//
// Purpose:
@@ -1230,631 +1231,6 @@
// ****************************************************************************
-// Method: avtCCMFileFormat::GetMesh
-//
-// Purpose:
-// Gets the mesh associated with this file. The mesh is returned as a
-// derived type of vtkDataSet (ie vtkRectilinearGrid, vtkStructuredGrid,
-// vtkUnstructuredGrid, etc).
-//
-// Arguments:
-// domain The index of the domain. If there are NDomains, this
-// value is guaranteed to be between 0 and NDomains-1,
-// regardless of block origin.
-// meshname The name of the mesh of interest. This can be ignored if
-// there is only one mesh.
-//
-// Programmer: Brad Whitlock
-// Creation: Thu Aug 2 15:01:17 PST 2007
-//
-// Modifications:
-// Brad Whitlock, Tue Dec 18 12:57:28 PST 2007
-// Added support for 2D polygonal shapes.
-//
-// Kathleen Bonnell, Thu Feb 28 15:00:24 PST 2008
-// If the primary variable (activeVisItVar) is defined only on a portion of
-// the mesh, only retrieve (and tesselate) those cells it is defined upon.
-//
-// Dave Bremer, Fri Apr 4 16:29:49 PDT 2008
-// Fixed a bug in which cell and vertex ids were mistaken for 1-based
-// indices.
-//
-// Brad Whitlock, Thu Oct 1 13:36:48 PDT 2009
-// I refactored this routine into helper routines and added support for
-// automatically subdividing a mesh on the fly.
-//
-// ****************************************************************************
-
-#ifndef MDSERVER
-#include <PolygonToTriangles.C>
-#endif
-
-vtkDataSet *
-avtCCMFileFormat::GetMesh(int domain, const char *meshname)
-{
-#ifdef MDSERVER
- return 0;
-#else
- // Override domain if we're automatically dividing the data
- int dom = subdividingSingleMesh ? 0 : domain;
-
- vtkUnstructuredGrid *ugrid = NULL;
- vtkPoints *points = NULL;
-
- TRY
- {
- // Read the points
- points = ReadPoints(dom, meshname);
-
- // Read the cell connectivity
- CellInfoVector cellInfo;
- int minFaceSize = VTK_LARGE_INTEGER;
- int maxFaceSize = -1;
- ReadCellInfo(dom, meshname,
- cellInfo, minFaceSize, maxFaceSize);
-
- //
- // Convert cellInfo into vtkUnstructuredGrid
- //
- SelectCellsForThisProcessor(cellInfo, points);
-
- ugrid = vtkUnstructuredGrid::New();
-
- // Determine cell topology from face lists
- if (minFaceSize == 2 && maxFaceSize == 2)
- {
- // 2D edges that we must assemble into polygons and tessellate into
- // triangles that VisIt can digest.
- TesselateCells2D(domain, cellInfo, points, ugrid);
- }
- else if (minFaceSize <= 4 && maxFaceSize <= 4)
- {
-#ifdef ENABLE_SUBDIVISION
- // If we're subdividing a single domain on the fly then we create
- // original cell numbers so we can use them in the GetVar method
- // to return only the cell values that we selected for this chunk
- // of the mesh.
- unsigned int oc[2] = {dom, 0};
- vtkUnsignedIntArray *origCells = 0;
- if(subdividingSingleMesh)
- {
- int useCount = 0;
- for(unsigned int i = 0; i < cellInfo.size(); ++i)
- useCount += (cellInfo[i].id != -1) ? 1 : 0;
- origCells = vtkUnsignedIntArray::New();
- origCells->SetName("avtOriginalCellNumbers");
- origCells->SetNumberOfComponents(2);
- origCells->Allocate(useCount * 3);
- originalCells[dom] = origCells;
- }
-#endif
- ugrid->SetPoints(points);
- // We have zoo elements that we can deal with.
- vtkCellArray *cellArray = vtkCellArray::New();
- intVector cellTypes;
- bool unhandledCellType = false;
- for (unsigned int i = 0; i < cellInfo.size(); i++)
- {
- const CellInfo &ci = cellInfo[i];
- if(ci.id == -1)
- continue;
-#ifdef ENABLE_SUBDIVISION
- oc[1] = ci.id;
-#endif
- switch(ci.faces.size())
- {
- case 4 :
- BuildTet(ci, cellArray, cellTypes);
-#ifdef ENABLE_SUBDIVISION
- if(subdividingSingleMesh)
- origCells->InsertNextTupleValue(oc);
-#endif
- break;
- case 5 :
- {
- int nNodes = 0;
- for (size_t j = 0; j < ci.faces.size(); j++)
- {
- nNodes += ci.faces[j].nodes.size();
- }
- if (nNodes == 16) // Pyramid
- {
- BuildPyramid(ci, cellArray, cellTypes);
-#ifdef ENABLE_SUBDIVISION
- if(subdividingSingleMesh)
- origCells->InsertNextTupleValue(oc);
-#endif
- }
- else if (nNodes == 18) // Wedge
- {
- BuildWedge(ci, cellArray, cellTypes);
-#ifdef ENABLE_SUBDIVISION
- if(subdividingSingleMesh)
- origCells->InsertNextTupleValue(oc);
-#endif
- }
- else
- unhandledCellType = true;
- break;
- }
- case 6 :
- BuildHex(ci, cellArray, cellTypes);
-#ifdef ENABLE_SUBDIVISION
- if(subdividingSingleMesh)
- origCells->InsertNextTupleValue(oc);
-#endif
- break;
- default :
- unhandledCellType = true;
- break;
- }
- }
- ugrid->SetCells(&cellTypes[0], cellArray);
- cellArray->Delete();
- }
- else
- {
- TesselateCell(domain, cellInfo, points, ugrid);
- }
-
- points->Delete();
- }
- CATCHALL
- {
- if(points != NULL)
- points->Delete();
- if(ugrid != NULL)
- ugrid->Delete();
- }
- ENDTRY
-
- return ugrid;
-#endif
-}
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::ReadPoints
-//
-// Purpose:
-// Reads the points associated with a specified domain/mesh.
-//
-// Arguments:
-// dom : The domain number.
-// meshname : The name of the mesh.(for error reporting)
-//
-// Returns: The vtkPoints object that contains the points.
-//
-// Note: This method was broken out from the original GetMesh routine.
-//
-// Programmer: Kathleen Bonnell, Brad Whitlock
-// Creation: Thu Oct 1 13:29:03 PDT 2009
-//
-// Modifications:
-//
-// ****************************************************************************
-
-vtkPoints *
-avtCCMFileFormat::ReadPoints(int dom, const char *meshname)
-{
- CCMIOID processor, vertices, topology, solution;
- bool hasSolution = true;
- if(!GetIDsForDomain(dom, processor, vertices, topology, solution,
- hasSolution))
- {
- EXCEPTION1(InvalidVariableException, meshname);
- }
-
- // Read the size of the vertices
- CCMIOSize nnodes = 0;
- CCMIOEntitySize(&ccmErr, vertices, &nnodes, NULL);
- if(ccmErr != kCCMIONoErr)
- {
- debug4 << "CCMIOEntitySize for vertices failed with error " ;
- debug4 << ccmErr << endl;
- EXCEPTION1(InvalidVariableException, meshname);
- }
-
- // Read the dimensions of the vertex.
- int dims = 1;
- float scale;
- CCMIOReadVerticesf(&ccmErr, vertices, &dims, NULL, NULL, NULL, 0, 1);
- if(ccmErr != kCCMIONoErr)
- {
- debug4 << "CCMIOReadVertices for first vertex dimensions ";
- debug4 << "failed with error " << ccmErr << endl;
- EXCEPTION1(InvalidVariableException, meshname);
- }
-
- // Allocate VTK memory.
- vtkPoints *points = vtkPoints::New();
- points->SetNumberOfPoints(nnodes);
- float *pts = (float *)points->GetVoidPointer(0);
-
- // Read the data into the VTK points.
- CCMIOID mapID;
- if(dims == 2)
- {
- // Read 2D points and convert to 3D, storing into VTK.
- float *pts2d = new float[2 * nnodes];
- CCMIOReadVerticesf(&ccmErr, vertices, &dims, &scale, &mapID, pts2d,
- 0, nnodes);
- float *src = pts2d;
- float *dest = pts;
- for(int i = 0; i < nnodes; ++i)
- {
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = 0.;
- }
- delete [] pts2d;
- }
- else
- {
- // Read the data directly into the VTK buffer.
- CCMIOReadVerticesf(&ccmErr, vertices, &dims, &scale, &mapID, pts,
- 0, nnodes);
- }
-
- // Scale the points, according to the scale factor read with the
- // vertices.
- for(int i = 0; i < nnodes; ++i)
- {
- pts[0] *= scale;
- pts[1] *= scale;
- pts[2] *= scale;
- pts += 3;
- }
-
- return points;
-}
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::ReadCellInfo
-//
-// Purpose:
-// Reads the cell info associated with a specified domain/mesh.
-//
-// Arguments:
-// dom : The domain number.
-// meshname : The name of the mesh.(for error reporting)
-// cellInfo : The cell information to populate.
-// minFaceSize : Return value of the min face size.
-// maxFaceSize : Return value of the max face size.
-//
-// Returns:
-//
-// Note: This method was broken out from the original GetMesh routine.
-// min/maxFaceSize are used to determine whether tesselation is
-// required.
-//
-// Programmer: Kathleen Bonnell, Brad Whitlock
-// Creation: Thu Oct 1 13:29:03 PDT 2009
-//
-// Modifications:
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::ReadCellInfo(int dom, const char *meshname,
- CellInfoVector &cellInfo, int &minFaceSize, int &maxFaceSize)
-{
- CCMIOID processor, vertices, topology, solution;
- bool hasSolution = true;
- if(!GetIDsForDomain(dom, processor, vertices, topology, solution,
- hasSolution))
- {
- EXCEPTION1(InvalidVariableException, meshname);
- }
-
- // Read the size of the vertices
- CCMIOSize nnodes = 0;
- CCMIOEntitySize(&ccmErr, vertices, &nnodes, NULL);
- if(ccmErr != kCCMIONoErr)
- {
- debug4 << "CCMIOEntitySize for vertices failed with error " ;
- debug4 << ccmErr << endl;
- EXCEPTION1(InvalidVariableException, meshname);
- }
-
- // Read the dimensions of the vertex and get the mapID
- int dims = 1;
- CCMIOID mapID;
- CCMIOReadVerticesf(&ccmErr, vertices, &dims, NULL, &mapID, NULL, 0, 1);
- if(ccmErr != kCCMIONoErr)
- {
- debug4 << "CCMIOReadVertices for first vertex dimensions ";
- debug4 << "failed with error " << ccmErr << endl;
- EXCEPTION1(InvalidVariableException, meshname);
- }
-
- // Read the vertex ids
- intVector tmpVertexMap(nnodes);
- CCMIOReadMap(&ccmErr, mapID, &tmpVertexMap[0], kCCMIOStart, kCCMIOEnd);
- IDMap vertexIDMap;
- vertexIDMap.SetIDs(tmpVertexMap);
- tmpVertexMap.clear();
-
- // Get the topology information
- CCMIOID faceID, cellsID;
- unsigned int nIFaces = 0, nCells = 0, size = 0;
- intVector cells;
- //intVector cellMatType;
-
- // Read the cells entity
- CCMIOGetEntity(&ccmErr, topology, kCCMIOCells, 0, &cellsID);
- // Read the cells entity size (num cells)
- CCMIOEntitySize(&ccmErr, cellsID, &nCells, NULL);
- cells.resize(nCells);
- cellInfo.resize(nCells);
- //cellMatType.resize(nCells);
- // this gets the cell types and the map that stores the cell ids
- CCMIOReadCells(&ccmErr, cellsID, &mapID, NULL,
- kCCMIOStart, kCCMIOEnd);
- // this reads the cellids from the map.
- CCMIOReadMap(&ccmErr, mapID, &cells[0], kCCMIOStart, kCCMIOEnd);
- for (int i = 0; i < nCells; ++i)
- cellInfo[i].id = cells[i];
-
- IDMap cellIDMap;
- cellIDMap.SetIDs(cells);
-
- // Read the boundary faces.
- int index = 0;
- int count = 0;
- int nBoundaries = 0;
- while (CCMIONextEntity(NULL, topology, kCCMIOBoundaryFaces, &index,
- &faceID) == kCCMIONoErr)
- {
- nBoundaries++;
- }
-
- index = 0;
- while (CCMIONextEntity(NULL, topology, kCCMIOBoundaryFaces, &index,
- &faceID) == kCCMIONoErr)
- {
- CCMIOSize nBFaces;
- CCMIOEntitySize(&ccmErr, faceID, &nBFaces, NULL);
- GetFaces(faceID, kCCMIOBoundaryFaces, nBFaces,
- cellIDMap, vertexIDMap,
- minFaceSize, maxFaceSize, cellInfo);
- }
-
- // Read the internal faces.
- // Get the InternalFaces entity.
- CCMIOGetEntity(&ccmErr, topology, kCCMIOInternalFaces, 0, &faceID);
- // Get the InternalFaces size (num faces).
- CCMIOEntitySize(&ccmErr, faceID, &nIFaces, NULL);
-
- GetFaces(faceID, kCCMIOInternalFaces, nIFaces, cellIDMap, vertexIDMap,
- minFaceSize, maxFaceSize, cellInfo);
-
-
- if (find(varsOnSubmesh.begin(), varsOnSubmesh.end(), activeVisItVar)
- != varsOnSubmesh.end())
- {
- // need to reduce the number of cells we actually process.
- intVector validCells;
- CellInfoVector vcv;
- GetCellMapData(dom, activeVisItVar, validCells);
-
- for (int i = 0; i < cellInfo.size(); ++i)
- {
- if (find(validCells.begin(), validCells.end(), cellInfo[i].id)
- != validCells.end())
- {
- vcv.push_back(cellInfo[i]);
- }
- }
- cellInfo = vcv;
- }
-
- debug5 << "minFaceSize = " << minFaceSize
- << ", maxFaceSize = " << maxFaceSize << endl;
-}
-
-#ifdef ENABLE_SUBDIVISION
-// ****************************************************************************
-// Method: ComputePatchCenter
-//
-// Purpose:
-// Computes the center and bounds of the patch.
-//
-// Arguments:
-// centers : The centers for each cell in the mesh.
-// patch : The list of cellids that make up the patch.
-// center : The calculated center of the patch.
-// bounds : The calculated bounds of the patch.
-//
-// Programmer: Brad Whitlock
-// Creation: Tue Oct 6 16:12:08 PDT 2009
-//
-// Modifications:
-//
-// ****************************************************************************
-
-static void
-ComputePatchCenter(const double *centers, const intVector &patch, double *center, double *bounds)
-{
- center[0] = 0.;
- center[1] = 0.;
- center[2] = 0.;
- int nMatches = 0;
- for(int i = 0; i < patch.size(); ++i)
- {
- const double *c = centers + patch[i] * 3;
-
- // Compute extents of cell centers.
- if(nMatches == 0)
- {
- bounds[0] = bounds[1] = c[0];
- bounds[2] = bounds[3] = c[1];
- bounds[4] = bounds[5] = c[2];
- }
- else
- {
- if(c[0] < bounds[0])
- bounds[0] = c[0];
- if(c[0] > bounds[1])
- bounds[1] = c[0];
-
- if(c[1] < bounds[2])
- bounds[2] = c[1];
- if(c[1] > bounds[3])
- bounds[3] = c[1];
-
- if(c[2] < bounds[4])
- bounds[4] = c[2];
- if(c[2] > bounds[5])
- bounds[5] = c[2];
- }
-
- center[0] += c[0];
- center[1] += c[1];
- center[2] += c[2];
- nMatches++;
- }
- if(nMatches > 0)
- {
- center[0] /= double(nMatches);
- center[1] /= double(nMatches);
- center[2] /= double(nMatches);
- }
-}
-
-// ****************************************************************************
-// Method: DivideLargestPatch
-//
-// Purpose:
-// Divides the largest patch in the patch vector.
-//
-// Arguments:
-// centers : The centers of all cells in the mesh.
-// patches : The list of all patches.
-//
-// Returns:
-//
-// Note: This routine modifies the patches vector by splitting 1 of the
-// patches, replacing the split patch with piece0. piece1 is appended
-// to the patch vector.
-//
-// Programmer: Brad Whitlock
-// Creation: Tue Oct 6 16:13:33 PDT 2009
-//
-// Modifications:
-//
-// ****************************************************************************
-
-static void
-DivideLargestPatch(const double *centers, std::vector<intVector> &patches)
-{
- // Find the index of the largest patch
- int maxIndex = 0;
- for(int i = 1; i < patches.size(); ++i)
- if(patches[i].size() > patches[maxIndex].size())
- maxIndex = i;
-
- // Compute the center at which we will bisect.
- double center[3], bounds[6];
- ComputePatchCenter(centers, patches[maxIndex], center, bounds);
-
- // Figure out the longest dimension since that's the dimension we'll bisect.
- double dX = bounds[1] - bounds[0];
- double dY = bounds[3] - bounds[2];
- double dZ = bounds[5] - bounds[4];
- int longestDimension = 2;
- if(dX > dY)
- {
- if(dX > dZ)
- longestDimension = 0;
- }
- else
- {
- if(dY > dZ)
- longestDimension = 1;
- }
-
- const intVector &patch = patches[maxIndex];
- intVector piece0, piece1;
- for(int j = 0; j < patch.size(); ++j)
- {
- const double *c = centers + patch[j] * 3;
- if(c[longestDimension] > center[longestDimension])
- piece0.push_back(patch[j]);
- else
- piece1.push_back(patch[j]);
- }
- patches[maxIndex] = piece0;
- patches.push_back(piece1);
-}
-#endif
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::SelectCellsForThisProcessor
-//
-// Purpose:
-// This routine divides the cells spatially into PAR_Size() different bins
-// and sets all of the ids for the cells in cellInfo to -1 (invalid) unless
-// their bin matches PAR_Rank(). This means that we are marking a subset of
-// the cells in cellInfo as being valid so we can return just a part of the
-// dataset.
-//
-// Arguments:
-// cellInfo : The vector of cell data.
-// points : The points used by the cells.
-//
-// Returns:
-//
-// Note: This method is just used in parallel when we have a single
-// domain dataset that we want to automatically chunk up under the
-// covers.
-//
-// Programmer: Brad Whitlock
-// Creation: Thu Oct 1 13:25:17 PDT 2009
-//
-// Modifications:
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::SelectCellsForThisProcessor(CellInfoVector &cellInfo, vtkPoints *points)
-{
-#ifdef ENABLE_SUBDIVISION
- if(subdividingSingleMesh)
- {
- // Compute cell centers
- double *centers = new double[cellInfo.size() * 3];
- for(size_t i = 0; i < cellInfo.size(); ++i)
- cellInfo[i].CellCenter(centers + i * 3, points);
-
- // Start out with all cells in 1 patch
- std::vector<intVector> patches;
- intVector allCells;
- for(size_t i = 0; i < cellInfo.size(); ++i)
- allCells.push_back(i);
- patches.push_back(allCells);
-
- // Divide the largest patch until we have enough patches.
- while(patches.size() < PAR_Size())
- DivideLargestPatch(centers, patches);
-
- // Set cellid to -1 unless we're on the patch whose id == PAR_Rank.
- for(size_t p = 0; p < patches.size(); ++p)
- {
- if(p == PAR_Rank())
- continue;
-
- const intVector &patch = patches[p];
- for(size_t i = 0; i < patch.size(); ++i)
- cellInfo[patch[i]].id = -1;
- }
-
- delete [] centers;
- }
-#endif
-}
-
-
-// ****************************************************************************
// Method: avtCCMFileFormat::RegisterVariableList
//
// Purpose:
@@ -2219,363 +1595,6 @@
}
// ****************************************************************************
-// Method: avtCCMFileFormat::TesselateCell
-//
-// Purpose:
-//
-//
-//
-//
-// Arguments:
-// civ Contains cell information.
-// points The points comprising the dataset.
-// ugrid The unstructured grid we are building.
-//
-//
-// Programmer: Kathleen Bonnell
-// Creation: October 1, 2007
-//
-// Modifications:
-// Kathleen Bonnell, Thu Feb 28 15:00:24 PST 2008
-// Use cellid stored in CellInfo in avtOriginalCellNumbers array.
-//
-// Kathleen Bonnell, Thu Mar 6 09:21:02 PST 2008
-// Change fbounds to doubleVector to get around compiler problem on Windows.
-//
-// Dave Bremer, Fri Apr 4 16:29:49 PDT 2008
-// Fixed a bug in which cell and vertex ids were mistaken for 1-based
-// indices.
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::TesselateCell(const int domain, const CellInfoVector &civ,
- vtkPoints *points, vtkUnstructuredGrid *ugrid)
-{
-#ifndef MDSERVER
- int dom = subdividingSingleMesh ? 0 : domain;
-
- const char *mName = "avtCCMFileFormat::TesselateCell: ";
- unsigned int i, j, k;
- unsigned int tetCount = 0;
- vtkPoints *pts = vtkPoints::New();
- pts->Allocate(points->GetNumberOfPoints());
- VertexManager uniqueVerts(pts);
- ccmPolygonToTriangles tess(&uniqueVerts);
- unsigned int oc[2] = {dom, 0};
-
- int useCount = 0;
- for(i = 0; i < civ.size(); ++i)
- useCount += (civ[i].id != -1) ? 1 : 0;
-
- originalCells[dom] = vtkUnsignedIntArray::New();
- originalCells[dom]->SetName("avtOriginalCellNumbers");
- originalCells[dom]->SetNumberOfComponents(2);
- originalCells[dom]->Allocate(useCount * 3);
-
- for (i = 0; i < civ.size(); ++i)
- {
- const CellInfo &ci = civ[i];
- if(ci.id == -1)
- continue;
-
- oc[1] = ci.id;
- int nFaces = ci.faces.size();
- int nPts = 0;
- doubleVector fbounds;
- for (j = 0; j < nFaces; ++j)
- {
- nPts += ci.faces[j].nodes.size();
- fbounds.push_back(VTK_LARGE_FLOAT);
- fbounds.push_back(-VTK_LARGE_FLOAT);
- fbounds.push_back(VTK_LARGE_FLOAT);
- fbounds.push_back(-VTK_LARGE_FLOAT);
- fbounds.push_back(VTK_LARGE_FLOAT);
- fbounds.push_back(-VTK_LARGE_FLOAT);
- }
- double *pt;
- double cbounds[6] = {VTK_LARGE_FLOAT, -VTK_LARGE_FLOAT,
- VTK_LARGE_FLOAT, -VTK_LARGE_FLOAT,
- VTK_LARGE_FLOAT, -VTK_LARGE_FLOAT};
-
- int cnt = 0;
- for (j = 0; j < nFaces; ++j)
- {
- const intVector &nodes = ci.faces[j].nodes;
-
- for (k = 0; k < nodes.size(); ++k)
- {
- cnt++;
- pt = points->GetPoint(nodes[k]);
-
- if (pt[0] < cbounds[0])
- cbounds[0] = pt[0];
- if (pt[0] > cbounds[1])
- cbounds[1] = pt[0];
- if (pt[1] < cbounds[2])
- cbounds[2] = pt[1];
- if (pt[1] > cbounds[3])
- cbounds[3] = pt[1];
- if (pt[2] < cbounds[4])
- cbounds[4] = pt[2];
- if (pt[2] > cbounds[5])
- cbounds[5] = pt[2];
-
- if (pt[0] < fbounds[j*6+0])
- fbounds[j*6+0] = pt[0];
- if (pt[0] > fbounds[j*6+1])
- fbounds[j*6+1] = pt[0];
- if (pt[1] < fbounds[j*6+2])
- fbounds[j*6+2] = pt[1];
- if (pt[1] > fbounds[j*6+3])
- fbounds[j*6+3] = pt[1];
- if (pt[2] < fbounds[j*6+4])
- fbounds[j*6+4] = pt[2];
- if (pt[2] > fbounds[j*6+5])
- fbounds[j*6+5] = pt[2];
- } // k nodes
- } // j faces
-
- double cc[3] = {0.,0.,0.};
- double fc[3] = {0.,0.,0.};
- for (j = 0; j < 3; ++j)
- cc[j] = (cbounds[2*j+1]+cbounds[2*j])/2.0;
- int centerId = uniqueVerts.GetVertexId(cc);
-
- for (j = 0; j < nFaces; ++j)
- {
- // Find the face center
- const intVector &nodes = ci.faces[j].nodes;
- double fc[3] = {0.,0.,0.};
- for (k = 0; k < 3; ++k)
- fc[k] = (fbounds[2*k+1+(6*j)]+fbounds[2*k+(6*j)])/2.0;
-
- // Tesselate the face
- double n[3] = {(cc[0] - fc[0]), (cc[1] - fc[1]), (cc[2] - fc[2])};
- tess.SetNormal(n);
- tess.BeginPolygon();
- tess.BeginContour();
- for (k = 0; k < nodes.size(); ++k)
- {
- cnt++;
- pt = points->GetPoint(nodes[k]);
- tess.AddVertex(pt);
- } // k nodes
- tess.EndContour();
- tess.EndPolygon();
-
- // Make a tet for each triangle in the face to the cell center.
- vtkIdType verts[4];
- verts[3] = centerId;
- if (tess.GetNumTriangles() > 0)
- {
- for (k = 0; k < tess.GetNumTriangles(); ++k)
- {
- int a, b, c;
- tess.GetTriangle(k, a, b, c);
- verts[0] = a;
- verts[1] = b;
- verts[2] = c;
- ugrid->InsertNextCell(VTK_TETRA, 4, verts);
- ((vtkUnsignedIntArray*)originalCells[dom])->
- InsertNextTupleValue(oc);
- }
- tetCount += tess.GetNumTriangles();
- }
- // prepare for next cell
- tess.ClearTriangles();
- } // end face
- }
- pts->Squeeze();
-
- ugrid->SetPoints(pts);
- pts->Delete();
- ugrid->GetCellData()->AddArray(originalCells[dom]);
- ugrid->GetCellData()->CopyFieldOn("avtOriginalCellNumbers");
-
- debug4 << mName << "Input number of polyhedral cells: " << civ.size()
- << endl;
- debug4 << mName << "Output tetrahedral cells: " << tetCount << endl;
-#endif
-}
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::TesselateCells2D
-//
-// Purpose:
-// Adds the 2D cells to the unstructured grid, tessellating them as needed.
-//
-// Arguments:
-// dom : The domain number
-// civ : The cell information vector.
-// points : The points that we'll allocate during tessellation.
-// ugrid : The return unstructured grid object.
-//
-// Returns:
-//
-// Note:
-//
-// Programmer: Brad Whitlock
-// Creation: Tue Dec 18 12:54:56 PST 2007
-//
-// Modifications:
-// Kathleen Bonnell, Thu Feb 28 15:00:24 PST 2008
-// Use cellid stored in CellInfo in avtOriginalCellNumbers array.
-//
-// Kathleen Bonnell, Thu Mar 6 09:21:02 PST 2008
-// Remove unused variables.
-//
-// Dave Bremer, Fri Apr 4 16:29:49 PDT 2008
-// Fixed a bug in which cell and vertex ids were mistaken for 1-based
-// indices.
-//
-// ****************************************************************************
-
-typedef std::pair<int,int> edge_pair;
-
-void
-avtCCMFileFormat::TesselateCells2D(const int domain, const CellInfoVector &civ,
- vtkPoints *points, vtkUnstructuredGrid *ugrid)
-{
-#ifndef MDSERVER
- int dom = subdividingSingleMesh ? 0 : domain;
-
- unsigned int i, k;
- vtkPoints *pts = vtkPoints::New();
- pts->Allocate(points->GetNumberOfPoints());
- VertexManager uniqueVerts(pts);
- ccmPolygonToTriangles tess(&uniqueVerts);
- unsigned int oc[2] = {dom, 0};
-
- int useCount = 0;
- for(i = 0; i < civ.size(); ++i)
- useCount += (civ[i].id != -1) ? 1 : 0;
-
- originalCells[dom] = vtkUnsignedIntArray::New();
- originalCells[dom]->SetName("avtOriginalCellNumbers");
- originalCells[dom]->SetNumberOfComponents(2);
- originalCells[dom]->Allocate(useCount*3);
-
- const double n[3] = {0., 0., 1.};
-
- for (i = 0; i < civ.size(); ++i)
- {
- const CellInfo &ci = civ[i];
- if(ci.id == -1)
- continue;
-
- oc[1] = ci.id;
- tess.SetNormal(n);
- tess.BeginPolygon();
-
- // We need to sort the edges around the polygon so we can tessellate
- // by adding the first vertex of each edge to define the contour. We
- // could do a different approach making n-1 triangles for the number
- // of edges in the shape but this way supports concave polygons whereas
- // the other approach does not.
-
- // Put all of the line segments in a pool of free edges.
- std::set<edge_pair> freeEdges;
- for (int f = 0; f < ci.faces.size(); ++f)
- {
- edge_pair e01(ci.faces[f].nodes[0], ci.faces[f].nodes[1]);
- freeEdges.insert(e01);
- }
-
- while(freeEdges.size() > 0)
- {
- std::deque<int> shape;
-
- // Get seed edge and remove it from the pool
- edge_pair currentEdge;
- if(freeEdges.begin() != freeEdges.end())
- {
- currentEdge = *freeEdges.begin();
- freeEdges.erase(freeEdges.begin());
- }
- shape.push_back(currentEdge.first);
- shape.push_back(currentEdge.second);
-
- // Now, look for edges that contain either of the points in
- // the current edge.
- bool found;
- do
- {
- found = false;
- for(std::set<edge_pair>::iterator pos = freeEdges.begin();
- pos != freeEdges.end() && !found; ++pos)
- {
- if(currentEdge.first == pos->first)
- {
- currentEdge.first = pos->second;
- shape.push_front(pos->second);
- freeEdges.erase(pos);
- found = true;
- }
- else if(currentEdge.first == pos->second)
- {
- currentEdge.first = pos->first;
- shape.push_front(pos->first);
- freeEdges.erase(pos);
- found = true;
- }
- else if(currentEdge.second == pos->first)
- {
- currentEdge.second = pos->second;
- shape.push_back(pos->second);
- freeEdges.erase(pos);
- found = true;
- }
- else if(currentEdge.second == pos->second)
- {
- currentEdge.second = pos->first;
- shape.push_back(pos->first);
- freeEdges.erase(pos);
- found = true;
- }
- }
- } while(found);
-
- if(shape.size() > 2)
- {
- tess.BeginContour();
- for(int v = 0; v < shape.size(); ++v)
- tess.AddVertex(points->GetPoint(shape[v]));
- tess.EndContour();
- }
- }
- tess.EndPolygon();
-
- vtkIdType verts[4];
- if (tess.GetNumTriangles() > 0)
- {
- for (k = 0; k < tess.GetNumTriangles(); ++k)
- {
- int a, b, c;
- tess.GetTriangle(k, a, b, c);
- verts[0] = a;
- verts[1] = b;
- verts[2] = c;
- ugrid->InsertNextCell(VTK_TRIANGLE, 3, verts);
-
- ((vtkUnsignedIntArray*)originalCells[dom])->
- InsertNextTupleValue(oc);
- }
- }
-
- // prepare for next cell
- tess.ClearTriangles();
- }
-
- pts->Squeeze();
- ugrid->SetPoints(pts);
- pts->Delete();
- ugrid->GetCellData()->AddArray(originalCells[dom]);
- ugrid->GetCellData()->CopyFieldOn("avtOriginalCellNumbers");
-#endif
-}
-
-// ****************************************************************************
// Method: avtCCMFileFormat::BuildHex
//
// Purpose:
@@ -2820,250 +1839,7 @@
}
-
-
-
-
-//
-// avtCCMFileFormat::FaceInfo class
-//
-
// ****************************************************************************
-// Method: avtCCMFileFormat::FaceInfo::FaceInfo
-//
-// Purpose:
-// Constructor
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// Dave Bremer, Fri Apr 4 16:29:49 PDT 2008
-// Removed unused face id.
-//
-// ****************************************************************************
-
-avtCCMFileFormat::FaceInfo::FaceInfo()
-{
- //id = -1;
- cells[0] = -1;
- cells[1] = -1;
-}
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::FaceInfo::FaceInfo
-//
-// Purpose:
-// Copy Constructor
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// Dave Bremer, Fri Apr 4 16:29:49 PDT 2008
-// Removed unused face id.
-//
-// ****************************************************************************
-
-avtCCMFileFormat::FaceInfo::FaceInfo(const avtCCMFileFormat::FaceInfo &obj)
-{
- //id = obj.id;
- cells[0] = obj.cells[0];
- cells[1] = obj.cells[1];
- nodes = obj.nodes;
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::FaceInfo::~FaceInfo
-//
-// Purpose:
-// Destructor
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// ****************************************************************************
-
-avtCCMFileFormat::FaceInfo::~FaceInfo()
-{
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::FaceInfo::operator =
-//
-// Purpose:
-// Assignment operator
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// Dave Bremer, Fri Apr 4 16:29:49 PDT 2008
-// Removed unused face id.
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::FaceInfo::operator =(const avtCCMFileFormat::FaceInfo &obj)
-{
- //id = obj.id;
- cells[0] = obj.cells[0];
- cells[1] = obj.cells[1];
- nodes = obj.nodes;
-}
-
-//
-// avtCCMFileFormat::CellInfo class
-//
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::CellInfo::CellInfo
-//
-// Purpose:
-// Constructor
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// ****************************************************************************
-
-avtCCMFileFormat::CellInfo::CellInfo()
-{
- id = -1;
-}
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::CellInfo::CellInfo
-//
-// Purpose:
-// Copy Constructor
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// ****************************************************************************
-
-avtCCMFileFormat::CellInfo::CellInfo(const avtCCMFileFormat::CellInfo &obj)
-{
- id = obj.id;
- faceTypes = obj.faceTypes;
- faces = obj.faces;
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::CellInfo::~CellInfo
-//
-// Purpose:
-// Destructor
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// ****************************************************************************
-
-avtCCMFileFormat::CellInfo::~CellInfo()
-{
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::CellInfo::operator =
-//
-// Purpose:
-// Assignment operator
-//
-// Programmer: Kathleen Bonnell
-// Creation: September 6, 2007
-//
-// Modifications:
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::CellInfo::operator =(const avtCCMFileFormat::CellInfo &obj)
-{
- id = obj.id;
- faceTypes = obj.faceTypes;
- faces = obj.faces;
-}
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::CellInfo::CellCenter
-//
-// Purpose:
-// Determines the cell center from its nodes.
-//
-// Arguments:
-// center : The returned center.
-// pts : The global points array that stores all of the nodes.
-//
-// Programmer: Brad Whitlock
-// Creation: Thu Oct 1 14:02:37 PDT 2009
-//
-// Modifications:
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::CellInfo::CellCenter(double *center, vtkPoints *pts) const
-{
- int npts = 0;
- double c[3] = {0.,0.,0.};
- for(int i = 0; i < faces.size(); ++i)
- {
- for(int j = 0; j < faces[i].nodes.size(); ++j, ++npts)
- {
- double *pt = pts->GetPoint(faces[i].nodes[j]);
- c[0] += pt[0];
- c[1] += pt[1];
- c[2] += pt[2];
- }
- }
- center[0] = c[0] / double(npts);
- center[1] = c[1] / double(npts);
- center[2] = c[2] / double(npts);
-}
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::CellInfo::UseNodes
-//
-// Purpose:
-// Sets a true value into a domain-node-sized bool array for each node that
-// the cell uses.
-//
-// Arguments:
-// pts : The array containing the values for whether a node is used.
-//
-// Programmer: Brad Whitlock
-// Creation: Thu Oct 1 14:03:22 PDT 2009
-//
-// Modifications:
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::CellInfo::UseNodes(bool *pts) const
-{
- for(int i = 0; i < faces.size(); ++i)
- for(int j = 0; j < faces[i].nodes.size(); ++j)
- pts[faces[i].nodes[j]] = true;
-}
-
-// ****************************************************************************
// Method: operator << (ostream &os, CCMIOEntity e)
//
// Purpose:
@@ -3205,168 +1981,4 @@
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::IDMap::IDMap
-//
-// Purpose:
-// Constructor
-//
-// Programmer: Dave Bremer
-// Creation: Fri Apr 4 16:29:49 PDT 2008
-//
-// Modifications:
-//
-// ****************************************************************************
-
-avtCCMFileFormat::IDMap::IDMap()
-{
- bSequential = false;
- bReverseMap = false;
- iFirstElem = 0;
- numIDs = 0;
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::IDMap::SetIDs
-//
-// Purpose:
-// Analyze a set of IDs and build a structure for mapping them back
-// to the index corresponding to their position in v.
-//
-// Programmer: Dave Bremer
-// Creation: Fri Apr 4 16:29:49 PDT 2008
-//
-// Modifications:
-//
-// ****************************************************************************
-
-void
-avtCCMFileFormat::IDMap::SetIDs(const intVector &v)
-{
- numIDs = v.size();
-
- bSequential = true;
- bReverseMap = false;
- iFirstElem = v[0];
-
- int min = v[0], max = v[0];
-
- int ii;
- for (ii = 1; ii < v.size(); ii++)
- {
- if (v[ii-1]+1 != v[ii])
- bSequential = false;
- if (v[ii] < min)
- min = v[ii];
- if (v[ii] > max)
- max = v[ii];
- }
-
- //Don't bother copying data in, in this case.
- if (bSequential)
- return;
-
- if (max-min+1 <= v.size()*2)
- {
- bReverseMap = true;
- iFirstElem = min;
-
- ids.resize(max-min+1, -1);
- for (ii = 0; ii < v.size(); ii++)
- {
- ids[v[ii]-iFirstElem] = ii;
- }
- }
- else
- {
- bReverseMap = false;
-
- ids.resize(v.size()*2);
-
- for (ii = 0; ii < v.size(); ii++)
- {
- ids[ii*2] = v[ii];
- ids[ii*2+1] = ii;
- }
- qsort( &ids[0], v.size(), sizeof(int)*2, avtCCMFileFormat::IDMap::compare);
- }
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::IDMap::compare
-//
-// Purpose:
-// compare function for qsort
-//
-// Programmer: Dave Bremer
-// Creation: Fri Apr 4 16:29:49 PDT 2008
-//
-// Modifications:
-//
-// ****************************************************************************
-
-int
-avtCCMFileFormat::IDMap::compare(const void *a, const void *b)
-{
- return ( *((int *)a) - *((int *)b) );
-}
-
-
-// ****************************************************************************
-// Method: avtCCMFileFormat::IDMap::IDtoIndex
-//
-// Purpose:
-// Map an id to an array index. Return -1 if the id is not in the map.
-//
-// Programmer: Dave Bremer
-// Creation: Fri Apr 4 16:29:49 PDT 2008
-//
-// Modifications:
-//
-// ****************************************************************************
-
-int
-avtCCMFileFormat::IDMap::IDtoIndex(int id) const
-{
- if (bSequential)
- {
- int r = id - iFirstElem;
- if (r >= 0 && r < numIDs)
- return r;
- }
- else if (bReverseMap)
- {
- if (id-iFirstElem >= 0 && id-iFirstElem < ids.size())
- return ids[id-iFirstElem];
- }
- else
- {
- int min = 0, max = ids.size()/2 - 1;
- int mid = (min+max)/2;
-
- while (min <= max)
- {
- if (id < ids[mid*2])
- {
- max = mid-1;
- mid = (min+max)/2;
- }
- else if (id > ids[mid*2])
- {
- min = mid+1;
- mid = (min+max)/2;
- }
- else
- {
- return ids[mid*2+1];
- }
- }
- }
- return -1;
-}
-
-
*/
Modified: MOAB/trunk/ReadCCMIO.hpp
===================================================================
--- MOAB/trunk/ReadCCMIO.hpp 2010-01-31 14:57:45 UTC (rev 3515)
+++ MOAB/trunk/ReadCCMIO.hpp 2010-01-31 17:55:42 UTC (rev 3516)
@@ -45,33 +45,39 @@
private:
- MBErrorCode read_processor(CCMIOID rootID, CCMIOID processorID, CCMIOSize_t proc);
+ MBErrorCode read_processor(CCMIOID rootID, CCMIOID problemID,
+ CCMIOID processorID, CCMIOSize_t proc,
+ MBRange *new_ents);
MBErrorCode read_cells(CCMIOSize_t proc, CCMIOID processorID,
CCMIOID verticesID, CCMIOID topologyID,
CCMIOID solutionID, bool has_solution,
- TupleList &vert_map);
+ TupleList &vert_map, MBRange *new_cells);
MBErrorCode construct_cells(TupleList &face_map,
#ifndef TUPLE_LIST
SenseList &sense_map,
#endif
- TupleList &vert_map, MBRange &new_cells);
+ TupleList &vert_map,
+ std::vector<MBEntityHandle> &new_cells);
MBErrorCode create_cell_from_faces(std::vector<MBEntityHandle> &facehs,
std::vector<int> &senses,
MBEntityHandle &cell);
+ MBErrorCode read_gids_and_types(CCMIOID problemID,
+ CCMIOID topologyID,
+ std::vector<MBEntityHandle> &cells);
MBErrorCode read_all_faces(CCMIOID topologyID, TupleList &vert_map,
TupleList &face_map
#ifndef TUPLE_LIST
,SenseList &sense_map
#endif
- );
+ , MBRange *new_faces);
MBErrorCode read_faces(CCMIOID faceID, CCMIOEntity bdy_or_int,
@@ -80,7 +86,7 @@
#ifndef TUPLE_LIST
,SenseList &sense_map
#endif
- );
+ , MBRange *new_faces);
MBErrorCode make_faces(int *farray,
TupleList &vert_map,
@@ -88,7 +94,7 @@
MBErrorCode read_vertices(CCMIOSize_t proc, CCMIOID processorID, CCMIOID verticesID,
CCMIOID topologyID, CCMIOID solutionID, bool has_solution,
- MBRange &verts, TupleList &vert_map);
+ MBRange *verts, TupleList &vert_map);
MBErrorCode get_processors(CCMIOID stateID, CCMIOID &processorID,
@@ -105,6 +111,14 @@
const IDTag* subset_list = 0,
int subset_list_length = 0 );
+ MBErrorCode load_matset_data(CCMIOID problemID);
+
+ MBErrorCode load_metadata(CCMIOID rootID, CCMIOID problemID,
+ const MBEntityHandle *file_set);
+
+ MBErrorCode create_matset_tags(MBTag &matNameTag, MBTag &matPorosityTag,
+ MBTag &matSpinTag, MBTag &matGroupTag);
+
//! Cached tags for reading. Note that all these tags are defined when the
//! core is initialized.
MBTag mMaterialSetTag;
@@ -117,6 +131,8 @@
MBReadUtilIface* readMeshIface;
+ MBRange newMatsets;
+
bool hasSolution;
};
More information about the moab-dev
mailing list