From ad8c673eb6fe08e954ec85e8acad8c51c536a0b5 Mon Sep 17 00:00:00 2001 From: John Omotani Date: Fri, 2 Nov 2018 14:13:41 +0000 Subject: [PATCH 1/5] Fix location checking in ShiftedMetric::shiftZ() Fixing the low-level shiftZ method means that toFieldAligned/fromFieldAligned also do the right thing. Check that input to shiftZ is at same location as the shift angle zShift (i.e. CELL_CENTRE). Set location of result returned from zShift to be the same as the location of the input. --- src/mesh/parallel/shiftedmetric.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesh/parallel/shiftedmetric.cxx b/src/mesh/parallel/shiftedmetric.cxx index 80fdc37274..fc81e9fbe7 100644 --- a/src/mesh/parallel/shiftedmetric.cxx +++ b/src/mesh/parallel/shiftedmetric.cxx @@ -143,11 +143,13 @@ const Field3D ShiftedMetric::fromFieldAligned(const Field3D &f) { const Field3D ShiftedMetric::shiftZ(const Field3D &f, const arr3Dvec &phs) { ASSERT1(&mesh == f.getMesh()); + ASSERT1(f.getLocation() == CELL_CENTRE); // only have zShift for CELL_CENTRE, so can only deal with CELL_CENTRE inputs if(mesh.LocalNz == 1) return f; // Shifting makes no difference Field3D result(&mesh); result.allocate(); + result.setLocation(f.getLocation()); for(int jx=0;jx Date: Tue, 11 Dec 2018 09:48:32 +0000 Subject: [PATCH 2/5] Check locations are the same in ShiftedMetric::shiftZ(Field3D,Field2D) --- src/mesh/parallel/shiftedmetric.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesh/parallel/shiftedmetric.cxx b/src/mesh/parallel/shiftedmetric.cxx index fc81e9fbe7..1d0c119dc4 100644 --- a/src/mesh/parallel/shiftedmetric.cxx +++ b/src/mesh/parallel/shiftedmetric.cxx @@ -181,6 +181,7 @@ void ShiftedMetric::shiftZ(const BoutReal *in, const std::vector &phs, //Old approach retained so we can still specify a general zShift const Field3D ShiftedMetric::shiftZ(const Field3D &f, const Field2D &zangle) { ASSERT1(&mesh == f.getMesh()); + ASSERT1(f.getLocation() == zangle.getLocation()); if(mesh.LocalNz == 1) return f; // Shifting makes no difference From 0b47f397303bfb23ed67aa8408f14a4df6a5e871 Mon Sep 17 00:00:00 2001 From: John Omotani Date: Tue, 11 Dec 2018 09:57:34 +0000 Subject: [PATCH 3/5] Check Mesh and location in ShiftedMetric::calcYUpDown() --- src/mesh/parallel/shiftedmetric.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesh/parallel/shiftedmetric.cxx b/src/mesh/parallel/shiftedmetric.cxx index 1d0c119dc4..91a858b87d 100644 --- a/src/mesh/parallel/shiftedmetric.cxx +++ b/src/mesh/parallel/shiftedmetric.cxx @@ -104,6 +104,9 @@ ShiftedMetric::ShiftedMetric(Mesh &m) : mesh(m), zShift(&m) { * Calculate the Y up and down fields */ void ShiftedMetric::calcYUpDown(Field3D &f) { + ASSERT1(&mesh == f.getMesh()); + ASSERT1(f.getLocation() == CELL_CENTRE); // only have zShift for CELL_CENTRE, so can only deal with CELL_CENTRE inputs + f.splitYupYdown(); Field3D& yup = f.yup(); From 39df79a76577011814c9496c80b7fb7260bd94da Mon Sep 17 00:00:00 2001 From: John Omotani Date: Tue, 11 Dec 2018 10:01:23 +0000 Subject: [PATCH 4/5] Check Mesh and location in FCI::calcYUpDown, FCI::integrateYUpDown --- src/mesh/parallel/fci.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mesh/parallel/fci.cxx b/src/mesh/parallel/fci.cxx index 25002ffed3..eeb1d96b46 100644 --- a/src/mesh/parallel/fci.cxx +++ b/src/mesh/parallel/fci.cxx @@ -296,6 +296,12 @@ const Field3D FCIMap::integrate(Field3D &f) const { void FCITransform::calcYUpDown(Field3D &f) { TRACE("FCITransform::calcYUpDown"); + ASSERT1(f.getMesh() == &mesh); + + // Only have forward_map/backward_map for CELL_CENTRE, so can only deal with + // CELL_CENTRE inputs + ASSERT1(f.getLocation() == CELL_CENTRE); + // Ensure that yup and ydown are different fields f.splitYupYdown(); @@ -307,6 +313,12 @@ void FCITransform::calcYUpDown(Field3D &f) { void FCITransform::integrateYUpDown(Field3D &f) { TRACE("FCITransform::integrateYUpDown"); + ASSERT1(f.getMesh() == &mesh); + + // Only have forward_map/backward_map for CELL_CENTRE, so can only deal with + // CELL_CENTRE inputs + ASSERT1(f.getLocation() == CELL_CENTRE); + // Ensure that yup and ydown are different fields f.splitYupYdown(); From dfb5215ebdc5695a757ee473edb6a72f9724f40c Mon Sep 17 00:00:00 2001 From: John Omotani Date: Tue, 12 Feb 2019 20:03:55 +0000 Subject: [PATCH 5/5] Move Mesh checks to FCIMap methods FCITransform does not store a Mesh reference, so don't check the mesh of the input field in FCITransform methods. The mesh of the field is checked in the FCIMap methods that are called by the FCITransform methods anyway. --- src/mesh/parallel/fci.cxx | 6 +----- src/mesh/parallel/fci.hxx | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/mesh/parallel/fci.cxx b/src/mesh/parallel/fci.cxx index ff6435ae1c..825eb1dfca 100644 --- a/src/mesh/parallel/fci.cxx +++ b/src/mesh/parallel/fci.cxx @@ -256,7 +256,7 @@ FCIMap::FCIMap(Mesh& mesh, int offset_, BoundaryRegionPar* boundary, bool zperio Field3D FCIMap::integrate(Field3D &f) const { TRACE("FCIMap::integrate"); - ASSERT3(&map_mesh == f.getMesh()); + ASSERT1(&map_mesh == f.getMesh()); // Cell centre values Field3D centre = interp->interpolate(f); @@ -316,8 +316,6 @@ Field3D FCIMap::integrate(Field3D &f) const { void FCITransform::calcYUpDown(Field3D& f) { TRACE("FCITransform::calcYUpDown"); - ASSERT1(f.getMesh() == &mesh); - // Only have forward_map/backward_map for CELL_CENTRE, so can only deal with // CELL_CENTRE inputs ASSERT1(f.getLocation() == CELL_CENTRE); @@ -334,8 +332,6 @@ void FCITransform::calcYUpDown(Field3D& f) { void FCITransform::integrateYUpDown(Field3D& f) { TRACE("FCITransform::integrateYUpDown"); - ASSERT1(f.getMesh() == &mesh); - // Only have forward_map/backward_map for CELL_CENTRE, so can only deal with // CELL_CENTRE inputs ASSERT1(f.getLocation() == CELL_CENTRE); diff --git a/src/mesh/parallel/fci.hxx b/src/mesh/parallel/fci.hxx index 37a87a96e6..5d987c20e0 100644 --- a/src/mesh/parallel/fci.hxx +++ b/src/mesh/parallel/fci.hxx @@ -58,7 +58,7 @@ public: BoutMask corner_boundary_mask; Field3D interpolate(Field3D& f) const { - ASSERT3(&map_mesh == f.getMesh()); + ASSERT1(&map_mesh == f.getMesh()); return interp->interpolate(f); }