Fix ForcingBody function with mixed coordinates and equation variables
If equation variables are used in the ForcingBody function, the coordinate Arrays are allocated but not assigned value. The defaul value 0 is used for all coordinate variables. This patch can be applied to have a quick fix.
diff --git a/library/SolverUtils/Forcing/ForcingBody.cpp b/library/SolverUtils/Forcing/ForcingBody.cpp
index 57d407be2..6a21b8e76 100644
--- a/library/SolverUtils/Forcing/ForcingBody.cpp
+++ b/library/SolverUtils/Forcing/ForcingBody.cpp
@@ -136,6 +136,7 @@ void ForcingBody::Update(
// Coupled forcing
int nq = pFields[0]->GetNpoints();
Array<OneD, NekDouble> xc(nq), yc(nq), zc(nq), t(nq, time);
+ pFields[0]->GetCoords(xc, yc, zc);
std::string varstr = "x y z";
std::vector<Array<OneD, const NekDouble>> fielddata = {xc, yc,
zc, t};
In the ForcingBody, the coordinate Arrays and variable Arrays are allocated and released in each loop. This overhead is unnecessary. We can reformat this process to imporve its performance and ability.
In addition,
-
In the v_InitObject function, automatically find which coordinate or variable is used in the expression.
-
The body force doesn't need to be defined for all variables.
Edited by Ankang Gao