void avtSTARFileFormat:: addDerivedVariables(avtDatabaseMetaData *md, int timeState) { TRACE(md, timestate); NOTNULL(mDataManager); // if all 11 primary variables there, add the derived variables too if(mDataManager->numVariables()==11) { Expression e; string submenu = "=Derived Variables /"; int numEntries = sizeof DerivedVariableTable/ sizeof DerivedVariableTable[0]; for(int i=0; i<numEntries; i++) { e.SetName(submenu + DerivedVariableTable[i].name); e.SetDefinition(DerivedVariableTable[i].expression); e.SetType(DerivedVariableTable[i].expressionType); DEBUG("adding derived variable '%s'='%s'", DerivedVariableTable[i].name.c_str(), DerivedVariableTable[i].expression.c_str()); md->AddExpression(&e); } } }
void avtRAWFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md) { avtMeshMetaData *mmd = new avtMeshMetaData; mmd->name = "mesh"; mmd->meshType = AVT_SURFACE_MESH; mmd->spatialDimension = 3; mmd->topologicalDimension = 2; mmd->numBlocks = meshes.size(); stringVector names; for(int i = 0; i < meshes.size(); ++i) names.push_back(meshes[i].domainName); mmd->blockNames = names; md->Add(mmd); const char *expdefs[] = {"coord(mesh)[0]","coord(mesh)[1]","coord(mesh)[2]"}; const char *expnames[] = {"x", "y", "z"}; for(int i = 0; i < 3; ++i) { Expression expr; expr.SetName(expnames[i]); expr.SetDefinition(expdefs[i]); expr.SetType(Expression::ScalarMeshVar); md->AddExpression(&expr); } }
void VisItDataServerPrivate::DefineVectorExpression(const std::string &name, const std::string &def) { Expression expr; expr.SetName(name); expr.SetDefinition(def); expr.SetType(Expression::VectorMeshVar); exprList.AddExpressions(expr); }
void avtOVERFLOWFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md) { // // We are using ndomains as a flag to indicate if we have read // the file. // if (!ndomains) { InitializeFile(); } // // Create the mesh metadata // avtMeshMetaData *mesh = new avtMeshMetaData; mesh->name = "mesh"; mesh->meshType = AVT_CURVILINEAR_MESH; mesh->numBlocks = ndomains; mesh->blockOrigin = 1; mesh->cellOrigin = 1; mesh->spatialDimension = 3; mesh->topologicalDimension = 3; mesh->blockTitle = "Zones"; mesh->blockPieceName = "Zone"; mesh->hasSpatialExtents = false; md->Add(mesh); // // Add our variable names // for (int i=0; i<nq; i++) { char name[1024]; SNPRINTF(name, 1024, "Q%d", i+1); AddScalarVarToMetaData(md, name, "mesh", AVT_NODECENT); } // // The "global" variables work well as expressions with no type // for (std::map<string,float>::iterator it=varmap.begin(); it!=varmap.end(); it++) { Expression exp; exp.SetName(it->first); char def[1024]; sprintf(def, "%f", it->second); exp.SetDefinition(def); exp.SetType(Expression::Unknown); md->AddExpression(&exp); } // // And don't forget we got TIME for this file! // md->SetTime(timestep, varmap["TIME"]); }
// **************************************************************************** // Method: ModelFitCommonPluginInfo::GetCreatedExpressions // // Purpose: // Get the expressions this operator can generate. // // Arguments: // md the metadata to create our expressions around // // Programmer: Rob Sisneros // Creation: omitted // // Modifications: // Jeremy Meredith, Thu Jan 12 13:28:49 EST 2012 // Some files, like curves, don't have expressions. Don't assume // we have any meshes in our file. // // **************************************************************************** ExpressionList * ModelFitCommonPluginInfo::GetCreatedExpressions(const avtDatabaseMetaData *md) { int i; int numMeshes = md->GetNumMeshes(); if (numMeshes == 0) return NULL; Expression *e = new Expression(); char mesh[1024]; strcpy(mesh, md->GetMesh(0)->name.c_str()); std::string varname = "operators/ModelFit/model"; //("; //varname += mesh; //varname += ")"; e->SetName(varname); char defn[1024]; sprintf(defn, "point_constant(%s, 0)", mesh); e->SetDefinition(defn); e->SetMeshName(std::string(mesh)); e->SetType(Expression::ScalarMeshVar); e->SetFromOperator(true); e->SetOperatorName("ModelFit"); ExpressionList *expressions = new ExpressionList; expressions->AddExpressions(*e); delete e; e = new Expression(); varname = "operators/ModelFit/distance"; //("; //varname += mesh; //varname += ")"; e->SetName(varname); sprintf(defn, "point_constant(%s, 0)", mesh); e->SetDefinition(defn); e->SetMeshName(std::string(mesh)); e->SetType(Expression::ScalarMeshVar); e->SetFromOperator(true); e->SetOperatorName("ModelFit"); expressions->AddExpressions(*e); return expressions; }
void avtTimeIteratorExpression::UpdateExpressions(int ts) { ParsingExprList *pel = ParsingExprList::Instance(); ExpressionList new_list = *(pel->GetList()); int nvars = varnames.size(); if (cmfeType == POS_CMFE) nvars--; for (int i = 0 ; i < nvars ; i++) { // No new expression has to be made in this case. if (VariableComesFromCurrentTime(i)) continue; std::string meshname = GetInput()->GetInfo().GetAttributes().GetMeshname(); char expr_defn[1024]; if (cmfeType == CONN_CMFE) { SNPRINTF(expr_defn, 1024, "conn_cmfe(<[%d]i:%s>, <%s>)", ts, varnames[i].c_str(), meshname.c_str()); } else { int defVarIndex = varnames.size()-1; SNPRINTF(expr_defn, 1024, "pos_cmfe(<[%d]i:%s>, <%s>, %s)", ts, varnames[i].c_str(), meshname.c_str(), varnames[defVarIndex].c_str()); } std::string exp_name = GetInternalVarname(i); bool alreadyInList = false; for (int j = 0 ; j < new_list.GetNumExpressions() ; j++) { if (new_list[j].GetName() == exp_name) { alreadyInList = true; new_list[j].SetDefinition(expr_defn); } } if (!alreadyInList) { Expression exp; exp.SetName(exp_name); exp.SetDefinition(expr_defn); exp.SetType(Expression::Unknown); new_list.AddExpressions(exp); } } *(pel->GetList()) = new_list; }
void avtConnectedComponentsFilter::GetCustomExpressions(std::vector<Expression> &elist) { Expression exp; char fullname[1024]; SNPRINTF(fullname, 1024, "operators/ConnectedComponents/%s", varname.c_str()); exp.SetName(fullname); char defn[1024]; std::string gzopt = "\"true\""; if (!atts.GetEnableGhostNeighborsOptimization()) gzopt = "\"false\""; SNPRINTF(defn, 1024, "conn_components(%s,%s)", varname.c_str(),gzopt.c_str()); exp.SetDefinition(defn); exp.SetType(Expression::ScalarMeshVar); elist.push_back(exp); }
ExpressionList * ExtractPointFunction2DCommonPluginInfo::GetCreatedExpressions(const avtDatabaseMetaData *md) { char name[1024]; char defn[1024]; ExpressionList *el = new ExpressionList; for (int i = 0 ; i < md->GetNumArrays() ; i++) { const char *array = md->GetArrays(i).name.c_str(); const char *mesh = md->GetArrays(i).meshName.c_str(); Expression e; sprintf(name, "operators/ExtractPointFunction2D/%s", array); e.SetName(name); e.SetType(Expression::ScalarMeshVar); e.SetFromOperator(true); e.SetOperatorName("ExtractPointFunction2D"); sprintf(defn, "cell_constant(<%s>, 0)", mesh); e.SetDefinition(defn); el->AddExpressions(e); } const ExpressionList &oldEL = md->GetExprList(); for (int i = 0 ; i < oldEL.GetNumExpressions() ; i++) { const Expression &e = oldEL.GetExpressions(i); if (e.GetType() == Expression::ArrayMeshVar) { { if (e.GetFromOperator()) continue; // weird ordering behavior otherwise Expression e2; sprintf(name, "operators/ExtractPointFunction2D/%s", e.GetName().c_str()); e2.SetName(name); e2.SetType(Expression::ScalarMeshVar); e2.SetFromOperator(true); e2.SetOperatorName("ExtractPointFunction2D"); sprintf(defn, "cell_constant(<%s>, 0.)", e.GetName().c_str()); e2.SetDefinition(defn); el->AddExpressions(e2); } } } return el; }
void avtFluxFilter::GetCustomExpressions(std::vector<Expression> &elist) { Expression exp; char fullname[1024]; SNPRINTF(fullname, 1024, "operators/Flux/%s", varname.c_str()); exp.SetName(fullname); char defn[1024]; if (atts.GetWeight()) SNPRINTF(defn, 1024, "dot(cell_surface_normal(%s), %s)*%s", varname.c_str(), atts.GetFlowField().c_str(), atts.GetWeightField().c_str()); else SNPRINTF(defn, 1024, "dot(cell_surface_normal(%s), %s)", varname.c_str(), atts.GetFlowField().c_str()); exp.SetDefinition(defn); exp.SetType(Expression::ScalarMeshVar); elist.push_back(exp); }
void AddExpression(ExpressionList &new_list, std::string &var, int time) { char exp_name[1024]; SNPRINTF(exp_name, 1024, "AVT_TRACE_HIST_%s", var.c_str()); char exp_defn[1024]; const char *meshname = var.c_str(); // The expression language will let // you put in a variable for the // meshname since it can use that to // find the meshname. meshname = "quadmesh"; SNPRINTF(exp_defn, 1024, "pos_cmfe(<[%d]i:%s>, %s, 0.)", time, var.c_str(), meshname); Expression exp; exp.SetName(exp_name); exp.SetDefinition(exp_defn); exp.SetType(Expression::Unknown); new_list.AddExpressions(exp); }
avtContract_p avtVolumeFilter::ModifyContract(avtContract_p contract) { avtContract_p newcontract = NULL; if (primaryVariable != NULL) { delete [] primaryVariable; } avtDataRequest_p ds = new avtDataRequest(contract->GetDataRequest()); const char *var = ds->GetVariable(); bool setupExpr = false; char exprDef[128]; std::string exprName = (std::string)"_expr_" + (std::string)var; if (atts.GetScaling() == VolumeAttributes::Linear) { #ifdef HAVE_LIBSLIVR if ((atts.GetRendererType() == VolumeAttributes::RayCastingSLIVR) || ((atts.GetRendererType() == VolumeAttributes::RayCasting) && (atts.GetSampling() == VolumeAttributes::Trilinear))) ds->SetDesiredGhostDataType(GHOST_ZONE_DATA); #endif newcontract = new avtContract(contract, ds); primaryVariable = new char[strlen(var)+1]; strcpy(primaryVariable, var); } else if (atts.GetScaling() == VolumeAttributes::Log) { setupExpr = true; if (atts.GetUseColorVarMin()) { char m[16]; SNPRINTF(m, 16, "%f", atts.GetColorVarMin()); SNPRINTF(exprDef, 128, "log10withmin(<%s>, %s)", var, m); } else { SNPRINTF(exprDef, 128, "log10(<%s>)", var); } avtDataRequest_p nds = new avtDataRequest(exprName.c_str(), ds->GetTimestep(), ds->GetRestriction()); nds->AddSecondaryVariable(var); #ifdef HAVE_LIBSLIVR if ((atts.GetRendererType() == VolumeAttributes::RayCastingSLIVR) || ((atts.GetRendererType() == VolumeAttributes::RayCasting) && (atts.GetSampling() == VolumeAttributes::Trilinear))) nds->SetDesiredGhostDataType(GHOST_ZONE_DATA); #endif newcontract = new avtContract(contract, nds); primaryVariable = new char[exprName.size()+1]; strcpy(primaryVariable, exprName.c_str()); } else // VolumeAttributes::Skew) { setupExpr = true; SNPRINTF(exprDef, 128, "var_skew(<%s>, %f)", var, atts.GetSkewFactor()); avtDataRequest_p nds = new avtDataRequest(exprName.c_str(), ds->GetTimestep(), ds->GetRestriction()); nds->AddSecondaryVariable(var); #ifdef HAVE_LIBSLIVR if ((atts.GetRendererType() == VolumeAttributes::RayCastingSLIVR) || ((atts.GetRendererType() == VolumeAttributes::RayCasting) && (atts.GetSampling() == VolumeAttributes::Trilinear))) nds->SetDesiredGhostDataType(GHOST_ZONE_DATA); #endif newcontract = new avtContract(contract, nds); primaryVariable = new char[strlen(exprName.c_str())+1]; strcpy(primaryVariable, exprName.c_str()); } if (setupExpr) { ExpressionList *elist = ParsingExprList::Instance()->GetList(); Expression *e = NULL; for (int i = 0 ; i < elist->GetNumExpressions() ; i++) { if (elist->GetExpressions(i).GetName() == exprName) { e = &(elist->GetExpressions(i)); break; } } bool shouldDelete = false; if (e == NULL) { e = new Expression(); shouldDelete = true; } e->SetName(exprName.c_str()); e->SetDefinition(exprDef); e->SetType(Expression::ScalarMeshVar); elist->AddExpressions(*e); if (shouldDelete) delete e; } newcontract->NoStreaming(); newcontract->SetHaveRectilinearMeshOptimizations(true); return newcontract; }
avtContract_p avtVectorFilter::ModifyContract(avtContract_p contract) { avtContract_p rv = contract; avtDataRequest_p ds = contract->GetDataRequest(); // // Create the expression definition // string edef = string("magnitude(<") + ds->GetVariable() + string(">)"); ExpressionList *elist = ParsingExprList::Instance()->GetList(); Expression *e = new Expression(); e->SetName(magVarName.c_str()); e->SetDefinition(edef.c_str()); e->SetType(Expression::ScalarMeshVar); elist->AddExpressions(*e); delete e; // Create a new dcontract so that we can add the secondary var. avtDataRequest_p nds = new avtDataRequest(ds->GetVariable(), ds->GetTimestep(), ds->GetRestriction()); nds->AddSecondaryVariable(magVarName.c_str()); rv = new avtContract(contract, nds); rv->SetCalculateVariableExtents(magVarName, true); // If we're not using the stride, then we have to calculate // the per-domain vectorc count by dividing by the number of // domains, which we can't calculate if we're streaming. if (!useStride) rv->NoStreaming(); avtDataAttributes &data = GetInput()->GetInfo().GetAttributes(); if (contract->GetDataRequest()->MayRequireZones() || contract->GetDataRequest()->MayRequireNodes() || origOnly) { keepNodeZone = true; if (data.ValidActiveVariable()) { if (data.GetCentering() == AVT_NODECENT) { rv->GetDataRequest()->TurnNodeNumbersOn(); } else if (data.GetCentering() == AVT_ZONECENT) { rv->GetDataRequest()->TurnZoneNumbersOn(); } } else { // canot determine variable centering, so turn on both // node numbers and zone numbers. rv->GetDataRequest()->TurnNodeNumbersOn(); rv->GetDataRequest()->TurnZoneNumbersOn(); } } else { keepNodeZone = false; } return rv; }
avtContract_p avtCracksClipperFilter::ModifyContract(avtContract_p inContract) { calculateDensity = false; if (strncmp(pipelineVariable, "operators/CracksClipper", strlen("operators/CracksClipper")) == 0) { calculateDensity = true; varname = pipelineVariable; } // Retrieve secondary variables, if any, to pass along to the // newly created DataSpec avtDataRequest_p inDR = inContract->GetDataRequest(); avtDataRequest_p outDR; avtDataAttributes &inAtts = GetInput()->GetInfo().GetAttributes(); if (calculateDensity) { outDR = new avtDataRequest(inDR, inAtts.GetMeshname().c_str()); } else { outDR = new avtDataRequest(inDR); } std::vector<CharStrRef> vars2 = inDR->GetSecondaryVariablesWithoutDuplicates(); // Add any previously existing SecondaryVariables. for (size_t i = 0; i < vars2.size(); i++) { outDR->AddSecondaryVariable(*(vars2[i])); } // Add secondary variables necessary for CracksClipper outDR->AddSecondaryVariable(atts.GetCrack1Var().c_str()); outDR->AddSecondaryVariable(atts.GetCrack2Var().c_str()); outDR->AddSecondaryVariable(atts.GetCrack3Var().c_str()); outDR->AddSecondaryVariable(atts.GetStrainVar().c_str()); if (calculateDensity) { outDR->AddSecondaryVariable(atts.GetInMassVar().c_str()); } ExpressionList *elist = ParsingExprList::Instance()->GetList(); Expression *e = new Expression(); std::string edef = std::string("volume2(<") + inAtts.GetMeshname() + std::string(">)"); e->SetName("cracks_vol"); e->SetDefinition(edef.c_str()); e->SetType(Expression::ScalarMeshVar); elist->AddExpressions(*e); delete e; outDR->AddSecondaryVariable("cracks_vol"); avtContract_p rv = new avtContract(inContract, outDR); // // Since this filter 'clips' the dataset, the zone and possibly // node numbers will be invalid, request them when needed. // if (inContract->GetDataRequest()->MayRequireZones() || inContract->GetDataRequest()->MayRequireNodes()) { if (inAtts.ValidActiveVariable()) { if (inAtts.GetCentering() == AVT_NODECENT) { rv->GetDataRequest()->TurnNodeNumbersOn(); } else if (inAtts.GetCentering() == AVT_ZONECENT) { rv->GetDataRequest()->TurnZoneNumbersOn(); } } else { // canot determine variable centering, so turn on both // node numbers and zone numbers. rv->GetDataRequest()->TurnNodeNumbersOn(); rv->GetDataRequest()->TurnZoneNumbersOn(); } } return rv; }
void avtSTARFileFormat:: PopulateDatabaseMetaData(avtDatabaseMetaData *md, int timeState) { TRACE(md,timeState); NOTNULL(mDataManager); BOUNDS_CHECK(mResolution, 0, mDataManager->numResolutions()); DEBUG("md=%p, timeState=%d", md, timeState); const double* extents = NULL; // not sure why this is NULL int numBlocks = mDataManager->numXchunks(mResolution) * mDataManager->numYchunks(mResolution) * mDataManager->numZchunks(mResolution); int blockOrigin = 0; // must be 0 for Single Domain? int numDims = 3; int topologyDimension = 3; const char* meshname = "ggcm"; AddMeshToMetaData(md, meshname, AVT_RECTILINEAR_MESH, extents, numBlocks, blockOrigin, numDims, topologyDimension); // assuming there is only one mesh... avtMeshMetaData& mmd = md->GetMeshes(0); mmd.LODs = mDataManager->numResolutions() - 1; debug4 << "Telling VisIt we have " << mmd.LODs << " levels of detail.\n"; for(int i=0; i<mDataManager->numVariables(); i++) { string varname = mDataManager->variableNameAt(i); if(mDataManager->isVectorComponent(varname)) { DEBUG("Adding vector component '%s'", varname.c_str()); // following set of commands equivalent to AddScalarVarToMetaData() avtScalarMetaData *smd = new avtScalarMetaData(); smd->name = varname.c_str(); smd->meshName = meshname; smd->centering = AVT_NODECENT; // end equivalent to calling AddScalarVarToMetaData() smd->hideFromGUI = true; // dont put vector components on menu md->Add(smd); } else if(mDataManager->isScalar(varname)) { DEBUG("Adding scalar '%s'", varname.c_str()); AddScalarVarToMetaData(md, varname.c_str(), meshname, AVT_NODECENT); if(mDataManager->hasMinVal() && mDataManager->hasMaxVal()) { double minmax[2]; minmax[0] = mDataManager->minVal(); minmax[1] = mDataManager->maxVal(); md->SetExtents(varname.c_str(), minmax); } } else if(mDataManager->isVector(varname)) { DEBUG("Adding vector '%s'", varname.c_str()); AddVectorVarToMetaData(md, varname.c_str(), meshname, AVT_NODECENT, numDims); } else if(mDataManager->isTensor(varname)) { ERROR("Tensors not supported yet"); } } for(int i=0; i<mDataManager->numVectorExpressions(); i++) { string expression = mDataManager->vectorExpressionAt(i); vector<string> components = split(expression, " \t\n,{};"); string name = components[0].erase(components[0].length()-1); Expression vectorvar; vectorvar.SetName(name); vectorvar.SetDefinition(expression); vectorvar.SetType(Expression::VectorMeshVar); DEBUG("adding vector '%s' with expression '%s'", name.c_str(), expression.c_str()); md->AddExpression(&vectorvar); } vector<int> cycles; GetCycles(cycles); md->SetCycles(cycles); //md->SetCyclesAreAccurate(true); vector<double> times; GetTimes(times); md->SetTimes(times); //md->SetTimesAreAccurate(true); md->SetTemporalExtents(0, GetNTimesteps()-1); addDerivedVariables(md, timeState); }