void
avtLocateAndPickNodeQuery::SetInputParams(const MapNode &params)
{
    if (params.HasEntry("vars"))
    {
        const stringVector &v = params.GetEntry("vars")->AsStringVector();
        if (v.empty())
            EXCEPTION2(QueryArgumentException, "vars", 1);
        timeCurveSpecs["nResultsToStore"] = (int)v.size();
        pickAtts.SetVariables(v);
    }
    else
        EXCEPTION1(QueryArgumentException, "vars");

    if (params.HasNumericVectorEntry("ray_start_point"))
    {
        doubleVector v;
        params.GetEntry("ray_start_point")->ToDoubleVector(v);
        if (v.size() != 3)
            EXCEPTION2(QueryArgumentException, "ray_start_point", 3);
        pickAtts.SetRayPoint1(v);
    }
    else
        EXCEPTION1(QueryArgumentException, "ray_start_point");

    if (params.HasNumericVectorEntry("ray_end_point"))
    {
        doubleVector v;
        params.GetEntry("ray_end_point")->ToDoubleVector(v);
        if (v.size() != 3)
            EXCEPTION2(QueryArgumentException, "ray_end_point", 3);
        pickAtts.SetRayPoint2(v);
    }
    else
        EXCEPTION1(QueryArgumentException, "ray_end_point");

    if (params.HasNumericEntry("domain"))
        domain = params.GetEntry("domain")->ToInt();
    else
        EXCEPTION1(QueryArgumentException, "domain");

    if (params.HasNumericEntry("element"))
        node = params.GetEntry("element")->ToInt();
    else
        EXCEPTION1(QueryArgumentException, "element");
}
void
VisitHotPointInteractor::Start2DMode(INTERACTION_MODE mode)
{
    if(!proxy.HasPlots())
    {
        return;
    }

    VisitInteractor  *newInteractor  = NULL;
    switch(mode)
    {
    case NAVIGATE:
        if(navigate2D == NULL)
        {
            navigate2D = new Navigate2D(proxy);
        }
        newInteractor = navigate2D;
        break;
    case NODE_PICK:
    case ZONE_PICK:
    case SPREADSHEET_PICK:
    case DDT_PICK:
        if(pick == NULL)
        {
            pick = new Pick(proxy);
        }
        newInteractor = pick;
        break;
    case ZOOM:
        if(zoom2D == NULL)
        {
            zoom2D = new Zoom2D(proxy);
        }
        newInteractor = zoom2D;
        break;
    case LINEOUT:
        if(lineout2D == NULL)
        {
            lineout2D = new Lineout2D(proxy);
        }
        newInteractor = lineout2D;
        break;
    }

    if(newInteractor == NULL)
    {
        //
        // We have an invalid navigation mode or an invalid window mode.
        //
        EXCEPTION1(BadInteractorException, mode);
    }

    //
    // No reason to set the interactor again if it is the same one.
    //
    if(newInteractor != currentInteractor)
        SetInteractor(newInteractor);
}
void
avtTimeIteratorExpression::Execute(void)
{
    FinalizeTimeLoop();
    avtContract_p contract = ConstructContractWithVarnames();
    contract->DisableExtentsCalculations();

    // Store off the original expression list.
    ParsingExprList *pel = ParsingExprList::Instance();
    ExpressionList orig_list = *(pel->GetList());

    InitializeOutput();

    std::string db = GetInput()->GetInfo().GetAttributes().GetFullDBName();
    ref_ptr<avtDatabase> dbp = avtCallback::GetDatabase(db, 0, NULL);
    if (*dbp == NULL)
        EXCEPTION1(InvalidFilesException, db.c_str());

    // The first EEF already set up its expressions ... we need a new one
    // to set up filters for the CMFE expressions.
    avtExpressionEvaluatorFilter myeef;
    myeef.SetInput(GetInput());
    for (int i = 0 ; i < numTimeSlicesToProcess ; i++)
    {
        int timeSlice = firstTimeSlice + i*timeStride;
        if (timeSlice > actualLastTimeSlice)
            timeSlice = actualLastTimeSlice;
        debug1 << "Time iterating expression working on time slice " 
               << timeSlice << endl;
        UpdateExpressions(timeSlice);
        // won't re-execute without setting modified to true, because
        // it doesn't check to see if expression definitions change.
        myeef.ReleaseData();
        myeef.GetOutput()->Update(contract);
        avtCallback::ResetTimeout(5*60);
        Barrier();
        avtCallback::ResetTimeout(5*60);

        avtDatabaseMetaData *md = dbp->GetMetaData(timeSlice, false,
                                                   false, false);
        currentCycle = md->GetCycles()[timeSlice];
        currentTime  = md->GetTimes()[timeSlice];

        ProcessDataTree(myeef.GetTypedOutput()->GetDataTree(), i);
        debug1 << "Time iterating expression done working on time slice " 
               << timeSlice << endl;
    }

    // Get the upstream filters back the way they are supposed to be.
    GetInput()->Update(executionContract);

    FinalizeOutput();

    // Restore the original expression list ... i.e. undo the temporary
    // expressions we put in.
    *(pel->GetList()) = orig_list;
}
vtkDataArray *
ADIOSFileObject::AllocateArray(ADIOS_DATATYPES &t)
{
    vtkDataArray *array = NULL;
    switch (t)
    {
      case adios_unsigned_byte:
        array = vtkCharArray::New();
        break;
      case adios_byte:
        array = vtkUnsignedCharArray::New();
        break;
      case adios_string:
        array = vtkCharArray::New();
        break;
        
      case adios_unsigned_short:
        array = vtkUnsignedShortArray::New();
        break;
      case adios_short:
        array = vtkShortArray::New();
        break;
        
      case adios_unsigned_integer:
        array = vtkUnsignedIntArray::New(); 
        break;
      case adios_integer:
        array = vtkIntArray::New(); 
        break;
        
      case adios_unsigned_long:
        array = vtkUnsignedLongArray::New(); 
        break;
      case adios_long:
        array = vtkLongArray::New(); 
        break;
        
      case adios_real:
        array = vtkFloatArray::New(); 
        break;
        
      case adios_double:
        array = vtkDoubleArray::New(); 
        break;
        
      case adios_long_double: // 16 bytes
      case adios_complex:     //  8 bytes
      case adios_double_complex: // 16 bytes
      default:
        std::string str = "Inavlid variable type";
        EXCEPTION1(InvalidVariableException, str);
        break;
    }

    return array;
}
// ****************************************************************************
//  Method:  VisitHotPointInteractor::StartAxisArrayMode
//
//  Purpose:
//    Sets up the interactors for axis array window mode.
//
//  Arguments:
//    mode       the interaction mode
//
//  Programmer:  Jeremy Meredith
//  Creation:    January 31, 2008
//
//  Modifications:
//   Jeremy Meredith, Mon Feb  4 13:24:08 EST 2008
//   Added zoom interactor for AxisArray mode.
//
//   Gunther H. Weber, Wed Mar 19 16:10:11 PDT 2008
//   Added SPREADSHEET_PICK 
//
//   Eric Brugger, Tue Dec  9 16:32:45 PST 2008
//   Added code to set the axis orientation for the navigateAxisArray.
//
//   Jonathan Byrd (Allinea Software), Sun Dec 18, 2011
//   Added the DDT_PICK mode
//
//   Eric Brugger, Mon Nov  5 15:48:46 PST 2012
//   I added the ability to display the parallel axes either horizontally
//   or vertically.
//
// ****************************************************************************
void
VisitHotPointInteractor::StartAxisArrayMode(INTERACTION_MODE mode)
{
    if (!proxy.HasPlots())
    {
        return;
    }

    VisitInteractor  *newInteractor  = NULL;
    switch(mode)
    {
      case LINEOUT:
      // We don't have a lineout or zoom interaction.
      // Fall through to navigation mode.
      case NAVIGATE:
        if (navigateAxisArray == NULL)
        {
            navigateAxisArray = new NavigateAxisArray(proxy);
        }
        navigateAxisArray->SetAxisOrientation(NavigateAxisArray::Vertical);
        navigateAxisArray->SetDomainOrientation(NavigateAxisArray::Horizontal);
        newInteractor = navigateAxisArray;
        break;
      case ZOOM:
        if(zoomAxisArray == NULL)
        {
            zoomAxisArray = new ZoomAxisArray(proxy);
        }
        newInteractor = zoomAxisArray;
        break;
      case ZONE_PICK:
      case NODE_PICK:
      case SPREADSHEET_PICK:
      case DDT_PICK:
        if (pick == NULL)
        {
            pick = new Pick(proxy);
        }
        newInteractor = pick;
        break;
    }

    if (newInteractor == NULL)
    {
        //
        // We have an invalid navigation mode or an invalid window mode.
        //
        EXCEPTION1(BadInteractorException, mode);
    }

    //
    // No reason to set the interactor again if it is the same one.
    //
    if (newInteractor != currentInteractor)
        SetInteractor(newInteractor);
}
avtIVPVTKTimeVaryingField::avtIVPVTKTimeVaryingField( vtkDataSet* dataset, 
                                                      avtCellLocator* locator,
                                                      double _t0, double _t1 ) 
  : ds(dataset), loc(locator), t0(_t0), t1(_t1), dt(_t1-_t0)
{
    if( ds )
        ds->Register( NULL );

    if( (velData[0] = ds->GetPointData()->GetVectors()) )
    {
        velCellBased = false;

        velData[1] = ds->GetPointData()->GetArray( NextTimePrefix );
    }
    else if( (velData[0] = ds->GetCellData()->GetVectors()) )
    {
        velCellBased = true;

        velData[1] = ds->GetCellData()->GetArray( NextTimePrefix );
    }
    else 
    {
        velData[0] = velData[1] = NULL;
        EXCEPTION1( ImproperUseException, 
                    "avtIVPVTKTimeVaryingField: Can't locate vectors to interpolate." );
    }

    if( velData[1] == NULL )
    {
        EXCEPTION1( ImproperUseException, 
                    "avtIVPVTKTimeVaryingField: Can't locate second pair of vectors to interpolate." );
    }

    lastCell = -1;
    lastPos.x = lastPos.y = lastPos.z =
        std::numeric_limits<double>::quiet_NaN();

    std::fill( sclData[0], sclData[0]+256, (vtkDataArray*)NULL );
    std::fill( sclData[1], sclData[1]+256, (vtkDataArray*)NULL );
    std::fill( sclCellBased, sclCellBased+256, false );

    sclDataName.resize( 256 );
}
void
avtLineScanQuery::PreExecute(void)
{
    avtDatasetQuery::PreExecute();

    if (numBins <= 0)
    {
        EXCEPTION1(VisItException, "There must be at least one bin.");
    }
    if (numLines <= 0)
    {
        EXCEPTION1(VisItException, "There must be at least one line.");
    }
    if (minLength < 0 || maxLength <= minLength)
    {
        EXCEPTION1(VisItException, "The min length must be less than the max "
                        "length and they both must be positive.");
    }
}
void
avtExecuteThenTimeLoopFilter::FinalizeTimeLoop()
{
    int numStates = GetInput()->GetInfo().GetAttributes().GetNumStates();

    if (startTime < 0)
    {
        startTime = 0;
    }
    if (endTime < 0)
    {
        endTime = numStates - 1;
    }
    if (stride < 0)
    {
        stride = 1;
    }

    if (startTime > endTime)
    {
        std::string msg("Start time must be smaller than or equal to the end time for " );
        msg += GetType();
        msg += ".\n";
        EXCEPTION1(ImproperUseException, msg);
    }

    nFrames = (int) ceil((((float)endTime-startTime))/(float)stride) + 1; 

    // ARS - This check will always pass because of the additional
    // frame added to nFrames above and startTime must be greater than
    // or equal to endTime. Thus it is commented out.

//     if (nFrames < 1)
//     {
//         std::string msg(GetType());
//         msg = msg +  " requires at least 1 frame, please correct start " + 
//                "and end times and try again.";
//         EXCEPTION1(ImproperUseException, msg);
//    }

    if (endTime >= numStates)
    {
        std::string msg(GetType());
        msg += ":  Clamping end time to number of available timesteps.";
        avtCallback::IssueWarning(msg.c_str());
    }

    //
    // Ensure that the specified endTime is included,
    // regardless of the stride.
    //
    actualEnd = startTime + nFrames * stride;
    if (actualEnd < endTime)
        actualEnd = endTime + stride;
}
void
avtGTCFileFormat::BinData( int dim, parallelBuffer **array, float *vars, float *ids,
                            float **myVarsPtr, float **myIdsPtr )
{
    int ptCnt = nTotalPoints / nProcs;
    int remainder = nTotalPoints % nProcs;

    float *ptrIDs = ids, *ptrVars = vars, *myVars = *myVarsPtr, *myIds = *myIdsPtr;
    float *data = new float[dim+1];
    
    for ( int i = 0; i < nPoints; i++ )
    {
        int id = ((int) *ptrIDs) - 1; //Make the id 0...N-1 for the math below.
        int whichProc;

        // Determine which processor this ID goes to.
        if ( id < (remainder * (ptCnt+1)) )
            whichProc = id / (ptCnt+1);
        else
        {
            int id2 = id - (remainder * (ptCnt+1));
            whichProc = remainder + id2/ptCnt;
        }

        if ( whichProc < 0 || whichProc >= nProcs )
        {
            char str[512];
            sprintf( str, "Bad Id mapping: %d ==> %d\n", id, whichProc );
            EXCEPTION1( InvalidDBTypeException, str );
        }

        // This is our data, so copy it to the front of the var, ids arrays.
        if ( whichProc == rank )
        {
            // ID
            *myIds++ = *ptrIDs++;
            for ( int j = 0; j < dim; j++ )
                *myVars++ = *ptrVars++;
        }
        // This data isn't ours. Stash it in the buffer to be sent.        
        else   
        {
            // ID
            data[0] = *ptrIDs++;
            for ( int j = 0; j < dim; j++ )
                data[j+1] = *ptrVars++;
            array[whichProc]->Add( data );
        }
    }
    
    delete [] data;

    *myIdsPtr = myIds;
    *myVarsPtr = myVars;
}
vtkDataArray *
avtADIOSBasicFileFormat::GetVar(int timestate, int domain, const char *varname)
{
    debug1 << "avtADIOSBasicFileFormat::GetVar " << varname << endl;
    Initialize();
    vtkFloatArray *arr = NULL;
    if (! fileObj->ReadVariable(varname, timestate, &arr))
        EXCEPTION1(InvalidVariableException, varname);
        
    return arr;
}
Example #11
0
OperatorPluginManager *
ViewerProxy::GetOperatorPluginManager() const
{
    if(operatorPlugins == 0)
    {
        EXCEPTION1(ImproperUseException, "ViewerProxy::InitializePlugins "
            "must be called before ViewerProxy::GetOperatorPluginManager");
    }

    return operatorPlugins;
}
avtFileFormatInterface *
VASP_CreateFileFormatInterface(const char * const *list, int nList, int nBlock)
{
    avtFileFormatInterface *ffi = 0;

    if (list != 0 && nList > 0)
    {
        // Determine the type of reader that we want to use.
        int flavor = -1;
        TRY
        {
            std::string fn(list[0]);
            if(flavor == -1 && avtOUTCARFileFormat::Identify(fn))
            {
                flavor = 0;
                debug4 << "Database is avtOUTCARFileFormat" << endl;
            }

            if(flavor == -1 && avtCHGCARFileFormat::Identify(fn))
            {
                flavor = 1;
                debug4 << "Database is avtCHGCARFileFormat" << endl;
            }

            if(flavor == -1 && avtPOSCARFileFormat::Identify(fn))
            {
                flavor = 2;
                debug4 << "Database is avtPOSCARFileFormat" << endl;
            }

            if(flavor == -1)
            {
                EXCEPTION1(InvalidFilesException, list[0]);
            }
        }
        CATCH(VisItException)
        {
            RETHROW;
        }
        ENDTRY

        switch(flavor)
        {
          case 0:
            ffi = avtOUTCARFileFormat::CreateInterface(list, nList, nBlock);
            break;
          case 1:
            ffi = avtCHGCARFileFormat::CreateInterface(list, nList, nBlock);
            break;
          case 2:
            ffi = avtPOSCARFileFormat::CreateInterface(list, nList, nBlock);
            break;
        }
    }
void
avtIVPVTKTimeVaryingField::SetScalarVariable(unsigned char index, const std::string& name)
{
    vtkDataArray* data[2] = { NULL, NULL };
    bool cellBased;

    if( (data[0] = ds->GetPointData()->GetScalars( name.c_str() )) )
    {
        cellBased = false;
        data[1] = 
            ds->GetPointData()->GetArray( (NextTimePrefix+name).c_str() );
    }
    else if( (data[0] = ds->GetCellData()->GetScalars( name.c_str() )) )
    {
        cellBased = true;
        data[1] = 
            ds->GetCellData()->GetArray( (NextTimePrefix+name).c_str() );
    }
    else
        EXCEPTION1( ImproperUseException, 
                    "avtIVPVTKTimeVaryingField: Can't locate scalar \"" + name + 
                    "\" to interpolate." );

/* TODO. not sure we want all data to have a second value
    if( data[1] == NULL )
        EXCEPTION1( ImproperUseException, 
                    "avtIVPVTKTimeVaryingField: Can't locate next scalar \"" + name + 
                    "\" to interpolate." );
*/

    if( data[0]->GetNumberOfComponents() != 1 || 
        (data[1] && data[1]->GetNumberOfComponents() != 1) )
        EXCEPTION1( ImproperUseException,
                    "avtIVPVTKTimeVaryingField: Given variable \"" + name +
                    "\" is not scalar." );
        
    sclDataName[index] = name;
    sclData[0][index] = data[0];
    sclData[1][index] = data[1];
    sclCellBased[index] = cellBased;
}
void
avtFluxFilter::InferVariableNameFromContract(avtContract_p c)
{
    avtDataRequest_p in_dr = c->GetDataRequest();

    bool foundIt = false;
    if (strncmp(in_dr->GetVariable(), "operators/Flux/",
                strlen("operators/Flux/")) == 0)
    {
        foundIt = true;
        if (atts.GetFlowField() == "default")
        {
             EXCEPTION1(VisItException, "You can't set the flow field as \"default\" "
                        "since the default field is not a vector.");
        }
        if (atts.GetWeight() && atts.GetWeightField() == "default")
        {
             EXCEPTION1(VisItException, "You can't set the weighting field as \"default\" "
                        "since that would lead to a recursive definition.");
        }
        varname = in_dr->GetVariable()+strlen("operators/Flux/");
    }

    if (!foundIt)
    {
        std::vector<CharStrRef>   vars2nd = in_dr->GetSecondaryVariablesWithoutDuplicates();
        for (size_t i = 0 ; i < vars2nd.size() ; i++)
        if (strncmp(*(vars2nd[i]), "operators/Flux/",
                    strlen("operators/Flux/")) == 0)
        {
            foundIt = true;
            varname = *(vars2nd[i])+strlen("operators/Flux/");
        }
    }

    if (!foundIt)
    {
        EXCEPTION1(VisItException, "Unable to determine variable name from contract");
    }
}
void 
avtShapeletDecompositionQuery::SetInputParams(const MapNode & params)
{
    if (params.HasNumericEntry("beta"))
    {
        double b = params.GetEntry("beta")->ToDouble();
        if (b < 1.0)
        {
            EXCEPTION1(VisItException, "Shapelet Decomposition requires "
                       "beta and nmax >= 1.");
        }
        SetBeta(b);
    }
    else
    {
        SetBeta(1.0);
    }

    if (params.HasNumericEntry("nmax"))
    {
        int m = params.GetEntry("nmax")->ToInt();
        SetNMax(m < 1 ? 1 : m);
    }
 
    SetDecompOutputFileName("");

    if (params.HasEntry("recomp_file"))
    {
        std::string rf(params.GetEntry("recomp_file")->AsString());
        if (rf.empty())
        {
            EXCEPTION1(QueryArgumentException, "recomp_file");
        }
        SetRecompOutputFileName(rf);
    }
    else 
    {
        SetRecompOutputFileName("");
    }
}
avtCellLocatorRect::avtCellLocatorRect( vtkDataSet* ds ) :
    avtCellLocator( ds )
{
    vtkRectilinearGrid* rg = vtkRectilinearGrid::SafeDownCast( dataSet );

    if( dataSet->GetDataObjectType() != VTK_RECTILINEAR_GRID || rg == NULL )
        EXCEPTION1( ImproperUseException, "avtCellLocatorRect: Dataset is not rectilinear." );

    // copy the coordinate arrays for faster access later
    vtkDataArray* ca[3] = { 
        rg->GetXCoordinates(),
        rg->GetYCoordinates(),
        rg->GetZCoordinates(),
    };

    for( unsigned int d=0; d<3; ++d )
    {
        coord[d].resize( ca[d]->GetNumberOfTuples() );
        ascending[d] = true;

        for( unsigned int i=0; i<coord[d].size(); ++i )
        {
            coord[d][i] = ca[d]->GetComponent( i, 0 );
            if (i == 1)
            {
               if (coord[d][1] < coord[d][0])
                   ascending[d] = false;
            }
            else if (i > 1)
            {
                bool thisPairAscending = (coord[d][i] > coord[d][i-1]);
                if (thisPairAscending != ascending[d])
                {
                    EXCEPTION1( ImproperUseException, "avtCellLocatorRect: Coordinate "
                       "arrays are not monotonic.");
                }
            }
        }
    }    
}
Example #17
0
const std::string &
ViewerProxy::GetLocalUserName() const
{
    if(viewer == 0 && viewerP == 0)
    {
        EXCEPTION1(VisItException, "Viewer not created.");
    }

    if(viewer != 0)
        return viewer->GetLocalUserName();

    return viewerP->GetLocalUserName();
}
void
ADIOSFileObject::OpenGroup(int grpIdx)
{
    if (!gps)
        return;
    if (gps[grpIdx] == NULL)
        gps[grpIdx] = adios_gopen_byid(fp, grpIdx);

    if (gps[grpIdx] == NULL)
    {
        std::string errmsg = "Error opening group "+std::string(fp->group_namelist[grpIdx])+" in " + fileName;
        EXCEPTION1(InvalidDBTypeException, errmsg.c_str());
    }
}
int
avtScalarMetaData::AddEnumNameRange(std::string name, double min, double max)
{
    if (min > max)
    {
        EXCEPTION1(ImproperUseException, name);
    }

    enumNames.push_back(name);
    enumRanges.push_back(min);
    enumRanges.push_back(max);

    return enumNames.size() - 1;
}
Example #20
0
void
avtRayCompositer::InsertOpaqueImage(avtImage_p img)
{
    avtImageRepresentation &rep = img->GetImage();
    if (rep.GetZBuffer() == NULL)
    {
        //
        // How can we incorporate an image if it has no zbuffer?
        //
        EXCEPTION1(ImproperUseException, "Need Z buffer.");
    }

    opaqueImage = img;
}
void
avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob, 
    const SelectionProperties &selProps, avtNamedSelectionExtension *ext)
{
    const char *mName = "avtNamedSelectionManager::CreateNamedSelection: ";
    StackTimer t0("CreateNamedSelection");

    if (strcmp(dob->GetType(), "avtDataset") != 0)
    {
        EXCEPTION1(VisItException, "Named selections only work on data sets");
    }

    // Save the selection properties.
    AddSelectionProperties(selProps);

    // Augment the contract based on the selection properties.
    avtContract_p c0 = dob->GetContractFromPreviousExecution();
    bool needsUpdate = false;
    avtContract_p contract = ext->ModifyContract(c0, selProps, needsUpdate);

    // 
    // Let the input try to create the named selection ... some have special
    // logic, for example the parallel coordinates filter.
    //
    const std::string &selName = selProps.GetName();
    avtNamedSelection *ns = NULL;
    if(selProps.GetSelectionType() == SelectionProperties::BasicSelection)
    {
        ns = dob->GetSource()->CreateNamedSelection(contract, selName);
        if (ns != NULL)
        {
            int curSize = selList.size();
            selList.resize(curSize+1);
            selList[curSize] = ns;

            //
            // Save out the named selection in case of engine crash / 
            // save/restore session, etc.
            //  
            SaveNamedSelection(selName, true);
            return;
        }
    }

    //
    // Call into the extension to get the per-processor named selection.
    //
    TimedCodeBlock("Creating selection in extension",
        ns = ext->GetSelection(dob, selProps, cache);
    );
vtkDataSet *
avtADIOSBasicFileFormat::GetMesh(int timestate, int domain, const char *meshname)
{
    debug1 << "avtADIOSBasicFileFormat::GetMesh " << meshname << endl;
    Initialize();

    // Look it up in the mesh table.
    std::map<std::string,meshInfo>::const_iterator m = meshes.find(meshname);
    if (m != meshes.end())
    {
        vtkRectilinearGrid *grid = NULL;
        grid = CreateUniformGrid(m->second.start,
                                 m->second.count);
        grid->Register(NULL);
        
        return grid;
    }

    //It might be a curve.
    std::map<std::string, ADIOSVar>::const_iterator v = fileObj->variables.find(meshname);
    if (v != fileObj->variables.end() && v->second.dim == 1)
    {
        vtkRectilinearGrid *grid = NULL;
        grid = CreateUniformGrid(v->second.start,
                                 v->second.count);
        vtkFloatArray *vals = NULL;
        if (!fileObj->ReadVariable(meshname, timestate, &vals))
            EXCEPTION1(InvalidVariableException, meshname);
        vals->SetName(meshname);
        grid->GetPointData()->SetScalars(vals);
        vals->Delete();
        grid->Register(NULL);
        return grid;
    }
    debug1<<meshname<<" not found"<<endl;
    EXCEPTION1(InvalidVariableException, meshname);
}
vtkDataArray *
avtMM5FileFormat::GetVar(int timestate, const char *varname)
{
    mm5_fieldinfo_t *field = 0;

    Initialize();
   
    if(mm5file == 0)
    {
        EXCEPTION1(InvalidVariableException, varname);
    }

    field = mm5_file_find_field(mm5file, varname, timestate);

    if(field == 0)
    {
        EXCEPTION1(InvalidVariableException, varname);
    }

    // Set up the return array.
    vtkFloatArray *rv = vtkFloatArray::New();
    int n_elements = field->header.end_index[0] *
            field->header.end_index[1] *
            field->header.end_index[2] *
            field->header.end_index[3];
    rv->SetNumberOfTuples(n_elements);
    float *fptr = (float *)rv->GetVoidPointer(0);

    // Read the data directly into the array.
    if(mm5_file_read_field(mm5file, varname, timestate, fptr) == 0)
    {
        rv->Delete();
        EXCEPTION1(InvalidVariableException, varname);
    }

    return rv;
}
// ****************************************************************************
//  Method: avtConnComponentsLengthQuery::Execute
//
//  Purpose:
//      Processes a single input domain to update the per component area sums.
//
//  Arguments:
//      ds       Input dataset
//      dom      Input domain number
//
//  Programmer: Cyrus Harrison
//  Creation:   Wed Jun 15 13:09:43 PDT 2011
//
// ****************************************************************************
void
avtConnComponentsLengthQuery::Execute(vtkDataSet *ds, const int dom)
{
    // get the number of cells to process
    int ncells = ds->GetNumberOfCells();

    // get the component labels and volume arrays
    vtkIntArray  *labels =(vtkIntArray*)ds->GetCellData()->GetArray("avt_ccl");
    vtkDataArray *vol= ds->GetCellData()->GetArray("avt_weight");

    // make sure the volume and component label arrays are valid
    if (vol == NULL)
    {
        EXCEPTION1(InvalidVariableException, "avt_weight");
    }

    if (labels == NULL)
    {
        EXCEPTION1(InvalidVariableException, "avt_ccl");
    }

    double len_val = 0.0;
    // loop over all cells
    for (int i = 0 ; i < ncells ; i++)
    {
        // get the cell  & and its component label
        vtkCell *cell    = ds->GetCell(i);
        int      comp_id = labels->GetValue(i);

        // get cell area
        len_val = (double) vol->GetTuple1(i);

        // add to total component area
        lengthPerComp[comp_id] += len_val;
    }
}
/** Method: avtGGCM constructor
 *  Programmer: tfogal -- generated by xml2avt
 *  Creation:   Thu Jun 1 13:38:54 PST 2006 */
avtGGCMFileFormat::avtGGCMFileFormat(const char *filename,
                                     DBOptionsAttributes *db)
                       : avtMTSDFileFormat(&filename, 1)
{
    assert(filename != NULL);

    DeriveGridFile(filename, &this->fn_grid);
    if(this->fn_grid == NULL)
    {
        EXCEPTION1(InvalidDBTypeException, "Could not derive grid filename.");
    }

    this->selList.clear();
    this->selsApplied = NULL;
    this->restricted = false;
}
void
ADIOSFileObject::CloseGroup(int grpIdx)
{
    if (!gps)
        return;
    if (gps[grpIdx] != NULL)
    {
        int val = adios_gclose(gps[grpIdx]);
        gps[grpIdx] = NULL;
        if (val != 0)
        {
            std::string errmsg = "Error closing group "+std::string(fp->group_namelist[grpIdx])+" in " + fileName;
            EXCEPTION1(InvalidDBTypeException, errmsg.c_str());
        }
    }
}
int *
avtGTCFileFormat::GetDataShareMatrix( parallelBuffer **array )
{
    // Binning done, now tell everyone else how many particles we have for them.
    int *particleCnts = new int[nProcs], *gatherCnts = new int[nProcs*nProcs];
    
    for ( int i = 0; i < nProcs; i++ )
        particleCnts[i] = array[i]->Size();

    // Allgather is a little overkill, but there isn't much data.
    int err = MPI_Allgather( particleCnts, nProcs, MPI_INT,
                             gatherCnts, nProcs*nProcs, MPI_INT, VISIT_MPI_COMM );
    if ( err != MPI_SUCCESS )
        EXCEPTION1(InvalidDBTypeException, "GTC Reader: MPI_Allgather() failure." );
    
    return gatherCnts;
}
avtCellList *
avtSamplePoints::GetCellList(void)
{
    if (varnames.size() <= 0)
    {
        EXCEPTION1(VisItException, 
            "Degenerate case: asked to resample a data set with no variables."
            "  This has not been implemented.");
    }

    if (celllist == NULL)
    {
        celllist = new avtCellList(GetNumberOfVariables());
    }

    return celllist;
}
Example #29
0
AdvDocument *
GetDocument(AdvDocFile *f, const std::string &var)
{
    AdvDocument *doc = adv_dio_open_by_property(f, 0, 
        "content_type", "HDDM_FEGenericAttribute",
        "label", var.c_str(), 0);
    if(doc == 0)
    {
        doc = adv_dio_open_by_property(f, 0, 
            "content_type", "FEGenericAttribute",
            "label", var.c_str(), 0);
    }
    if(doc == 0)
    {
        EXCEPTION1(InvalidVariableException, var.c_str());
    }
    return doc;
}
Example #30
0
const std::string &
ViewerProxy::GetLocalHostName() const
{
    if(viewer == 0 && viewerP == 0)
    {
        EXCEPTION1(VisItException, "Viewer not created.");
    }

    if(viewer != 0)
        return viewer->GetLocalHostName();

#if 0
    return viewerP->GetLocalHostName();
#else
    cerr << "Fix ViewerProxy::GetLocalHostName: " << __LINE__ << endl;
    return *(new std::string("localhost"));
#endif
}