Commit 396aad77 authored by whitlocb's avatar whitlocb

Fixed expressions in batch simulations. Fix operator-created variables in...

Fixed expressions in batch simulations. Fix operator-created variables in batch simulations. Fixed a streamline export bug.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@29521 18c085ea-50e0-402c-830e-de6fd14e8384
parent 18653e55
......@@ -1408,6 +1408,10 @@ avtPICSFilter::Execute(void)
}
else
{
// Clear _ics, which would contain stale pointers to ic's that
// no longer seem to exist. This comes up in export.
_ics.clear();
GetIntegralCurvesFromInitialSeeds(_ics);
icAlgo->SetAllSeedsSentToAllProcs( GetAllSeedsSentToAllProcs() );
......
......@@ -42,8 +42,12 @@
#include <DebugStream.h>
#include <DatabasePluginManager.h>
#include <DatabasePluginInfo.h>
#include <ExpressionList.h>
#include <Expression.h>
#include <ParsingExprList.h>
#include <SimPlotPluginManager.h>
#include <SimOperatorPluginManager.h>
#include <OperatorPluginInfo.h>
#include <PlotPluginInfo.h>
#include <LoadBalancer.h>
#include <NetworkManager.h>
......@@ -85,6 +89,12 @@
#include <SimPlotPluginManager.h>
#include <SimOperatorPluginManager.h>
#include <VisItParser.h>
#include <avtExprNodeFactory.h>
#include <ExprParser.h>
#include <avtDatabaseMetaData.h>
#include <avtParallel.h>
#include <cstring>
#include <sstream>
......@@ -158,6 +168,13 @@ SimEngine::SimEngine() : Engine()
#endif
, viewerInitialized(false), simsource(), rpcNotifier(NULL)
{
// Install an avtExprNodeFactory object in the parser. This is critical for
// making the parser create avt versions of the parse objects, which is needed
// for the various dynamic_cast calls in the expression library to convert
// the avt*Expr objects.
Parser *p = new ExprParser(new avtExprNodeFactory());
// This saves the instance in ParsingExprList::Instance(). Don't free.
ParsingExprList *l = new ParsingExprList(p);
}
// ****************************************************************************
......@@ -293,6 +310,70 @@ SimEngine::CreatePluginManagers()
GetNetMgr()->SetDatabasePluginManager(new DatabasePluginManager());
}
// ****************************************************************************
// Method: SimEngine::SimulationTimeStepChanged
//
// Purpose:
// This method is called when we change timesteps.
//
// Note: We need this for in situ.
//
// Programmer: Brad Whitlock
// Creation: Fri Oct 14 15:02:36 PDT 2016
//
// Modifications:
//
// ****************************************************************************
void
SimEngine::SimulationTimeStepChanged()
{
// Get the new metadata from the simulation, save it.
Engine::SimulationTimeStepChanged();
// Let's the use new metadata to make sure that expressions are up to date.
ExpressionList newList;
//
// Create a new expression list that contains all of the expressions
// from the main expression list that are not expressions that come
// from databases.
//
ExpressionList *exprList = ParsingExprList::Instance()->GetList();
for(int i = 0; i < exprList->GetNumExpressions(); ++i)
{
const Expression &expr = exprList->GetExpressions(i);
if(!expr.GetFromDB() && !expr.GetFromOperator())
newList.AddExpressions(expr);
}
// Add the expressions for the database.
for (int i = 0 ; i < metaData->GetNumberOfExpressions(); ++i)
newList.AddExpressions(*(metaData->GetExpression(i)));
// NOTE: adapted from VariableMenuPopulator::GetOperatorCreatedExpressions
// Iterate over the meshes in the metadata and add operator-created expressions
// for each relevant mesh.
avtDatabaseMetaData md2 = *metaData;
md2.GetExprList() = newList;
for(int j = 0; j < GetOperatorPluginManager()->GetNEnabledPlugins(); j++)
{
std::string id(GetOperatorPluginManager()->GetEnabledID(j));
CommonOperatorPluginInfo *ComInfo = GetOperatorPluginManager()->GetCommonPluginInfo(id);
ExpressionList *fromOperators = ComInfo->GetCreatedExpressions(&md2);
if(fromOperators != NULL)
{
for(int k = 0; k < fromOperators->GetNumExpressions(); k++)
newList.AddExpressions(fromOperators->GetExpressions(k));
delete fromOperators;
}
}
// Stash the expressions.
if(newList != *exprList)
*exprList = newList;
}
// ****************************************************************************
// Method: SimEngine::SimulationInitiateCommand
//
......
......@@ -74,6 +74,7 @@ public:
SimEngine();
virtual ~SimEngine();
virtual void SimulationTimeStepChanged();
virtual void SimulationInitiateCommand(const std::string &command);
void InitializeViewer(const std::vector<std::string> &plotPlugins,
......
......@@ -64,13 +64,6 @@ visit_handle SimGetMesh(int, const char *, void *);
visit_handle SimGetVariable(int, const char *, void *);
visit_handle SimGetDomainList(const char *, void *);
#ifdef DEFINE_EXPRESSIONS
/* Expression names and definitions. */
static const char *exprNames[] = {"nid", "zid", "xc", "yc", "zc", "radius"};
static const char *exprDefinitions[] = {"nodeid(mesh)", "zoneid(mesh)",
"coord(mesh)[0]", "coord(mesh)[1]", "coord(mesh)[2]", "sqrt(xc*xc+yc*yc+zc*zc)"};
#endif
/******************************************************************************
* Simulation data and functions
******************************************************************************/
......@@ -257,6 +250,20 @@ void mainloop_batch(simulation_data *sim)
double origin[] = {5., 5., 5.}, normal[] = {0., 0.707, 0.707};
double isos[] = {5., 11., 18.};
double v0[] = {1.,1.,1.}, v1[] = {5., 1.5, 7.}, v2[] = {8., 2., 5.};
double seeds[] = {
0.5, 0.5, 0.5,
1.5, 0.5, 0.5,
2.5, 0.5, 0.5,
3.5, 0.5, 0.5,
4.5, 0.5, 0.5,
5.5, 0.5, 0.5,
0.5, 4.5, 0.5,
1.5, 4.5, 0.5,
2.5, 4.5, 0.5,
3.5, 4.5, 0.5,
4.5, 4.5, 0.5,
5.5, 4.5, 0.5};
int lseeds = sizeof(seeds) / sizeof(double);
#ifdef PARALLEL
double init0, init1;
init0 = MPI_Wtime();
......@@ -331,6 +338,14 @@ void mainloop_batch(simulation_data *sim)
{
printf("iso export returned %s\n", extract_err(err));
}
/* NOTE: This exercises expressions and operator-created vars. */
sprintf(filebase, "streamline_%04d", sim->cycle);
err = extract_streamline(filebase, "vec", seeds, lseeds, extractvars);
if(sim->par_rank == 0)
{
printf("streamline export returned %s\n", extract_err(err));
}
}
if(sim->render)
......@@ -391,7 +406,7 @@ int main(int argc, char **argv)
#if 1
/* Let's restrict the plugins that we load in batch. */
strcpy(options, "-plotplugins Contour,Mesh,Pseudocolor -operatorplugins Slice,Isosurface,Threshold -noconfig");
strcpy(options, "-plotplugins Contour,Mesh,Pseudocolor -operatorplugins Slice,IntegralCurve,Isosurface,Threshold -noconfig");
opt = options + strlen(options);
#else
opt = options;
......@@ -581,9 +596,8 @@ SimGetMetaData(void *cbdata)
{
visit_handle mmd = VISIT_INVALID_HANDLE;
visit_handle vmd = VISIT_INVALID_HANDLE;
#ifdef DEFINE_EXPRESSIONS
visit_handle emd = VISIT_INVALID_HANDLE;
#endif
/* Set the simulation state. */
VisIt_SimulationMetaData_setMode(md, VISIT_SIMMODE_RUNNING);
VisIt_SimulationMetaData_setCycleTime(md, sim->cycle, sim->time);
......@@ -651,19 +665,15 @@ SimGetMetaData(void *cbdata)
VisIt_VariableMetaData_setCentering(vmd, VISIT_VARCENTERING_NODE);
VisIt_SimulationMetaData_addVariable(md, vmd);
}
#ifdef DEFINE_EXPRESSIONS
/* Add expressions for VisIt to calculate. */
for(i = 0; i < 6; ++i)
if(VisIt_ExpressionMetaData_alloc(&emd) == VISIT_OKAY)
{
if(VisIt_ExpressionMetaData_alloc(&emd) == VISIT_OKAY)
{
VisIt_ExpressionMetaData_setName(emd, exprNames[i]);
VisIt_ExpressionMetaData_setDefinition(emd, exprDefinitions[i]);
VisIt_ExpressionMetaData_setType(emd, VISIT_VARTYPE_SCALAR);
VisIt_SimulationMetaData_addExpression(md, emd);
}
VisIt_ExpressionMetaData_setName(emd, "vec");
VisIt_ExpressionMetaData_setDefinition(emd, "gradient(radius)");
VisIt_ExpressionMetaData_setType(emd, VISIT_VARTYPE_VECTOR);
VisIt_SimulationMetaData_addExpression(md, emd);
}
#endif
}
return md;
......
......@@ -198,3 +198,32 @@ int extract_iso(const char *filebase, const char *isovar,
return retval;
}
int extract_streamline(const char *filebase, const char *vectorvar,
const double *seeds, int lseeds, const char **extractvars)
{
int retval = -1;
char opvarname[1024];
if(filebase == NULL || vectorvar == NULL || seeds == NULL || lseeds < 3 || extractvars == NULL)
return -1;
/* 2.10.x has a Streamline plot. 2.11.x and later does not so use IntegralCurve. */
/* We have to make a plot of an operator-created var.*/
sprintf(opvarname, "operators/IntegralCurve/%s", vectorvar);
if(VisItAddPlot("Pseudocolor", opvarname) == VISIT_OKAY)
{
/* Adding the plot also added the IntegralCurve operator. */
VisItSetOperatorOptionsI("sourceType", 1); /* point list */
VisItSetOperatorOptionsDv("pointList", seeds, lseeds);
if(VisItDrawPlots() == VISIT_OKAY)
{
retval = export_visit(filebase, extractvars);
}
VisItDeleteActivePlots();
}
return retval;
}
......@@ -25,4 +25,7 @@ int extract_iso(const char *filebase, const char *isovar,
const double *isovalues, int nisovalues,
const char **extractvars);
int extract_streamline(const char *filebase, const char *vectorvar,
const double *seeds, int lseeds, const char **extractvars);
#endif
......@@ -8076,45 +8076,6 @@ ViewerPlotList::UpdateExpressionList(bool considerPlots, bool update)
ExpressionList newList;
GetViewerStateManager()->GetVariableMethods()->GetAllExpressions(newList, host, db, t);
//
// Update the expression list with the set of variables
// created by the operators in the active plots.
//
// First, remove the old ones since we're about to regenerate them.
for (int i=newList.GetNumExpressions()-1 ; i>=0; --i)
{
if (newList[i].GetFromOperator())
{
newList.RemoveExpressions(i);
}
}
// Then add everything created by any active plots' operators.
for (int i=0 ; i < nPlots ; i++)
{
if (!plots[i].active)
continue;
ViewerPlot *plot = plots[i].plot;
for (int j = 0 ; j < plot->GetNOperators() ; j++)
{
ViewerOperator *oper = plot->GetOperator(j);
const avtDatabaseMetaData *md = plot->GetMetaData();
ExpressionList *exprs = oper->GetCreatedVariables(md);
if (exprs != NULL)
{
for (int k = 0 ; k < exprs->GetNumExpressions() ; k++)
{
Expression exp = exprs->GetExpressions(k);
exp.SetFromOperator(true);
newList.AddExpressions(exp);
}
delete exprs;
}
}
}
//
// If the new expression list is different from the expression list
// that we already have, save the new expression list and send it to
......
......@@ -46,6 +46,8 @@
#include <DebugStream.h>
#include <ExpressionList.h>
#include <Expression.h>
#include <OperatorPluginInfo.h>
#include <OperatorPluginManager.h>
#include <ParsingExprList.h>
#include <VisItException.h>
......@@ -279,7 +281,7 @@ ViewerVariableMethods::GetUserExpressions(ExpressionList &newList)
for(int i = 0; i < exprList->GetNumExpressions(); ++i)
{
const Expression &expr = exprList->GetExpressions(i);
if(!expr.GetFromDB())
if(!expr.GetFromDB() && !expr.GetFromOperator())
newList.AddExpressions(expr);
}
}
......@@ -316,7 +318,7 @@ ViewerVariableMethods::GetDatabaseExpressions(ExpressionList &newList,
{
// Store all of the specified database's expressions in the
// new list.
if(host.size() > 0 && db.size() > 0)
if(!host.empty() && !db.empty())
{
const avtDatabaseMetaData *md = 0;
if(state == ViewerFileServerInterface::ANY_STATE)
......@@ -332,12 +334,76 @@ ViewerVariableMethods::GetDatabaseExpressions(ExpressionList &newList,
}
}
// ****************************************************************************
// Method: ViewerVariableMethods::GetOperatorCreatedExpressions
//
// Purpose:
// Gets the operator-created expressions for the specified database.
//
// Arguments:
// newList : The return list for the database expressions.
// host : The host where the database is located.
// db : The database name.
// state : The database time state.
//
// Returns: The list of database expressions.
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Fri Feb 18 09:45:27 PDT 2005
//
// Modifications:
//
// ****************************************************************************
void
ViewerVariableMethods::GetOperatorCreatedExpressions(ExpressionList &newList,
const std::string &host, const std::string &db, int state)
{
// Store all of the specified database's expressions in the
// new list.
if(!host.empty() && !db.empty())
{
const avtDatabaseMetaData *md = 0;
if(state == ViewerFileServerInterface::ANY_STATE)
md = GetViewerFileServer()->GetMetaData(host, db);
else
md = GetViewerFileServer()->GetMetaDataForState(host, db, state);
if (md != 0)
{
// Start with the user's expressions and this database's expressions.
ExpressionList userAndDB;
GetUserExpressions(userAndDB);
for (int i = 0 ; i < md->GetNumberOfExpressions(); ++i)
userAndDB.AddExpressions(*(md->GetExpression(i)));
// We'll make operator-created expressions for all user and db expressions.
// Note that we only append the operator-created expressions to the return.
avtDatabaseMetaData md2 = *md;
md2.GetExprList() = userAndDB;
for(int j = 0; j < GetOperatorPluginManager()->GetNEnabledPlugins(); j++)
{
std::string id(GetOperatorPluginManager()->GetEnabledID(j));
CommonOperatorPluginInfo *ComInfo = GetOperatorPluginManager()->GetCommonPluginInfo(id);
ExpressionList *fromOperators = ComInfo->GetCreatedExpressions(&md2);
if(fromOperators != NULL)
{
for(int k = 0; k < fromOperators->GetNumExpressions(); k++)
newList.AddExpressions(fromOperators->GetExpressions(k));
delete fromOperators;
}
}
}
}
}
// ****************************************************************************
// Method: ViewerVariableMethods::GetAllExpressions
//
// Purpose:
// Gets user-defined expressions and the expressions for the specified
// database.
// Gets user-defined expressions, the expressions for the specified
// database, and the operator-created expressions .
//
// Arguments:
// newList : The return list for the database expressions.
......@@ -358,8 +424,8 @@ void
ViewerVariableMethods::GetAllExpressions(ExpressionList &newList,
const std::string &host, const std::string &db, int state)
{
// Store all of the expressions that are not database expressions
// in the new list.
// Store all of the expressions in the new list.
GetUserExpressions(newList);
GetDatabaseExpressions(newList, host, db, state);
GetOperatorCreatedExpressions(newList, host, db, state);
}
......@@ -82,6 +82,10 @@ public:
const std::string &host,
const std::string &db,
int state);
void GetOperatorCreatedExpressions(ExpressionList &newList,
const std::string &host,
const std::string &db,
int state);
void GetAllExpressions(ExpressionList &newList,
const std::string &host,
const std::string &db,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment