@@ -12,27 +12,32 @@ namespace adios2
1212namespace core
1313{
1414
15- VariableDerived::VariableDerived (const std::string &name, adios2::derived::Expression expr,
16- const DataType exprType, const bool isConstant,
17- const DerivedVarType varType,
15+ VariableDerived::VariableDerived (const std::string &name, adios2::derived::ExprNode exprTree,
16+ adios2::derived::ExprCodeStream codeStream,
17+ const std::string &exprString, const DataType exprType,
18+ const Dims &shape, const Dims &start, const Dims &count,
19+ const bool isConstant, const DerivedVarType varType,
1820 const std::map<std::string, DataType> nameToType)
19- : VariableBase(name, exprType, helper::GetDataTypeSize(exprType), expr.GetShape(), expr.GetStart( ),
20- expr.GetCount( ), isConstant ),
21- m_DerivedType (varType), m_NameToType(nameToType), m_Expr(expr )
21+ : VariableBase(name, exprType, helper::GetDataTypeSize(exprType), shape, start, count, isConstant ),
22+ m_DerivedType (varType), m_NameToType(nameToType ), m_ExprTree(std::move(exprTree) ),
23+ m_CodeStream(std::move(codeStream)), m_ExprString(exprString )
2224{
2325 if (varType != DerivedVarType::StoreData)
2426 m_WriteData = false ;
2527}
2628
2729DerivedVarType VariableDerived::GetDerivedType () { return m_DerivedType; }
2830
29- std::vector<std::string> VariableDerived::VariableNameList () { return m_Expr.VariableNameList (); }
31+ std::vector<std::string> VariableDerived::VariableNameList () { return m_CodeStream.InputVarNames ; }
32+
3033void VariableDerived::UpdateExprDim (std::map<std::string, std::tuple<Dims, Dims, Dims>> NameToDims)
3134{
32- m_Expr.SetDims (NameToDims);
33- m_Shape = m_Expr.GetShape ();
34- m_Start = m_Expr.GetStart ();
35- m_Count = m_Expr.GetCount ();
35+ auto outDims = adios2::derived::GetDims (m_CodeStream, NameToDims);
36+ m_Shape = std::get<2 >(outDims);
37+ m_Start = std::get<0 >(outDims);
38+ m_Count = std::get<1 >(outDims);
39+ if (!m_Shape.empty ())
40+ m_ShapeID = ShapeID::GlobalArray;
3641}
3742
3843std::vector<std::tuple<void *, Dims, Dims>>
@@ -80,7 +85,7 @@ VariableDerived::ApplyExpression(std::map<std::string, std::unique_ptr<MinVarInf
8085 inputData.insert ({variable.first , varData});
8186 }
8287 std::vector<adios2::derived::DerivedData> outputData =
83- m_Expr. ApplyExpression ( numBlocks, inputData);
88+ adios2::derived::Execute (m_CodeStream, numBlocks, inputData);
8489
8590 std::vector<std::tuple<void *, Dims, Dims>> blockData;
8691 for (size_t i = 0 ; i < numBlocks; i++)
@@ -115,7 +120,7 @@ VariableDerived::CreateEmptyData(std::map<std::string, std::unique_ptr<MinVarInf
115120 nameToDims.insert ({variable.first , varDims});
116121 }
117122
118- auto outputDims = m_Expr. GetDims (nameToDims);
123+ auto outputDims = adios2::derived:: GetDims (m_CodeStream, nameToDims);
119124
120125 blockData.push_back ({nullptr , std::get<0 >(outputDims), std::get<1 >(outputDims)});
121126 }
0 commit comments