diff --git a/src/avt/Expressions/Abstract/avtExpressionFilter.C b/src/avt/Expressions/Abstract/avtExpressionFilter.C index f122e654747..445df1e4e41 100644 --- a/src/avt/Expressions/Abstract/avtExpressionFilter.C +++ b/src/avt/Expressions/Abstract/avtExpressionFilter.C @@ -51,9 +51,6 @@ using namespace std; // Hank Childs, Thu Aug 26 16:36:30 PDT 2010 // Initialize calculateExtents. // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Initialize nProcessedArgs. -// // **************************************************************************** avtExpressionFilter::avtExpressionFilter() @@ -61,7 +58,6 @@ avtExpressionFilter::avtExpressionFilter() outputVariableName = NULL; currentTimeState = 0; calculateExtents = false; - nProcessedArgs = 0; } @@ -102,9 +98,6 @@ avtExpressionFilter::~avtExpressionFilter() // actually avtExprNodes. This can happen when processing macro // expressions. // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Count the number of arguments that this filter processes here. -// // **************************************************************************** void @@ -128,7 +121,6 @@ avtExpressionFilter::ProcessArguments(ArgsExpr *args, ExprPipelineState *state) continue; } expr_node->CreateFilters(state); - nProcessedArgs++; } } diff --git a/src/avt/Expressions/Abstract/avtExpressionFilter.h b/src/avt/Expressions/Abstract/avtExpressionFilter.h index f109d4fee90..c8ebb19a3d9 100644 --- a/src/avt/Expressions/Abstract/avtExpressionFilter.h +++ b/src/avt/Expressions/Abstract/avtExpressionFilter.h @@ -90,10 +90,6 @@ class ExprNode; // Kathleen Biagas, Thu Apr 5 10:07:43 PDT 2012 // Added CreateArrayFromMesh. // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Added nProcessedArgs to keep track of the number of arguments that this -// filter processes in ProcessArguments(). -// // **************************************************************************** class EXPRESSION_API avtExpressionFilter : virtual public @@ -125,7 +121,6 @@ class EXPRESSION_API avtExpressionFilter : virtual public protected: char *outputVariableName; int currentTimeState; - int nProcessedArgs; bool calculateExtents; virtual bool IsPointVariable(); diff --git a/src/avt/Expressions/Management/avtFunctionExpr_CreateMathFilters.C b/src/avt/Expressions/Management/avtFunctionExpr_CreateMathFilters.C index d8ad24186e5..6bb3d0da452 100644 --- a/src/avt/Expressions/Management/avtFunctionExpr_CreateMathFilters.C +++ b/src/avt/Expressions/Management/avtFunctionExpr_CreateMathFilters.C @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -30,8 +29,6 @@ #include #include -#include - #include // **************************************************************************** @@ -56,69 +53,61 @@ // Add log10withmin. This is possible with if, gt, and log, but more // efficiently implemented in a single filter. // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Alphabetically ordered by functionName for easier reading. -// Added "divide" filter. -// // **************************************************************************** avtExpressionFilter * avtFunctionExpr::CreateMathFilters(const std::string &functionName) const { - debug5 << "Entering avtFunctionExpr::CreateMathFilters(const string&)" << std::endl; avtExpressionFilter *f = 0; - if (functionName == "abs") - f = new avtAbsValExpression(); - else if (functionName == "acos") - f = new avtArccosExpression(); - else if (functionName == "asin") - f = new avtArcsinExpression(); - else if (functionName == "atan") - f = new avtArctanExpression(); - else if (functionName == "atan2") - f = new avtArctan2Expression(); - else if (functionName == "ceil") - f = new avtCeilingExpression(); + if (functionName == "sin") + f = new avtSinExpression(); + else if (functionName == "sinh") + f = new avtSinhExpression(); else if (functionName == "cos") f = new avtCosExpression(); else if (functionName == "cosh") f = new avtCoshExpression(); + else if (functionName == "tan") + f = new avtTanExpression(); + else if (functionName == "tanh") + f = new avtTanhExpression(); + else if (functionName == "atan") + f = new avtArctanExpression(); + else if (functionName == "atan2") + f = new avtArctan2Expression(); + else if (functionName == "asin") + f = new avtArcsinExpression(); + else if (functionName == "acos") + f = new avtArccosExpression(); else if (functionName == "deg2rad") f = new avtDegreeToRadianExpression(); - else if (functionName == "divide") - f = new avtBinaryDivideExpression(true); - else if (functionName == "exp") - f = new avtExpExpression(); - else if (functionName == "floor") - f = new avtFloorExpression(); + else if (functionName == "rad2deg") + f = new avtRadianToDegreeExpression(); + else if (functionName == "abs") + f = new avtAbsValExpression(); else if (functionName == "ln") f = new avtNaturalLogExpression(); + else if (functionName == "exp") + f = new avtExpExpression(); else if ((functionName == "log") || (functionName == "log10")) f = new avtBase10LogExpression(); else if (functionName == "log10withmin") f = new avtBase10LogWithMinExpression(); + else if (functionName == "sqrt") + f = new avtSquareRootExpression(); + else if ((functionName == "sq") || (functionName == "sqr")) + f = new avtSquareExpression(); else if (functionName == "mod" || functionName == "modulo") f = new avtModuloExpression(); - else if (functionName == "rad2deg") - f = new avtRadianToDegreeExpression(); - else if ((functionName == "random") || (functionName == "rand")) - f = new avtRandomExpression(); + else if (functionName == "ceil") + f = new avtCeilingExpression(); + else if (functionName == "floor") + f = new avtFloorExpression(); else if (functionName == "round") f = new avtRoundExpression(); - else if (functionName == "sin") - f = new avtSinExpression(); - else if (functionName == "sinh") - f = new avtSinhExpression(); - else if ((functionName == "sq") || (functionName == "sqr")) - f = new avtSquareExpression(); - else if (functionName == "sqrt") - f = new avtSquareRootExpression(); - else if (functionName == "tan") - f = new avtTanExpression(); - else if (functionName == "tanh") - f = new avtTanhExpression(); + else if ((functionName == "random") || (functionName == "rand")) + f = new avtRandomExpression(); - debug5 << "Exiting avtFunctionExpr::CreateMathFilters(const string&)" << std::endl; return f; } diff --git a/src/avt/Expressions/Math/avtBinaryDivideExpression.C b/src/avt/Expressions/Math/avtBinaryDivideExpression.C index 476a8801e3e..843ce73ec03 100644 --- a/src/avt/Expressions/Math/avtBinaryDivideExpression.C +++ b/src/avt/Expressions/Math/avtBinaryDivideExpression.C @@ -3,19 +3,15 @@ // details. No copyright assignment is required to contribute to VisIt. // ************************************************************************* // -// avtBinaryDivideExpression.C // +// avtBinaryDivideExpression.C // // ************************************************************************* // #include -#include #include #include -#include -#include #include -#include // **************************************************************************** @@ -28,26 +24,11 @@ // Programmer: Hank Childs // Creation: February 5, 2004 // -// Modifications: -// -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Populate class fields with default values. Added alternate constructor to -// be used when smart division is requested. -// // **************************************************************************** avtBinaryDivideExpression::avtBinaryDivideExpression() { - tolerance = 1e-16; - value_if_zero = 0.0; - smart_division = false; -} - -avtBinaryDivideExpression::avtBinaryDivideExpression(bool _process_anyways) -{ - tolerance = 1e-16; - value_if_zero = 0.0; - smart_division = _process_anyways; + ; } @@ -69,129 +50,6 @@ avtBinaryDivideExpression::~avtBinaryDivideExpression() } -// **************************************************************************** -// Method: avtBinaryDivideExpression::DeriveVariable -// -// Purpose: -// Derives the variable that results from the expression. At least two -// inputs are required, and there may be two option inputs if smart -// division is enabled. -// -// Arguments: -// in_ds The dataset from which to extract the desired variables -// involved in the expression. -// -// Returns: The derived variable that results from the expression. The -// calling class must free this memory. -// -// Programmer: Eddie Rusu -// Creation: Wed Sep 11 08:59:52 PDT 2019 -// -// **************************************************************************** - -vtkDataArray * -avtBinaryDivideExpression::DeriveVariable(vtkDataSet* in_ds, - int currentDomainsIndex) -{ - debug3 << "Entering avtBinaryDivideExpression::DeriveVariable(vtkDataSet*," - "int)" << std::endl; - // Get the variables and their centerings - avtCentering var1_centering; - avtCentering var2_centering; - vtkDataArray *data1 = DetermineCentering(&var1_centering, in_ds, - varnames[0]); - vtkDataArray *data2 = DetermineCentering(&var2_centering, in_ds, - varnames[1]); - - // If smart_division is activated, then we check for 3rd and 4th inputs. - if (smart_division) - { - // Check if there is a third variable. If so, that variable is the - // value_if_zero. - avtCentering dummy; - if (varnames.size() >= 3 && nProcessedArgs >= 3) - { - vtkDataArray *data3 = DetermineCentering(&dummy, in_ds, - varnames[2]); - value_if_zero = data3->GetTuple1(0); - debug5 << "avtBinaryDivideExpression::DeriveVariable: User " - "specified a divide_by_zero_value of " << value_if_zero - << "." << std::endl; - - } - // TODO: this feature can be easily enhanced to to handle a - // multi-variable divide by zero case. For example, suppose the user - // wants the value_if_zero to vary over the tuples/components as - // represented by some variable. This can be easily done here. - - // Check if there is a 4th variable. If so, that variable is the - // tolerance. - if (varnames.size() >= 4 && nProcessedArgs >= 4) - { - vtkDataArray *data4 = DetermineCentering(&dummy, in_ds, - varnames[3]); - tolerance = data4->GetTuple1(0); - if (tolerance < 0.0) - { - EXCEPTION2(ExpressionException, outputVariableName, - "tolerance must be nonnegative."); - } - debug5 << "avtBinaryDivideExpression::DeriveVariable: User " - "specified a tolerance of " << tolerance << "." - << std::endl; - } - // TODO: this feature can be easily enhanced to to handle a - // multi-variable divide by zero case. For example, suppose the user - // wants to specify varying tolernaces over the mesh as represented by - // some variable. This can be easily done here. - } - - - debug5 << "avtBinaryDivideExpression::DeriveVariable: Centering " - "determined. Now we recenter if needed" << std::endl; - // Determine the centering that should be used. - // If they have different centering (i.e. one has zone centering), then - // zone centering will be used. If they have the same centering, then - // whatever that centering is will be used. - if (var1_centering != var2_centering) - { - centering = AVT_ZONECENT; - if (var1_centering == AVT_NODECENT) - { - data1 = Recenter(in_ds, data1, var1_centering, outputVariableName); - } - else - { - data2 = Recenter(in_ds, data2, var2_centering, outputVariableName); - } - } - else - { - centering = var1_centering; - } - - debug5 << "avtBinaryDivideExpression::DeriveVariable: Values have been " - "recentered as needed. Now we perform the operation" << std::endl; - // Setup the output variable - int nComps1 = data1->GetNumberOfComponents(); - int nComps2 = data2->GetNumberOfComponents(); - int nComps = nComps1 >= nComps2 ? nComps1 : nComps2; - int nVals = data1->GetNumberOfTuples(); - if (nVals == 1) // data1 is a singleton - nVals = data2->GetNumberOfTuples(); - - vtkDataArray *output = vtkDoubleArray::New(); - output->SetNumberOfComponents(nComps); - output->SetNumberOfTuples(nVals); - - DoOperation(data1, data2, output, nComps, nVals); - - debug3 << "Exiting avtBinaryDivideExpression::DeriveVariable(" - "vtkDataSet*, int)" << std::endl; - return output; -} - - // **************************************************************************** // Method: avtBinaryDivideExpression::DoOperation // @@ -204,7 +62,7 @@ avtBinaryDivideExpression::DeriveVariable(vtkDataSet* in_ds, // in2 The second input data array. // out The output data array. // ncomponents The number of components ('1' for scalar, '2' or '3' for -// vectors, etc.). Not used for this filter. +// vectors, etc.) // ntuples The number of tuples (ie 'npoints' or 'ncells') // // Programmer: Sean Ahern
@@ -224,10 +82,6 @@ avtBinaryDivideExpression::DeriveVariable(vtkDataSet* in_ds, // Hank Childs, Mon Jan 14 17:58:58 PST 2008 // Add support for singleton constants. // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Defined 0 as a tolerance instead of absolutely 0.0. Added smart division -// in the form of CheckZero at each division. -// // **************************************************************************** void @@ -235,45 +89,52 @@ avtBinaryDivideExpression::DoOperation(vtkDataArray *in1, vtkDataArray *in2, vtkDataArray *out, int ncomponents, int ntuples) { - debug4 << "Entering avtBinaryDivideExpression::DoOperation(vtkDataArray*, " - "vtkDataArray*, vtkDataArray*, int, int)" << std::endl; bool var1IsSingleton = (in1->GetNumberOfTuples() == 1); bool var2IsSingleton = (in2->GetNumberOfTuples() == 1); int in1ncomps = in1->GetNumberOfComponents(); int in2ncomps = in2->GetNumberOfComponents(); if ((in1ncomps == 1) && (in2ncomps == 1)) { - debug5 << "avtBinaryDivideExpression::DoOperation: Scalar top and " - "bottom." << std::endl; for (int i = 0 ; i < ntuples ; i++) { vtkIdType tup1 = (var1IsSingleton ? 0 : i); vtkIdType tup2 = (var2IsSingleton ? 0 : i); double val1 = in1->GetTuple1(tup1); double val2 = in2->GetTuple1(tup2); - out->SetTuple1(i, CheckZero(val1,val2)); + if (val1 == 0. && val2 == 0.) + { + out->SetTuple1(i, 1.); + } + else if (val2 == 0. && val1 != 0.) + { + EXCEPTION2(ExpressionException, outputVariableName, + "You can't divide by zero"); + } + else + out->SetTuple1(i, val1 / val2); } } else if (in1ncomps > 1 && in2ncomps == 1) { - debug5 << "avtBinaryDivideExpression::DoOperation: Vector top, scalar " - "bottom." << std::endl; for (int i = 0 ; i < ntuples ; i++) { vtkIdType tup1 = (var1IsSingleton ? 0 : i); vtkIdType tup2 = (var2IsSingleton ? 0 : i); double val2 = in2->GetTuple1(tup2); + if (val2 == 0) + { + EXCEPTION2(ExpressionException, outputVariableName, + "You can't divide by zero"); + } for (int j = 0 ; j < in1ncomps ; j++) { double val1 = in1->GetComponent(tup1, j); - out->SetComponent(i, j, CheckZero(val1, val2)); + out->SetComponent(i, j, val1/val2); } } } else if (in1ncomps == 1 && in2ncomps > 1) { - debug5 << "avtBinaryDivideExpression::DoOperation: Scalar top, vector " - "bottom." << std::endl; for (int i = 0 ; i < ntuples ; i++) { vtkIdType tup1 = (var1IsSingleton ? 0 : i); @@ -282,7 +143,12 @@ avtBinaryDivideExpression::DoOperation(vtkDataArray *in1, vtkDataArray *in2, for (int j = 0 ; j < in2ncomps ; j++) { double val2 = in2->GetComponent(tup2, j); - out->SetComponent(i, j, CheckZero(val1, val2)); + if (val2 == 0) + { + EXCEPTION2(ExpressionException, outputVariableName, + "You can't divide by zero"); + } + out->SetComponent(i, j, val1/val2); } } } @@ -291,102 +157,6 @@ avtBinaryDivideExpression::DoOperation(vtkDataArray *in1, vtkDataArray *in2, EXCEPTION2(ExpressionException, outputVariableName, "Division of vectors in undefined."); } - debug4 << "Exiting avtBinaryDivideExpression::DoOperation(vtkDataArray*, " - "vtkDataArray*, vtkDataArray*, int, int)" << std::endl; -} - - -// **************************************************************************** -// Method: avtBinaryDivideExpression::DetermineCentering -// -// Purpose: -// Determines the centering of an input variable and outputs the -// data array. -// -// Arguments: -// centering_out A pointer to the centering variable. -// in_ds Dataset from which to extract the array. -// varname The name of the variable we want to extract. -// -// Returns: The cell- or node-centered data array. -// -// Programmer: Eddie Rusu -// Creation: Wed Sep 11 08:59:52 PDT 2019 -// -// **************************************************************************** - -vtkDataArray* -avtBinaryDivideExpression::DetermineCentering(avtCentering *centering_out, - vtkDataSet *in_ds, const char *varname) -{ - debug5 << "Entering avtBinaryDivideExpression::DetermineCentering(" - "avtCentering*, vtkDataSet*, const char*)" << std::endl; - debug5 << "\t For " << varname << std::endl; - vtkDataArray* out = in_ds->GetCellData()->GetArray(varname); - if (out == NULL) - { - out = in_ds->GetPointData()->GetArray(varname); - if (out == NULL) - { - EXCEPTION2(ExpressionException, outputVariableName, - "An internal error occurred when calculating an " - "expression. Please contact a VisIt developer."); - } - else - { - *(centering_out) = AVT_NODECENT; - debug5 << "Exiting avtBinaryDivideExpression::DetermineCentering(" - "avtCentering*, vtkDataSet*, const char*)" << std::endl; - return out; - } - } - else - { - *(centering_out) = AVT_ZONECENT; - debug5 << "Exiting avtBinaryDivideExpression::DetermineCentering(" - "avtCentering*, vtkDataSet*, const char*)" << std::endl; - return out; - } -} - - -// **************************************************************************** -// Method: avtBinaryDivideExpression::CheckZero -// -// Purpose: -// Checks the values involved in the division. If the denominator is -// within tolerance of zero, then we throw an exception. However, if smart -// division is activated, then we return the specified divide by zero -// value. -// -// Arguments: -// top The numerator. -// bottom The denominator. -// -// Programmer: Eddie Rusu -// Creation: Thu Aug 29 15:05:08 PDT 2019 -// -// **************************************************************************** - -double -avtBinaryDivideExpression::CheckZero(double top, double bottom) -{ - if (fabs(bottom) < this->tolerance) - { - if (this->smart_division) - { - return this->value_if_zero; - } - else - { - EXCEPTION2(ExpressionException, outputVariableName, - "You can't divide by zero"); - } - } - else - { - return top / bottom; - } } diff --git a/src/avt/Expressions/Math/avtBinaryDivideExpression.h b/src/avt/Expressions/Math/avtBinaryDivideExpression.h index 3b39ba58ae4..1c4cf1bf163 100644 --- a/src/avt/Expressions/Math/avtBinaryDivideExpression.h +++ b/src/avt/Expressions/Math/avtBinaryDivideExpression.h @@ -32,39 +32,23 @@ class vtkDataArray; // Hank Childs, Mon Jan 14 17:58:58 PST 2008 // Allow constants to be created as singletons. // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Added the notion and logic of "smart division" or "guarded division". -// // **************************************************************************** class EXPRESSION_API avtBinaryDivideExpression : public avtBinaryMathExpression { public: avtBinaryDivideExpression(); - avtBinaryDivideExpression(bool); virtual ~avtBinaryDivideExpression(); virtual const char *GetType(void) { return "avtBinaryDivideExpression"; }; virtual const char *GetDescription(void) { return "Calculating binary division"; }; - virtual int NumVariableArguments() { - return nProcessedArgs > 4 ? 4 : nProcessedArgs; - }; protected: - virtual vtkDataArray *DeriveVariable(vtkDataSet*, int); - virtual void DoOperation(vtkDataArray *in1, vtkDataArray *in2, - vtkDataArray *out, int ncomps, int ntuples); - virtual bool CanHandleSingletonConstants(void) {return true;}; - - private: - double tolerance; - double value_if_zero; - bool smart_division; - - vtkDataArray* DetermineCentering(avtCentering*, vtkDataSet*, const char*); - double CheckZero(double, double); + virtual void DoOperation(vtkDataArray *in1, vtkDataArray *in2, + vtkDataArray *out, int ncomps, int ntuples); + virtual bool CanHandleSingletonConstants(void) {return true;}; }; diff --git a/src/gui/QvisExpressionsWindow.C b/src/gui/QvisExpressionsWindow.C index f167036b096..609c9d240bf 100644 --- a/src/gui/QvisExpressionsWindow.C +++ b/src/gui/QvisExpressionsWindow.C @@ -159,9 +159,6 @@ // Kevin Griffin, Tue Aug 5 15:01:27 PDT 2014 // Added q_criterion and lambda2 // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Added "divide" function under the "Math" menu. -// // **************************************************************************** struct ExprNameList @@ -210,7 +207,6 @@ const char *expr_math[] = { "abs", "ceil", "floor", - "divide", "exp", "ln", "log10", @@ -1603,9 +1599,6 @@ QvisExpressionsWindow::UpdateStandardExpressionEditor(const QString &expr_def) // Brad Whitlock, Wed Sep 12 17:21:19 PDT 2012 // Add bin expression. // -// Eddie Rusu, Wed Sep 11 08:59:52 PDT 2019 -// Added divide expression with optional arguments. -// // **************************************************************************** QString @@ -1797,11 +1790,6 @@ QvisExpressionsWindow::ExpandFunction(const QString &func_name) res += QString("(, [0., 1., 2.])"); doParens = false; } - else if (func_name == "divide") - { - res += QString("(, , [, ])"); - doParens = false; - } if (doParens) { diff --git a/src/resources/help/en_US/relnotes3.0.2.html b/src/resources/help/en_US/relnotes3.0.2.html index ac6859a1f56..5a98785595e 100644 --- a/src/resources/help/en_US/relnotes3.0.2.html +++ b/src/resources/help/en_US/relnotes3.0.2.html @@ -50,7 +50,6 @@
  • The Xdmf reader now supports time-varying grid counts via a top-level <Information Name="TimeVaryingMetaData" Value="True"/> node in the Xdmf file.
  • Added a reader for Xolotl files. Xolotl is an open-source, high performance plasma-surface interactions simulator that is under development with the DOE's SciDAC program. VisIt will automatically recognize files that end with the extention ".xolotl" as Xolotl files.
  • Binary distributions have been added for Ubuntu 16, Ubuntu 18, Debian 9, and Fedora 27.
  • -
  • Added "divide" built-in expression for enhanced divison to allow users to specify divide by zero value and tolerance for zero.
  • Support for reading Uintah files has been added to the Red Hat Enterprise Linux 7, Ubunutu 16, Ubuntu 18, Debian 9 and Fedora 27 binary distributions.
  • diff --git a/src/test/tests/hybrid/expressions.py b/src/test/tests/hybrid/expressions.py index 942bb7c42da..02814bdcf2f 100644 --- a/src/test/tests/hybrid/expressions.py +++ b/src/test/tests/hybrid/expressions.py @@ -364,23 +364,6 @@ DeleteAllPlots() OpenDatabase(silo_data_path("rect2d.silo")) -# Test divide expression -DefineScalarExpression('divide1', 'divide(d,p)') -AddPlot('Pseudocolor','divide1') -DrawPlots() -Test('divide1') - -DefineScalarExpression('divide2', 'divide(d,p,0.0,2.0)') -AddPlot('Pseudocolor','divide2') -DrawPlots() -Test('divide2') -DeleteAllPlots() - -DefineScalarExpression('divide3', 'divide(d,p,1.0,2.0)') -AddPlot('Pseudocolor','divide3') -DrawPlots() -Test('divide3') - DefineScalarExpression("resrad", "resrad(recenter(u), 0.1)") AddPlot("Pseudocolor", "resrad") DrawPlots()