diff --git a/examples/fci-wave-logn/fci-wave.cxx b/examples/fci-wave-logn/fci-wave.cxx
index a6c3afaabd..d83bfeaa45 100644
--- a/examples/fci-wave-logn/fci-wave.cxx
+++ b/examples/fci-wave-logn/fci-wave.cxx
@@ -16,7 +16,7 @@ class FCIwave : public PhysicsModel {
Field3D Div_par_integrate(const Field3D &f) {
Field3D f_B = f / Bxyz;
- f_B.splitYupYdown();
+ f_B.createYupYdown();
mesh->getParallelTransform().integrateYUpDown(f_B);
// integrateYUpDown replaces all yup/down points, so the boundary conditions
@@ -106,7 +106,7 @@ class FCIwave : public PhysicsModel {
// Calculate the flux divergence using Div_par_integrate
Field3D nv = n * v;
- nv.splitYupYdown();
+ nv.createYupYdown();
for (const auto ® : mesh->getBoundariesPar()) {
Field3D &nv_next = nv.ynext(reg->dir);
nv_next.allocate();
diff --git a/examples/fci-wave/fci-wave.cxx b/examples/fci-wave/fci-wave.cxx
index 013acf6c91..c89b255c1b 100644
--- a/examples/fci-wave/fci-wave.cxx
+++ b/examples/fci-wave/fci-wave.cxx
@@ -17,7 +17,7 @@ class FCIwave : public PhysicsModel {
Field3D Div_par_integrate(const Field3D &f) {
Field3D f_B = f / Bxyz;
- f_B.splitYupYdown();
+ f_B.createYupYdown();
mesh->getParallelTransform().integrateYUpDown(f_B);
// integrateYUpDown replaces all yup/down points, so the boundary conditions
@@ -93,7 +93,7 @@ class FCIwave : public PhysicsModel {
logn.applyParallelBoundary();
n = exp(logn);
- n.splitYupYdown();
+ n.createYupYdown();
n.yup() = exp(logn.yup());
n.ydown() = exp(logn.ydown());
} else {
@@ -107,7 +107,7 @@ class FCIwave : public PhysicsModel {
Field3D momflux = nv * v;
// Apply boundary conditions to v
- v.splitYupYdown();
+ v.createYupYdown();
v.yup().allocate();
v.ydown().allocate();
v.applyParallelBoundary();
@@ -115,7 +115,7 @@ class FCIwave : public PhysicsModel {
// Ensure that boundary conditions are consistent
// between v, nv and momentum flux
- momflux.splitYupYdown();
+ momflux.createYupYdown();
for (const auto ® : mesh->getBoundariesPar()) {
// Using the values of density and velocity on the boundary
const Field3D &n_next = n.ynext(reg->dir);
diff --git a/include/bout/paralleltransform.hxx b/include/bout/paralleltransform.hxx
index a25540354a..9308b8dad9 100644
--- a/include/bout/paralleltransform.hxx
+++ b/include/bout/paralleltransform.hxx
@@ -59,7 +59,7 @@ public:
* Merges the yup and ydown() fields of f, so that
* f.yup() = f.ydown() = f
*/
- void calcYUpDown(Field3D &f) override {f.mergeYupYdown();}
+ void calcYUpDown(Field3D &f) override;
/*!
* The field is already aligned in Y, so this
diff --git a/include/field3d.hxx b/include/field3d.hxx
index bd085f7c73..6af3bb7c1d 100644
--- a/include/field3d.hxx
+++ b/include/field3d.hxx
@@ -157,7 +157,7 @@ class Mesh; // #include "bout/mesh.hxx"
To have separate fields for yup and ydown, first call
- f.splitYupYdown(); // f.yup() and f.ydown() separate
+ f.createYupYdown(); // f.yup() and f.ydown() separate
f.yup(); // ok
f.yup()(0,1,0) // error; f.yup not allocated
@@ -229,12 +229,13 @@ class Field3D : public Field, public FieldData {
* Ensure that this field has separate fields
* for yup and ydown.
*/
- void splitYupYdown();
+ DEPRECATED(void splitYupYdown());
+ void createYupYdown();
/*!
* Ensure that yup and ydown refer to this field
*/
- void mergeYupYdown();
+ DEPRECATED(void mergeYupYdown());
/// Check if this field has yup and ydown fields
bool hasYupYdown() const {
diff --git a/src/field/field3d.cxx b/src/field/field3d.cxx
index c62900285a..92999a2c5b 100644
--- a/src/field/field3d.cxx
+++ b/src/field/field3d.cxx
@@ -189,6 +189,17 @@ void Field3D::splitYupYdown() {
ydown_field = new Field3D(fieldmesh);
}
+void Field3D::createYupYdown() {
+ TRACE("Field3D::createYupYdown");
+
+ if((yup_field != this) && (yup_field != nullptr))
+ return;
+
+ // yup_field and ydown_field null
+ yup_field = new Field3D(fieldmesh);
+ ydown_field = new Field3D(fieldmesh);
+}
+
void Field3D::mergeYupYdown() {
TRACE("Field3D::mergeYupYdown");
diff --git a/src/mesh/coordinates.cxx b/src/mesh/coordinates.cxx
index 10dcd9b4df..f7981902c9 100644
--- a/src/mesh/coordinates.cxx
+++ b/src/mesh/coordinates.cxx
@@ -712,7 +712,7 @@ const Field3D Coordinates::Div_par(const Field3D &f, CELL_LOC outloc,
f_B.mergeYupYdown();
} else {
// Distinct fields
- f_B.splitYupYdown();
+ f_B.createYupYdown();
f_B.yup() = f.yup() / Bxy_floc;
f_B.ydown() = f.ydown() / Bxy_floc;
}
diff --git a/src/mesh/parallel/fci.cxx b/src/mesh/parallel/fci.cxx
index 63f53856a7..bf0c0ce29c 100644
--- a/src/mesh/parallel/fci.cxx
+++ b/src/mesh/parallel/fci.cxx
@@ -297,7 +297,7 @@ void FCITransform::calcYUpDown(Field3D &f) {
TRACE("FCITransform::calcYUpDown");
// Ensure that yup and ydown are different fields
- f.splitYupYdown();
+ f.createYupYdown();
// Interpolate f onto yup and ydown fields
f.ynext(forward_map.dir) = forward_map.interpolate(f);
@@ -308,7 +308,7 @@ void FCITransform::integrateYUpDown(Field3D &f) {
TRACE("FCITransform::integrateYUpDown");
// Ensure that yup and ydown are different fields
- f.splitYupYdown();
+ f.createYupYdown();
// Integrate f onto yup and ydown fields
f.ynext(forward_map.dir) = forward_map.integrate(f);
diff --git a/src/mesh/parallel/makefile b/src/mesh/parallel/makefile
index 9c4817b008..c21e4b9c02 100644
--- a/src/mesh/parallel/makefile
+++ b/src/mesh/parallel/makefile
@@ -2,7 +2,7 @@
BOUT_TOP = ../../..
DIRS =
-SOURCEC = shiftedmetric.cxx fci.cxx
+SOURCEC = shiftedmetric.cxx fci.cxx paralleltransformidentity.cxx
TARGET = lib
include $(BOUT_TOP)/make.config
diff --git a/src/mesh/parallel/paralleltransformidentity.cxx b/src/mesh/parallel/paralleltransformidentity.cxx
new file mode 100644
index 0000000000..7e8b1c88fd
--- /dev/null
+++ b/src/mesh/parallel/paralleltransformidentity.cxx
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * Copyright 2018 B.D. Dudson, J.T. Omotani
+ *
+ * Contact: Ben Dudson, bd512@york.ac.uk
+ *
+ * This file is part of BOUT++.
+ *
+ * BOUT++ is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * BOUT++ is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with BOUT++. If not, see .
+ *
+ **************************************************************************/
+
+#include
+#include
+
+void ParallelTransformIdentity::calcYUpDown(Field3D &f) {
+ f.mergeYupYdown();
+}
diff --git a/src/mesh/parallel/shiftedmetric.cxx b/src/mesh/parallel/shiftedmetric.cxx
index 13067fe07c..052656a87b 100644
--- a/src/mesh/parallel/shiftedmetric.cxx
+++ b/src/mesh/parallel/shiftedmetric.cxx
@@ -95,7 +95,7 @@ ShiftedMetric::ShiftedMetric(Mesh &m) : mesh(m), zShift(&m) {
* Calculate the Y up and down fields
*/
void ShiftedMetric::calcYUpDown(Field3D &f) {
- f.splitYupYdown();
+ f.createYupYdown();
Field3D& yup = f.yup();
yup.allocate();
diff --git a/tests/unit/field/test_field3d.cxx b/tests/unit/field/test_field3d.cxx
index bb13235d6d..68e1a64c0f 100644
--- a/tests/unit/field/test_field3d.cxx
+++ b/tests/unit/field/test_field3d.cxx
@@ -214,7 +214,7 @@ TEST_F(Field3DTest, SplitYupYDown) {
EXPECT_FALSE(field.hasYupYdown());
- field.splitYupYdown();
+ field.createYupYdown();
EXPECT_TRUE(field.hasYupYdown());
@@ -223,8 +223,8 @@ TEST_F(Field3DTest, SplitYupYDown) {
auto& ydown = field.ydown();
EXPECT_NE(&field, &ydown);
- // Should be able to split again without any problems
- field.splitYupYdown();
+ // Should be able to create again without any problems
+ field.createYupYdown();
// Would be nice to check yup2 != yup, but not sure this is possible
// to do in general
@@ -259,11 +259,11 @@ TEST_F(Field3DTest, MergeYupYDown) {
EXPECT_EQ(&field, &ydown2);
}
-TEST_F(Field3DTest, SplitThenMergeYupYDown) {
+TEST_F(Field3DTest, CreateThenMergeYupYDown) {
Field3D field;
field = 0.;
- field.splitYupYdown();
+ field.createYupYdown();
auto& yup = field.yup();
EXPECT_NE(&field, &yup);
@@ -282,7 +282,7 @@ TEST_F(Field3DTest, Ynext) {
Field3D field;
field = 0.;
- field.splitYupYdown();
+ field.createYupYdown();
auto& yup = field.ynext(1);
EXPECT_NE(&field, &yup);
@@ -296,7 +296,7 @@ TEST_F(Field3DTest, Ynext) {
TEST_F(Field3DTest, ConstYnext) {
Field3D field(0.);
- field.splitYupYdown();
+ field.createYupYdown();
const Field3D& field2 = field;