33 #include <gridfields/type.h>
34 #include <gridfields/gridfield.h>
35 #include <gridfields/grid.h>
36 #include <gridfields/implicit0cells.h>
37 #include <gridfields/gridfieldoperator.h>
38 #include <gridfields/restrict.h>
39 #include <gridfields/refrestrict.h>
40 #include <gridfields/array.h>
60 using namespace ugrid;
65 TwoDMeshTopology::TwoDMeshTopology():
67 nodeCoordinateArrays(0),
69 faceNodeConnectivityArray(0),
71 faceCoordinateNames(0),
72 faceCoordinateArrays(0),
80 rangeDataArrays =
new vector<MeshDataVariable *>();
81 sharedIntArrays =
new vector<int *>();
82 sharedFloatArrays =
new vector<float *>();
89 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - BEGIN" << endl);
90 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - (" <<
this <<
")" << endl);
92 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting GF::GridField 'resultGridField'." << endl);
93 delete resultGridField;
97 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting GF::GridField 'inputGridField'." << endl);
98 delete d_inputGridField;
100 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting GF::Grid 'gridTopology'." << endl);
104 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting GF::Arrays..." << endl);
105 for (vector<GF::Array *>::iterator it = gfArrays.begin(); it != gfArrays.end(); ++it) {
106 GF::Array *gfa = *it;
107 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting GF:Array '" << gfa->getName() <<
"'" << endl);
110 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - GF::Arrays deleted." << endl);
114 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting sharedIntArrays..." << endl);
115 for (vector<int *>::iterator it = sharedIntArrays->begin(); it != sharedIntArrays->end(); ++it) {
117 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting integer array '" << i <<
"'" << endl);
120 delete sharedIntArrays;
122 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting sharedFloatArrays..." << endl);
123 for (vector<float *>::iterator it = sharedFloatArrays->begin(); it != sharedFloatArrays->end(); ++it) {
125 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting float array '" << f <<
"'" << endl);
128 delete sharedFloatArrays;
130 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting range data vector" << endl);
131 delete rangeDataArrays;
132 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Range data vector deleted." << endl);
135 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting vector of node coordinate arrays." << endl);
136 delete nodeCoordinateArrays;
138 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting vector of face coordinate arrays." << endl);
139 delete faceCoordinateArrays;
141 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - Deleting face node connectivity cell array (GF::Node's)." << endl);
142 delete[] fncCellArray;
145 BESDEBUG(
"ugrid",
"~TwoDMeshTopology() - END" << endl);
158 BaseType *bt = dds->var(meshVarName);
163 throw Error(
"Unable to locate variable: "+meshVarName);
170 if (dimension.empty()) {
171 string msg =
"TwoDMeshTopology::init() - The mesh topology variable '" + meshVar->name() +
"' is missing the required attribute named '" +
UGRID_TOPOLOGY_DIMENSION +
"'";
177 ingestNodeCoordinateArrays(meshVar, dds);
183 ingestFaceCoordinateArrays(meshVar,dds);
187 ingestFaceNodeConnectivityArray(meshVar,dds);
200 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setNodeCoordinateDimension() - BEGIN" << endl);
202 libdap::Array::Dim_iter ait1;
205 for (ait1 = dapArray->dim_begin(); ait1 != dapArray->dim_end(); ++ait1) {
207 string dimName = dapArray->dimension_name(ait1);
209 if(dimName.compare(nodeDimensionName) == 0){
210 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setNodeCoordinateDimension() - Found dimension name matching nodeDimensionName '"<< nodeDimensionName <<
"'" << endl);
211 int size = dapArray->dimension_size(ait1,
true);
212 if(size == nodeCount){
213 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setNodeCoordinateDimension() - Dimension sizes match (" << libdap::long_to_string(nodeCount) <<
") - DONE" << endl);
223 "Unable to determine the node coordinate dimension of the range variable '"
224 + mdv->
getName() +
"' The node dimension is named '"+ nodeDimensionName
225 +
"' with size " + libdap::long_to_string(nodeCount)
237 libdap::Array::Dim_iter ait1;
239 for (ait1 = dapArray->dim_begin(); ait1 != dapArray->dim_end(); ++ait1) {
240 string dimName = dapArray->dimension_name(ait1);
242 if(dimName.compare(faceDimensionName) == 0){
243 int size = dapArray->dimension_size(ait1,
true);
244 if(size == faceCount){
253 "Unable to determine the face coordinate dimension of the range variable '"
254 + mdv->
getName() +
"' The face coordinate dimension is named '"+ faceDimensionName
255 +
"' with size " + libdap::long_to_string(faceCount)
265 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setLocationCoordinateDimension() - BEGIN" << endl);
274 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setLocationCoordinateDimension() - Checking Node variable '"<< mdv->
getName() <<
"'" << endl);
276 setNodeCoordinateDimension(mdv);
283 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setLocationCoordinateDimension() - Checking Face variable '"<< mdv->
getName() <<
"'" << endl);
285 setFaceCoordinateDimension(mdv);
293 string msg =
"TwoDMeshTopology::setLocationCoordinateDimension() - Unknown/Unsupported location value '" +
300 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setLocationCoordinateDimension() - MeshDataVariable '"<< mdv->
getName() <<
301 "' is a "<< locstr <<
" variable," << endl);
302 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setLocationCoordinateDimension() - MeshDataVariable '"<< mdv->
getName() <<
305 BESDEBUG(
"ugrid",
"TwoDMeshTopology::setLocationCoordinateDimension() - DONE" << endl);
310 #if 0 // Unused crufty code from previous efforts
314 BESDEBUG(
"ugrid",
"TwoDMeshTopology::addDataVariable() - BEGIN" << endl);
316 BESDEBUG(
"ugrid",
"TwoDMeshTopology::addDataVariable() - Adding MeshDataVariable '"<< mdv->
getName() <<
"' " << endl);
317 rangeDataArrays->push_back(mdv);
318 BESDEBUG(
"ugrid",
"TwoDMeshTopology::addDataVariable() - DONE" << endl);
329 void TwoDMeshTopology::ingestFaceNodeConnectivityArray(libdap::BaseType *meshTopology, libdap::DDS *dds)
332 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - Locating FNCA" << endl);
334 string face_node_connectivity_var_name;
335 AttrTable at = meshTopology->get_attr_table();
338 if (iter_fnc != at.attr_end()) {
339 face_node_connectivity_var_name = at.get_attr(iter_fnc, 0);
343 "The mesh_topology variable is named " + meshTopology->name());
349 BaseType *btp = dds->var(face_node_connectivity_var_name);
353 "The mesh_topology variable is named "+meshTopology->name());
357 libdap::Array *fncArray =
dynamic_cast<libdap::Array*
>(btp);
359 throw Error(malformed_expr,
"Face Node Connectivity variable '"+face_node_connectivity_var_name+
"' is not an Array type. It's an instance of " + btp->type_name());
362 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - Located FNC Array '" << fncArray->name() <<
"'." << endl);
365 int numDims = fncArray->dimensions(
true) ;
367 throw Error(malformed_expr,
"Face Node Connectivity variable '"+face_node_connectivity_var_name
368 +
"' Must have two (2) dimensions. It has " + libdap::long_to_string(numDims));
371 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - FNC Array '" << fncArray->name() <<
"' has two (2) dimensions." << endl);
375 libdap::Array::Dim_iter firstDim = fncArray->dim_begin();
376 libdap::Array::Dim_iter secondDim = fncArray->dim_begin();
380 if(faceDimensionName.empty()){
383 int sizeFirst = fncArray->dimension_size(firstDim,
true);
384 int sizeSecond = fncArray->dimension_size(secondDim,
true);
385 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - sizeFirst: "<< libdap::long_to_string(sizeFirst) << endl);
386 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - sizeSecond: "<< libdap::long_to_string(sizeSecond) << endl);
388 if(sizeFirst < sizeSecond){
389 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - FNC Array first dimension is smaller than second." << endl);
390 fncNodesDim = firstDim;
391 fncFacesDim = secondDim;
394 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - FNC Array second dimension is smaller than first." << endl);
395 fncNodesDim = secondDim;
396 fncFacesDim = firstDim;
399 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - fncFacesDim name: '" << fncArray->dimension_name(fncFacesDim) <<
"'" << endl);
400 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - fncFacesDim size: '" << fncArray->dimension_size(fncFacesDim,
true) <<
"'" << endl);
402 faceDimensionName = fncArray->dimension_name(fncFacesDim);
408 if(faceDimensionName.compare(fncArray->dimension_name(firstDim)) == 0){
409 fncNodesDim = secondDim;
410 fncFacesDim = firstDim;
412 else if(faceDimensionName.compare(fncArray->dimension_name(secondDim)) == 0){
413 fncNodesDim = firstDim;
414 fncFacesDim = secondDim;
417 string msg =
"The face coordinate dimension of the Face Node Connectivity variable '"+face_node_connectivity_var_name
418 +
"' Has dimension name.'"+ fncArray->dimension_name(fncFacesDim) +
"' which does not match the existing face coordinate dimension name '"
419 + faceDimensionName +
"'";
423 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - Face dimension names match." << endl);
427 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - Face dimension name: '" << faceDimensionName <<
"'" << endl);
431 faceCount = fncArray->dimension_size(fncFacesDim,
true);
432 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - Face count: "<< libdap::long_to_string(faceCount) << endl);
437 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - Face count: "<< libdap::long_to_string(faceCount) << endl);
438 if(faceCount!=fncArray->dimension_size(fncFacesDim,
true) ){
439 string msg =
"The faces dimension of the Face Node Connectivity variable '"+face_node_connectivity_var_name
440 +
"' Has size "+ libdap::long_to_string(fncArray->dimension_size(fncFacesDim,
true))+
" which does not match the existing face count of "
441 + libdap::long_to_string(faceCount);
445 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceNodeConnectivityArray() - Face counts match!" << endl);
448 faceNodeConnectivityArray = fncArray;
450 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFaceNodeConnectivityArray() - Got FCNA '"+fncArray->name()+
"'" << endl);
459 void TwoDMeshTopology::ingestFaceCoordinateArrays(libdap::BaseType *meshTopology, libdap::DDS *dds)
461 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - BEGIN Gathering face coordinate arrays..." << endl);
463 if(faceCoordinateArrays==0)
464 faceCoordinateArrays =
new vector<libdap::Array *>();
466 faceCoordinateArrays->clear();
468 string face_coordinates;
469 AttrTable at = meshTopology->get_attr_table();
472 if (iter_nodeCoors != at.attr_end()) {
473 face_coordinates = at.get_attr(iter_nodeCoors, 0);
480 vector<string> faceCoordinateNames =
split(face_coordinates,
' ');
483 vector<string>::iterator coorName_it;
484 for (coorName_it = faceCoordinateNames.begin();
485 coorName_it != faceCoordinateNames.end(); ++coorName_it) {
486 string faceCoordinateName = *coorName_it;
488 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - Processing face coordinate '"<< faceCoordinateName <<
"'." << endl);
491 BaseType *btp = dds->var(faceCoordinateName);
495 + faceCoordinateName +
"'! "
496 +
"The mesh_topology variable is named "
497 + meshTopology->name());
499 libdap::Array *newFaceCoordArray =
dynamic_cast<libdap::Array*
>(btp);
500 if (newFaceCoordArray == 0) {
501 throw Error(malformed_expr,
502 "Face coordinate variable '" + faceCoordinateName
503 +
"' is not an Array type. It's an instance of "
508 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - Found face coordinate array '"<< faceCoordinateName <<
"'." << endl);
511 if(newFaceCoordArray->dimensions(
true) != 1){
512 throw Error(malformed_expr,
513 "Face coordinate variable '" + faceCoordinateName
514 +
"' has more than one dimension. That's just not allowed. It has "
515 + long_to_string(newFaceCoordArray->dimensions(
true)) +
" dimensions."
518 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - Face coordinate array '"<< faceCoordinateName <<
"' has a single dimension." << endl);
522 string dimName = newFaceCoordArray->dimension_name(newFaceCoordArray->dim_begin());
523 int dimSize = newFaceCoordArray->dimension_size(newFaceCoordArray->dim_begin(),
true);
525 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - dimName: '"<< dimName <<
"' dimSize: "
526 << libdap::long_to_string(dimSize) << endl);
528 if(faceDimensionName.empty()){
529 faceDimensionName = dimName;
531 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - faceDimensionName: '"<< faceDimensionName <<
"' " << endl);
533 if(faceDimensionName.compare(dimName)!=0 ){
535 "The face coordinate array '" + faceCoordinateName
536 +
"' has the named dimension '"+ dimName +
"' which differs from the expected dimension name '"+faceDimensionName
537 +
"'. The mesh_topology variable is named " + meshTopology->name());
539 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - Face dimension names match." << endl);
545 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - faceCount: "<< libdap::long_to_string(faceCount) << endl);
547 if(faceCount!=dimSize){
549 "The face coordinate array '" + faceCoordinateName
550 +
"' has a dimension size of " + libdap::long_to_string(dimSize) +
" which differs from the the expected size of "
551 + libdap::long_to_string(faceCount) +
" The mesh_topology variable is named "
552 + meshTopology->name());
554 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - Face counts match." << endl);
557 faceCoordinateArrays->push_back(newFaceCoordArray);
558 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - Face coordinate array '"<< faceCoordinateName <<
"' ingested." << endl);
560 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - Located "<< libdap::long_to_string(faceCoordinateArrays->size()) <<
" face coordinate arrays." << endl);
563 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - No Face Coordinates Found." << endl);
567 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestFaceCoordinateArrays() - DONE" << endl);
577 void TwoDMeshTopology::ingestNodeCoordinateArrays(libdap::BaseType *meshTopology, libdap::DDS *dds)
579 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - BEGIN Gathering node coordinate arrays..." << endl);
581 string node_coordinates;
582 AttrTable at = meshTopology->get_attr_table();
585 if (iter_nodeCoors != at.attr_end()) {
586 node_coordinates = at.get_attr(iter_nodeCoors, 0);
590 " variable! The mesh_topology variable is named " + meshTopology->name());
594 if(nodeCoordinateArrays==0)
595 nodeCoordinateArrays =
new vector<libdap::Array *>();
597 nodeCoordinateArrays->clear();
601 vector<string> nodeCoordinateNames =
split(node_coordinates,
' ');
604 vector<string>::iterator coorName_it;
605 for (coorName_it = nodeCoordinateNames.begin();
606 coorName_it != nodeCoordinateNames.end(); ++coorName_it) {
607 string nodeCoordinateName = *coorName_it;
609 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - Processing node coordinate '"<< nodeCoordinateName <<
"'." << endl);
612 BaseType *btp = dds->var(nodeCoordinateName);
616 + nodeCoordinateName +
"'! "
617 +
"The mesh_topology variable is named "
618 + meshTopology->name());
620 libdap::Array *newNodeCoordArray =
dynamic_cast<libdap::Array*
>(btp);
621 if (newNodeCoordArray == 0) {
622 throw Error(malformed_expr,
623 "Node coordinate variable '" + nodeCoordinateName
624 +
"' is not an Array type. It's an instance of "
627 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - Found node coordinate array '"<< nodeCoordinateName <<
"'." << endl);
630 if(newNodeCoordArray->dimensions(
true) != 1){
631 throw Error(malformed_expr,
632 "Node coordinate variable '" + nodeCoordinateName
633 +
"' has more than one dimension. That's just not allowed. It has "
634 + long_to_string(newNodeCoordArray->dimensions(
true)) +
" dimensions."
637 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - Node coordinate array '"<< nodeCoordinateName <<
"' has a single dimension." << endl);
641 string dimName = newNodeCoordArray->dimension_name(newNodeCoordArray->dim_begin());
642 int dimSize = newNodeCoordArray->dimension_size(newNodeCoordArray->dim_begin(),
true);
644 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - dimName: '"<< dimName <<
"' dimSize: "
645 << libdap::long_to_string(dimSize) << endl);
647 if(nodeDimensionName.empty()){
648 nodeDimensionName = dimName;
650 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - nodeDimensionName: '"<< nodeDimensionName <<
"' " << endl);
651 if(nodeDimensionName.compare(dimName)!=0 ){
653 "The node coordinate array '" + nodeCoordinateName
654 +
"' has the named dimension '"+ dimName +
"' which differs from the expected dimension name '"+nodeDimensionName
655 +
"'. The mesh_topology variable is named " + meshTopology->name());
657 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - Node dimension names match." << endl);
663 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - nodeCount: "<< libdap::long_to_string(nodeCount) << endl);
665 if(nodeCount!=dimSize){
667 "The node coordinate array '" + nodeCoordinateName
668 +
"' has a dimension size of " + libdap::long_to_string(dimSize) +
" which differs from the the expected size of "
669 + libdap::long_to_string(nodeCount) +
" The mesh_topology variable is named "
670 + meshTopology->name());
672 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - Node counts match." << endl);
676 nodeCoordinateArrays->push_back(newNodeCoordArray);
677 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - Coordinate array '"<< nodeCoordinateName <<
"' ingested." << endl);
682 BESDEBUG(
"ugrid",
"TwoDMeshTopology::ingestNodeCoordinateArrays() - DONE" << endl);
690 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Building GridFields objects for mesh_topology variable "<<
getMeshVariable()->
name() << endl);
692 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Constructing new GF::Grid for "<<
name() << endl);
693 gridTopology =
new GF::Grid(
name());
696 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Building and adding implicit range Nodes to the GF::Grid" << endl);
697 GF::AbstractCellArray *nodes =
new GF::Implicit0Cells(nodeCount);
699 gridTopology->setKCells(nodes,
node);
708 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Building face node connectivity Cell array from the DAP version" << endl);
709 GF::CellArray *faceNodeConnectivityCells = getFaceNodeConnectivityCells();
714 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Attaching Cell array to GF::Grid" << endl);
715 gridTopology->setKCells(faceNodeConnectivityCells,
face);
718 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Construct new GF::GridField from GF::Grid" << endl);
719 d_inputGridField =
new GF::GridField(gridTopology);
725 vector<libdap::Array *>::iterator ncit;
726 for (ncit = nodeCoordinateArrays->begin(); ncit != nodeCoordinateArrays->end(); ++ncit) {
727 libdap::Array *nca = *ncit;
728 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Adding node coordinate "<< nca->name() <<
" to GF::GridField at rank 0" << endl);
730 gfArrays.push_back(gfa);
731 d_inputGridField->AddAttribute(
node, gfa);
736 for (ncit = faceCoordinateArrays->begin(); ncit != faceCoordinateArrays->end(); ++ncit) {
737 libdap::Array *fca = *ncit;
738 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Adding face coordinate "<< fca->name() <<
" to GF::GridField at rank " <<
face << endl);
740 gfArrays.push_back(gfa);
741 d_inputGridField->AddAttribute(
face, gfa);
747 #if 0 // Unused crufty code from previous efforts
751 void TwoDMeshTopology::buildRestrictedGfTopology(
locationType loc,
string filterExpression){
758 return resultGridField->Size(dim);
763 #if 0 // Unused crufty code from previous efforts
767 void TwoDMeshTopology::buildGridFieldsTopology()
774 for (vector<MeshDataVariable *>::iterator mdv_it = rangeDataArrays->begin(); mdv_it != rangeDataArrays->end(); ++mdv_it) {
777 BESDEBUG(
"ugrid",
"TwoDMeshTopology::buildGridFieldsTopology() - Adding mesh data variable '"<< mdVar->
getName() <<
"' to GF::GridField at rank "<< mdVar->
getGridLocation() << endl);
779 gfArrays.push_back(gfa);
797 GF::Node *TwoDMeshTopology::getFncArrayAsGFCells(libdap::Array *fncVar)
800 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFncArrayAsGFNodes() - BEGIN" << endl);
803 int nodesPerFace = fncVar->dimension_size(fncNodesDim,
true);
804 int faceCount = fncVar->dimension_size(fncFacesDim,
true);
808 GF::Node *cells =
new GF::Node[ faceCount * nodesPerFace ];
810 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFncArrayAsGFNodes() - Reading DAP data into GF::Node array." << endl);
811 GF::Node *temp_nodes = ugrid::extractArray<GF::Node>(fncVar);
818 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFncArrayAsGFNodes() - Re-packing and copying GF::Node array to result." << endl);
819 for (
int fIndex = 0; fIndex < faceCount; fIndex++) {
820 for(
int nIndex=0; nIndex<nodesPerFace ; nIndex++){
821 cells[nodesPerFace * fIndex + nIndex] = temp_nodes[fIndex + (faceCount * nIndex)];
826 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFncArrayAsGFNodes() - Deleting intermediate GF::Node array." << endl);
827 delete [] temp_nodes;
829 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFncArrayAsGFNodes() - DONE" << endl);
838 int TwoDMeshTopology::getStartIndex(libdap::Array *array)
840 AttrTable &at = array->get_attr_table();
842 if (start_index_iter != at.attr_end()) {
844 AttrTable::entry *start_index_entry = *start_index_iter;
845 if (start_index_entry->attr->size() == 1) {
846 string val = (*start_index_entry->attr)[0];
847 BESDEBUG(
"TwoDMeshTopology::getStartIndex",
"value: " << val << endl);
848 stringstream buffer(val);
853 buffer >> start_index;
856 throw Error(malformed_expr,
857 "Index origin attribute exists, but either no value supplied, or more than one value supplied.");
866 GF::CellArray *TwoDMeshTopology::getFaceNodeConnectivityCells()
869 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFaceNodeConnectivityCells() - Building face node connectivity Cell " <<
870 "array from the Array "<< faceNodeConnectivityArray->name() << endl);
872 int nodesPerFace = faceNodeConnectivityArray->dimension_size(fncNodesDim);
873 int total_size = nodesPerFace * faceCount;
875 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFaceNodeConnectivityCells() - Converting FNCArray to GF::Node array." << endl);
876 fncCellArray = getFncArrayAsGFCells(faceNodeConnectivityArray);
880 int startIndex = getStartIndex(faceNodeConnectivityArray);
881 if (startIndex != 0) {
882 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFaceNodeConnectivityCells() - Applying startIndex to GF::Node array." << endl);
883 for (
int j = 0; j < total_size; j++) {
884 fncCellArray[j] -= startIndex;
888 GF::CellArray *rankTwoCells =
new GF::CellArray(fncCellArray, faceCount, nodesPerFace);
891 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getFaceNodeConnectivityCells() - DONE" << endl);
901 BESDEBUG(
"ugrid",
"TwoDMeshTopology::applyRestrictOperator() - BEGIN" << endl);
907 BESDEBUG(
"ugrid",
"TwoDMeshTopology::applyRestrictOperator() - Constructing new GF::RestrictOp using user "<<
908 "supplied 'dimension' value and filter expression combined with the GF:GridField " << endl);
909 GF::RestrictOp op = GF::RestrictOp(filterExpression, loc, d_inputGridField);
913 BESDEBUG(
"ugrid",
"TwoDMeshTopology::applyRestrictOperator() - Applying GridField operator." << endl);
914 GF::GridField *resultGF = op.getResult();
915 resultGridField = resultGF;
916 BESDEBUG(
"ugrid",
"TwoDMeshTopology::applyRestrictOperator() - GridField operator applied and result obtained." << endl);
917 BESDEBUG(
"ugrid",
"TwoDMeshTopology::applyRestrictOperator() - END" << endl);
921 #if 0 // Unused crufty code from previous efforts
925 static void rDAWorker(
926 libdap::Array *dapArray,
927 libdap::Array::Dim_iter thisDim,
928 libdap::Array::Dim_iter locationCoordinateDim,
932 if(thisDim==dapArray->dim_end()){
946 libdap::Array::Dim_iter nextDim = thisDim;
949 if(thisDim==locationCoordinateDim){
951 if(nextDim!=dapArray->dim_end()){
952 string msg =
"rDAWorker() - The location coordinate dimension is not the last dimension in the array. Hyperslab subsetting of this dimension is not supported.";
954 throw Error(malformed_expr, msg);
959 rDAWorker(dapArray, nextDim, locationCoordinateDim, gridLocation, results);
964 unsigned int start = dapArray->dimension_start(thisDim,
true);
965 unsigned int stride = dapArray->dimension_stride(thisDim,
true);
966 unsigned int stop = dapArray->dimension_stop(thisDim,
true);
968 for(
unsigned int dimIndex=start; dimIndex<=stop ; dimIndex+=stride){
969 dapArray->add_constraint(thisDim,dimIndex,1,dimIndex);
970 rDAWorker(dapArray, nextDim, locationCoordinateDim, gridLocation, results);
974 dapArray->add_constraint(thisDim,start,stride,stop);
989 libdap::Array *TwoDMeshTopology::restrictDapArray(libdap::Array *dapArray, libdap::Array::Dim_iter locationCoordinateDim,
locationType gridLocation){
997 vector<unsigned int> arrayShape(dapArray->dimensions(
true));
1001 arrayShape[dapArray->dimensions(
true) - 1] = resultGridField->GetGrid()->countKCells(
node);
1005 rDAWorker(dapArray, dapArray->dim_begin(), locationCoordinateDim, gridLocation, result);
1007 libdap::Array *myResult = 0;
1014 #if 0 // Unused crufty code from previous efforts
1015 void TwoDMeshTopology::restrictRange( vector<BaseType *> *results){
1018 BESDEBUG(
"ugrid",
"TwoDMeshTopology::restrictRange() - BEGIN" << endl);
1021 BESDEBUG(
"ugrid",
"TwoDMeshTopology::restrictRange() - Normalizing Grid." << endl);
1022 resultGridField->GetGrid()->normalize();
1025 BESDEBUG(
"ugrid",
"TwoDMeshTopology::restrictRange() - Adding the coordinate node arrays to the response." << endl);
1026 vector<libdap::Array *>::iterator it;
1027 for (it = nodeCoordinateArrays->begin(); it != nodeCoordinateArrays->end(); ++it) {
1028 libdap::Array *sourceCoordinateArray = *it;
1029 libdap::Array *resultCoordinateArray = getGFAttributeAsDapArray(sourceCoordinateArray,
node, resultGridField );
1030 results->push_back(resultCoordinateArray);
1033 BESDEBUG(
"ugrid",
"TwoDMeshTopology::restrictRange() - Adding the new face node connectivity array to the response." << endl);
1034 libdap::Array *resultFaceNodeConnectivityDapArray = getGridFieldCellArrayAsDapArray(resultGridField, faceNodeConnectivityArray);
1035 results->push_back(resultFaceNodeConnectivityDapArray);
1039 BESDEBUG(
"ugrid",
"TwoDMeshTopology::restrictRange() - Processing range variable data arrays." << endl);
1040 vector<MeshDataVariable *>::iterator mdvIt;
1041 for (mdvIt = rangeDataArrays->begin(); mdvIt != rangeDataArrays->end(); ++mdvIt) {
1045 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldToDapObjects() - Processing MeshDataVariable '"<< mdv->
getName() <<
"' array type is "<< mdv->
getDapArray()->type_name() << endl);
1049 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldToDapObjects() - Retrieved restricted DAP Array for MeshDataVariable '"<< mdv->
getName() <<
"'" << endl);
1050 results->push_back(resultRangeVar);
1051 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldToDapObjects() - DAP Array added to result" << endl);
1053 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldToDapObjects() - DAP Array added to result" << endl);
1058 BESDEBUG(
"ugrid",
"TwoDMeshTopology::restrictRange() - END" << endl);
1067 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldStructureToDapObjects() - BEGIN" << endl);
1069 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldStructureToDapObjects() - Normalizing Grid." << endl);
1070 resultGridField->GetGrid()->normalize();
1073 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldStructureToDapObjects() - Converting the node coordinate arrays to DAP arrays." << endl);
1074 vector<libdap::Array *>::iterator it;
1075 for (it = nodeCoordinateArrays->begin(); it != nodeCoordinateArrays->end(); ++it) {
1076 libdap::Array *sourceCoordinateArray = *it;
1077 libdap::Array *resultCoordinateArray = getGFAttributeAsDapArray(sourceCoordinateArray,
node, resultGridField );
1078 results->push_back(resultCoordinateArray);
1083 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldStructureToDapObjects() - Converting the face coordinate arrays to DAP arrays." << endl);
1084 for (it = faceCoordinateArrays->begin(); it != faceCoordinateArrays->end(); ++it) {
1085 libdap::Array *sourceCoordinateArray = *it;
1086 libdap::Array *resultCoordinateArray = getGFAttributeAsDapArray(sourceCoordinateArray,
face, resultGridField );
1087 results->push_back(resultCoordinateArray);
1093 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldStructureToDapObjects() - Adding the new face node connectivity array to the response." << endl);
1094 libdap::Array *resultFaceNodeConnectivityDapArray = getGridFieldCellArrayAsDapArray(resultGridField, faceNodeConnectivityArray);
1095 results->push_back(resultFaceNodeConnectivityDapArray);
1099 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldStructureToDapObjects() - END" << endl);
1104 #if 0 // Unused crufty code from previous efforts
1108 void TwoDMeshTopology::convertResultRangeVarsToDapObjects(vector<BaseType *> *results)
1111 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultRangeVarsToDapObjects() - BEGIN" << endl);
1115 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultRangeVarsToDapObjects() - Adding the range variable data arrays to the response." << endl);
1116 vector<MeshDataVariable *>::iterator mdvIt;
1117 for (mdvIt = rangeDataArrays->begin(); mdvIt != rangeDataArrays->end(); ++mdvIt) {
1119 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultRangeVarsToDapObjects() - Processing MeshDataVariable '"<< mdv->
getName() <<
"' array type is "<< mdv->
getDapArray()->type_name() << endl);
1121 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultRangeVarsToDapObjects() - Retrieved restricted DAP Array for MeshDataVariable '"<< mdv->
getName() <<
"'" << endl);
1122 results->push_back(resultRangeVar);
1123 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultRangeVarsToDapObjects() - DAP Array added to result" << endl);
1126 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultRangeVarsToDapObjects() - END" << endl);
1131 #if 0 // Unused crufty code from previous efforts
1135 void TwoDMeshTopology::convertResultGridFieldToDapObjects(vector<BaseType *> *results)
1138 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldToDapObjects() - BEGIN" << endl);
1141 convertResultRangeVarsToDapObjects(results);
1143 BESDEBUG(
"ugrid",
"TwoDMeshTopology::convertResultGridFieldToDapObjects() - END" << endl);
1155 libdap::Array *TwoDMeshTopology::getNewFncDapArray(libdap::Array *templateArray,
int N)
1159 int dimCount = templateArray->dimensions(
true);
1162 "Expected a 2 dimensional array. The array '"
1163 + templateArray->name() +
"' has "
1164 + libdap::long_to_string(dimCount) +
" dimensions.");
1167 libdap::Array::Dim_iter di = templateArray->dim_begin();
1168 if (di->c_size != 3) {
1170 "Expected a 2 dimensional array with shape of 3xN! The array '"
1171 + templateArray->name() +
"' has a first "
1172 +
"dimension of size " + libdap::long_to_string(di->c_size);
1173 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getNewFcnDapArray() - "<< msg << endl);
1174 templateArray->print_decl(cerr,
" ",
true,
false,
true);
1176 throw Error(malformed_expr, msg);
1181 Int32 tmplt(templateArray->name());
1182 libdap::Array *newArray =
new libdap::Array(templateArray->name(),&tmplt);
1185 newArray->append_dim(3, di->name);
1190 newArray->append_dim(N, di->name);
1193 newArray->set_attr_table(templateArray->get_attr_table());
1196 newArray->reserve_value_capacity(3 * N);
1198 #if 0 // This is debugging - keep it around we might need it...
1199 cerr<<
"getNewFcnDapArray() -"<<endl<<endl;
1200 cerr <<
"Newly minted Array: "<< endl;
1201 newArray->print_val(cerr);
1215 libdap::Array *TwoDMeshTopology::getGridFieldCellArrayAsDapArray(GF::GridField *resultGridField, libdap::Array *sourceFcnArray)
1218 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGridFieldCellArrayAsDapArray() - BEGIN" << endl);
1221 GF::CellArray* gfCellArray = (GF::CellArray*) (resultGridField->GetGrid()->getKCells(2));
1224 vector<vector<int> > nodes2 = gfCellArray->makeArrayInts();
1226 libdap::Array *resultFncDapArray = getNewFncDapArray(sourceFcnArray, nodes2.size());
1229 vector<dods_int32> rowMajorNodes;
1233 int startIndex = getStartIndex(sourceFcnArray);
1234 if (startIndex != 0) {
1235 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGridFieldCellArrayAsDapArray() - Updating locations to match source FaceNodeConnectivity array." << endl);
1240 for (
unsigned int firstDim = 0; firstDim < 3; firstDim++) {
1241 for (
unsigned int secondDim = 0; secondDim < nodes2.size();
1243 dods_int32 val = nodes2.at(secondDim).at(firstDim) + startIndex;
1244 rowMajorNodes.push_back(val);
1248 #if 0 // This is debugging - keep it around we might need it.
1249 cerr <<
"getGridFieldCellArrayAsDapArray() - rowMajorNodes: " << endl <<
"{";
1250 for (
unsigned int j=0; j < rowMajorNodes.size(); j++) {
1251 dods_int32 val = rowMajorNodes.at(j);
1252 cerr << val <<
", ";
1254 cerr <<
"}" << endl;
1258 resultFncDapArray->set_value(rowMajorNodes, rowMajorNodes.size());
1260 #if 0 // This is debugging - keep it around we might need it.
1261 cerr <<
"getGridFieldCellArrayAsDapArray() - DAP Array: "<< endl;
1262 resultFcnDapArray->print_val(cerr);
1264 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGridFieldCellArrayAsDapArray() - DONE" << endl);
1266 return resultFncDapArray;
1272 static libdap::Array::Dim_iter copySizeOneDimensions(libdap::Array *sourceArray, libdap::Array *dapArray){
1274 libdap::Array::Dim_iter dataDimension;
1275 for (libdap::Array::Dim_iter srcArrIt = sourceArray->dim_begin(); srcArrIt != sourceArray->dim_end() ;++srcArrIt) {
1278 int dimSize = sourceArray->dimension_size(srcArrIt,
true);
1279 string dimName = sourceArray->dimension_name(srcArrIt);
1283 BESDEBUG(
"ugrid",
"TwoDMeshTopology::copySizeOneDimensions() - Adding size one dimension '"<< dimName <<
"' from source array into result." << endl);
1284 dapArray->append_dim(dimSize, dimName);
1287 BESDEBUG(
"ugrid",
"TwoDMeshTopology::copySizeOneDimensions() - Located data dimension '"<< dimName <<
"' in source array." << endl);
1289 dataDimension = srcArrIt;
1292 BESDEBUG(
"ugrid",
"TwoDMeshTopology::copySizeOneDimensions() - Returning dimension iterator pointing to '"<< sourceArray->dimension_name(dataDimension) <<
"'." << endl);
1293 return dataDimension;
1302 libdap::Array *TwoDMeshTopology::getGFAttributeAsDapArray(libdap::Array *templateArray,
locationType rank, GF::GridField *resultGridField)
1305 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - BEGIN" << endl);
1309 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - Retrieving GF::GridField Attribute '" <<
1310 templateArray->name() <<
"'" << endl);
1311 GF::Array* gfa = resultGridField->GetAttribute(rank, templateArray->name());
1313 libdap::Array *dapArray;
1314 BaseType *templateVar = templateArray->var();
1317 switch (templateVar->type()) {
1322 case dods_int32_c: {
1324 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - Retrieving GF::Array as libdap::Array of libdap::Int32." << endl);
1325 vector<dods_int32> GF_ints = gfa->makeArray();
1327 libdap::Int32 tmpltVar(templateVar->name());
1328 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - libdap::Int32 template variable name: " << tmpltVar.name() << endl);
1329 dapArray =
new libdap::Array(templateArray->name(), &tmpltVar);
1332 libdap::Array::Dim_iter dataDimension = copySizeOneDimensions(templateArray, dapArray);
1335 dimName = templateArray->dimension_name(dataDimension);
1336 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - Adding dimension " << dimName << endl);
1338 dapArray->append_dim(GF_ints.size(), dimName);
1341 dapArray->set_value(GF_ints, GF_ints.size());
1344 case dods_float32_c:
1345 case dods_float64_c: {
1347 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - Retrieving GF::Array as libdap::Array of libdap::Float64." << endl);
1348 vector<dods_float64> GF_floats = gfa->makeArrayf();
1350 libdap::Float64 tmpltVar(templateVar->name());
1351 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - libdap::Float64 template variable name: " << tmpltVar.name() << endl);
1352 dapArray =
new libdap::Array(templateArray->name(), &tmpltVar);
1355 libdap::Array::Dim_iter dataDimension = copySizeOneDimensions(templateArray, dapArray);
1358 dimName = templateArray->dimension_name(dataDimension);
1359 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - Adding dimension " << dimName << endl);
1360 dapArray->append_dim(GF_floats.size(), dimName);
1363 dapArray->set_value(GF_floats, GF_floats.size());
1367 throw InternalErr(__FILE__, __LINE__,
1368 "Unknown DAP type encountered when converting to gridfields array");
1372 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - Copying libdap::Attribute's from template array " << templateArray->name() << endl);
1373 dapArray->set_attr_table(templateArray->get_attr_table());
1375 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getGFAttributeAsDapArray() - DONE" << endl);
1401 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - BEGIN" << endl);
1405 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - Retrieving GF::GridField Attribute '" <<
1406 attrName <<
"'" << endl);
1409 if(resultGridField->IsAttribute(rank,attrName)){
1410 gfa = resultGridField->GetAttribute(rank, attrName);
1413 string msg =
"Oddly, the requested attribute '"+ attrName +
"' associated with rank "+ libdap::long_to_string(rank) +
1414 " does not appear in the resultGridField object! \n" +
1415 "resultGridField->MaxRank(): " + libdap::long_to_string(resultGridField->MaxRank());
1417 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - ERROR! " << msg << endl);
1418 throw InternalErr(__FILE__, __LINE__,
1419 "ERROR - Unable to locate requested GridField attribute. "+ msg);
1427 case dods_int32_c: {
1429 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - Retrieving GF::Array as libdap::Array of libdap::Int32." << endl);
1430 vector<dods_int32> GF_ints = gfa->makeArray();
1432 for(
unsigned int i=0; i<GF_ints.size() ; i++){
1433 s <<
"GF_ints[" << i <<
"]: " << GF_ints[i] << endl;
1435 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - Retrieved GF_ints: "<< endl << s.str());
1440 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - Copying GF result to target memory" << endl);
1441 memcpy(target, &GF_ints[0], GF_ints.size()*
sizeof(dods_int32));
1444 case dods_float32_c:
1445 case dods_float64_c: {
1447 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - Retrieving GF::Array as libdap::Array of libdap::Float64." << endl);
1448 vector<dods_float64> GF_floats = gfa->makeArrayf();
1451 for(
unsigned int i=0; i<GF_floats.size() ; i++){
1452 s <<
"GF_ints[" << i <<
"]: " << GF_floats[i] << endl;
1454 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - Retrieved GF_floats: "<< endl << s.str());
1455 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - Copying GF result to target memory" << endl);
1456 memcpy(target, &GF_floats[0], GF_floats.size()*
sizeof(dods_float64));
1461 throw InternalErr(__FILE__, __LINE__,
1462 "Unknown DAP type encountered when converting to gridfields result values");
1464 BESDEBUG(
"ugrid",
"TwoDMeshTopology::getResultGFAttributeValues() - END" << endl);
1469 static string getIndexVariableName(
locationType location){
1474 return "node_index";
1480 return "face_index";
1488 string msg =
"TwoDMeshTopology::setLocationCoordinateDimension() - Unknown/Unsupported location value '" +
1489 libdap::long_to_string(location) +
"'";
1516 string msg =
"TwoDMeshTopology::setLocationCoordinateDimension() - Unknown/Unsupported location value '" +
1517 libdap::long_to_string(location) +
"'";
1531 string name = getIndexVariableName(location);
1533 BESDEBUG(
"ugrid",
"TwoDMeshTopology::addIndexVariable() - Adding index variable '" << name <<
1534 "' size: " << libdap::long_to_string(size) <<
" at rank " << libdap::long_to_string(location) << endl);
1537 d_inputGridField->AddAttribute(location, indexArray);
1538 gfArrays.push_back(indexArray);
1549 string name = getIndexVariableName(location);
void applyRestrictOperator(locationType loc, string filterExpression)
libdap::BaseType * getMeshVariable()
void getResultIndex(locationType location, void *target)
libdap::Array::Dim_iter getLocationCoordinateDimension()
void buildBasicGfTopology()
#define UGRID_FACE_NODE_CONNECTIVITY
void init(string meshVarName, libdap::DDS *dds)
only call this from the constructor?? Seems like the thing to do, but then the constructor will be po...
void setLocationCoordinateDimension(MeshDataVariable *mdv)
GF::Array * extractGridFieldArray(libdap::Array *a, vector< int * > *sharedIntArrays, vector< float * > *sharedFloatArrays)
Extract data from a DAP array and return those values in a gridfields array.
locationType getGridLocation()
void getResultGFAttributeValues(string attrName, libdap::Type type, locationType rank, void *target)
Retrieves a single dimensional GF attribute array from a GF::GridField and places the data into DAP a...
GF::Array * newGFIndexArray(string name, long size, vector< int * > *sharedIntArrays)
static class NCMLUtil overview
libdap::Array * getDapArray()
#define UGRID_MESH_TOPOLOGY
void addIndexVariable(locationType location)
Adds an index variable at the gridfields rank as indicated by the passed locationType.
int getInputGridSize(locationType location)
long computeConstrainedShape(libdap::Array *a, std::vector< unsigned int > *shape)
Compute the constrained shape of the Array and return it in a vector.
#define UGRID_FACE_COORDINATES
vector< string > & split(const string &s, char delim, vector< string > &elems)
Splits the string on the passed char.
void convertResultGridFieldStructureToDapObjects(vector< libdap::BaseType * > *results)
void setLocationCoordinateDimension(libdap::Array::Dim_iter cdim)
int getResultGridSize(locationType location)
#define UGRID_START_INDEX
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
#define UGRID_TOPOLOGY_DIMENSION
string getAttributeValue(BaseType *bt, string aName)
#define UGRID_NODE_COORDINATES