AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Variable.cpp File Reference

Virtual variables environment to allow the user define/manipulate the variables used in the simulation externally. (see Aqua::InpuOutput::Variable and Aqua::InpuOutput::Variables) More...

#include <algorithm>
#include <sstream>
#include "Variable.hpp"
#include "AuxiliarMethods.hpp"
#include "InputOutput/Logger.hpp"
#include "CalcServer/CalcServer.hpp"
Include dependency graph for Variable.cpp:

Namespaces

namespace  Aqua
 Main AQUAgpusph namespace.
namespace  Aqua::InputOutput
 Input/Output data interfaces.

Macros

#define __DEFINE_AQUA_VEC(NAME, TYPE, DIMS, NPTYPE)
#define SPLIT_EXPR_AND_CHECK(var_name, expr, exprs_out, n)
#define SCALAR_SOLVER(vartype, toktype)
#define VEC_SOLVER(vartype, toktype, n)
#define REG_VEC_BLOCK(TYPE)

Functions

std::string Aqua::InputOutput::npy_type_name (int np_type)
template<typename T>
const std::string Aqua::InputOutput::valptr_as_string (T *ptr, unsigned int n)
 Stringify a value pointer.
std::string Aqua::InputOutput::tokNameToVarName (const std::string &name)
 Convert the names populated at the tokenizer to variable names.

Variables

static std::ostringstream Aqua::InputOutput::pyerr

Detailed Description

Virtual variables environment to allow the user define/manipulate the variables used in the simulation externally. (see Aqua::InpuOutput::Variable and Aqua::InpuOutput::Variables)

Macro Definition Documentation

◆ __DEFINE_AQUA_VEC

#define __DEFINE_AQUA_VEC ( NAME,
TYPE,
DIMS,
NPTYPE )
Value:
NAME::NAME(const std::string varname) \
: ScalarVecVariable(varname, #TYPE, DIMS, NPTYPE) \
{ \
for (unsigned int i = 0; i < DIMS; i++) \
_value.s[i] = 0; \
}
#define DIMS
Definition PST.cl:43

◆ REG_VEC_BLOCK

#define REG_VEC_BLOCK ( TYPE)
Value:
else if (!type.compare(#TYPE)) { \
TYPE ## Variable* var = new TYPE ## Variable(name); \
if (value.compare("")) { \
TYPE val = solve<TYPE>(name, value); \
var->set(&val); \
} \
_vars.push_back(var); \
}

◆ SCALAR_SOLVER

#define SCALAR_SOLVER ( vartype,
toktype )
Value:
template<> \
vartype \
Variables::solve(const std::string& name, const std::string& value) \
{ \
SPLIT_EXPR_AND_CHECK(name, value, value_strs, 1); \
toktype val = tok.solve<toktype>(value_strs[0]); \
tok.registerVariable<toktype>(name, val); \
return (vartype)val; \
}

◆ SPLIT_EXPR_AND_CHECK

#define SPLIT_EXPR_AND_CHECK ( var_name,
expr,
exprs_out,
n )
Value:
std::vector<std::string> exprs_out = split_formulae(expr); \
if (exprs_out.size() < n) { \
std::ostringstream msg; \
msg << "Failure parsing the expression \"" << expr \
<< "\" for variable \"" << var_name << "\"" << std::endl; \
LOG(L_ERROR, msg.str()); \
msg.str(""); \
msg << n << " fields required instead of " << exprs_out.size() \
<< std::endl; \
LOG0(L_DEBUG, msg.str()); \
throw std::runtime_error("Invalid number of fields"); \
}

◆ VEC_SOLVER

#define VEC_SOLVER ( vartype,
toktype,
n )
Value:
template<> \
vartype \
Variables::solve(const std::string& name, const std::string& value) \
{ \
vartype out; \
const char* extensions[16] = { "_x", "_y", "_z", "_w", \
"_yx", "_yy", "_yz", "_yw", \
"_zx", "_zy", "_zz", "_zw", \
"_wx", "_wy", "_wz", "_ww" }; \
SPLIT_EXPR_AND_CHECK(name, value, value_strs, n); \
for (unsigned int i = 0; i < n; i++) { \
toktype val = tok.solve<toktype>(value_strs[i]); \
tok.registerVariable(name + extensions[i], val); \
out.s[i] = val; \
} \
return out; \
}