SpatialOps

All Nebo field operations are within the SpatialOps
namespace and are defined/implemented in the file NeboOperators.h. For the most part, users should not need to look at implementations, which use template metaprogramming extensively.
To access any of these operators, please use:
A Nebo Expression can be:
1.3
, 2
etc.Each Nebo Expression has a field type. Each subexpression of an expression must have the same field type. If two incompatible field types are used in the same expression, the code will NOT compile, and it will result in a lengthy compiler error.
In the following table, result
refers to a SpatialField whereas arg1
and arg2
can be a scalar, SpatialField or Nebo expression. All operations are applied pointwise on the arguments.
Operation  Operator  Basic Syntax  Reference 

Addition  +  result <<= arg1 + arg2  SpatialOps::SumOp 
Subtraction    result <<= arg1  arg2  SpatialOps::DiffOp 
Multiplication  *  result <<= arg1 * arg2  SpatialOps::ProdOp 
Division  /  result <<= arg1 / arg2  SpatialOps::DivOp 
Negation    result <<= arg  SpatialOps::NegFcn 
In the following table, result
refers to a SpatialField whereas arg
can be a scalar, SpatialField or Nebo expression. All operations are applied pointwise on the arguments.
Operation  Operator  Basic Syntax  Reference 

cosine  cos  result <<= cos(arg)  SpatialOps::CosFcn 
sine  sin  result <<= sin(arg)  SpatialOps::SinFcn 
tangent  tan  result <<= tan(arg)  SpatialOps::TanFcn 
exponential (with base 'e')  exp  result <<= exp(arg)  SpatialOps::ExpFcn 
error function  erf  result <<= erf(arg)  SpatialOps::ErfFcn 
inverse error function  inv_erf  result <<= inv_erf(arg)  SpatialOps::InvErfFcn 
complimentary error function  erfc  result <<= erfc(arg)  SpatialOps::ErfcFcn 
inverse complimentary error function  inv_erfc  result <<= inv_erfc(arg)  SpatialOps::InvErfcFcn 
hyperbolic tan  tanh  result <<= tanh(arg)  SpatialOps::TanhFcn 
gamma function  gamma  result <<= gamma(arg)  SpatialOps::GammaFcn 
natural logarithm  log  result <<= log(arg)  SpatialOps::LogFcn 
base 10 logarithm  log10  result <<= log10(arg)  SpatialOps::Log10Fcn 
exponentiation (with given base 'arg')  pow  result <<= pow(arg,val)  SpatialOps::PowFcn 
square root  sqrt  result <<= sqrt(arg)  SpatialOps::SqrtFcn 
square  square  result <<= square(arg)  SpatialOps::SquareFcn 
cube  cube  result <<= cube(arg)  SpatialOps::CubeFcn 
absolute value  abs  result <<= abs(arg)  SpatialOps::AbsFcn 
Comparison operators perform pointwise comparisons. In the following table, arg1
and arg2
can be scalars, SpatialFields, or Nebo expressions. These comparison operations are typically used with cond.
Operation  Operator  Basic Syntax  Reference 

Greater than  >  arg1 > arg2  SpatialOps::GreaterThanCmp 
Less than  <  arg1 < arg2  SpatialOps::LessThanCmp 
Equal to  ==  arg1 == arg2  SpatialOps::EqualCmp 
Greater or equal to  >=  arg1 >= arg2  SpatialOps::GreaterThanEqualCmp 
Less or equal to  <=  arg1 <= arg2  SpatialOps::LessThanEqualCmp 
Not equal to  !=  arg1 != arg2  SpatialOps::InequalCmp 
Below, result
is a field containing the pointwise result of the associated operation on arg1
and arg2
which can be scalars, SpatialFields or Nebo expressions:
Operation  Operator  Basic Syntax  Reference 

Maximum  max  result <<= max(arg1,arg2)  SpatialOps::MaxFcn 
Minimum  min  result <<= min(arg1,arg2)  SpatialOps::MinFcn 
Nebo logical operators perform pointwise combinations of the results of comparison operations and / or masks.
Operation  Operator  Basic Syntax  Reference 

And  &&  result <<= expr1 && expr2  SpatialOps::AndOp 
Or    result <<= expr1  expr2  SpatialOps::OrOp 
Not  !  result <<= !expr  SpatialOps::NotOp 
Operation  Operator  Basic Syntax 

max  nebo_max  result <<= nebo_max( expr ) 
min  nebo_min  result <<= nebo_min( expr ) 
sum  nebo_sum  result <<= nebo_sum( expr ) 
L2 norm  nebo_norm  result <<= nebo_norm( expr ) 
There are also variants of these operations that exclude ghost cells:
Operation  Operator  Basic Syntax 

max  nebo_max_interior  result <<= nebo_max_interior( expr ) 
min  nebo_min_interior  result <<= nebo_min_interior( expr ) 
sum  nebo_sum_interior  result <<= nebo_sum_interior( expr ) 
L2 norm  nebo_norm_interior  result <<= nebo_norm_interior( expr ) 
Frequently one wishes to perform calculations of the form:
for i if ( condition1 ) f[i] = something; else if( condition2 ) f[i] = something else; ... else f[i] = some default; end
In Nebo, this is accomplished via cond
which has the basic syntax:
f <<= cond( condition1, result1 ) ( condition2, result2 ) ... ( defaultResult );
There are a few guidelines/rules when using cond
for
loop example above.cond
as summarized in the following table: Item  Valid inputs 

condition  Nebo comparison operators or logical operators or masks 
result  Scalar, SpatialField, or Nebo expression 
cond
expression must have at least one clause, and the requirements for each clause are as follows:A few examples of cond:
The conditional statement if and the ternary operator ( ? : ) cannot be overloaded in C++. Thus, to have pointwise conditional evaluation over fields, Nebo introduces cond
, as used in many functional languages (introduced by LISP). Fortunately, cond
fits into Nebo's syntax through C++ operator overloading and template metaprogramming, which Nebo exploits. Additionally, through the use of inlined templated functions, cond
compiles down to nested ternary operators ( ? : ). Thus, while the templates for cond
are not simple, the executed code is simple and efficient.