Commit 5aaaf54b authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added function fieldAdd().

parent c9843182
......@@ -412,16 +412,7 @@ Vertintap(void *process)
{
ps_prog.init(varList1[dpressID]);
fieldFill(ps_prog, 0);
if (memtype == MemType::Float)
{
for (int k = 0; k < nhlevf; ++k)
for (size_t i = 0; i < gridsize; i++) ps_prog.vec_f[i] += vardata1[dpressID].vec_f[k * gridsize + i];
}
else
{
for (int k = 0; k < nhlevf; ++k)
for (size_t i = 0; i < gridsize; i++) ps_prog.vec_d[i] += vardata1[dpressID].vec_d[k * gridsize + i];
}
for (int k = 0; k < nhlevf; ++k) fieldAdd(ps_prog, vardata1[dpressID], k);
}
else
{
......
......@@ -133,6 +133,17 @@ void fieldCopy(const Field3D &field_src, int levelID, Field &field_tgt)
std::copy(field_src.vec_d.begin() + offset, field_src.vec_d.begin() + offset + size, field_tgt.vec_d.begin());
}
void fieldAdd(Field &field1, const Field3D &field2, int levelID)
{
const auto size = field1.gridsize * field1.nwpv;
const auto offset = levelID * size;
if (field1.memType == MemType::Float)
for (size_t i = 0; i < size; i++) field1.vec_f[i] += field2.vec_f[offset + i];
else
for (size_t i = 0; i < size; i++) field1.vec_d[i] += field2.vec_d[offset + i];
}
// functor that returns true if value is equal to the value of the constructor parameter provided
class valueDblIsEqual
{
......
......@@ -90,6 +90,7 @@ using Field3DVector = std::vector<Field3D>;
void fieldFill(Field &field, double value);
void fieldCopy(const Field &field_src, Field &field_tgt);
void fieldCopy(const Field3D &field_src, int levelID, Field &field_tgt);
void fieldAdd(Field &field1, const Field3D &field2, int levelID);
size_t fieldNumMiss(const Field &field);
size_t fieldNumMV(Field &field);
std::pair<double, double> fieldMinMax(Field &field);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment