diff --git a/include/boundary_region.hxx b/include/boundary_region.hxx index cc53f1b54e..09bdc3aa6c 100644 --- a/include/boundary_region.hxx +++ b/include/boundary_region.hxx @@ -8,7 +8,11 @@ class BoundaryRegion; #include class Mesh; -extern Mesh* mesh; +namespace bout { +namespace globals { + extern Mesh* mesh; ///< Global mesh +} // namespace bout +} // namespace globals /// Location of boundary enum BndryLoc {BNDRY_XIN=1, @@ -24,9 +28,9 @@ public: BoundaryRegionBase() = delete; BoundaryRegionBase(std::string name, Mesh *passmesh = nullptr) - : localmesh(passmesh ? passmesh : mesh), label(std::move(name)) {} + : localmesh(passmesh ? passmesh : bout::globals::mesh), label(std::move(name)) {} BoundaryRegionBase(std::string name, BndryLoc loc, Mesh *passmesh = nullptr) - : localmesh(passmesh ? passmesh : mesh), label(std::move(name)), location(loc) {} + : localmesh(passmesh ? passmesh : bout::globals::mesh), label(std::move(name)), location(loc) {} virtual ~BoundaryRegionBase() {} diff --git a/include/bout.hxx b/include/bout.hxx index 921d81bc7f..278a2a7fa2 100644 --- a/include/bout.hxx +++ b/include/bout.hxx @@ -38,6 +38,7 @@ #include "boutcomm.hxx" +#include #include "globals.hxx" #include "field2d.hxx" @@ -65,6 +66,13 @@ const BoutReal BOUT_VERSION = BOUT_VERSION_DOUBLE; ///< Version number +#ifndef BOUT_NO_USING_NAMESPACE_BOUTGLOBALS +// Include using statement by default in user code. +// Macro allows us to include bout.hxx or physicsmodel.hxx without the using +// statement in library code. +using namespace bout::globals; +#endif // BOUT_NO_USING_NAMESPACE_BOUTGLOBALS + // BOUT++ main functions /*! diff --git a/include/bout/expr.hxx b/include/bout/expr.hxx index ef14cb84af..4cbe31cb9f 100644 --- a/include/bout/expr.hxx +++ b/include/bout/expr.hxx @@ -12,6 +12,8 @@ #ifndef __EXPR_H__ #define __EXPR_H__ +#warning expr.hxx is deprecated. Do not use! + #include #include #include @@ -33,7 +35,7 @@ public: typedef Field3D type; Field3DExpr(const Field3D &f) : data(&f(0,0,0)) {} - const BoutReal& operator()(int x, int y, int z) const { return data[(x*mesh->LocalNy + y)*mesh->LocalNz + z]; } + const BoutReal& operator()(int x, int y, int z) const { return data[(x*bout::globals::mesh->LocalNy + y)*bout::globals::mesh->LocalNz + z]; } private: const BoutReal *data; }; @@ -43,7 +45,7 @@ public: typedef Field2D type; Field2DExpr(const Field2D &f) : data(&f(0,0)) {} - const BoutReal& operator()(int x, int y, int z) const { return data[x*mesh->LocalNy + y]; } + const BoutReal& operator()(int x, int y, int z) const { return data[x*bout::globals::mesh->LocalNy + y]; } private: const BoutReal *data; }; @@ -186,9 +188,9 @@ template const Field3D eval3D(Expr e) { Field3D result; result.allocate(); - for(int i=0;iLocalNx;i++) - for(int j=0;jLocalNy;j++) - for(int k=0;kLocalNz;k++) + for(int i=0;iLocalNx;i++) + for(int j=0;jLocalNy;j++) + for(int k=0;kLocalNz;k++) result(i,j,k) = e(i,j,k); return result; } diff --git a/include/bout/fv_ops.hxx b/include/bout/fv_ops.hxx index f1bbf8bd6e..8015d97f0f 100644 --- a/include/bout/fv_ops.hxx +++ b/include/bout/fv_ops.hxx @@ -10,6 +10,7 @@ #include "../vector2d.hxx" #include "../utils.hxx" +#include namespace FV { /*! @@ -182,6 +183,10 @@ namespace FV { ASSERT2(f_in.getLocation() == v_in.getLocation()); + Mesh* mesh = f_in.getMesh(); + ASSERT1(mesh == v_in.getMesh()); + ASSERT1(mesh == wave_speed.getMesh()); + CellEdges cellboundary; Field3D f = mesh->toFieldAligned(f_in); @@ -341,6 +346,9 @@ namespace FV { const Field3D Div_f_v(const Field3D &n_in, const Vector3D &v, bool bndry_flux) { ASSERT2(n_in.getLocation() == v.getLocation()); + Mesh* mesh = n_in.getMesh(); + ASSERT1(mesh == v.x.getMesh()); + CellEdges cellboundary; Coordinates *coord = n_in.getCoordinates(); diff --git a/include/bout/invert/laplacexz.hxx b/include/bout/invert/laplacexz.hxx index 5bdb3902be..34200a648e 100644 --- a/include/bout/invert/laplacexz.hxx +++ b/include/bout/invert/laplacexz.hxx @@ -39,8 +39,8 @@ class LaplaceXZ { public: LaplaceXZ(Mesh* m = nullptr, Options* UNUSED(options) = nullptr, - const CELL_LOC loc = CELL_CENTRE) - : localmesh(m==nullptr ? mesh : m), location(loc) {} + const CELL_LOC loc = CELL_CENTRE) + : localmesh(m == nullptr ? bout::globals::mesh : m), location(loc) {} virtual ~LaplaceXZ() {} virtual void setCoefs(const Field2D &A, const Field2D &B) = 0; diff --git a/include/bout/invertable_operator.hxx b/include/bout/invertable_operator.hxx index 6886cb4a13..e5650f70c3 100644 --- a/include/bout/invertable_operator.hxx +++ b/include/bout/invertable_operator.hxx @@ -35,6 +35,7 @@ class InvertableOperator; #ifdef BOUT_HAS_PETSC +#include #include #include #include @@ -133,7 +134,7 @@ public: : operatorFunction(func), preconditionerFunction(func), opt(optIn == nullptr ? optIn : Options::getRoot()->getSection("invertableOperator")), - localmesh(localmeshIn == nullptr ? mesh : localmeshIn), doneSetup(false) { + localmesh(localmeshIn == nullptr ? bout::globals::mesh : localmeshIn), doneSetup(false) { AUTO_TRACE(); }; diff --git a/include/bout/physicsmodel.hxx b/include/bout/physicsmodel.hxx index 6e98ecebbf..8f4f3266d1 100644 --- a/include/bout/physicsmodel.hxx +++ b/include/bout/physicsmodel.hxx @@ -43,6 +43,7 @@ class PhysicsModel; #include "solver.hxx" #include "unused.hxx" #include "bout/macro_for_each.hxx" + /*! Base class for physics models */ @@ -310,7 +311,7 @@ private: solver->setModel(model); \ Monitor * bout_monitor = new BoutMonitor(); \ solver->addMonitor(bout_monitor, Solver::BACK); \ - solver->outputVars(dump); \ + solver->outputVars(bout::globals::dump); \ solver->solve(); \ delete model; \ delete solver; \ diff --git a/include/bout/solver.hxx b/include/bout/solver.hxx index 411011f82e..5d0108f588 100644 --- a/include/bout/solver.hxx +++ b/include/bout/solver.hxx @@ -71,7 +71,9 @@ typedef int (*TimestepMonitorFunc)(Solver *solver, BoutReal simtime, BoutReal la #include "vector2d.hxx" #include "vector3d.hxx" +#define BOUT_NO_USING_NAMESPACE_BOUTGLOBALS #include "physicsmodel.hxx" +#undef BOUT_NO_USING_NAMESPACE_BOUTGLOBALS #include #include @@ -290,7 +292,7 @@ class Solver { /// /// @param[inout] outputfile The file to add variable to /// @param[in] save_repeat If true, add variables with time dimension - void outputVars(Datafile &outputfile, bool save_repeat=true); + virtual void outputVars(Datafile &outputfile, bool save_repeat=true); /*! * Create a Solver object. This uses the "type" option diff --git a/include/datafile.hxx b/include/datafile.hxx index ecfd369312..22cbc2c3be 100644 --- a/include/datafile.hxx +++ b/include/datafile.hxx @@ -15,10 +15,6 @@ class Datafile; #define __DATAFILE_H__ #include "bout_types.hxx" -#include "field2d.hxx" -#include "field3d.hxx" -#include "vector2d.hxx" -#include "vector3d.hxx" #include "options.hxx" #include "bout/macro_for_each.hxx" @@ -26,6 +22,11 @@ class Datafile; #include #include +class Mesh; +class Field2D; +class Field3D; +class Vector2D; +class Vector3D; #include #include @@ -37,7 +38,7 @@ class Datafile; */ class Datafile { public: - Datafile(Options *opt = nullptr); + Datafile(Options *opt = nullptr, Mesh* mesh_in = nullptr); Datafile(Datafile &&other) noexcept; ~Datafile(); // need to delete filename @@ -78,6 +79,7 @@ class Datafile { void setAttribute(const std::string &varname, const std::string &attrname, BoutReal value); private: + Mesh* mesh; bool parallel; // Use parallel formats? bool flush; // Flush after every write? bool guards; // Write guard cells? @@ -137,63 +139,63 @@ class Datafile { }; /// Write this variable once to the grid file -#define SAVE_ONCE1(var) dump.add(var, #var, 0); +#define SAVE_ONCE1(var) bout::globals::dump.add(var, #var, 0); #define SAVE_ONCE2(var1, var2) { \ - dump.add(var1, #var1, 0); \ - dump.add(var2, #var2, 0);} + bout::globals::dump.add(var1, #var1, 0); \ + bout::globals::dump.add(var2, #var2, 0);} #define SAVE_ONCE3(var1, var2, var3) {\ - dump.add(var1, #var1, 0); \ - dump.add(var2, #var2, 0); \ - dump.add(var3, #var3, 0);} + bout::globals::dump.add(var1, #var1, 0); \ + bout::globals::dump.add(var2, #var2, 0); \ + bout::globals::dump.add(var3, #var3, 0);} #define SAVE_ONCE4(var1, var2, var3, var4) { \ - dump.add(var1, #var1, 0); \ - dump.add(var2, #var2, 0); \ - dump.add(var3, #var3, 0); \ - dump.add(var4, #var4, 0);} + bout::globals::dump.add(var1, #var1, 0); \ + bout::globals::dump.add(var2, #var2, 0); \ + bout::globals::dump.add(var3, #var3, 0); \ + bout::globals::dump.add(var4, #var4, 0);} #define SAVE_ONCE5(var1, var2, var3, var4, var5) {\ - dump.add(var1, #var1, 0); \ - dump.add(var2, #var2, 0); \ - dump.add(var3, #var3, 0); \ - dump.add(var4, #var4, 0); \ - dump.add(var5, #var5, 0);} + bout::globals::dump.add(var1, #var1, 0); \ + bout::globals::dump.add(var2, #var2, 0); \ + bout::globals::dump.add(var3, #var3, 0); \ + bout::globals::dump.add(var4, #var4, 0); \ + bout::globals::dump.add(var5, #var5, 0);} #define SAVE_ONCE6(var1, var2, var3, var4, var5, var6) {\ - dump.add(var1, #var1, 0); \ - dump.add(var2, #var2, 0); \ - dump.add(var3, #var3, 0); \ - dump.add(var4, #var4, 0); \ - dump.add(var5, #var5, 0); \ - dump.add(var6, #var6, 0);} + bout::globals::dump.add(var1, #var1, 0); \ + bout::globals::dump.add(var2, #var2, 0); \ + bout::globals::dump.add(var3, #var3, 0); \ + bout::globals::dump.add(var4, #var4, 0); \ + bout::globals::dump.add(var5, #var5, 0); \ + bout::globals::dump.add(var6, #var6, 0);} #define SAVE_ONCE(...) \ { MACRO_FOR_EACH(SAVE_ONCE1, __VA_ARGS__) } /// Write this variable every timestep -#define SAVE_REPEAT1(var) dump.add(var, #var, 1); +#define SAVE_REPEAT1(var) bout::globals::dump.add(var, #var, 1); #define SAVE_REPEAT2(var1, var2) { \ - dump.add(var1, #var1, 1); \ - dump.add(var2, #var2, 1);} + bout::globals::dump.add(var1, #var1, 1); \ + bout::globals::dump.add(var2, #var2, 1);} #define SAVE_REPEAT3(var1, var2, var3) {\ - dump.add(var1, #var1, 1); \ - dump.add(var2, #var2, 1); \ - dump.add(var3, #var3, 1);} + bout::globals::dump.add(var1, #var1, 1); \ + bout::globals::dump.add(var2, #var2, 1); \ + bout::globals::dump.add(var3, #var3, 1);} #define SAVE_REPEAT4(var1, var2, var3, var4) { \ - dump.add(var1, #var1, 1); \ - dump.add(var2, #var2, 1); \ - dump.add(var3, #var3, 1); \ - dump.add(var4, #var4, 1);} + bout::globals::dump.add(var1, #var1, 1); \ + bout::globals::dump.add(var2, #var2, 1); \ + bout::globals::dump.add(var3, #var3, 1); \ + bout::globals::dump.add(var4, #var4, 1);} #define SAVE_REPEAT5(var1, var2, var3, var4, var5) {\ - dump.add(var1, #var1, 1); \ - dump.add(var2, #var2, 1); \ - dump.add(var3, #var3, 1); \ - dump.add(var4, #var4, 1); \ - dump.add(var5, #var5, 1);} + bout::globals::dump.add(var1, #var1, 1); \ + bout::globals::dump.add(var2, #var2, 1); \ + bout::globals::dump.add(var3, #var3, 1); \ + bout::globals::dump.add(var4, #var4, 1); \ + bout::globals::dump.add(var5, #var5, 1);} #define SAVE_REPEAT6(var1, var2, var3, var4, var5, var6) {\ - dump.add(var1, #var1, 1); \ - dump.add(var2, #var2, 1); \ - dump.add(var3, #var3, 1); \ - dump.add(var4, #var4, 1); \ - dump.add(var5, #var5, 1); \ - dump.add(var6, #var6, 1);} + bout::globals::dump.add(var1, #var1, 1); \ + bout::globals::dump.add(var2, #var2, 1); \ + bout::globals::dump.add(var3, #var3, 1); \ + bout::globals::dump.add(var4, #var4, 1); \ + bout::globals::dump.add(var5, #var5, 1); \ + bout::globals::dump.add(var6, #var6, 1);} #define SAVE_REPEAT(...) \ { MACRO_FOR_EACH(SAVE_REPEAT1, __VA_ARGS__) } diff --git a/include/dataformat.hxx b/include/dataformat.hxx index b2ebd5d468..462bf712c0 100644 --- a/include/dataformat.hxx +++ b/include/dataformat.hxx @@ -40,9 +40,12 @@ class DataFormat; #include #include +class Mesh; + // Can't copy, to control access to file class DataFormat { public: + DataFormat(Mesh* mesh_in = nullptr); virtual ~DataFormat() { } // File opening routines virtual bool openr(const char *name) = 0; @@ -195,6 +198,9 @@ class DataFormat { /// ------- /// value A BoutReal attribute of the variable virtual bool getAttribute(const std::string &varname, const std::string &attrname, BoutReal &value) = 0; + + protected: + Mesh* mesh; }; // For backwards compatability. In formatfactory.cxx diff --git a/include/field.hxx b/include/field.hxx index 216c12a2a8..fa0710e0d4 100644 --- a/include/field.hxx +++ b/include/field.hxx @@ -33,6 +33,7 @@ class Field; #include "bout_types.hxx" #include "boutexception.hxx" +#include #include "msg_stack.hxx" #include "stencils.hxx" #include @@ -41,7 +42,6 @@ class Field; class Mesh; class Coordinates; -extern Mesh * mesh; ///< Global mesh #ifdef TRACK #include @@ -94,7 +94,7 @@ class Field { if (fieldmesh){ return fieldmesh; } else { - return mesh; + return bout::globals::mesh; } } diff --git a/include/globals.hxx b/include/globals.hxx index e98fe36345..88bab32731 100644 --- a/include/globals.hxx +++ b/include/globals.hxx @@ -27,10 +27,13 @@ #ifndef __GLOBALS_H__ #define __GLOBALS_H__ -#include "bout/mesh.hxx" #include "datafile.hxx" #include "bout/macro_for_each.hxx" +class Mesh; + +namespace bout { +namespace globals { #ifndef GLOBALORIGIN #define GLOBAL extern #define SETTING(name, val) extern name @@ -83,5 +86,7 @@ GLOBAL Datafile dump; #undef GLOBAL #undef SETTING +} // namespace globals +} // namespace bout #endif // __GLOBALS_H__ diff --git a/include/interpolation.hxx b/include/interpolation.hxx index 2fe51191d9..b20389a00e 100644 --- a/include/interpolation.hxx +++ b/include/interpolation.hxx @@ -220,7 +220,7 @@ protected: public: Interpolation(int y_offset = 0, Mesh* localmeshIn = nullptr) - : localmesh(localmeshIn == nullptr ? mesh : localmeshIn), + : localmesh(localmeshIn == nullptr ? bout::globals::mesh : localmeshIn), skip_mask(*localmesh, false), y_offset(y_offset) {} Interpolation(const BoutMask &mask, int y_offset = 0, Mesh *mesh = nullptr) : Interpolation(y_offset, mesh) { diff --git a/include/invert_laplace.hxx b/include/invert_laplace.hxx index bab11d7ec6..e6a4417208 100644 --- a/include/invert_laplace.hxx +++ b/include/invert_laplace.hxx @@ -105,7 +105,7 @@ const int INVERT_OUT_RHS = 32768; ///< Use input value in RHS at outer boundary /// Base class for Laplacian inversion class Laplacian { public: - Laplacian(Options *options = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh* mesh_in = mesh); + Laplacian(Options *options = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh* mesh_in = nullptr); virtual ~Laplacian() {} /// Set coefficients for inversion. Re-builds matrices if necessary @@ -192,7 +192,7 @@ public: * * @param[in] opt The options section to use. By default "laplace" will be used */ - static Laplacian *create(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + static Laplacian *create(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr); static Laplacian* defaultInstance(); ///< Return pointer to global singleton static void cleanup(); ///< Frees all memory diff --git a/include/invert_parderiv.hxx b/include/invert_parderiv.hxx index c46dfe817f..6eff81f6b1 100644 --- a/include/invert_parderiv.hxx +++ b/include/invert_parderiv.hxx @@ -63,8 +63,8 @@ public: * with pure virtual members, so can't be created directly. * To create an InvertPar object call the create() static function. */ - InvertPar(Options *UNUSED(opt), Mesh *mesh_in = mesh) - : localmesh(mesh_in) {} + InvertPar(Options *UNUSED(opt), Mesh *mesh_in = nullptr) + : localmesh(mesh_in==nullptr ? bout::globals::mesh : mesh_in) {} virtual ~InvertPar() {} /*! @@ -72,7 +72,7 @@ public: * * Note: For consistency this should be renamed "create" and take an Options* argument */ - static InvertPar* Create(Mesh *mesh_in = mesh); + static InvertPar* Create(Mesh *mesh_in = nullptr); /*! * Solve the system of equations diff --git a/include/mask.hxx b/include/mask.hxx index cc1539e550..60b82c0fa9 100644 --- a/include/mask.hxx +++ b/include/mask.hxx @@ -61,7 +61,7 @@ public: BoutMask(Mesh& mesh, bool value=false) : BoutMask(mesh.LocalNx, mesh.LocalNy, mesh.LocalNz, value) {} // Default constructor uses global mesh - BoutMask() : BoutMask(*mesh) {} + BoutMask() : BoutMask(*bout::globals::mesh) {} // Assignment from bool BoutMask& operator=(bool value) { diff --git a/locale/README.md b/locale/README.md index 9b0ed60967..8ace1f9bd3 100644 --- a/locale/README.md +++ b/locale/README.md @@ -22,6 +22,15 @@ Start a new translation: make locale-XX where XX is the language e.g. "de" for German, or a language_country code e.g. "de_DE". -This will update a .po file if it already exists. -Edit the .po file, translating or deleting new entries, then remake the .mo files. - +Edit the .po file, translating or deleting new entries: + * Make sure to set the charset (around line 16) to utf-8. + * msgid is the original text. Write in msgstr the translated string. + * You can reorder arguments using %n$s like this:: + msgid "" + "Options: Setting a value from same source (%s) to new value '%s' - old value " + "was '%s'." + msgstr "" + "Options: The Value %3$s is overwritten with %2$s from the same source (%1%s)" +There are also editors for editing .po files, e.g. poeditor. + +Calling `make locale-XX` again will update the .po file. diff --git a/locale/de/libbout.po b/locale/de/libbout.po new file mode 100644 index 0000000000..8e1069a418 --- /dev/null +++ b/locale/de/libbout.po @@ -0,0 +1,727 @@ +# German translations for BOUT++ package. +# Copyright (C) 2019 THE BOUT++'S COPYRIGHT HOLDER +# This file is distributed under the same license as the BOUT++ package. +# David , 2019. +# +msgid "" +msgstr "" +"Project-Id-Version: BOUT++ 4.2.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-02-06 17:31+0000\n" +"PO-Revision-Date: 2019-02-06 17:32+0000\n" +"Last-Translator: David \n" +"Language-Team: German\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.2.1\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:335 +#, c-format +msgid "" +"\t -> Core region jyseps2_1-jyseps1_1 (%d-%d = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" +"\t -> `Core` Region iyseps2_1-iyseps1_1 (%d-%d = %d) muss ein Vielfaches von " +"MYSUB (%d) sein\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:364 +#, c-format +msgid "" +"\t -> Core region jyseps2_2-jyseps1_1 (%d-%d = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" +"\t -> `Core` Region jyseps2_2-jyseps1_1 (%d-%d = %d) muss ein Vielfaches von " +"MYSUB (%d) sein\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:342 +#, c-format +msgid "" +"\t -> Core region jyseps2_2-jyseps1_2 (%d-%d = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" +"\t -> `Core` Region jyseps2_2-jyseps1_2 (%d-%d = %d) muss ein Vielfaches von " +"MYSUB (%d) sein\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:377 +msgid "\t -> Good value\n" +msgstr "\t -> Wert OK\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:326 +#, c-format +msgid "\t -> Leg region jyseps1_1+1 (%d) must be a multiple of MYSUB (%d)\n" +msgstr "" +"\t -> `Leg` Region jyseps1_1+1 (%d) muss ein Vielfaches von MYSUB (%d) sein\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:356 +#, c-format +msgid "" +"\t -> leg region jyseps1_2-ny_inner+1 (%d-%d+1 = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" +"\t -> `Leg` Region jyseps1_2-ny_inner+1 (%d-%d+1 = %d) muss ein Vielfaches " +"von MYSUB (%d) sein\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:372 +#, c-format +msgid "" +"\t -> leg region ny-jyseps2_2-1 (%d-%d-1 = %d) must be a multiple of MYSUB " +"(%d)\n" +msgstr "" +"\t -> `Leg` Region ny-jyseps2_2-1 (%d-%d-1 = %d) muss ein Vielfaches von " +"MYSUB (%d) sein\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:350 +#, c-format +msgid "" +"\t -> leg region ny_inner-jyseps2_1-1 (%d-%d-1 = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" +"\t -> `Leg` Region ny_inner-jyseps2_1-1 (%d-%d-1 = %d) muss ein Vielfaches " +"von MYSUB (%d) sein\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:319 +#, c-format +msgid "\t -> ny/NYPE (%d/%d = %d) must be >= MYG (%d)\n" +msgstr "\t -> ny/NYPE (%d/%d = %d) muss >= MYG (%d) sein\n" + +#. Loop over all possibilities +#. Processors divide equally +#. Mesh in X divides equally +#. Mesh in Y divides equally +#: ../src/mesh/impls/bout/boutmesh.cxx:312 +#, c-format +msgid "\tCandidate value: %d\n" +msgstr "\tzu überprüfender Wert: %d\n" + +#: ../src/bout++.cxx:387 +msgid "\tChecking disabled\n" +msgstr "\tChecks sind deaktiviert\n" + +#: ../src/bout++.cxx:385 +#, c-format +msgid "\tChecking enabled, level %d\n" +msgstr "\tChecks der Stufe %d sind aktiviert\n" + +#. Print command line options +#: ../src/bout++.cxx:431 +msgid "\tCommand line options for this run : " +msgstr "\tKommandozeilenoptionen für diese Ausführung: " + +#. The stringify is needed here as BOUT_FLAGS_STRING may already contain quoted strings +#. which could cause problems (e.g. terminate strings). +#: ../src/bout++.cxx:428 +#, c-format +msgid "\tCompiled with flags : %s\n" +msgstr "\tWurde kompiliert mit den Optionen : %s\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:391 +#, c-format +msgid "" +"\tDomain split (NXPE=%d, NYPE=%d) into domains (localNx=%d, localNy=%d)\n" +msgstr "" +"\tDas Gebiet wird in NXPE=%d mal NYPE=%d Gebiete der Größe localNx=%d mal " +"localNy=%d aufgeteilt\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:416 +#, c-format +msgid "\tERROR: Cannot split %d Y points equally between %d processors\n" +msgstr "" +"\tFEHLER: %d Punkte in der Y-Richtung können nicht gleichmässig zwischen %d " +"Prozessen verteilt werden\n" + +#: ../src/sys/options/options_ini.cxx:173 +#, c-format +msgid "" +"\tEmpty key\n" +"\tLine: %s" +msgstr "" +"\tUngesetzter Schlüssel (Key)\n" +"\tZeile: %s" + +#: ../src/sys/optionsreader.cxx:140 +#, c-format +msgid "\tEmpty key or value in command line '%s'\n" +msgstr "\tSchlüssel (Key) oder Wert nicht gesetzt in der Befehlszeile '%s'\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:127 +msgid "\tGrid size: " +msgstr "\tGittergröße: " + +#: ../src/mesh/impls/bout/boutmesh.cxx:143 +msgid "\tGuard cells (x,y): " +msgstr "\tGuardzellen (x,y): " + +#: ../src/sys/options/options_ini.cxx:177 +#, c-format +msgid "" +"\tKey must not contain ':' character\n" +"\tLine: %s" +msgstr "" +"\tDer Schlüssel darf nicht ':' enthalten\n" +"\tZeile: %s" + +#: ../src/sys/optionsreader.cxx:127 +#, c-format +msgid "\tMultiple '=' in command-line argument '%s'\n" +msgstr "\t'=' darf nicht mehrfach vorkommen: '%s'\n" + +#: ../src/bout++.cxx:415 +msgid "\tOpenMP parallelisation disabled\n" +msgstr "\tOpenMP Parallelisierung ist deaktiviert\n" + +#: ../src/bout++.cxx:413 +#, c-format +msgid "\tOpenMP parallelisation enabled, using %d threads\n" +msgstr "\tOpenMP Parallelisierung mit %d Threads ist aktiviert\n" + +#. Mark the option as used +#. Option not found +#: ../include/options.hxx:298 ../include/options.hxx:319 +#: ../src/sys/options.cxx:136 ../src/sys/options.cxx:172 +#: ../src/sys/options.cxx:200 ../src/sys/options.cxx:221 +#: ../src/sys/options.cxx:224 +msgid "\tOption " +msgstr "\tOption " + +#: ../src/sys/options.cxx:97 +#, c-format +msgid "" +"\tOption %s = %s (%s) overwritten with:\n" +"\t\t%s = %s (%s)\n" +msgstr "" +"\tOption %s = %s (%s) wird mit\n" +"\t\t%s = %s (%s) überschrieben\n" + +#: ../src/sys/options.cxx:226 +#, c-format +msgid "\tOption '%s': Boolean expected. Got '%s'\n" +msgstr "\tOption '%s': Boolscherwert erwartet, '%s' gefunden\n" + +#: ../src/sys/options/options_ini.cxx:74 +#, c-format +msgid "\tOptions file '%s' not found\n" +msgstr "\tDie Optionendatei '%s' konnte nicht gefunden werden\n" + +#: ../src/bout++.cxx:409 +msgid "\tParallel NetCDF support disabled\n" +msgstr "\tParallele-NetCDF Unterstützung ist deaktiviert\n" + +#: ../src/bout++.cxx:407 +msgid "\tParallel NetCDF support enabled\n" +msgstr "\tParllele-NetCDF Unterstützung ist aktiviert\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:124 +msgid "\tRead nz from input grid file\n" +msgstr "\tnz wird von der Griddatei gelesen\n" + +#: ../src/mesh/mesh.cxx:124 +msgid "\tReading contravariant vector " +msgstr "\tKontravariantevektoren werden gelesen " + +#: ../src/mesh/mesh.cxx:117 ../src/mesh/mesh.cxx:138 +msgid "\tReading covariant vector " +msgstr "\tKovariantevektoren werden gelesen " + +#: ../src/bout++.cxx:393 +msgid "\tSignal handling disabled\n" +msgstr "\tSignalverarbeitung ist deaktiviert\n" + +#: ../src/bout++.cxx:391 +msgid "\tSignal handling enabled\n" +msgstr "\tSignalverarbeitung ist aktiviert\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:858 +msgid "\tdone\n" +msgstr "\tfertig\n" + +#: ../src/bout++.cxx:402 +msgid "\tnetCDF support disabled\n" +msgstr "\tNetCDF Unterstützung ist deaktiviert\n" + +#: ../src/bout++.cxx:397 +msgid "\tnetCDF support enabled\n" +msgstr "\tNetCDF Unterstützung ist aktiviert\n" + +#: ../src/bout++.cxx:400 +msgid "\tnetCDF4 support enabled\n" +msgstr "\tNetCDF4 Unterstützung ist aktiviert\n" + +#: ../src/bout++.cxx:166 +#, c-format +msgid "" +"\n" +" -d \tLook in for input/output files\n" +" -f \tUse OPTIONS given in \n" +" -o \tSave used OPTIONS given to \n" +" -l, --log \tPrint log to \n" +" -v, --verbose\t\tIncrease verbosity\n" +" -q, --quiet\t\tDecrease verbosity\n" +msgstr "" +"\n" +" -d \tEin- und Ausgabedateien sind im \n" +" -f \tOptinen werden aus der gelesen\n" +" -o \tGenutzte Optionen werden in der " +" gespeichert\n" +" -l, --log \tSchreibe das Log in die \n" +" -v, --verbose\t\tWortreicherer Ausgabe\n" +" -q, --quiet\t\tNur wichtigere Ausgaben anzeigen\n" + +#: ../src/solver/solver.cxx:563 +#, c-format +msgid "" +"\n" +"Run finished at : %s\n" +msgstr "" +"\n" +"Simulation beendet um %s\n" + +#: ../src/solver/solver.cxx:534 +#, c-format +msgid "" +"\n" +"Run started at : %s\n" +msgstr "" +"\n" +"Simulation gestartet um %s\n" + +#: ../src/bout++.cxx:175 +#, c-format +msgid " -c, --color\t\tColor output using bout-log-color\n" +msgstr " -c, --color\t\tFarbliche Ausgabe mit bout-log-color\n" + +#: ../src/bout++.cxx:178 +#, c-format +msgid "" +" -h, --help\t\tThis message\n" +" restart [append]\tRestart the simulation. If append is specified, append " +"to the existing output files, otherwise overwrite them\n" +" VAR=VALUE\t\tSpecify a VALUE for input parameter VAR\n" +"\n" +"For all possible input parameters, see the user manual and/or the physics " +"model source (e.g. %s.cxx)\n" +msgstr "" +" -h, --help\t\tDiese Information\n" +" restart \t\tDie Simulation fortsetzen.\n" +" append \t\tDie dump Dateien weiter schreiben, ansonsten werden sie " +"überschrieben. Benötigt `restart`\n" +" VAR=WERT \t\tSetzt den Wert WERT für die Variable VAR\n" +"\n" +"Weitere Eingabeparameter sind in dem Manual und dem Quellcode (z.B. %s.cxx) " +"des Physikmoduls definiert.\n" + +#: ../src/sys/options.cxx:248 +msgid "All options used\n" +msgstr "Alle genutzten Optionen\n" + +#. / Print intro +#: ../src/bout++.cxx:365 +#, c-format +msgid "BOUT++ version %s\n" +msgstr "BOUT++ Version %s\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:828 +msgid "Boundary regions in this processor: " +msgstr "Randgebiete auf diesem Prozessor: " + +#: ../src/mesh/impls/bout/boutmesh.cxx:407 +#, c-format +msgid "Cannot split %d X points equally between %d processors\n" +msgstr "" +"%d Punkte in der X-Richtung können nicht gleichmässig zwischen %d Prozessen " +"verteilt werden\n" + +#: ../src/bout++.cxx:372 +#, c-format +msgid "" +"Code compiled on %s at %s\n" +"\n" +msgstr "" +"Der Code wurde am %s um %s kompiliert\n" +"\n" + +#: ../src/sys/optionsreader.cxx:142 +msgid "Command line" +msgstr "Befehlszeile" + +#. / Print compile-time options +#: ../src/bout++.cxx:382 +msgid "Compile-time options:\n" +msgstr "Kompiliert mit:\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:837 +msgid "Constructing default regions" +msgstr "Standardregionen werden erstellt" + +#: ../src/mesh/impls/bout/boutmesh.cxx:385 +msgid "" +"Could not find a valid value for NXPE. Try a different number of processors." +msgstr "" +"Es konnte keine gültige Anzahl an Prozessoren in X Richtung gefunden " +"werden (NXPE). Versuche es mit einer anderen Zahl an Prozessoren." + +#: ../src/sys/options/options_ini.cxx:132 +#, c-format +msgid "Could not open output file '%s'\n" +msgstr "Die Ausgabedatei '%s' konnte nicht geöffnet werden\n" + +#. Error reading +#: ../src/mesh/mesh.cxx:278 +#, c-format +msgid "Could not read integer array '%s'\n" +msgstr "Der Ganzzahlen-Array '%s' konnte nicht gelesen werden\n" + +#. Failed . Probably not important enough to stop the simulation +#: ../src/bout++.cxx:324 +#, c-format +msgid "Could not run bout-log-color. Make sure it is in your PATH\n" +msgstr "" +"Der Befehl 'bout-log-color' konnte nicht ausgeführt werden. Stellen Sie " +"sicher, dass er sich in $PATH befindet.\n" + +#: ../src/solver/solver.cxx:642 +#, c-format +msgid "Couldn't add Monitor: %g is not a multiple of %g!" +msgstr "" +"'Monitor' konnte nicht hinzugefügt werden: %g ist nicht ein Vielfaches " +"von %g!" + +#: ../src/mesh/mesh.cxx:349 +#, c-format +msgid "Couldn't find region %s in regionMap2D" +msgstr "Die Region '%s' ist nicht in regionMap2D" + +#: ../src/mesh/mesh.cxx:341 +#, c-format +msgid "Couldn't find region %s in regionMap3D" +msgstr "Die Region '%s' ist nicht in regionMap3D" + +#: ../src/mesh/mesh.cxx:357 +#, c-format +msgid "Couldn't find region %s in regionMapPerp" +msgstr "Die Region '%s' ist nicht in regionMapPerp" + +#: ../src/sys/options.cxx:192 +#, c-format +msgid "Couldn't get BoutReal from option %s = '%s'" +msgstr "" +"Die Option %s = '%s' konnte nicht als Gleitkommazahl interpretiert werden." + +#: ../src/sys/options.cxx:156 +#, c-format +msgid "Couldn't get integer from option %s = '%s'" +msgstr "Die Option %s = '%s' konnte nicht als ganze Zahl interpretiert werden." + +#: ../src/bout++.cxx:281 +#, c-format +msgid "DataDir \"%s\" does not exist or is not accessible\n" +msgstr "Der Datenordner \"%s\" existiert nicht oder ist nicht lesbar\n" + +#: ../src/bout++.cxx:278 +#, c-format +msgid "DataDir \"%s\" is not a directory\n" +msgstr "\"%s\" soll als Datenordner verwendet werden, ist jedoch kein Ordner\n" + +#: ../src/solver/solver.cxx:597 +msgid "ERROR: Solver is already initialised\n" +msgstr "FEHLER: Der Integrator ist bereits initialisiert.\n" + +#: ../src/bout++.cxx:470 +msgid "Error encountered during initialisation\n" +msgstr "Es wurde ein Fehler während der Initialisierung gefunden\n" + +#: ../src/bout++.cxx:515 +#, c-format +msgid "Error encountered during initialisation: %s\n" +msgstr "Es wurde ein Fehler während der Initialisierung gefunden: %s\n" + +#: ../src/bout++.cxx:554 +msgid "Error whilst writing settings" +msgstr "Es wurde ein Fehler beim Schreiben der Einstellungsdatei gefunden" + +#: ../src/mesh/impls/bout/boutmesh.cxx:147 +#, c-format +msgid "Error: nx must be greater than 2 times MXG (2 * %d)" +msgstr "Fehler: nx muss größer als 2 mal MXG sein (2 * %d)" + +#: ../src/solver/solver.cxx:526 +msgid "Failed to initialise solver-> Aborting\n" +msgstr "Der Integrator konnte nicht initialisiert werden. Der Prozess wird abgebrochen\n" + +#. Best option +#. Results in square domains +#: ../src/mesh/impls/bout/boutmesh.cxx:305 +#, c-format +msgid "Finding value for NXPE (ideal = %f)\n" +msgstr "Suche NXPE Wert (optimal = %f)\n" + +#: ../src/solver/solver.cxx:599 +msgid "Initialising solver\n" +msgstr "initialisiere den Integrator\n" + +#: ../src/bout++.cxx:270 +msgid "" +"Input and output file for settings must be different.\n" +"Provide -o to avoid this issue.\n" +msgstr "" +"Optionendatei (Eingabe) und Einstellungsdatei (Ausgabe) müssen verschieden " +"sein.\n" +"Verwende -o .\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:91 +msgid "Loading mesh" +msgstr "Lade das Gitter" + +#: ../src/mesh/impls/bout/boutmesh.cxx:106 +msgid "Mesh must contain nx" +msgstr "Das Gitter muss nx enthalten" + +#: ../src/mesh/impls/bout/boutmesh.cxx:109 +msgid "Mesh must contain ny" +msgstr "Das Gitter muss ny enthalten" + +#. Not found +#: ../src/mesh/mesh.cxx:282 +#, c-format +msgid "Missing integer array %s\n" +msgstr "Ganzzahlen-Array '%s' nicht gesetzt\n" + +#: ../src/solver/solver.cxx:696 ../src/solver/solver.cxx:703 +msgid "Monitor signalled to quit\n" +msgstr "Beendigung durch Monitor\n" + +#: ../src/mesh/impls/bout/boutmesh.cxx:834 +msgid "No boundary regions in this processor" +msgstr "Keine Randregionen auf diesem Prozessor" + +#: ../src/mesh/impls/bout/boutmesh.cxx:235 +#, c-format +msgid "Number of processors (%d) not divisible by NPs in x direction (%d)\n" +msgstr "" +"Anzahl an Prozessoren (%d) nicht teilbar durch Anzahl in x Richtung (%d)\n" + +#. Less than 1 time-step left +#: ../src/bout++.cxx:704 +#, c-format +msgid "Only %e seconds left. Quitting\n" +msgstr "Nur noch %e Sekunden verfügbar. Abbruch\n" + +#: ../src/sys/options.cxx:130 ../src/sys/options.cxx:148 +#: ../src/sys/options.cxx:184 ../src/sys/options.cxx:212 +#, c-format +msgid "Option %s has no value" +msgstr "Der Option '%s' wurde kein Wert zugewiesen" + +#: ../src/sys/options.cxx:59 +#, c-format +msgid "Option %s is not a section" +msgstr "Die Option '%s' ist keine Gruppierung" + +#. Doesn't exist +#: ../src/sys/options.cxx:70 +#, c-format +msgid "Option %s:%s does not exist" +msgstr "Die Option %s:%s exisitiert nicht" + +#: ../src/sys/options.cxx:101 +#, c-format +msgid "" +"Options: Setting a value from same source (%s) to new value '%s' - old value " +"was '%s'." +msgstr "" +"Optionen: Der Wert %3$s wird mit dem Wert %2$s gleichen Ursprungs (%1$s) " +"überschrieben." + +#: ../src/bout++.cxx:376 +#, c-format +msgid "" +"Processor number: %d of %d\n" +"\n" +msgstr "" +"Prozessorennummer: %d von %d\n" +"\n" + +#: ../src/mesh/mesh.cxx:388 +#, c-format +msgid "Registered region 2D %s" +msgstr "2D Region '%s' hinzugefügt" + +#: ../src/mesh/mesh.cxx:379 +#, c-format +msgid "Registered region 3D %s" +msgstr "3D Region '%s' hinzugefügt" + +#: ../src/mesh/mesh.cxx:397 +#, c-format +msgid "Registered region Perp %s" +msgstr "Perp Region '%s' hinzugefügt" + +#: ../src/bout++.cxx:367 +#, c-format +msgid "Revision: %s\n" +msgstr "Revision: %s\n" + +#: ../src/solver/solver.cxx:564 +msgid "Run time : " +msgstr "Dauer: " + +#. / Run the solver +#: ../src/solver/solver.cxx:531 +msgid "" +"Running simulation\n" +"\n" +msgstr "" +"Simulation wird gestartet\n" +"\n" + +#: ../src/bout++.cxx:665 +msgid "" +"Sim Time | RHS evals | Wall Time | Calc Inv Comm I/O SOLVER\n" +"\n" +msgstr "" +"Simu Zeit | RHS Berech. | Echtdauer | Rechnen Inver Komm I/O " +"Integrator\n" +"\n" + +#: ../src/bout++.cxx:668 +msgid "" +"Sim Time | RHS_e evals | RHS_I evals | Wall Time | Calc Inv " +"Comm I/O SOLVER\n" +"\n" +msgstr "" +"Simu Zeit | #expl RHS | #impl RHS | Echtdauer | Rechnen Inv " +"Komm I/O Integrator\n" +"\n" + +#: ../src/solver/solver.cxx:521 +#, c-format +msgid "Solver running for %d outputs with monitor timestep of %e\n" +msgstr "" +"Integriere mit einem `Monitor`-Zeitschritt von %2$e für %1$d Aufrufe.\n" + +#: ../src/solver/solver.cxx:519 +#, c-format +msgid "Solver running for %d outputs with output timestep of %e\n" +msgstr "Integriere %d Zeitschritte von je %e\n" + +#: ../src/solver/solver.cxx:648 +#, c-format +msgid "" +"Solver::addMonitor: Cannot reduce timestep (from %g to %g) after init is " +"called!" +msgstr "" +"Der Integrator kann den Zeitschritt nicht von %g auf %g reduzieren, nachdem " +"er initialisiert wurde!" + +#: ../src/solver/solver.cxx:1061 +#, c-format +msgid "" +"Time derivative at wrong location - Field is at %s, derivative is at %s for " +"field '%s'\n" +msgstr "" +"Die zeitliche Ableitung ist an der falschen Stelle. Das Feld '%3$s' ist an " +"Position %1$s, während die Ableitung an Position %2$s ist.\n" + +#: ../src/solver/solver.cxx:1267 +#, c-format +msgid "Time derivative for variable '%s' not set" +msgstr "Zeitliche Ableitung für Variable '%s' nicht gesetzt" + +#: ../src/mesh/mesh.cxx:385 +#, c-format +msgid "Trying to add an already existing region %s to regionMap2D" +msgstr "Die Region '%s' ist bereits vorhanden in der regionMap2D" + +#: ../src/mesh/mesh.cxx:376 +#, c-format +msgid "Trying to add an already existing region %s to regionMap3D" +msgstr "Die Region '%s' ist bereits vorhanden in der regionMap3D" + +#: ../src/mesh/mesh.cxx:394 +#, c-format +msgid "Trying to add an already existing region %s to regionMapPerp" +msgstr "Die Region '%s' ist bereits vorhanden in der regionMapPerp" + +#: ../src/mesh/mesh.cxx:313 +msgid "" +"Unrecognised paralleltransform option.\n" +"Valid choices are 'identity', 'shifted', 'fci'" +msgstr "" +"Unbekannte Paralleltransformation\n" +"Gültige Optionen sind 'identity', 'shifted', 'fci'" + +#: ../src/sys/options.cxx:250 +msgid "Unused options:\n" +msgstr "Ungenutzte Optionen:\n" + +#: ../src/bout++.cxx:202 +#, c-format +msgid "Usage is %s -d \n" +msgstr "Benutzung: %s -d \n" + +#: ../src/bout++.cxx:214 +#, c-format +msgid "Usage is %s -f \n" +msgstr "Benutzung: %s -f \n" + +#: ../src/bout++.cxx:237 +#, c-format +msgid "Usage is %s -l \n" +msgstr "Benutzung: %s -f \n" + +#: ../src/bout++.cxx:226 +#, c-format +msgid "Usage is %s -o \n" +msgstr "Benutzung: %s -f \n" + +#. Print help message -- note this will be displayed once per processor as we've not started MPI yet. +#: ../src/bout++.cxx:164 +#, c-format +msgid "" +"Usage: %s [-d ] [-f ] [restart [append]] " +"[VAR=VALUE]\n" +msgstr "" +"Benutzung: %s [-d ] [-f ] [restart [append]] " +"[VAR=WERT]\n" + +#: ../src/sys/options.cxx:166 +#, c-format +msgid "Value for option %s = %e is not an integer" +msgstr "Wert der Option %s = %e ist keine Ganzzahl" + +#: ../src/solver/solver.cxx:1020 ../src/solver/solver.cxx:1024 +#, c-format +msgid "Variable '%s' not initialised" +msgstr "Variable '%s' ist nicht initialisiert" + +#. Should be a power of 2 for efficient FFTs +#: ../src/mesh/impls/bout/boutmesh.cxx:119 +msgid "" +"WARNING: Number of toroidal points should be 2^n for efficient FFT " +"performance -- consider changing MZ if using FFTs\n" +msgstr "" +"WARNUNG: Anzahl der toroidalen Punkte sollte 2^n für effiziente FFTs sein. Ändere MZ " +"falls FFTs verwendet werden\n" + +#: ../src/sys/optionsreader.cxx:60 +#, c-format +msgid "Writing options to file %s\n" +msgstr "Optionen werden in %s gespeichert\n" + +#. / The source label given to default values +#: ../src/sys/options.cxx:11 +msgid "default" +msgstr "Vorgabe" + +#: ../src/mesh/impls/bout/boutmesh.cxx:156 +msgid "nx must be greater than 2*MXG" +msgstr "nx muss größer als 2*MXG sein" + +#, fuzzy +#~ msgid ") overwritten with:" +#~ msgstr ") überschrieben mit %s" + +#~ msgid "Monitor signalled to quit" +#~ msgstr "Der Monitor signaliserte die Beendigung" diff --git a/locale/libbout.pot b/locale/libbout.pot index 8f66cc21be..595771f856 100644 --- a/locale/libbout.pot +++ b/locale/libbout.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-11-01 17:55+0000\n" +"POT-Creation-Date: 2019-02-06 17:31+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,42 +17,99 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../src/mesh/impls/bout/boutmesh.cxx:376 +#: ../src/mesh/impls/bout/boutmesh.cxx:335 +#, c-format +msgid "" +"\t -> Core region jyseps2_1-jyseps1_1 (%d-%d = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" + +#: ../src/mesh/impls/bout/boutmesh.cxx:364 +#, c-format +msgid "" +"\t -> Core region jyseps2_2-jyseps1_1 (%d-%d = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" + +#: ../src/mesh/impls/bout/boutmesh.cxx:342 +#, c-format +msgid "" +"\t -> Core region jyseps2_2-jyseps1_2 (%d-%d = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" + +#: ../src/mesh/impls/bout/boutmesh.cxx:377 msgid "\t -> Good value\n" msgstr "" +#: ../src/mesh/impls/bout/boutmesh.cxx:326 +#, c-format +msgid "\t -> Leg region jyseps1_1+1 (%d) must be a multiple of MYSUB (%d)\n" +msgstr "" + +#: ../src/mesh/impls/bout/boutmesh.cxx:356 +#, c-format +msgid "" +"\t -> leg region jyseps1_2-ny_inner+1 (%d-%d+1 = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" + +#: ../src/mesh/impls/bout/boutmesh.cxx:372 +#, c-format +msgid "" +"\t -> leg region ny-jyseps2_2-1 (%d-%d-1 = %d) must be a multiple of MYSUB " +"(%d)\n" +msgstr "" + +#: ../src/mesh/impls/bout/boutmesh.cxx:350 +#, c-format +msgid "" +"\t -> leg region ny_inner-jyseps2_1-1 (%d-%d-1 = %d) must be a multiple of " +"MYSUB (%d)\n" +msgstr "" + +#: ../src/mesh/impls/bout/boutmesh.cxx:319 +#, c-format +msgid "\t -> ny/NYPE (%d/%d = %d) must be >= MYG (%d)\n" +msgstr "" + #. Loop over all possibilities #. Processors divide equally #. Mesh in X divides equally #. Mesh in Y divides equally -#: ../src/mesh/impls/bout/boutmesh.cxx:311 +#: ../src/mesh/impls/bout/boutmesh.cxx:312 #, c-format msgid "\tCandidate value: %d\n" msgstr "" -#: ../src/bout++.cxx:370 +#: ../src/bout++.cxx:387 msgid "\tChecking disabled\n" msgstr "" -#: ../src/bout++.cxx:368 +#: ../src/bout++.cxx:385 #, c-format msgid "\tChecking enabled, level %d\n" msgstr "" +#. Print command line options +#: ../src/bout++.cxx:431 +msgid "\tCommand line options for this run : " +msgstr "" + #. The stringify is needed here as BOUT_FLAGS_STRING may already contain quoted strings #. which could cause problems (e.g. terminate strings). -#: ../src/bout++.cxx:411 +#: ../src/bout++.cxx:428 #, c-format msgid "\tCompiled with flags : %s\n" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:390 +#: ../src/mesh/impls/bout/boutmesh.cxx:391 #, c-format msgid "" "\tDomain split (NXPE=%d, NYPE=%d) into domains (localNx=%d, localNy=%d)\n" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:415 +#: ../src/mesh/impls/bout/boutmesh.cxx:416 #, c-format msgid "\tERROR: Cannot split %d Y points equally between %d processors\n" msgstr "" @@ -89,24 +146,31 @@ msgstr "" msgid "\tMultiple '=' in command-line argument '%s'\n" msgstr "" -#: ../src/bout++.cxx:398 +#: ../src/bout++.cxx:415 msgid "\tOpenMP parallelisation disabled\n" msgstr "" -#: ../src/bout++.cxx:396 +#: ../src/bout++.cxx:413 #, c-format msgid "\tOpenMP parallelisation enabled, using %d threads\n" msgstr "" #. Mark the option as used #. Option not found -#: ../src/sys/options.cxx:96 ../src/sys/options.cxx:136 -#: ../src/sys/options.cxx:172 ../src/sys/options.cxx:200 -#: ../src/sys/options.cxx:221 ../src/sys/options.cxx:224 #: ../include/options.hxx:298 ../include/options.hxx:319 +#: ../src/sys/options.cxx:136 ../src/sys/options.cxx:172 +#: ../src/sys/options.cxx:200 ../src/sys/options.cxx:221 +#: ../src/sys/options.cxx:224 msgid "\tOption " msgstr "" +#: ../src/sys/options.cxx:97 +#, c-format +msgid "" +"\tOption %s = %s (%s) overwritten with:\n" +"\t\t%s = %s (%s)\n" +msgstr "" + #: ../src/sys/options.cxx:226 #, c-format msgid "\tOption '%s': Boolean expected. Got '%s'\n" @@ -117,11 +181,11 @@ msgstr "" msgid "\tOptions file '%s' not found\n" msgstr "" -#: ../src/bout++.cxx:392 +#: ../src/bout++.cxx:409 msgid "\tParallel NetCDF support disabled\n" msgstr "" -#: ../src/bout++.cxx:390 +#: ../src/bout++.cxx:407 msgid "\tParallel NetCDF support enabled\n" msgstr "" @@ -137,31 +201,31 @@ msgstr "" msgid "\tReading covariant vector " msgstr "" -#: ../src/bout++.cxx:376 +#: ../src/bout++.cxx:393 msgid "\tSignal handling disabled\n" msgstr "" -#: ../src/bout++.cxx:374 +#: ../src/bout++.cxx:391 msgid "\tSignal handling enabled\n" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:842 +#: ../src/mesh/impls/bout/boutmesh.cxx:858 msgid "\tdone\n" msgstr "" -#: ../src/bout++.cxx:385 +#: ../src/bout++.cxx:402 msgid "\tnetCDF support disabled\n" msgstr "" -#: ../src/bout++.cxx:380 +#: ../src/bout++.cxx:397 msgid "\tnetCDF support enabled\n" msgstr "" -#: ../src/bout++.cxx:383 +#: ../src/bout++.cxx:400 msgid "\tnetCDF4 support enabled\n" msgstr "" -#: ../src/bout++.cxx:172 +#: ../src/bout++.cxx:166 #, c-format msgid "" "\n" @@ -187,12 +251,12 @@ msgid "" "Run started at : %s\n" msgstr "" -#: ../src/bout++.cxx:181 +#: ../src/bout++.cxx:175 #, c-format msgid " -c, --color\t\tColor output using bout-log-color\n" msgstr "" -#: ../src/bout++.cxx:184 +#: ../src/bout++.cxx:178 #, c-format msgid "" " -h, --help\t\tThis message\n" @@ -204,30 +268,26 @@ msgid "" "model source (e.g. %s.cxx)\n" msgstr "" -#: ../src/sys/options.cxx:97 -msgid ") overwritten with:" -msgstr "" - #: ../src/sys/options.cxx:248 msgid "All options used\n" msgstr "" #. / Print intro -#: ../src/bout++.cxx:348 +#: ../src/bout++.cxx:365 #, c-format msgid "BOUT++ version %s\n" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:827 +#: ../src/mesh/impls/bout/boutmesh.cxx:828 msgid "Boundary regions in this processor: " msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:406 +#: ../src/mesh/impls/bout/boutmesh.cxx:407 #, c-format msgid "Cannot split %d X points equally between %d processors\n" msgstr "" -#: ../src/bout++.cxx:355 +#: ../src/bout++.cxx:372 #, c-format msgid "" "Code compiled on %s at %s\n" @@ -239,15 +299,15 @@ msgid "Command line" msgstr "" #. / Print compile-time options -#: ../src/bout++.cxx:365 +#: ../src/bout++.cxx:382 msgid "Compile-time options:\n" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:836 +#: ../src/mesh/impls/bout/boutmesh.cxx:837 msgid "Constructing default regions" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:384 +#: ../src/mesh/impls/bout/boutmesh.cxx:385 msgid "" "Could not find a valid value for NXPE. Try a different number of processors." msgstr "" @@ -264,7 +324,7 @@ msgid "Could not read integer array '%s'\n" msgstr "" #. Failed . Probably not important enough to stop the simulation -#: ../src/bout++.cxx:308 +#: ../src/bout++.cxx:324 #, c-format msgid "Could not run bout-log-color. Make sure it is in your PATH\n" msgstr "" @@ -299,12 +359,12 @@ msgstr "" msgid "Couldn't get integer from option %s = '%s'" msgstr "" -#: ../src/bout++.cxx:261 +#: ../src/bout++.cxx:281 #, c-format msgid "DataDir \"%s\" does not exist or is not accessible\n" msgstr "" -#: ../src/bout++.cxx:258 +#: ../src/bout++.cxx:278 #, c-format msgid "DataDir \"%s\" is not a directory\n" msgstr "" @@ -313,16 +373,16 @@ msgstr "" msgid "ERROR: Solver is already initialised\n" msgstr "" -#: ../src/bout++.cxx:441 +#: ../src/bout++.cxx:470 msgid "Error encountered during initialisation\n" msgstr "" -#: ../src/bout++.cxx:486 +#: ../src/bout++.cxx:515 #, c-format msgid "Error encountered during initialisation: %s\n" msgstr "" -#: ../src/bout++.cxx:525 +#: ../src/bout++.cxx:554 msgid "Error whilst writing settings" msgstr "" @@ -335,11 +395,18 @@ msgstr "" msgid "Failed to initialise solver-> Aborting\n" msgstr "" +#. Best option +#. Results in square domains +#: ../src/mesh/impls/bout/boutmesh.cxx:305 +#, c-format +msgid "Finding value for NXPE (ideal = %f)\n" +msgstr "" + #: ../src/solver/solver.cxx:599 msgid "Initialising solver\n" msgstr "" -#: ../src/bout++.cxx:250 +#: ../src/bout++.cxx:270 msgid "" "Input and output file for settings must be different.\n" "Provide -o to avoid this issue.\n" @@ -363,25 +430,21 @@ msgstr "" msgid "Missing integer array %s\n" msgstr "" -#: ../src/solver/solver.cxx:696 -msgid "Monitor signalled to quit" -msgstr "" - -#: ../src/solver/solver.cxx:703 +#: ../src/solver/solver.cxx:696 ../src/solver/solver.cxx:703 msgid "Monitor signalled to quit\n" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:833 +#: ../src/mesh/impls/bout/boutmesh.cxx:834 msgid "No boundary regions in this processor" msgstr "" -#: ../src/mesh/impls/bout/boutmesh.cxx:234 +#: ../src/mesh/impls/bout/boutmesh.cxx:235 #, c-format msgid "Number of processors (%d) not divisible by NPs in x direction (%d)\n" msgstr "" #. Less than 1 time-step left -#: ../src/bout++.cxx:675 +#: ../src/bout++.cxx:704 #, c-format msgid "Only %e seconds left. Quitting\n" msgstr "" @@ -410,26 +473,29 @@ msgid "" "was '%s'." msgstr "" -#: ../src/bout++.cxx:359 +#: ../src/bout++.cxx:376 #, c-format msgid "" "Processor number: %d of %d\n" "\n" msgstr "" -#: ../src/mesh/mesh.cxx:376 -msgid "Registered region 2D " +#: ../src/mesh/mesh.cxx:388 +#, c-format +msgid "Registered region 2D %s" msgstr "" -#: ../src/mesh/mesh.cxx:367 -msgid "Registered region 3D " +#: ../src/mesh/mesh.cxx:379 +#, c-format +msgid "Registered region 3D %s" msgstr "" -#: ../src/mesh/mesh.cxx:385 -msgid "Registered region Perp " +#: ../src/mesh/mesh.cxx:397 +#, c-format +msgid "Registered region Perp %s" msgstr "" -#: ../src/bout++.cxx:350 +#: ../src/bout++.cxx:367 #, c-format msgid "Revision: %s\n" msgstr "" @@ -445,13 +511,13 @@ msgid "" "\n" msgstr "" -#: ../src/bout++.cxx:636 +#: ../src/bout++.cxx:665 msgid "" "Sim Time | RHS evals | Wall Time | Calc Inv Comm I/O SOLVER\n" "\n" msgstr "" -#: ../src/bout++.cxx:639 +#: ../src/bout++.cxx:668 msgid "" "Sim Time | RHS_e evals | RHS_I evals | Wall Time | Calc Inv " "Comm I/O SOLVER\n" @@ -487,17 +553,17 @@ msgstr "" msgid "Time derivative for variable '%s' not set" msgstr "" -#: ../src/mesh/mesh.cxx:373 +#: ../src/mesh/mesh.cxx:385 #, c-format msgid "Trying to add an already existing region %s to regionMap2D" msgstr "" -#: ../src/mesh/mesh.cxx:364 +#: ../src/mesh/mesh.cxx:376 #, c-format msgid "Trying to add an already existing region %s to regionMap3D" msgstr "" -#: ../src/mesh/mesh.cxx:382 +#: ../src/mesh/mesh.cxx:394 #, c-format msgid "Trying to add an already existing region %s to regionMapPerp" msgstr "" @@ -512,28 +578,28 @@ msgstr "" msgid "Unused options:\n" msgstr "" -#: ../src/bout++.cxx:200 +#: ../src/bout++.cxx:202 #, c-format msgid "Usage is %s -d \n" msgstr "" -#: ../src/bout++.cxx:209 +#: ../src/bout++.cxx:214 #, c-format msgid "Usage is %s -f \n" msgstr "" -#: ../src/bout++.cxx:226 +#: ../src/bout++.cxx:237 #, c-format msgid "Usage is %s -l \n" msgstr "" -#: ../src/bout++.cxx:218 +#: ../src/bout++.cxx:226 #, c-format msgid "Usage is %s -o \n" msgstr "" #. Print help message -- note this will be displayed once per processor as we've not started MPI yet. -#: ../src/bout++.cxx:170 +#: ../src/bout++.cxx:164 #, c-format msgid "" "Usage: %s [-d ] [-f ] [restart [append]] " @@ -558,7 +624,8 @@ msgid "" msgstr "" #: ../src/sys/optionsreader.cxx:60 -msgid "Writing options to file " +#, c-format +msgid "Writing options to file %s\n" msgstr "" #. / The source label given to default values diff --git a/locale/makefile b/locale/makefile index 74e245618f..9b67440f6e 100644 --- a/locale/makefile +++ b/locale/makefile @@ -12,7 +12,7 @@ locale: $(MO_FILES) # Create the template file, combining all source files libbout.pot: FORCE - xgettext --keyword=_ --language=c++ --add-comments --sort-output -o $@ `find ../ -name "*.[ch]xx"` + xgettext --keyword=_ --language=c++ --add-comments --sort-output -o $@ `find ../ -name "[^.#]*.[ch]xx"` # Update a .po file # If it doesn't exist then create; if it exists then update diff --git a/src/bout++.cxx b/src/bout++.cxx index 6e4ef0b5cd..53a5e45c39 100644 --- a/src/bout++.cxx +++ b/src/bout++.cxx @@ -44,13 +44,16 @@ const char DEFAULT_LOG[] = "BOUT.log"; #include "mpi.h" #include -#include #include #include #include #include #include +#define BOUT_NO_USING_NAMESPACE_BOUTGLOBALS +#include +#undef BOUT_NO_USING_NAMESPACE_BOUTGLOBALS + #include #include @@ -475,9 +478,9 @@ int BoutInitialise(int &argc, char **&argv) { try { ///////////////////////////////////////////// - mesh = Mesh::create(); ///< Create the mesh - mesh->load(); ///< Load from sources. Required for Field initialisation - mesh->setParallelTransform(); ///< Set the parallel transform from options + bout::globals::mesh = Mesh::create(); ///< Create the mesh + bout::globals::mesh->load(); ///< Load from sources. Required for Field initialisation + bout::globals::mesh->setParallelTransform(); ///< Set the parallel transform from options ///////////////////////////////////////////// /// Get some settings @@ -493,23 +496,23 @@ int BoutInitialise(int &argc, char **&argv) { // Set up the "dump" data output file output << "Setting up output (dump) file\n"; - dump = Datafile(options->getSection("output")); + bout::globals::dump = Datafile(options->getSection("output"), bout::globals::mesh); /// Open a file for the output if(append) { - dump.opena("%s/BOUT.dmp.%s", data_dir.c_str(), dump_ext.c_str()); + bout::globals::dump.opena("%s/BOUT.dmp.%s", data_dir.c_str(), dump_ext.c_str()); }else { - dump.openw("%s/BOUT.dmp.%s", data_dir.c_str(), dump_ext.c_str()); + bout::globals::dump.openw("%s/BOUT.dmp.%s", data_dir.c_str(), dump_ext.c_str()); } /// Add book-keeping variables to the output files - dump.add(const_cast(BOUT_VERSION), "BOUT_VERSION", false); - dump.add(simtime, "t_array", true); // Appends the time of dumps into an array - dump.add(iteration, "iteration", false); + bout::globals::dump.add(const_cast(BOUT_VERSION), "BOUT_VERSION", false); + bout::globals::dump.add(simtime, "t_array", true); // Appends the time of dumps into an array + bout::globals::dump.add(iteration, "iteration", false); //////////////////////////////////////////// - mesh->outputVars(dump); ///< Save mesh configuration into output file + bout::globals::mesh->outputVars(bout::globals::dump); ///< Save mesh configuration into output file }catch(BoutException &e) { output_error.write(_("Error encountered during initialisation: %s\n"), e.what()); @@ -556,10 +559,10 @@ int BoutFinalise() { } // Delete the mesh - delete mesh; + delete bout::globals::mesh; // Close the output file - dump.close(); + bout::globals::dump.close(); // Make sure all processes have finished writing before exit MPI_Barrier(BoutComm::get()); @@ -621,7 +624,7 @@ int BoutMonitor::call(Solver *solver, BoutReal t, int iter, int NOUT) { iteration = iter; /// Write dump file - dump.write(); + bout::globals::dump.write(); /// Collect timing information BoutReal wtime = Timer::resetTime("run"); diff --git a/src/field/field.cxx b/src/field/field.cxx index 3e4fd46987..4d133f722d 100644 --- a/src/field/field.cxx +++ b/src/field/field.cxx @@ -32,10 +32,8 @@ #include #include -Field::Field(Mesh *localmesh) : fieldmesh(localmesh) { - if (fieldmesh == nullptr) { - fieldmesh = mesh; - } +Field::Field(Mesh *localmesh) + : fieldmesh(localmesh==nullptr ? bout::globals::mesh : localmesh) { // Note we would like to do `fieldCoordinates = getCoordinates();` here but can't // currently as this would lead to circular/recursive behaviour (getCoordinates would diff --git a/src/field/field2d.cxx b/src/field/field2d.cxx index 7da30dacf4..5fcdef90df 100644 --- a/src/field/field2d.cxx +++ b/src/field/field2d.cxx @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -89,7 +90,7 @@ void Field2D::allocate() { if(data.empty()) { if(!fieldmesh) { /// If no mesh, use the global - fieldmesh = mesh; + fieldmesh = bout::globals::mesh; nx = fieldmesh->LocalNx; ny = fieldmesh->LocalNy; } @@ -549,8 +550,6 @@ void checkData(const Field2D &f, REGION region) { #if CHECK > 2 void invalidateGuards(Field2D &var) { - Mesh *localmesh = var.getMesh(); - BOUT_FOR(i, var.getRegion("RGN_GUARDS")) { var[i] = BoutNaN; } } #endif diff --git a/src/field/field3d.cxx b/src/field/field3d.cxx index 5b77bb998e..9333032543 100644 --- a/src/field/field3d.cxx +++ b/src/field/field3d.cxx @@ -108,7 +108,7 @@ void Field3D::allocate() { if(data.empty()) { if(!fieldmesh) { /// If no mesh, use the global - fieldmesh = mesh; + fieldmesh = bout::globals::mesh; nx = fieldmesh->LocalNx; ny = fieldmesh->LocalNy; nz = fieldmesh->LocalNz; @@ -1082,8 +1082,6 @@ Field2D DC(const Field3D &f, REGION rgn) { #if CHECK > 2 void invalidateGuards(Field3D &var) { - Mesh *localmesh = var.getMesh(); - BOUT_FOR(i, var.getRegion("RGN_GUARDS")) { var[i] = BoutNaN; } } #endif diff --git a/src/field/field_data.cxx b/src/field/field_data.cxx index 4251ace1b4..8282f9cda4 100644 --- a/src/field/field_data.cxx +++ b/src/field/field_data.cxx @@ -1,4 +1,5 @@ +#include #include #include #include @@ -20,7 +21,7 @@ void FieldData::setBoundary(const std::string &name) { output_info << "Setting boundary for variable " << name << endl; /// Loop over the mesh boundary regions - for(const auto& reg : mesh->getBoundaries()) { + for(const auto& reg : bout::globals::mesh->getBoundaries()) { BoundaryOp* op = static_cast(bfact->createFromOptions(name, reg)); if (op != nullptr) bndry_op.push_back(op); @@ -28,9 +29,9 @@ void FieldData::setBoundary(const std::string &name) { } /// Get the mesh boundary regions - std::vector par_reg = mesh->getBoundariesPar(); + std::vector par_reg = bout::globals::mesh->getBoundariesPar(); /// Loop over the mesh parallel boundary regions - for(const auto& reg : mesh->getBoundariesPar()) { + for(const auto& reg : bout::globals::mesh->getBoundariesPar()) { BoundaryOpPar* op = static_cast(bfact->createFromOptions(name, reg)); if (op != nullptr) bndry_op_par.push_back(op); @@ -43,7 +44,7 @@ void FieldData::setBoundary(const std::string &name) { void FieldData::setBoundary(const std::string &UNUSED(region), BoundaryOp *op) { /// Get the mesh boundary regions - std::vector reg = mesh->getBoundaries(); + std::vector reg = bout::globals::mesh->getBoundaries(); /// Find the region @@ -72,7 +73,7 @@ void FieldData::addBndryFunction(FuncPtr userfunc, BndryLoc location){ void FieldData::addBndryGenerator(FieldGeneratorPtr gen, BndryLoc location) { if(location == BNDRY_ALL){ - for(const auto& reg : mesh->getBoundaries()) { + for(const auto& reg : bout::globals::mesh->getBoundaries()) { bndry_generator[reg->location] = gen; } } else { diff --git a/src/field/fieldperp.cxx b/src/field/fieldperp.cxx index 07686b90f3..8ac0a2906d 100644 --- a/src/field/fieldperp.cxx +++ b/src/field/fieldperp.cxx @@ -28,6 +28,7 @@ #include +#include #include #include #include @@ -50,7 +51,7 @@ void FieldPerp::allocate() { if (data.empty()) { if (!fieldmesh) { /// If no mesh, use the global - fieldmesh = mesh; + fieldmesh = bout::globals::mesh; nx = fieldmesh->LocalNx; nz = fieldmesh->LocalNz; } @@ -538,8 +539,6 @@ void checkData(const FieldPerp &f, REGION region) { #if CHECK > 2 void invalidateGuards(FieldPerp &var) { - Mesh *localmesh = var.getMesh(); - BOUT_FOR(i, var.getRegion("RGN_GUARDS")) { var[i] = BoutNaN; } } #endif diff --git a/src/field/initialprofiles.cxx b/src/field/initialprofiles.cxx index 16b0fbc156..5fa35f98bb 100644 --- a/src/field/initialprofiles.cxx +++ b/src/field/initialprofiles.cxx @@ -36,6 +36,9 @@ * **************************************************************************/ +#include +#include +#include #include #include #include diff --git a/src/field/vecops.cxx b/src/field/vecops.cxx index 306317d2a9..e61a711e64 100644 --- a/src/field/vecops.cxx +++ b/src/field/vecops.cxx @@ -24,6 +24,7 @@ * **************************************************************************/ +#include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include /************************************************************************** * Gradient operators diff --git a/src/field/vector3d.cxx b/src/field/vector3d.cxx index 1959ce3bbe..80081d1931 100644 --- a/src/field/vector3d.cxx +++ b/src/field/vector3d.cxx @@ -472,7 +472,9 @@ const Vector3D Vector3D::operator/(const Field3D &rhs) const { ////////////////// DOT PRODUCT /////////////////// const Field3D Vector3D::operator*(const Vector3D &rhs) const { - Field3D result(x.getMesh()); + Mesh* mesh = x.getMesh(); + + Field3D result(mesh); ASSERT2(location == rhs.getLocation()) if(rhs.covariant ^ covariant) { diff --git a/src/fileio/datafile.cxx b/src/fileio/datafile.cxx index ba6b259395..80310d20d3 100644 --- a/src/fileio/datafile.cxx +++ b/src/fileio/datafile.cxx @@ -36,9 +36,11 @@ //#include "mpi.h" // For MPI_Wtime() #include +#include #include #include #include +#include #include #include #include @@ -46,10 +48,12 @@ #include #include "formatfactory.hxx" -Datafile::Datafile(Options *opt) : parallel(false), flush(true), guards(true), - floats(false), openclose(true), enabled(true), shiftOutput(false), - shiftInput(false), flushFrequencyCounter(0), flushFrequency(1), - file(nullptr), writable(false), appending(false), first_time(true) +Datafile::Datafile(Options *opt, Mesh* mesh_in) + : mesh(mesh_in==nullptr ? bout::globals::mesh : mesh_in), + parallel(false), flush(true), guards(true), floats(false), openclose(true), + enabled(true), shiftOutput(false), shiftInput(false), + flushFrequencyCounter(0), flushFrequency(1), file(nullptr), writable(false), + appending(false), first_time(true) { filenamelen=FILENAMELEN; filename=new char[filenamelen]; @@ -91,7 +95,7 @@ Datafile::Datafile(Datafile &&other) noexcept } Datafile::Datafile(const Datafile &other) : - parallel(other.parallel), flush(other.flush), guards(other.guards), + mesh(other.mesh), parallel(other.parallel), flush(other.flush), guards(other.guards), floats(other.floats), openclose(other.openclose), Lx(other.Lx), Ly(other.Ly), Lz(other.Lz), enabled(other.enabled), shiftOutput(other.shiftOutput), shiftInput(other.shiftInput), flushFrequencyCounter(other.flushFrequencyCounter), flushFrequency(other.flushFrequency), file(nullptr), writable(other.writable), appending(other.appending), first_time(other.first_time), @@ -106,6 +110,7 @@ Datafile::Datafile(const Datafile &other) : } Datafile& Datafile::operator=(Datafile &&rhs) noexcept { + mesh = rhs.mesh; parallel = rhs.parallel; flush = rhs.flush; guards = rhs.guards; @@ -189,7 +194,7 @@ bool Datafile::openw(const char *format, ...) { bout_vsnprintf(filename, filenamelen, format); // Get the data format - file = FormatFactory::getInstance()->createDataFormat(filename, parallel); + file = FormatFactory::getInstance()->createDataFormat(filename, parallel, mesh); if(!file) throw BoutException("Datafile::open: Factory failed to create a DataFormat!"); diff --git a/src/fileio/dataformat.cxx b/src/fileio/dataformat.cxx index 2fa1d9dd0d..cf09ea170b 100644 --- a/src/fileio/dataformat.cxx +++ b/src/fileio/dataformat.cxx @@ -1,8 +1,12 @@ +#include #include #include #include +DataFormat::DataFormat(Mesh* mesh_in) + : mesh(mesh_in==nullptr ? bout::globals::mesh : mesh_in) {} + bool DataFormat::openr(const std::string &name, int mype) { // Split into base name and extension size_t pos = name.find_last_of('.'); diff --git a/src/fileio/formatfactory.cxx b/src/fileio/formatfactory.cxx index 244b4da6e8..d2ee7fd8f8 100644 --- a/src/fileio/formatfactory.cxx +++ b/src/fileio/formatfactory.cxx @@ -12,6 +12,7 @@ #include #include +#include #include FormatFactory *FormatFactory::instance = nullptr; @@ -25,27 +26,29 @@ FormatFactory* FormatFactory::getInstance() { } // Work out which data format to use for given filename -std::unique_ptr FormatFactory::createDataFormat(const char *filename, bool parallel) { +std::unique_ptr FormatFactory::createDataFormat(const char *filename, + bool parallel, + Mesh* mesh_in) { if ((filename == nullptr) || (strcasecmp(filename, "default") == 0)) { // Return default file format if (parallel) { #ifdef PNCDF - return bout::utils::make_unique(); + return bout::utils::make_unique(mesh_in); #else } #ifdef NCDF4 - return bout::utils::make_unique(); + return bout::utils::make_unique(mesh_in); #else #ifdef NCDF - return bout::utils::make_unique(); + return bout::utils::make_unique(mesh_in); #else #ifdef HDF5 - return bout::utils::make_unique(); + return bout::utils::make_unique(mesh_in); #else #error No file format available; aborting. diff --git a/src/fileio/formatfactory.hxx b/src/fileio/formatfactory.hxx index c6830bb771..361773871c 100644 --- a/src/fileio/formatfactory.hxx +++ b/src/fileio/formatfactory.hxx @@ -14,7 +14,8 @@ public: static FormatFactory* getInstance(); std::unique_ptr createDataFormat(const char *filename = nullptr, - bool parallel = true); + bool parallel = true, + Mesh* mesh_in = nullptr); private: static FormatFactory* instance; ///< The only instance of this class (Singleton) diff --git a/src/fileio/impls/hdf5/h5_format.cxx b/src/fileio/impls/hdf5/h5_format.cxx index f6260982de..b938a52202 100644 --- a/src/fileio/impls/hdf5/h5_format.cxx +++ b/src/fileio/impls/hdf5/h5_format.cxx @@ -30,11 +30,12 @@ #include #include +#include #include #include #include -H5Format::H5Format(bool parallel_in) { +H5Format::H5Format(bool parallel_in, Mesh* mesh_in) : DataFormat(mesh_in) { parallel = parallel_in; x0 = y0 = z0 = t0 = 0; lowPrecision = false; @@ -69,7 +70,8 @@ H5Format::H5Format(bool parallel_in) { throw BoutException("Failed to set error stack to not print errors"); } -H5Format::H5Format(const char *name, bool parallel_in) { +H5Format::H5Format(const char *name, bool parallel_in, Mesh* mesh_in) + : DataFormat(mesh_in) { parallel = parallel_in; x0 = y0 = z0 = t0 = 0; lowPrecision = false; diff --git a/src/fileio/impls/hdf5/h5_format.hxx b/src/fileio/impls/hdf5/h5_format.hxx index 0853f695b6..b319aac461 100644 --- a/src/fileio/impls/hdf5/h5_format.hxx +++ b/src/fileio/impls/hdf5/h5_format.hxx @@ -54,9 +54,10 @@ class H5Format; class H5Format : public DataFormat { public: - H5Format(bool parallel_in = false); - H5Format(const char *name, bool parallel_in = false); - H5Format(const std::string &name, bool parallel_in = false) : H5Format(name.c_str(), parallel_in) {} + H5Format(bool parallel_in = false, Mesh* mesh_in = nullptr); + H5Format(const char *name, bool parallel_in = false, Mesh* mesh_in = nullptr); + H5Format(const std::string &name, bool parallel_in = false, Mesh* mesh_in = nullptr) + : H5Format(name.c_str(), parallel_in, mesh_in) {} ~H5Format(); using DataFormat::openr; diff --git a/src/fileio/impls/netcdf/nc_format.cxx b/src/fileio/impls/netcdf/nc_format.cxx index b648c638eb..7d9e2aa2a4 100644 --- a/src/fileio/impls/netcdf/nc_format.cxx +++ b/src/fileio/impls/netcdf/nc_format.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -37,7 +38,7 @@ using std::vector; // Define this to see loads of info messages //#define NCDF_VERBOSE -NcFormat::NcFormat() { +NcFormat::NcFormat(Mesh* mesh_in) : DataFormat(mesh_in) { dataFile = nullptr; x0 = y0 = z0 = t0 = 0; recDimList = new const NcDim*[4]; @@ -50,7 +51,7 @@ NcFormat::NcFormat() { fname = nullptr; } -NcFormat::NcFormat(const char *name) { +NcFormat::NcFormat(const char *name, Mesh* mesh_in) : DataFormat(mesh_in) { dataFile = nullptr; x0 = y0 = z0 = t0 = 0; recDimList = new const NcDim*[4]; diff --git a/src/fileio/impls/netcdf/nc_format.hxx b/src/fileio/impls/netcdf/nc_format.hxx index 4b65329e21..e1ebfaa964 100644 --- a/src/fileio/impls/netcdf/nc_format.hxx +++ b/src/fileio/impls/netcdf/nc_format.hxx @@ -55,9 +55,10 @@ class NcFormat; class NcFormat : public DataFormat { public: - NcFormat(); - NcFormat(const char *name); - NcFormat(const std::string &name) : NcFormat(name.c_str()) {} + NcFormat(Mesh* mesh_in = nullptr); + NcFormat(const char *name, Mesh* mesh_in = nullptr); + NcFormat(const std::string &name, Mesh* mesh_in = nullptr) + : NcFormat(name.c_str(), mesh_in) {} ~NcFormat(); using DataFormat::openr; diff --git a/src/fileio/impls/netcdf4/ncxx4.cxx b/src/fileio/impls/netcdf4/ncxx4.cxx index c6c084c7ef..a1c5c0e6e3 100644 --- a/src/fileio/impls/netcdf4/ncxx4.cxx +++ b/src/fileio/impls/netcdf4/ncxx4.cxx @@ -24,6 +24,7 @@ #ifdef NCDF4 +#include #include #include #include @@ -38,7 +39,7 @@ using namespace netCDF; // Define this to see loads of info messages //#define NCDF_VERBOSE -Ncxx4::Ncxx4() { +Ncxx4::Ncxx4(Mesh* mesh_in) : DataFormat(mesh_in) { dataFile = nullptr; x0 = y0 = z0 = t0 = 0; recDimList = new const NcDim*[4]; @@ -51,7 +52,7 @@ Ncxx4::Ncxx4() { fname = nullptr; } -Ncxx4::Ncxx4(const char *name) { +Ncxx4::Ncxx4(const char *name, Mesh* mesh_in) : DataFormat(mesh_in) { dataFile = nullptr; x0 = y0 = z0 = t0 = 0; recDimList = new const NcDim*[4]; diff --git a/src/fileio/impls/netcdf4/ncxx4.hxx b/src/fileio/impls/netcdf4/ncxx4.hxx index c0a9bdc6df..497b32df0b 100644 --- a/src/fileio/impls/netcdf4/ncxx4.hxx +++ b/src/fileio/impls/netcdf4/ncxx4.hxx @@ -56,9 +56,10 @@ class Ncxx4; class Ncxx4 : public DataFormat { public: - Ncxx4(); - Ncxx4(const char *name); - Ncxx4(const std::string &name) : Ncxx4(name.c_str()) {} + Ncxx4(Mesh* mesh_in = nullptr); + Ncxx4(const char *name, Mesh* mesh_in = nullptr); + Ncxx4(const std::string &name, Mesh* mesh_in = nullptr) + : Ncxx4(name.c_str(), mesh_in) {} ~Ncxx4(); using DataFormat::openr; diff --git a/src/fileio/impls/pnetcdf/pnetcdf.cxx b/src/fileio/impls/pnetcdf/pnetcdf.cxx index 2ba919bd66..4234de61b4 100644 --- a/src/fileio/impls/pnetcdf/pnetcdf.cxx +++ b/src/fileio/impls/pnetcdf/pnetcdf.cxx @@ -41,7 +41,7 @@ // Define this to see loads of info messages //#define NCDF_VERBOSE -PncFormat::PncFormat() { +PncFormat::PncFormat(Mesh* mesh_in) : DataFormat(mesh_in) { x0 = y0 = z0 = t0 = 0; lowPrecision = false; dimList = recDimList+1; @@ -51,7 +51,7 @@ PncFormat::PncFormat() { fname = nullptr; } -PncFormat::PncFormat(const char *name) { +PncFormat::PncFormat(const char *name, Mesh* mesh_in) : DataFormat(mesh_in) { x0 = y0 = z0 = t0 = 0; lowPrecision = false; dimList = recDimList+1; diff --git a/src/fileio/impls/pnetcdf/pnetcdf.hxx b/src/fileio/impls/pnetcdf/pnetcdf.hxx index 19f23d2917..dd355f22df 100644 --- a/src/fileio/impls/pnetcdf/pnetcdf.hxx +++ b/src/fileio/impls/pnetcdf/pnetcdf.hxx @@ -52,9 +52,10 @@ class PncFormat; class PncFormat : public DataFormat { public: - PncFormat(); - PncFormat(const char *name); - PncFormat(const std::string &name) : PncFormat(name.c_str()) {} + PncFormat(Mesh* mesh_in = nullptr); + PncFormat(const char *name, Mesh* mesh_in = nullptr); + PncFormat(const std::string &name, Mesh* mesh_in = nullptr) + : PncFormat(name.c_str(), mesh_in) {} ~PncFormat(); bool openr(const char *name) override; diff --git a/src/invert/lapack_routines.cxx b/src/invert/lapack_routines.cxx index 3efbcf1bd8..ce000e7d0b 100644 --- a/src/invert/lapack_routines.cxx +++ b/src/invert/lapack_routines.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef LAPACK diff --git a/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx b/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx index af950b7cbe..4370184bf0 100644 --- a/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx +++ b/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -327,8 +328,9 @@ const Field3D LaplaceCyclic::solve(const Field3D &rhs, const Field3D &x0) { } // Copy into array, transposing so kz is first index - for (int kz = 0; kz < nmode; kz++) - bcmplx((iy - ys) * nmode + kz, ix - xs) = k1d[kz]; + for (int kz = 0; kz < nmode; kz++) { + bcmplx3D((iy - ys) * nmode + kz, ix - xs) = k1d[kz]; + } } // Get elements of the tridiagonal matrix @@ -368,8 +370,9 @@ const Field3D LaplaceCyclic::solve(const Field3D &rhs, const Field3D &x0) { int ix = xs + ind / ny; int iy = ys + ind % ny; - for (int kz = 0; kz < nmode; kz++) + for (int kz = 0; kz < nmode; kz++) { k1d[kz] = xcmplx3D((iy - ys) * nmode + kz, ix - xs); + } for (int kz = nmode; kz < localmesh->LocalNz; kz++) k1d[kz] = 0.0; // Filtering out all higher harmonics diff --git a/src/invert/laplace/impls/cyclic/cyclic_laplace.hxx b/src/invert/laplace/impls/cyclic/cyclic_laplace.hxx index b007542569..d4419dd5f2 100644 --- a/src/invert/laplace/impls/cyclic/cyclic_laplace.hxx +++ b/src/invert/laplace/impls/cyclic/cyclic_laplace.hxx @@ -44,7 +44,7 @@ class LaplaceCyclic; */ class LaplaceCyclic : public Laplacian { public: - LaplaceCyclic(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceCyclic(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplaceCyclic(); using Laplacian::setCoefA; diff --git a/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx b/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx index 1ff40e9b0b..86b912154f 100644 --- a/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx +++ b/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx @@ -28,6 +28,7 @@ **************************************************************************/ #include "multigrid_laplace.hxx" +#include #include #include diff --git a/src/invert/laplace/impls/multigrid/multigrid_laplace.hxx b/src/invert/laplace/impls/multigrid/multigrid_laplace.hxx index 0067e1bb51..e0e05328eb 100644 --- a/src/invert/laplace/impls/multigrid/multigrid_laplace.hxx +++ b/src/invert/laplace/impls/multigrid/multigrid_laplace.hxx @@ -132,7 +132,8 @@ private: class LaplaceMultigrid : public Laplacian { public: - LaplaceMultigrid(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceMultigrid(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, + Mesh *mesh_in = nullptr); ~LaplaceMultigrid() {}; void setCoefA(const Field2D &val) override { diff --git a/src/invert/laplace/impls/mumps/mumps_laplace.hxx b/src/invert/laplace/impls/mumps/mumps_laplace.hxx index 6c37e63fa9..82fc082b7e 100644 --- a/src/invert/laplace/impls/mumps/mumps_laplace.hxx +++ b/src/invert/laplace/impls/mumps/mumps_laplace.hxx @@ -36,7 +36,7 @@ class LaplaceMumps; class LaplaceMumps : public Laplacian { public: - LaplaceMumps(Options *UNUSED(opt) = nullptr, const CELL_LOC UNUSED(loc) = CELL_CENTRE, Mesh *UNUSED(mesh_in) = mesh) { + LaplaceMumps(Options *UNUSED(opt) = nullptr, const CELL_LOC UNUSED(loc) = CELL_CENTRE, Mesh *UNUSED(mesh_in) = nullptr) { throw BoutException("Mumps library not available"); } @@ -76,7 +76,7 @@ public: class LaplaceMumps : public Laplacian { public: - LaplaceMumps(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceMumps(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplaceMumps() { mumps_struc.job = -2; dmumps_c(&mumps_struc); diff --git a/src/invert/laplace/impls/naulin/naulin_laplace.hxx b/src/invert/laplace/impls/naulin/naulin_laplace.hxx index b58d63f678..d1088722ab 100644 --- a/src/invert/laplace/impls/naulin/naulin_laplace.hxx +++ b/src/invert/laplace/impls/naulin/naulin_laplace.hxx @@ -37,7 +37,7 @@ class LaplaceNaulin; */ class LaplaceNaulin : public Laplacian { public: - LaplaceNaulin(Options *opt = NULL, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceNaulin(Options *opt = NULL, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplaceNaulin(); // ACoef is not implemented because the delp2solver that we use can probably diff --git a/src/invert/laplace/impls/pdd/pdd.hxx b/src/invert/laplace/impls/pdd/pdd.hxx index 0dff1dd6e0..62c2031afb 100644 --- a/src/invert/laplace/impls/pdd/pdd.hxx +++ b/src/invert/laplace/impls/pdd/pdd.hxx @@ -34,13 +34,14 @@ class LaplacePDD; #ifndef __LAPLACE_PDD_H__ #define __LAPLACE_PDD_H__ +#include #include #include #include class LaplacePDD : public Laplacian { public: - LaplacePDD(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh) + LaplacePDD(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr) : Laplacian(opt, loc, mesh_in), Acoef(0.0), Ccoef(1.0), Dcoef(1.0), PDD_COMM_XV(123), PDD_COMM_Y(456) { Acoef.setLocation(location); diff --git a/src/invert/laplace/impls/petsc/petsc_laplace.cxx b/src/invert/laplace/impls/petsc/petsc_laplace.cxx index c986b25910..fe9a4f2c62 100644 --- a/src/invert/laplace/impls/petsc/petsc_laplace.cxx +++ b/src/invert/laplace/impls/petsc/petsc_laplace.cxx @@ -27,6 +27,7 @@ #include "petsc_laplace.hxx" +#include #include #include #include diff --git a/src/invert/laplace/impls/petsc/petsc_laplace.hxx b/src/invert/laplace/impls/petsc/petsc_laplace.hxx index 61b094ace2..b71b504f59 100644 --- a/src/invert/laplace/impls/petsc/petsc_laplace.hxx +++ b/src/invert/laplace/impls/petsc/petsc_laplace.hxx @@ -37,7 +37,7 @@ class LaplacePetsc; class LaplacePetsc : public Laplacian { public: - LaplacePetsc(Options *UNUSED(opt) = nullptr, const CELL_LOC UNUSED(loc) = CELL_CENTRE, Mesh *UNUSED(mesh_in) = mesh) { + LaplacePetsc(Options *UNUSED(opt) = nullptr, const CELL_LOC UNUSED(loc) = CELL_CENTRE, Mesh *UNUSED(mesh_in) = nullptr) { throw BoutException("No PETSc solver available"); } @@ -68,7 +68,7 @@ public: class LaplacePetsc : public Laplacian { public: - LaplacePetsc(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplacePetsc(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplacePetsc() { KSPDestroy( &ksp ); VecDestroy( &xs ); diff --git a/src/invert/laplace/impls/serial_band/serial_band.cxx b/src/invert/laplace/impls/serial_band/serial_band.cxx index f773f90996..38c0e3ffa3 100644 --- a/src/invert/laplace/impls/serial_band/serial_band.cxx +++ b/src/invert/laplace/impls/serial_band/serial_band.cxx @@ -27,6 +27,7 @@ #include #include "serial_band.hxx" +#include #include #include #include diff --git a/src/invert/laplace/impls/serial_band/serial_band.hxx b/src/invert/laplace/impls/serial_band/serial_band.hxx index 05a7649e32..41c29b8875 100644 --- a/src/invert/laplace/impls/serial_band/serial_band.hxx +++ b/src/invert/laplace/impls/serial_band/serial_band.hxx @@ -36,7 +36,7 @@ class LaplaceSerialBand; class LaplaceSerialBand : public Laplacian { public: - LaplaceSerialBand(Options *opt = nullptr, const CELL_LOC = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceSerialBand(Options *opt = nullptr, const CELL_LOC = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplaceSerialBand(){}; using Laplacian::setCoefA; diff --git a/src/invert/laplace/impls/serial_tri/serial_tri.cxx b/src/invert/laplace/impls/serial_tri/serial_tri.cxx index f2d98e3f22..efc40e7126 100644 --- a/src/invert/laplace/impls/serial_tri/serial_tri.cxx +++ b/src/invert/laplace/impls/serial_tri/serial_tri.cxx @@ -27,6 +27,7 @@ #include "globals.hxx" #include "serial_tri.hxx" +#include #include #include #include diff --git a/src/invert/laplace/impls/serial_tri/serial_tri.hxx b/src/invert/laplace/impls/serial_tri/serial_tri.hxx index 519dc9a361..770b71050d 100644 --- a/src/invert/laplace/impls/serial_tri/serial_tri.hxx +++ b/src/invert/laplace/impls/serial_tri/serial_tri.hxx @@ -35,7 +35,7 @@ class LaplaceSerialTri; class LaplaceSerialTri : public Laplacian { public: - LaplaceSerialTri(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceSerialTri(Options *opt = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplaceSerialTri(){}; using Laplacian::setCoefA; diff --git a/src/invert/laplace/impls/shoot/shoot_laplace.cxx b/src/invert/laplace/impls/shoot/shoot_laplace.cxx index 405fef96be..6a813409ef 100644 --- a/src/invert/laplace/impls/shoot/shoot_laplace.cxx +++ b/src/invert/laplace/impls/shoot/shoot_laplace.cxx @@ -32,6 +32,7 @@ */ #include "shoot_laplace.hxx" +#include #include #include #include diff --git a/src/invert/laplace/impls/shoot/shoot_laplace.hxx b/src/invert/laplace/impls/shoot/shoot_laplace.hxx index db6e1bd617..a31780a032 100644 --- a/src/invert/laplace/impls/shoot/shoot_laplace.hxx +++ b/src/invert/laplace/impls/shoot/shoot_laplace.hxx @@ -37,7 +37,7 @@ class LaplaceShoot; class LaplaceShoot : public Laplacian { public: - LaplaceShoot(Options *opt = nullptr, const CELL_LOC = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceShoot(Options *opt = nullptr, const CELL_LOC = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplaceShoot(){}; using Laplacian::setCoefA; diff --git a/src/invert/laplace/impls/spt/spt.cxx b/src/invert/laplace/impls/spt/spt.cxx index 705f198c29..9b4d9e7452 100644 --- a/src/invert/laplace/impls/spt/spt.cxx +++ b/src/invert/laplace/impls/spt/spt.cxx @@ -32,6 +32,7 @@ */ #include +#include #include #include #include diff --git a/src/invert/laplace/impls/spt/spt.hxx b/src/invert/laplace/impls/spt/spt.hxx index 44b7d98eb8..1bdc064b98 100644 --- a/src/invert/laplace/impls/spt/spt.hxx +++ b/src/invert/laplace/impls/spt/spt.hxx @@ -66,7 +66,7 @@ class LaplaceSPT; */ class LaplaceSPT : public Laplacian { public: - LaplaceSPT(Options *opt = nullptr, const CELL_LOC = CELL_CENTRE, Mesh *mesh_in = mesh); + LaplaceSPT(Options *opt = nullptr, const CELL_LOC = CELL_CENTRE, Mesh *mesh_in = nullptr); ~LaplaceSPT(); using Laplacian::setCoefA; diff --git a/src/invert/laplace/invert_laplace.cxx b/src/invert/laplace/invert_laplace.cxx index 038d7adc6c..5d5fde2518 100644 --- a/src/invert/laplace/invert_laplace.cxx +++ b/src/invert/laplace/invert_laplace.cxx @@ -31,6 +31,7 @@ * */ +#include #include #include #include @@ -52,7 +53,7 @@ /// Laplacian inversion initialisation. Called once at the start to get settings Laplacian::Laplacian(Options *options, const CELL_LOC loc, Mesh *mesh_in) - : location(loc), localmesh(mesh_in) { + : location(loc), localmesh(mesh_in==nullptr ? bout::globals::mesh : mesh_in) { if (options == nullptr) { // Use the default options diff --git a/src/invert/laplace/laplacefactory.cxx b/src/invert/laplace/laplacefactory.cxx index 777cecb2dc..e112249d57 100644 --- a/src/invert/laplace/laplacefactory.cxx +++ b/src/invert/laplace/laplacefactory.cxx @@ -41,6 +41,10 @@ Laplacian* LaplaceFactory::createLaplacian(Options *options, const CELL_LOC loc, if (options == nullptr) options = Options::getRoot()->getSection("laplace"); + if (mesh_in == nullptr) { + mesh_in = bout::globals::mesh; + } + std::string type; if(mesh_in->firstX() && mesh_in->lastX()) { diff --git a/src/invert/laplace/laplacefactory.hxx b/src/invert/laplace/laplacefactory.hxx index 215ee8790d..780e8c2410 100644 --- a/src/invert/laplace/laplacefactory.hxx +++ b/src/invert/laplace/laplacefactory.hxx @@ -11,7 +11,8 @@ class LaplaceFactory { /// Return a pointer to the only instance static LaplaceFactory* getInstance(); - Laplacian *createLaplacian(Options *options = nullptr, const CELL_LOC loc = CELL_CENTRE, Mesh *mesh_in = mesh); + Laplacian *createLaplacian(Options *options = nullptr, const CELL_LOC loc = CELL_CENTRE, + Mesh *mesh_in = nullptr); private: LaplaceFactory() {} // Prevent instantiation of this class diff --git a/src/invert/laplacexy/laplacexy.cxx b/src/invert/laplacexy/laplacexy.cxx index 6fb32d5f14..dc7ec8b97e 100644 --- a/src/invert/laplacexy/laplacexy.cxx +++ b/src/invert/laplacexy/laplacexy.cxx @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -26,7 +27,7 @@ static PetscErrorCode laplacePCapply(PC pc,Vec x,Vec y) { } LaplaceXY::LaplaceXY(Mesh *m, Options *opt, const CELL_LOC loc) - : localmesh(m==nullptr ? mesh : m), location(loc) { + : localmesh(m==nullptr ? bout::globals::mesh : m), location(loc) { Timer timer("invert"); if (opt == nullptr) { diff --git a/src/invert/laplacexz/laplacexz.cxx b/src/invert/laplacexz/laplacexz.cxx index 1703c0b076..05bba728ca 100644 --- a/src/invert/laplacexz/laplacexz.cxx +++ b/src/invert/laplacexz/laplacexz.cxx @@ -9,7 +9,7 @@ LaplaceXZ* LaplaceXZ::create(Mesh *m, Options *options, const CELL_LOC loc) { if (m == nullptr) { // use global mesh - m = mesh; + m = bout::globals::mesh; } if (options == nullptr) { diff --git a/src/invert/parderiv/impls/cyclic/cyclic.hxx b/src/invert/parderiv/impls/cyclic/cyclic.hxx index 328c213a64..390228b57f 100644 --- a/src/invert/parderiv/impls/cyclic/cyclic.hxx +++ b/src/invert/parderiv/impls/cyclic/cyclic.hxx @@ -41,11 +41,12 @@ #include "invert_parderiv.hxx" #include "dcomplex.hxx" +#include #include "utils.hxx" class InvertParCR : public InvertPar { public: - InvertParCR(Options *opt, Mesh *mesh_in = mesh); + InvertParCR(Options *opt, Mesh *mesh_in = bout::globals::mesh); ~InvertParCR(); using InvertPar::solve; diff --git a/src/invert/parderiv/parderiv_factory.hxx b/src/invert/parderiv/parderiv_factory.hxx index d5a3a5cb17..5701f5ef48 100644 --- a/src/invert/parderiv/parderiv_factory.hxx +++ b/src/invert/parderiv/parderiv_factory.hxx @@ -11,9 +11,9 @@ class ParDerivFactory { /// Return a pointer to the only instance static ParDerivFactory* getInstance(); - InvertPar* createInvertPar(Mesh* mesh_in = mesh); - InvertPar *createInvertPar(const char *type, Options *opt = nullptr, Mesh* mesh_in = mesh); - InvertPar* createInvertPar(Options *opts, Mesh* mesh_in = mesh); + InvertPar* createInvertPar(Mesh* mesh_in = bout::globals::mesh); + InvertPar *createInvertPar(const char *type, Options *opt = nullptr, Mesh* mesh_in = bout::globals::mesh); + InvertPar* createInvertPar(Options *opts, Mesh* mesh_in = bout::globals::mesh); private: ParDerivFactory() {} // Prevent instantiation of this class static ParDerivFactory* instance; ///< The only instance of this class (Singleton) diff --git a/src/mesh/boundary_factory.cxx b/src/mesh/boundary_factory.cxx index 29f7df07a0..e2454d7371 100644 --- a/src/mesh/boundary_factory.cxx +++ b/src/mesh/boundary_factory.cxx @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/src/mesh/boundary_region.cxx b/src/mesh/boundary_region.cxx index bee26d439e..e1bdd88201 100644 --- a/src/mesh/boundary_region.cxx +++ b/src/mesh/boundary_region.cxx @@ -1,4 +1,5 @@ +#include #include #include #include diff --git a/src/mesh/boundary_standard.cxx b/src/mesh/boundary_standard.cxx index ba06f23feb..f80876d7fc 100644 --- a/src/mesh/boundary_standard.cxx +++ b/src/mesh/boundary_standard.cxx @@ -1,3 +1,4 @@ +#include #include #include #include @@ -29,6 +30,7 @@ void verifyNumPoints(BoundaryRegion *region, int ptsRequired) { int ptsAvailGlobal, ptsAvailLocal, ptsAvail; std::string side, gridType; + Mesh* mesh = region->localmesh; //Initialise var in case of no match and CHECK<=2 ptsAvail = ptsRequired; //Ensures test passes without exception @@ -121,6 +123,8 @@ void BoundaryDirichlet::apply(Field2D &f,BoutReal t) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Decide which generator to use @@ -308,6 +312,8 @@ void BoundaryDirichlet::apply(Field3D &f,BoutReal t) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Decide which generator to use @@ -545,6 +551,8 @@ void BoundaryDirichlet::apply_ddt(Field2D &f) { } void BoundaryDirichlet::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -573,6 +581,8 @@ void BoundaryDirichlet_O3::apply(Field2D &f,BoutReal t) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Decide which generator to use @@ -758,6 +768,8 @@ void BoundaryDirichlet_O3::apply(Field3D &f,BoutReal t) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Decide which generator to use @@ -957,6 +969,8 @@ void BoundaryDirichlet_O3::apply_ddt(Field2D &f) { } void BoundaryDirichlet_O3::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); bndry->first() ; @@ -988,6 +1002,8 @@ void BoundaryDirichlet_O4::apply(Field2D &f,BoutReal t) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Decide which generator to use @@ -1185,6 +1201,8 @@ void BoundaryDirichlet_O4::apply(Field3D &f,BoutReal t) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Decide which generator to use @@ -1389,6 +1407,8 @@ void BoundaryDirichlet_O4::apply_ddt(Field2D &f) { } void BoundaryDirichlet_O4::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -1417,6 +1437,8 @@ void BoundaryDirichlet_4thOrder::apply(Field2D &f) { } void BoundaryDirichlet_4thOrder::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); // Set (at 4th order) the value at the mid-point between the guard cell and the grid cell to be val for(bndry->first(); !bndry->isDone(); bndry->next1d()) for(int z=0;zLocalNz;z++) { @@ -1432,6 +1454,8 @@ void BoundaryDirichlet_4thOrder::apply_ddt(Field2D &f) { } void BoundaryDirichlet_4thOrder::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -1452,6 +1476,8 @@ BoundaryOp* BoundaryNeumann_NonOrthogonal::clone(BoundaryRegion *region, const s } void BoundaryNeumann_NonOrthogonal::apply(Field2D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Coordinates *metric = f.getCoordinates(); // Calculate derivatives for metric use mesh->communicate(f); @@ -1492,6 +1518,8 @@ void BoundaryNeumann_NonOrthogonal::apply(Field2D &f) { } void BoundaryNeumann_NonOrthogonal::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Coordinates *metric = f.getCoordinates(); // Calculate derivatives for metric use mesh->communicate(f); @@ -1557,6 +1585,8 @@ void BoundaryNeumann::apply(Field2D &f,BoutReal t) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Coordinates *metric = f.getCoordinates(); bndry->first(); @@ -1754,6 +1784,8 @@ void BoundaryNeumann::apply(Field3D &f) { void BoundaryNeumann::apply(Field3D &f,BoutReal t) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Coordinates *metric = f.getCoordinates(); bndry->first(); @@ -1957,6 +1989,8 @@ void BoundaryNeumann::apply_ddt(Field2D &f) { } void BoundaryNeumann::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -1979,6 +2013,8 @@ void BoundaryNeumann_O4::apply(Field2D &f) { } void BoundaryNeumann_O4::apply(Field2D &f,BoutReal t) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); // Set (at 4th order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used @@ -2036,6 +2072,8 @@ void BoundaryNeumann_O4::apply(Field3D &f) { } void BoundaryNeumann_O4::apply(Field3D &f,BoutReal t) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Decide which generator to use @@ -2091,6 +2129,8 @@ void BoundaryNeumann_O4::apply_ddt(Field2D &f) { } void BoundaryNeumann_O4::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -2121,6 +2161,8 @@ void BoundaryNeumann_4thOrder::apply(Field2D &f) { } void BoundaryNeumann_4thOrder::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Coordinates *metric = f.getCoordinates(); // Set (at 4th order) the gradient at the mid-point between the guard cell and the grid cell to be val // This sets the value of the co-ordinate derivative, i.e. DDX/DDY not Grad_par/Grad_perp.x @@ -2139,6 +2181,8 @@ void BoundaryNeumann_4thOrder::apply_ddt(Field2D &f) { } void BoundaryNeumann_4thOrder::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -2164,6 +2208,8 @@ void BoundaryNeumannPar::apply(Field2D &f) { } void BoundaryNeumannPar::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Coordinates *metric = f.getCoordinates(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -2219,6 +2265,8 @@ void BoundaryRobin::apply(Field2D &f) { } void BoundaryRobin::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); if(fabs(bval) < 1.e-12) { for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -2242,6 +2290,8 @@ void BoundaryConstGradient::apply(Field2D &f){ } void BoundaryConstGradient::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) f(bndry->x, bndry->y, z) = 2.*f(bndry->x - bndry->bx, bndry->y - bndry->by, z) - f(bndry->x - 2*bndry->bx,bndry->y - 2*bndry->by,z); @@ -2290,6 +2340,8 @@ void BoundaryZeroLaplace::apply(Field2D &f) { } void BoundaryZeroLaplace::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); int ncz = mesh->LocalNz; Coordinates *metric = f.getCoordinates(); @@ -2380,6 +2432,8 @@ void BoundaryZeroLaplace2::apply(Field2D &f) { } void BoundaryZeroLaplace2::apply(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); int ncz = mesh->LocalNz; ASSERT0(ncz % 2 == 0); // Allocation assumes even number @@ -2476,6 +2530,8 @@ void BoundaryConstLaplace::apply(Field3D &f) { throw BoutException("ERROR: Can't apply Zero Laplace condition to non-X boundaries\n"); } + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Coordinates *metric = f.getCoordinates(); int ncz = mesh->LocalNz; @@ -2544,6 +2600,9 @@ void BoundaryDivCurl::apply(Vector2D &UNUSED(f)) { } void BoundaryDivCurl::apply(Vector3D &var) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = var.x.getMesh()); + int jx, jy, jz, jzp, jzm; BoutReal tmp; @@ -2652,6 +2711,8 @@ void BoundaryFree_O2::apply(Field2D &f) { // Set (at 2nd order) the value at the mid-point between the guard cell and the grid cell to be val // N.B. Only first guard cells (closest to the grid) should ever be used + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Check for staggered grids @@ -2749,9 +2810,10 @@ void BoundaryFree_O2::apply(Field2D &f) { void BoundaryFree_O2::apply(Field3D &f) { // Extrapolate from the last evolved simulation cells into the guard cells at 3rd order. + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); - // Check for staggered grids CELL_LOC loc = f.getLocation(); @@ -2868,6 +2930,8 @@ void BoundaryFree_O2::apply_ddt(Field2D &f) { } void BoundaryFree_O2::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -2889,6 +2953,8 @@ BoundaryOp* BoundaryFree_O3::clone(BoundaryRegion *region, const std::listlocalmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); // Check for staggered grids @@ -2987,6 +3053,8 @@ void BoundaryFree_O3::apply(Field2D &f) { void BoundaryFree_O3::apply(Field3D &f) { // Extrapolate from the last evolved simulation cells into the guard cells at 3rd order. + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); bndry->first(); @@ -3114,6 +3182,8 @@ void BoundaryFree_O3::apply_ddt(Field2D &f) { } void BoundaryFree_O3::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); Field3D *dt = f.timeDeriv(); for(bndry->first(); !bndry->isDone(); bndry->next()) for(int z=0;zLocalNz;z++) @@ -3165,6 +3235,9 @@ void BoundaryRelax::apply_ddt(Field2D &f) { void BoundaryRelax::apply_ddt(Field3D &f) { TRACE("BoundaryRelax::apply_ddt(Field3D)"); + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); + // Make a copy of f Field3D g = f; // NOTE: This is not very efficient... copying entire field // Apply the boundary to g @@ -3238,6 +3311,9 @@ void BoundaryToFieldAligned::apply(Field2D &f, BoutReal t) { } void BoundaryToFieldAligned::apply(Field3D &f, BoutReal t) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); + //NOTE: This is not very efficient... updating entire field f = mesh->fromFieldAligned(f); @@ -3257,6 +3333,8 @@ void BoundaryToFieldAligned::apply_ddt(Field2D &f) { } void BoundaryToFieldAligned::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); f = mesh->fromFieldAligned(f); ddt(f) = mesh->fromFieldAligned(ddt(f)); op->apply_ddt(f); @@ -3281,6 +3359,8 @@ void BoundaryFromFieldAligned::apply(Field2D &f, BoutReal t) { } void BoundaryFromFieldAligned::apply(Field3D &f, BoutReal t) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); //NOTE: This is not very efficient... shifting entire field f = mesh->toFieldAligned(f); @@ -3300,6 +3380,8 @@ void BoundaryFromFieldAligned::apply_ddt(Field2D &f) { } void BoundaryFromFieldAligned::apply_ddt(Field3D &f) { + Mesh* mesh = bndry->localmesh; + ASSERT1(mesh = f.getMesh()); f = mesh->toFieldAligned(f); ddt(f) = mesh->toFieldAligned(ddt(f)); op->apply_ddt(f); diff --git a/src/mesh/coordinates.cxx b/src/mesh/coordinates.cxx index 974737da8a..7a4121a2d2 100644 --- a/src/mesh/coordinates.cxx +++ b/src/mesh/coordinates.cxx @@ -799,7 +799,7 @@ const Field3D Coordinates::Grad2_par2(const Field3D &f, CELL_LOC outloc, const s #include // Delp2 uses same coefficients as inversion code -const Field2D Coordinates::Delp2(const Field2D& f, CELL_LOC outloc, bool useFFT) { +const Field2D Coordinates::Delp2(const Field2D& f, CELL_LOC outloc, bool UNUSED(useFFT)) { TRACE("Coordinates::Delp2( Field2D )"); ASSERT1(location == outloc || outloc == CELL_DEFAULT); diff --git a/src/mesh/difops.cxx b/src/mesh/difops.cxx index fa88ec6868..0a2b8e79ca 100644 --- a/src/mesh/difops.cxx +++ b/src/mesh/difops.cxx @@ -24,7 +24,7 @@ **************************************************************************/ #include -#include +#include #include #include #include @@ -449,7 +449,9 @@ const Field2D Div_par_LtoC(const Field2D &var) { } const Field3D Div_par_LtoC(const Field3D &var) { - Field3D result; + Mesh* mesh = var.getMesh(); + + Field3D result(mesh); result.allocate(); Coordinates *metric = var.getCoordinates(CELL_CENTRE); @@ -478,7 +480,9 @@ const Field2D Div_par_CtoL(const Field2D &var) { } const Field3D Div_par_CtoL(const Field3D &var) { - Field3D result; + Mesh* mesh = var.getMesh(); + + Field3D result(mesh); result.allocate(); Coordinates *metric = var.getCoordinates(CELL_CENTRE); diff --git a/src/mesh/fv_ops.cxx b/src/mesh/fv_ops.cxx index d67fe767a6..f65b93911b 100644 --- a/src/mesh/fv_ops.cxx +++ b/src/mesh/fv_ops.cxx @@ -180,6 +180,9 @@ namespace FV { const Field3D D4DY4(const Field3D &d_in, const Field3D &f_in) { ASSERT2(d_in.getLocation() == f_in.getLocation()); + Mesh* mesh = d_in.getMesh(); + ASSERT1(mesh = f_in.getMesh()); + Field3D result = 0.0; result.setLocation(f_in.getLocation()); @@ -233,6 +236,8 @@ namespace FV { Field3D result = 0.0; result.setLocation(f_in.getLocation()); + Mesh* mesh = f_in.getMesh(); + // Convert to field aligned coordinates Field3D f = mesh->toFieldAligned(f_in); @@ -339,6 +344,7 @@ namespace FV { } void communicateFluxes(Field3D &f) { + Mesh* mesh = f.getMesh(); // Use X=0 as temporary buffer if (mesh->xstart != 2) diff --git a/src/mesh/impls/bout/boutmesh.cxx b/src/mesh/impls/bout/boutmesh.cxx index 8ed15a1cc6..eccea69cc2 100644 --- a/src/mesh/impls/bout/boutmesh.cxx +++ b/src/mesh/impls/bout/boutmesh.cxx @@ -301,7 +301,7 @@ int BoutMesh::load() { BoutReal ideal = sqrt(MX * NPES / static_cast(ny)); // Results in square domains - output_info.write("Finding value for NXPE (ideal = %f)\n", ideal); + output_info.write(_("Finding value for NXPE (ideal = %f)\n"), ideal); for (int i = 1; i <= NPES; i++) { // Loop over all possibilities if ((NPES % i == 0) && // Processors divide equally @@ -315,14 +315,14 @@ int BoutMesh::load() { // Check size of Y mesh if (ysub < MYG) { - output_info.write("\t -> ny/NYPE (%d/%d = %d) must be >= MYG (%d)\n", ny, nyp, + output_info.write(_("\t -> ny/NYPE (%d/%d = %d) must be >= MYG (%d)\n"), ny, nyp, ysub, MYG); continue; } // Check branch cuts if ((jyseps1_1 + 1) % ysub != 0) { output_info.write( - "\t -> Leg region jyseps1_1+1 (%d) must be a multiple of MYSUB (%d)\n", + _("\t -> Leg region jyseps1_1+1 (%d) must be a multiple of MYSUB (%d)\n"), jyseps1_1 + 1, ysub); continue; } @@ -331,45 +331,45 @@ int BoutMesh::load() { // Double Null if ((jyseps2_1 - jyseps1_1) % ysub != 0) { - output_info.write("\t -> Core region jyseps2_1-jyseps1_1 (%d-%d = %d) must " - "be a multiple of MYSUB (%d)\n", + output_info.write(_("\t -> Core region jyseps2_1-jyseps1_1 (%d-%d = %d) must " + "be a multiple of MYSUB (%d)\n"), jyseps2_1, jyseps1_1, jyseps2_1 - jyseps1_1, ysub); continue; } if ((jyseps2_2 - jyseps1_2) % ysub != 0) { - output_info.write("\t -> Core region jyseps2_2-jyseps1_2 (%d-%d = %d) must " - "be a multiple of MYSUB (%d)\n", + output_info.write(_("\t -> Core region jyseps2_2-jyseps1_2 (%d-%d = %d) must " + "be a multiple of MYSUB (%d)\n"), jyseps2_2, jyseps1_2, jyseps2_2 - jyseps1_2, ysub); continue; } // Check upper legs if ((ny_inner - jyseps2_1 - 1) % ysub != 0) { - output_info.write("\t -> leg region ny_inner-jyseps2_1-1 (%d-%d-1 = %d) must " - "be a multiple of MYSUB (%d)\n", + output_info.write(_("\t -> leg region ny_inner-jyseps2_1-1 (%d-%d-1 = %d) must " + "be a multiple of MYSUB (%d)\n"), ny_inner, jyseps2_1, ny_inner - jyseps2_1 - 1, ysub); continue; } if ((jyseps1_2 - ny_inner + 1) % ysub != 0) { - output_info.write("\t -> leg region jyseps1_2-ny_inner+1 (%d-%d+1 = %d) must " - "be a multiple of MYSUB (%d)\n", + output_info.write(_("\t -> leg region jyseps1_2-ny_inner+1 (%d-%d+1 = %d) must " + "be a multiple of MYSUB (%d)\n"), jyseps1_2, ny_inner, jyseps1_2 - ny_inner + 1, ysub); continue; } } else { // Single Null if ((jyseps2_2 - jyseps1_1) % ysub != 0) { - output_info.write("\t -> Core region jyseps2_2-jyseps1_1 (%d-%d = %d) must " - "be a multiple of MYSUB (%d)\n", + output_info.write(_("\t -> Core region jyseps2_2-jyseps1_1 (%d-%d = %d) must " + "be a multiple of MYSUB (%d)\n"), jyseps2_2, jyseps1_1, jyseps2_2 - jyseps1_1, ysub); continue; } } if ((ny - jyseps2_2 - 1) % ysub != 0) { - output_info.write("\t -> leg region ny-jyseps2_2-1 (%d-%d-1 = %d) must be a " - "multiple of MYSUB (%d)\n", + output_info.write(_("\t -> leg region ny-jyseps2_2-1 (%d-%d-1 = %d) must be a " + "multiple of MYSUB (%d)\n"), ny, jyseps2_2, ny - jyseps2_2 - 1, ysub); continue; } @@ -2223,7 +2223,7 @@ void BoutMesh::addBoundaryRegions() { all_boundaries.emplace_back("RGN_UPPER_Y"); // Inner X - if(mesh->firstX() && !mesh->periodicX) { + if(firstX() && !periodicX) { addRegion3D("RGN_INNER_X", Region(0, xstart-1, ystart, yend, 0, LocalNz-1, LocalNy, LocalNz, maxregionblocksize)); addRegion2D("RGN_INNER_X", Region(0, xstart-1, ystart, yend, 0, 0, @@ -2240,7 +2240,7 @@ void BoutMesh::addBoundaryRegions() { } // Outer X - if(mesh->firstX() && !mesh->periodicX) { + if(firstX() && !periodicX) { addRegion3D("RGN_OUTER_X", Region(xend+1, LocalNx-1, ystart, yend, 0, LocalNz-1, LocalNy, LocalNz, maxregionblocksize)); addRegion2D("RGN_OUTER_X", Region(xend+1, LocalNx-1, ystart, yend, 0, 0, diff --git a/src/mesh/interpolation/interpolation_factory.cxx b/src/mesh/interpolation/interpolation_factory.cxx index fb57cb1e75..f77d2f2658 100644 --- a/src/mesh/interpolation/interpolation_factory.cxx +++ b/src/mesh/interpolation/interpolation_factory.cxx @@ -47,16 +47,19 @@ Interpolation* InterpolationFactory::create(Options *options, Mesh *mesh) { Interpolation* InterpolationFactory::create(const std::string &name, Options *options, Mesh *localmesh) { // If no options section passed (e.g. for a variable), then use the // "interpolation" section - if (options == nullptr) + if (options == nullptr) { options = Options::getRoot()->getSection("interpolation"); + } // Use the global mesh if none passed - if (localmesh == nullptr) - localmesh = mesh; + if (localmesh == nullptr) { + localmesh = bout::globals::mesh; + } auto interp = findInterpolation(name); - if (interp == nullptr) + if (interp == nullptr) { throw BoutException("Could not find interpolation method '%s'", name.c_str()); + } return interp(localmesh); } diff --git a/src/mesh/mesh.cxx b/src/mesh/mesh.cxx index 941bfc6580..65b19df8fa 100644 --- a/src/mesh/mesh.cxx +++ b/src/mesh/mesh.cxx @@ -376,8 +376,8 @@ void Mesh::addRegion3D(const std::string ®ion_name, const Region<> ®ion) { throw BoutException(_("Trying to add an already existing region %s to regionMap3D"), region_name.c_str()); } regionMap3D[region_name] = region; - output_verbose << _("Registered region 3D ") << region_name << ": \n" - << "\t" << region.getStats() << "\n"; + output_verbose.write(_("Registered region 3D %s"),region_name.c_str()); + output_verbose << "\n:\t" << region.getStats() << "\n"; } void Mesh::addRegion2D(const std::string ®ion_name, const Region ®ion) { @@ -385,8 +385,8 @@ void Mesh::addRegion2D(const std::string ®ion_name, const Region ®i throw BoutException(_("Trying to add an already existing region %s to regionMap2D"), region_name.c_str()); } regionMap2D[region_name] = region; - output_verbose << _("Registered region 2D ") << region_name << ": \n" - << "\t" << region.getStats() << "\n"; + output_verbose.write(_("Registered region 2D %s"),region_name.c_str()); + output_verbose << "\n:\t" << region.getStats() << "\n"; } void Mesh::addRegionPerp(const std::string ®ion_name, const Region ®ion) { @@ -394,8 +394,8 @@ void Mesh::addRegionPerp(const std::string ®ion_name, const Region & throw BoutException(_("Trying to add an already existing region %s to regionMapPerp"), region_name.c_str()); } regionMapPerp[region_name] = region; - output_verbose << _("Registered region Perp ") << region_name << ": \n" - << "\t" << region.getStats() << "\n"; + output_verbose.write(_("Registered region Perp %s"),region_name.c_str()); + output_verbose << "\n:\t" << region.getStats() << "\n"; } void Mesh::createDefaultRegions(){ diff --git a/src/mesh/parallel_boundary_op.cxx b/src/mesh/parallel_boundary_op.cxx index 1fdd82bcaa..1b13325682 100644 --- a/src/mesh/parallel_boundary_op.cxx +++ b/src/mesh/parallel_boundary_op.cxx @@ -7,6 +7,8 @@ BoutReal BoundaryOpPar::getValue(int x, int y, int z, BoutReal t) { + Mesh* mesh = bndry->localmesh; + BoutReal xnorm; BoutReal ynorm; BoutReal znorm; @@ -35,6 +37,8 @@ BoutReal BoundaryOpPar::getValue(int x, int y, int z, BoutReal t) { BoutReal BoundaryOpPar::getValue(const BoundaryRegionPar &bndry, BoutReal t) { + Mesh* mesh = bndry.localmesh; + BoutReal xnorm; BoutReal ynorm; BoutReal znorm; diff --git a/src/physics/gyro_average.cxx b/src/physics/gyro_average.cxx index e67f11663a..b8f1a0cd83 100644 --- a/src/physics/gyro_average.cxx +++ b/src/physics/gyro_average.cxx @@ -27,6 +27,7 @@ * **************************************************************/ +#include #include #include #include @@ -89,7 +90,7 @@ const Field2D gyroPade1(const Field2D &f, const Field2D &rho, int flags) { const Field3D gyroPade2(const Field3D &f, BoutReal rho, int flags) { Field3D result = gyroPade1(gyroPade1(f, rho, flags), rho, flags); - mesh->communicate(result); + result.getMesh()->communicate(result); result = 0.5*rho*rho*Delp2( result ); result.applyBoundary("dirichlet"); return result; @@ -97,7 +98,7 @@ const Field3D gyroPade2(const Field3D &f, BoutReal rho, int flags) { const Field3D gyroPade2(const Field3D &f, const Field2D &rho, int flags) { Field3D result = gyroPade1(gyroPade1(f, rho, flags), rho, flags); - mesh->communicate(result); + result.getMesh()->communicate(result); result = 0.5*rho*rho*Delp2( result ); result.applyBoundary("dirichlet"); return result; diff --git a/src/physics/physicsmodel.cxx b/src/physics/physicsmodel.cxx index 98c56a329b..6235b1be4c 100644 --- a/src/physics/physicsmodel.cxx +++ b/src/physics/physicsmodel.cxx @@ -28,7 +28,11 @@ * **************************************************************************/ +#define BOUT_NO_USING_NAMESPACE_BOUTGLOBALS #include +#undef BOUT_NO_USING_NAMESPACE_BOUTGLOBALS + +#include PhysicsModel::PhysicsModel() : solver(nullptr), modelMonitor(this), splitop(false), userprecon(nullptr), @@ -127,7 +131,7 @@ int PhysicsModel::postInit(bool restarting) { // Add mesh information to restart file // Note this is done after reading, so mesh variables // are not overwritten. - mesh->outputVars(restart); + bout::globals::mesh->outputVars(restart); // Version expected by collect routine restart.addOnce(const_cast(BOUT_VERSION), "BOUT_VERSION"); diff --git a/src/physics/smoothing.cxx b/src/physics/smoothing.cxx index 4a3bc507b4..77326e2cb8 100644 --- a/src/physics/smoothing.cxx +++ b/src/physics/smoothing.cxx @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -461,6 +462,6 @@ const Field3D nl_filter(const Field3D &f, BoutReal w) { /// Perform filtering in Z, Y then X Field3D result = nl_filter_x(nl_filter_y(nl_filter_z(f, w), w), w); /// Communicate boundaries - mesh->communicate(result); + f.getMesh()->communicate(result); return result; } diff --git a/src/physics/sourcex.cxx b/src/physics/sourcex.cxx index 4094251960..1a549e50dc 100644 --- a/src/physics/sourcex.cxx +++ b/src/physics/sourcex.cxx @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include @@ -16,38 +18,42 @@ BoutReal TanH(BoutReal a) { } // create radial buffer zones to set jpar zero near radial boundaries -const Field2D source_tanhx(const Field2D &UNUSED(f), BoutReal swidth, BoutReal slength) { - Field2D result; +const Field2D source_tanhx(const Field2D &f, BoutReal swidth, BoutReal slength) { + Mesh* localmesh = f.getMesh(); + + Field2D result(localmesh); result.allocate(); // create a radial buffer zone to set jpar zero near radial boundary BOUT_FOR(i, result.getRegion("RGN_ALL")) { - BoutReal lx = mesh->GlobalX(i.x()) - slength; + BoutReal lx = localmesh->GlobalX(i.x()) - slength; BoutReal dampl = TanH(lx / swidth); result[i] = 0.5 * (1.0 - dampl); } // Need to communicate boundaries - mesh->communicate(result); + localmesh->communicate(result); return result; } // create radial buffer zones to set jpar zero near radial boundaries -const Field2D source_expx2(const Field2D &UNUSED(f), BoutReal swidth, BoutReal slength) { - Field2D result; +const Field2D source_expx2(const Field2D &f, BoutReal swidth, BoutReal slength) { + Mesh* localmesh = f.getMesh(); + + Field2D result(localmesh); result.allocate(); // create a radial buffer zone to set jpar zero near radial boundary BOUT_FOR(i, result.getRegion("RGN_ALL")) { - BoutReal lx = mesh->GlobalX(i.x()) - slength; + BoutReal lx = localmesh->GlobalX(i.x()) - slength; BoutReal dampl = exp(-lx * lx / swidth / swidth); result[i] = dampl; } // Need to communicate boundaries - mesh->communicate(result); + localmesh->communicate(result); return result; } @@ -55,18 +61,20 @@ const Field2D source_expx2(const Field2D &UNUSED(f), BoutReal swidth, BoutReal s // create radial buffer zones to set jpar zero near radial boundaries const Field3D sink_tanhx(const Field2D &UNUSED(f0), const Field3D &f, BoutReal swidth, BoutReal slength, bool UNUSED(BoutRealspace)) { - Field3D result; + Mesh* localmesh = f.getMesh(); + + Field3D result(localmesh); result.allocate(); // create a radial buffer zone to set jpar zero near radial boundary BOUT_FOR(i, result.getRegion("RGN_ALL")) { - BoutReal rlx = 1. - mesh->GlobalX(i.x()) - slength; + BoutReal rlx = 1. - localmesh->GlobalX(i.x()) - slength; BoutReal dampr = TanH(rlx / swidth); result[i] = 0.5 * (1.0 - dampr) * f[i]; } // Need to communicate boundaries - mesh->communicate(result); + localmesh->communicate(result); return result; } @@ -75,12 +83,14 @@ const Field3D sink_tanhx(const Field2D &UNUSED(f0), const Field3D &f, BoutReal s const Field3D mask_x(const Field3D &f, bool UNUSED(BoutRealspace)) { TRACE("mask_x"); - Field3D result; + Mesh* localmesh = f.getMesh(); + + Field3D result(localmesh); result.allocate(); // create a radial buffer zone to set jpar zero near radial boundary BOUT_FOR(i, result.getRegion("RGN_ALL")) { - BoutReal lx = mesh->GlobalX(i.x()); + BoutReal lx = localmesh->GlobalX(i.x()); BoutReal dampl = TanH(lx / 40.0); BoutReal dampr = TanH((1. - lx) / 40.0); @@ -88,7 +98,7 @@ const Field3D mask_x(const Field3D &f, bool UNUSED(BoutRealspace)) { } // Need to communicate boundaries - mesh->communicate(result); + localmesh->communicate(result); return result; } @@ -98,19 +108,21 @@ const Field3D sink_tanhxl(const Field2D &UNUSED(f0), const Field3D &f, BoutReal BoutReal slength, bool UNUSED(BoutRealspace)) { TRACE("sink_tanhx"); - Field3D result; + Mesh* localmesh = f.getMesh(); + + Field3D result(localmesh); result.allocate(); BOUT_FOR(i, result.getRegion("RGN_ALL")) { - BoutReal lx = mesh->GlobalX(i.x()) - slength; + BoutReal lx = localmesh->GlobalX(i.x()) - slength; BoutReal dampl = TanH(lx / swidth); result[i] = 0.5 * (1.0 - dampl) * f[i]; } // Need to communicate boundaries - mesh->communicate(result); + localmesh->communicate(result); return result; } @@ -119,18 +131,21 @@ const Field3D sink_tanhxl(const Field2D &UNUSED(f0), const Field3D &f, BoutReal const Field3D sink_tanhxr(const Field2D &UNUSED(f0), const Field3D &f, BoutReal swidth, BoutReal slength, bool UNUSED(BoutRealspace)) { TRACE("sink_tanhxr"); - Field3D result; + + Mesh* localmesh = f.getMesh(); + + Field3D result(localmesh); result.allocate(); BOUT_FOR(i, result.getRegion("RGN_ALL")) { - BoutReal rlx = 1. - mesh->GlobalX(i.x()) - slength; + BoutReal rlx = 1. - localmesh->GlobalX(i.x()) - slength; BoutReal dampr = TanH(rlx / swidth); result[i] = 0.5 * (1.0 - dampr) * f[i]; } // Need to communicate boundaries - mesh->communicate(result); + localmesh->communicate(result); return result; } @@ -139,7 +154,9 @@ const Field3D sink_tanhxr(const Field2D &UNUSED(f0), const Field3D &f, BoutReal const Field3D buff_x(const Field3D &f, bool UNUSED(BoutRealspace)) { TRACE("buff_x"); - Field3D result; + Mesh* localmesh = f.getMesh(); + + Field3D result(localmesh); result.allocate(); const BoutReal dampl = 1.e0; @@ -148,7 +165,7 @@ const Field3D buff_x(const Field3D &f, bool UNUSED(BoutRealspace)) { const BoutReal deltar = 0.05; BOUT_FOR(i, result.getRegion("RGN_ALL")) { - BoutReal lx = mesh->GlobalX(i.x()); + BoutReal lx = localmesh->GlobalX(i.x()); BoutReal rlx = 1. - lx; result[i] = (dampl * exp(-(lx * lx) / (deltal * deltal)) + @@ -157,7 +174,7 @@ const Field3D buff_x(const Field3D &f, bool UNUSED(BoutRealspace)) { } // Need to communicate boundaries - mesh->communicate(result); + localmesh->communicate(result); return result; } diff --git a/src/solver/impls/arkode/arkode.cxx b/src/solver/impls/arkode/arkode.cxx index 20316aac44..884f64fc4e 100644 --- a/src/solver/impls/arkode/arkode.cxx +++ b/src/solver/impls/arkode/arkode.cxx @@ -135,15 +135,26 @@ int ArkodeSolver::init(int nout, BoutReal tstep) { bool use_precon, use_jacobian, use_vector_abstol,set_linear; BoutReal start_timestep, max_timestep, min_timestep,fixed_timestep; bool imex,expl,impl; // Time-integration method - int MXSUB = mesh->xend - mesh->xstart + 1; + + // Compute band_width_default from actually added fields, to allow for multiple Mesh objects + // + // Previous implementation was equivalent to: + // int MXSUB = mesh->xend - mesh->xstart + 1; + // int band_width_default = n3Dvars()*(MXSUB+2); + int band_width_default = 0; + for (auto fvar : f3d) { + Mesh* localmesh = fvar.var->getMesh(); + band_width_default += localmesh->xend - localmesh->xstart + 3; + } + BoutReal cfl_frac; bool fixed_step; int mxsteps; // Maximum number of steps to take between outputs int mxorder; // Maximum lmm order to be used by the solver {TRACE("Getting options"); - options->get("mudq", mudq, n3Dvars()*(MXSUB+2)); - options->get("mldq", mldq, n3Dvars()*(MXSUB+2)); + options->get("mudq", mudq, band_width_default); + options->get("mldq", mldq, band_width_default); options->get("mukeep", mukeep, n3Dvars()+n2Dvars()); options->get("mlkeep", mlkeep, n3Dvars()+n2Dvars()); options->get("ATOL", abstol, 1.0e-12); @@ -712,11 +723,11 @@ void ArkodeSolver::set_abstol_values(BoutReal *abstolvec_data, int p = 0; // Counter for location in abstolvec_data array // All boundaries - for (const auto &i2d : mesh->getRegion2D("RGN_BNDRY")) { + for (const auto &i2d : bout::globals::mesh->getRegion2D("RGN_BNDRY")) { loop_abstol_values_op(i2d, abstolvec_data, p, f2dtols, f3dtols, true); } // Bulk of points - for (const auto &i2d : mesh->getRegion2D("RGN_NOBNDRY")) { + for (const auto &i2d : bout::globals::mesh->getRegion2D("RGN_NOBNDRY")) { loop_abstol_values_op(i2d, abstolvec_data, p, f2dtols, f3dtols, false); } } @@ -733,7 +744,7 @@ void ArkodeSolver::loop_abstol_values_op(Ind2D UNUSED(i2d), p++; } - for (int jz=0; jz < mesh->LocalNz; jz++) { + for (int jz=0; jz < bout::globals::mesh->LocalNz; jz++) { // Loop over 3D variables for(std::vector::size_type i=0; ixend - mesh->xstart + 1; + + // Compute band_width_default from actually added fields, to allow for multiple Mesh objects + // + // Previous implementation was equivalent to: + // int MXSUB = mesh->xend - mesh->xstart + 1; + // int band_width_default = n3Dvars()*(MXSUB+2); + int band_width_default = 0; + for (auto fvar : f3d) { + Mesh* localmesh = fvar.var->getMesh(); + band_width_default += localmesh->xend - localmesh->xstart + 3; + } + int mxsteps; // Maximum number of steps to take between outputs int mxorder; // Maximum lmm order to be used by the solver int lmm = CV_BDF; int iter = CV_NEWTON; {TRACE("Getting options"); - options->get("mudq", mudq, n3Dvars()*(MXSUB+2)); - options->get("mldq", mldq, n3Dvars()*(MXSUB+2)); + options->get("mudq", mudq, band_width_default); + options->get("mldq", mldq, band_width_default); options->get("mukeep", mukeep, n3Dvars()+n2Dvars()); options->get("mlkeep", mlkeep, n3Dvars()+n2Dvars()); options->get("ATOL", abstol, 1.0e-12); @@ -581,11 +592,11 @@ void CvodeSolver::set_abstol_values(BoutReal* abstolvec_data, std::vectorgetRegion2D("RGN_BNDRY")) { + for (const auto &i2d : bout::globals::mesh->getRegion2D("RGN_BNDRY")) { loop_abstol_values_op(i2d, abstolvec_data, p, f2dtols, f3dtols, true); } // Bulk of points - for (const auto &i2d : mesh->getRegion2D("RGN_NOBNDRY")) { + for (const auto &i2d : bout::globals::mesh->getRegion2D("RGN_NOBNDRY")) { loop_abstol_values_op(i2d, abstolvec_data, p, f2dtols, f3dtols, false); } } @@ -603,7 +614,7 @@ void CvodeSolver::loop_abstol_values_op(Ind2D UNUSED(i2d), p++; } - for (int jz=0; jz < mesh->LocalNz; jz++) { + for (int jz=0; jz < bout::globals::mesh->LocalNz; jz++) { // Loop over 3D variables for(std::vector::size_type i=0; ixend - mesh->xstart + 1; + // Compute band_width_default from actually added fields, to allow for multiple Mesh objects + // + // Previous implementation was equivalent to: + // int MXSUB = mesh->xend - mesh->xstart + 1; + // int band_width_default = n3Dvars()*(MXSUB+2); + int band_width_default = 0; + for (auto fvar : f3d) { + Mesh* localmesh = fvar.var->getMesh(); + band_width_default += localmesh->xend - localmesh->xstart + 3; + } BoutReal abstol, reltol; int maxl; @@ -134,8 +143,8 @@ IdaSolver::~IdaSolver() { } bool use_precon; bool correct_start; - OPTION(options, mudq, n3d*(MXSUB+2)); - OPTION(options, mldq, n3d*(MXSUB+2)); + OPTION(options, mudq, band_width_default); + OPTION(options, mldq, band_width_default); OPTION(options, mukeep, n3d); OPTION(options, mlkeep, n3d); options->get("ATOL", abstol, 1.0e-12); diff --git a/src/solver/impls/imex-bdf2/imex-bdf2.cxx b/src/solver/impls/imex-bdf2/imex-bdf2.cxx index 341bf6a474..b3dc3cf311 100644 --- a/src/solver/impls/imex-bdf2/imex-bdf2.cxx +++ b/src/solver/impls/imex-bdf2/imex-bdf2.cxx @@ -3,6 +3,7 @@ #include "imex-bdf2.hxx" +#include #include #include #include @@ -205,6 +206,9 @@ int IMEXBDF2::init(int nout, BoutReal tstep) { //Set up a snes object stored at the specified location void IMEXBDF2::constructSNES(SNES *snesIn){ + // Use global mesh for now + Mesh* mesh = bout::globals::mesh; + // Nonlinear solver interface (SNES) SNESCreate(BoutComm::get(),snesIn); @@ -1310,6 +1314,9 @@ PetscErrorCode IMEXBDF2::precon(Vec x, Vec f) { */ template< class Op > void IMEXBDF2::loopVars(BoutReal *u) { + // Use global mesh for now + Mesh* mesh = bout::globals::mesh; + // Loop over 2D variables for(auto it = f2d.begin(); it != f2d.end(); ++it) { Op op(it->var, it->F_var); // Initialise the operator diff --git a/src/solver/impls/petsc/petsc.cxx b/src/solver/impls/petsc/petsc.cxx index 90edc53398..c1ae7c8c1d 100644 --- a/src/solver/impls/petsc/petsc.cxx +++ b/src/solver/impls/petsc/petsc.cxx @@ -173,10 +173,19 @@ int PetscSolver::init(int NOUT, BoutReal TIMESTEP) { ierr = VecDestroy(&rhs_vec); ///////////// GET OPTIONS ///////////// - int MXSUB = mesh->xend - mesh->xstart + 1; + // Compute band_width_default from actually added fields, to allow for multiple Mesh objects + // + // Previous implementation was equivalent to: + // int MXSUB = mesh->xend - mesh->xstart + 1; + // int band_width_default = n3Dvars()*(MXSUB+2); + int band_width_default = 0; + for (auto fvar : f3d) { + Mesh* localmesh = fvar.var->getMesh(); + band_width_default += localmesh->xend - localmesh->xstart + 3; + } - OPTION(options, mudq, n3d*(MXSUB+2)); - OPTION(options, mldq, n3d*(MXSUB+2)); + OPTION(options, mudq, band_width_default); + OPTION(options, mldq, band_width_default); OPTION(options, mukeep, 0); OPTION(options, mlkeep, 0); OPTION(options, use_precon, false); @@ -376,14 +385,14 @@ int PetscSolver::init(int NOUT, BoutReal TIMESTEP) { PetscInt dof = n3Dvars(); // Maximum allowable size of stencil in x is the number of guard cells - PetscInt stencil_width = mesh->xstart; + PetscInt stencil_width_estimate = options->operator[]("stencil_width_estimate").withDefault(bout::globals::mesh->xstart); // This is the stencil in each direction (*2) along each dimension // (*3), plus the point itself. Not sure if this is correct // though, on several levels: // 1. Ignores corner points used in e.g. brackets // 2. Could have different stencil widths in each dimension // 3. FFTs couple every single point together - PetscInt cols = stencil_width*2*3+1; + PetscInt cols = stencil_width_estimate*2*3+1; PetscInt prealloc; // = cols*dof; ierr = MatCreate(comm,&J);CHKERRQ(ierr); diff --git a/src/solver/impls/power/power.cxx b/src/solver/impls/power/power.cxx index 04a1dd3b18..7f2f777899 100644 --- a/src/solver/impls/power/power.cxx +++ b/src/solver/impls/power/power.cxx @@ -37,8 +37,6 @@ int PowerSolver::init(int nout, BoutReal tstep) { // Allocate memory f0 = Array(nlocal); - // Save the eigenvalue to the output - dump.add(eigenvalue, "eigenvalue", true); eigenvalue = 0.0; // Put starting values into f0 diff --git a/src/solver/impls/power/power.hxx b/src/solver/impls/power/power.hxx index a753167820..913bd583f0 100644 --- a/src/solver/impls/power/power.hxx +++ b/src/solver/impls/power/power.hxx @@ -48,6 +48,14 @@ class PowerSolver : public Solver { int init(int nout, BoutReal tstep) override; int run() override; + + void outputVars(Datafile &outputfile, bool save_repeat=true) override { + // Include base class functionality + this->Solver::outputVars(outputfile, save_repeat); + + // Save the eigenvalue to the output + outputfile.add(eigenvalue, "eigenvalue", true); + } private: BoutReal curtime; // Current simulation time (fixed) diff --git a/src/solver/impls/pvode/pvode.cxx b/src/solver/impls/pvode/pvode.cxx index 6881e92110..be9d4cbfa9 100644 --- a/src/solver/impls/pvode/pvode.cxx +++ b/src/solver/impls/pvode/pvode.cxx @@ -27,6 +27,7 @@ #ifdef BOUT_HAS_PVODE +#include #include #include #include @@ -121,10 +122,20 @@ int PvodeSolver::init(int nout, BoutReal tstep) { ///////////// GET OPTIONS ///////////// int pvode_mxstep; - int MXSUB = mesh->xend - mesh->xstart + 1; + // Compute band_width_default from actually added fields, to allow for multiple Mesh objects + // + // Previous implementation was equivalent to: + // int MXSUB = mesh->xend - mesh->xstart + 1; + // int band_width_default = n3Dvars()*(MXSUB+2); + int band_width_default = 0; + for (auto fvar : f3d) { + Mesh* localmesh = fvar.var->getMesh(); + band_width_default += localmesh->xend - localmesh->xstart + 3; + } + - options->get("mudq", mudq, n3d*(MXSUB+2)); - options->get("mldq", mldq, n3d*(MXSUB+2)); + options->get("mudq", mudq, band_width_default); + options->get("mldq", mldq, band_width_default); options->get("mukeep", mukeep, 0); options->get("mlkeep", mlkeep, 0); options->get("ATOL", abstol, 1.0e-12); diff --git a/src/solver/impls/slepc/slepc.cxx b/src/solver/impls/slepc/slepc.cxx index f327137062..aaf5d420c4 100644 --- a/src/solver/impls/slepc/slepc.cxx +++ b/src/solver/impls/slepc/slepc.cxx @@ -606,10 +606,10 @@ void SlepcSolver::monitor(PetscInt its, PetscInt nconv, PetscScalar eigr[], output<create2D("solution", Options::getRoot()->getSection(name), mesh); + v = fact->create2D("solution", Options::getRoot()->getSection(name), v.getMesh()); } else { initial_profile(name, v); } @@ -184,6 +184,8 @@ void Solver::add(Field2D &v, const std::string name) { void Solver::add(Field3D &v, const std::string name) { TRACE("Adding 3D field: Solver::add(%s)", name.c_str()); + Mesh* mesh = v.getMesh(); + #if CHECK > 0 if (varAdded(name)) throw BoutException("Variable '%s' already added to Solver", name.c_str()); @@ -772,6 +774,9 @@ int Solver::call_timestep_monitors(BoutReal simtime, BoutReal lastdt) { int Solver::getLocalN() { + // Use global mesh: FIX THIS! + Mesh* mesh = bout::globals::mesh; + /// Cache the value, so this is not repeatedly called. /// This value should not change after initialisation static int cacheLocalN = -1; @@ -828,6 +833,9 @@ Solver* Solver::create(SolverType &type, Options *opts) { /// Perform an operation at a given Ind2D (jx,jy) location, moving data between BOUT++ and CVODE void Solver::loop_vars_op(Ind2D i2d, BoutReal *udata, int &p, SOLVER_VAR_OP op, bool bndry) { + // Use global mesh: FIX THIS! + Mesh* mesh = bout::globals::mesh; + int nz = mesh->LocalNz; switch(op) { @@ -962,6 +970,9 @@ void Solver::loop_vars_op(Ind2D i2d, BoutReal *udata, int &p, SOLVER_VAR_OP op, /// Loop over variables and domain. Used for all data operations for consistency void Solver::loop_vars(BoutReal *udata, SOLVER_VAR_OP op) { + // Use global mesh: FIX THIS! + Mesh* mesh = bout::globals::mesh; + int p = 0; // Counter for location in udata array // All boundaries @@ -1075,6 +1086,9 @@ void Solver::set_id(BoutReal *udata) { * */ const Field3D Solver::globalIndex(int localStart) { + // Use global mesh: FIX THIS! + Mesh* mesh = bout::globals::mesh; + Field3D index(-1, mesh); // Set to -1, indicating out of domain int n2d = f2d.size(); @@ -1358,11 +1372,11 @@ void Solver::add_mms_sources(BoutReal t) { // Iterate over 2D variables for(const auto& f : f2d) { - *f.F_var += fact->create2D("source", Options::getRoot()->getSection(f.name), mesh, (f.var)->getLocation(), t); + *f.F_var += fact->create2D("source", Options::getRoot()->getSection(f.name), f.var->getMesh(), (f.var)->getLocation(), t); } for(const auto& f : f3d) { - *f.F_var += fact->create3D("source", Options::getRoot()->getSection(f.name), mesh, (f.var)->getLocation(), t); + *f.F_var += fact->create3D("source", Options::getRoot()->getSection(f.name), f.var->getMesh(), (f.var)->getLocation(), t); } } @@ -1371,7 +1385,7 @@ void Solver::calculate_mms_error(BoutReal t) { FieldFactory *fact = FieldFactory::get(); for(const auto& f : f3d) { - Field3D solution = fact->create3D("solution", Options::getRoot()->getSection(f.name), mesh, (f.var)->getLocation(), t); + Field3D solution = fact->create3D("solution", Options::getRoot()->getSection(f.name), f.var->getMesh(), (f.var)->getLocation(), t); *(f.MMS_err) = *(f.var) - solution; } diff --git a/src/sys/options.cxx b/src/sys/options.cxx index ede54a01d7..f5169f47e3 100644 --- a/src/sys/options.cxx +++ b/src/sys/options.cxx @@ -93,10 +93,10 @@ void Options::_set(std::string val, std::string source, bool force) { // Check if current value the same as new value if (value.value != val) { if (force or value.source != source) { - output_warn << _("\tOption ") << full_name << " = " << value.value << " (" - << value.source << _(") overwritten with:") - << "\n" - << "\t\t" << full_name << " = " << val << " (" << source << ")\n"; + output_warn.write( + _("\tOption %s = %s (%s) overwritten with:\n\t\t%s = %s (%s)\n"), + full_name.c_str(), value.value.c_str(), value.source.c_str(), + full_name.c_str(), val.c_str(), source.c_str()); } else { throw BoutException(_("Options: Setting a value from same source (%s) to new value " "'%s' - old value was '%s'."), diff --git a/src/sys/optionsreader.cxx b/src/sys/optionsreader.cxx index 5fde50e3d9..34b4747cf6 100644 --- a/src/sys/optionsreader.cxx +++ b/src/sys/optionsreader.cxx @@ -57,7 +57,7 @@ void OptionsReader::write(Options *options, const char *file, ...) { bout_vsnprintf(filename,buf_len, file); - output_info << _("Writing options to file ") << filename << "\n"; + output_info.write(_("Writing options to file %s\n"),filename); // Need to decide what file format to use OptionParser *parser = new OptionINI(); diff --git a/tests/integrated/test-petsc_laplace/data/BOUT.inp b/tests/integrated/test-petsc_laplace/data/BOUT.inp index 2fa9cca300..f152111b41 100644 --- a/tests/integrated/test-petsc_laplace/data/BOUT.inp +++ b/tests/integrated/test-petsc_laplace/data/BOUT.inp @@ -1,8 +1,11 @@ mz = 129 -#MYG = 0 -grid = "grids/flat_grid.nc" +MYG = 0 dump_format = "nc" +[mesh] +nx = 132 +ny = 1 + [mesh:ddx] first=C4 second=C4 diff --git a/tests/integrated/test-petsc_laplace/grids/flat_grid.nc b/tests/integrated/test-petsc_laplace/grids/flat_grid.nc deleted file mode 100644 index 1d09c4a7b4..0000000000 Binary files a/tests/integrated/test-petsc_laplace/grids/flat_grid.nc and /dev/null differ diff --git a/tests/unit/field/test_field2d.cxx b/tests/unit/field/test_field2d.cxx index 5174afba11..ce27ae2203 100644 --- a/tests/unit/field/test_field2d.cxx +++ b/tests/unit/field/test_field2d.cxx @@ -18,7 +18,14 @@ #include /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; // Reuse the "standard" fixture for FakeMesh using Field2DTest = FakeMeshFixture; @@ -629,14 +636,14 @@ TEST_F(Field2DTest, InvalidateGuards) { TEST_F(Field2DTest, CreateFromBoutReal) { Field2D field(1.0); - EXPECT_TRUE(IsField2DEqualBoutReal(field, 1.0)); + EXPECT_TRUE(IsFieldEqual(field, 1.0)); } TEST_F(Field2DTest, CreateFromField2D) { Field2D field(99.0); Field2D result(field); - EXPECT_TRUE(IsField2DEqualBoutReal(result, 99.0)); + EXPECT_TRUE(IsFieldEqual(result, 99.0)); } TEST_F(Field2DTest, AssignFromBoutReal) { @@ -644,14 +651,14 @@ TEST_F(Field2DTest, AssignFromBoutReal) { field = 2.0; - EXPECT_TRUE(IsField2DEqualBoutReal(field, 2.0)); + EXPECT_TRUE(IsFieldEqual(field, 2.0)); } TEST_F(Field2DTest, AssignFromInvalid) { Field2D field; EXPECT_NO_THROW(field = std::nan("")); - EXPECT_TRUE(IsField2DEqualBoutReal(field, std::nan(""))); + EXPECT_TRUE(IsFieldEqual(field, std::nan(""))); } TEST_F(Field2DTest, UnaryMinus) { @@ -660,7 +667,7 @@ TEST_F(Field2DTest, UnaryMinus) { field = 2.0; field = -field; - EXPECT_TRUE(IsField2DEqualBoutReal(field, -2.0)); + EXPECT_TRUE(IsFieldEqual(field, -2.0)); } TEST_F(Field2DTest, AddEqualsBoutReal) { @@ -669,14 +676,14 @@ TEST_F(Field2DTest, AddEqualsBoutReal) { a = 1.0; a += 5.0; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 6.0)); + EXPECT_TRUE(IsFieldEqual(a, 6.0)); // Check case where field is not unique auto c = a; c += 5.0; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 6.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, 11.0)); + EXPECT_TRUE(IsFieldEqual(a, 6.0)); + EXPECT_TRUE(IsFieldEqual(c, 11.0)); } TEST_F(Field2DTest, AddEqualsField2D) { @@ -686,14 +693,14 @@ TEST_F(Field2DTest, AddEqualsField2D) { b = 3.0; a += b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); // Check case where field is not unique auto c = a; c += b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 5.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, 8.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(c, 8.0)); } TEST_F(Field2DTest, AddField2DBoutReal) { @@ -702,7 +709,7 @@ TEST_F(Field2DTest, AddField2DBoutReal) { a = 1.0; b = a + 2.0; - EXPECT_TRUE(IsField2DEqualBoutReal(b, 3.0)); + EXPECT_TRUE(IsFieldEqual(b, 3.0)); } TEST_F(Field2DTest, AddBoutRealField2D) { @@ -711,7 +718,7 @@ TEST_F(Field2DTest, AddBoutRealField2D) { a = 1.0; b = 3.0 + a; - EXPECT_TRUE(IsField2DEqualBoutReal(b, 4.0)); + EXPECT_TRUE(IsFieldEqual(b, 4.0)); } TEST_F(Field2DTest, AddField2DField2D) { @@ -721,7 +728,7 @@ TEST_F(Field2DTest, AddField2DField2D) { b = 2.0; c = a + b; - EXPECT_TRUE(IsField2DEqualBoutReal(c, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 3.0)); } TEST_F(Field2DTest, MultiplyEqualsBoutReal) { @@ -730,14 +737,14 @@ TEST_F(Field2DTest, MultiplyEqualsBoutReal) { a = 2.0; a *= 1.5; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 3.0)); + EXPECT_TRUE(IsFieldEqual(a, 3.0)); // Check case where field is not unique auto c = a; c *= 1.5; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 3.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, 4.5)); + EXPECT_TRUE(IsFieldEqual(a, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.5)); } TEST_F(Field2DTest, MultiplyEqualsField2D) { @@ -747,14 +754,14 @@ TEST_F(Field2DTest, MultiplyEqualsField2D) { b = 4.0; a *= b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); // Check case where field is not unique auto c = a; c *= b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 10.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, 40.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(c, 40.0)); } TEST_F(Field2DTest, MultiplyField2DBoutReal) { @@ -763,7 +770,7 @@ TEST_F(Field2DTest, MultiplyField2DBoutReal) { a = 1.5; b = a * 2.0; - EXPECT_TRUE(IsField2DEqualBoutReal(b, 3.0)); + EXPECT_TRUE(IsFieldEqual(b, 3.0)); } TEST_F(Field2DTest, MultiplyBoutRealField2D) { @@ -772,7 +779,7 @@ TEST_F(Field2DTest, MultiplyBoutRealField2D) { a = 2.5; b = 3.0 * a; - EXPECT_TRUE(IsField2DEqualBoutReal(b, 7.5)); + EXPECT_TRUE(IsFieldEqual(b, 7.5)); } TEST_F(Field2DTest, MultiplyField2DField2D) { @@ -782,7 +789,7 @@ TEST_F(Field2DTest, MultiplyField2DField2D) { b = 8.0; c = a * b; - EXPECT_TRUE(IsField2DEqualBoutReal(c, 32.0)); + EXPECT_TRUE(IsFieldEqual(c, 32.0)); } TEST_F(Field2DTest, SubtractEqualsBoutReal) { @@ -791,14 +798,14 @@ TEST_F(Field2DTest, SubtractEqualsBoutReal) { a = 1.0; a -= 5.0; - EXPECT_TRUE(IsField2DEqualBoutReal(a, -4.0)); + EXPECT_TRUE(IsFieldEqual(a, -4.0)); // Check case where field is not unique auto c = a; c -= 5.0; - EXPECT_TRUE(IsField2DEqualBoutReal(a, -4.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, -9.0)); + EXPECT_TRUE(IsFieldEqual(a, -4.0)); + EXPECT_TRUE(IsFieldEqual(c, -9.0)); } TEST_F(Field2DTest, SubtractEqualsField2D) { @@ -808,14 +815,14 @@ TEST_F(Field2DTest, SubtractEqualsField2D) { b = 7.0; a -= b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); // Check case where field is not unique auto c = a; c -= b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, -5.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, -12.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(c, -12.0)); } TEST_F(Field2DTest, SubtractField2DBoutReal) { @@ -824,7 +831,7 @@ TEST_F(Field2DTest, SubtractField2DBoutReal) { a = 10.0; b = a - 2.0; - EXPECT_TRUE(IsField2DEqualBoutReal(b, 8.0)); + EXPECT_TRUE(IsFieldEqual(b, 8.0)); } TEST_F(Field2DTest, SubtractBoutRealField2D) { @@ -833,7 +840,7 @@ TEST_F(Field2DTest, SubtractBoutRealField2D) { a = 10.0; b = 3.0 - a; - EXPECT_TRUE(IsField2DEqualBoutReal(b, -7.0)); + EXPECT_TRUE(IsFieldEqual(b, -7.0)); } TEST_F(Field2DTest, SubtractField2DField2D) { @@ -843,7 +850,7 @@ TEST_F(Field2DTest, SubtractField2DField2D) { b = 20.0; c = a - b; - EXPECT_TRUE(IsField2DEqualBoutReal(c, -10.0)); + EXPECT_TRUE(IsFieldEqual(c, -10.0)); } TEST_F(Field2DTest, DivideEqualsBoutReal) { @@ -852,14 +859,14 @@ TEST_F(Field2DTest, DivideEqualsBoutReal) { a = 2.5; a /= 5.0; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 0.5)); + EXPECT_TRUE(IsFieldEqual(a, 0.5)); // Check case where field is not unique auto c = a; c /= 5.0; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 0.5)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, 0.1)); + EXPECT_TRUE(IsFieldEqual(a, 0.5)); + EXPECT_TRUE(IsFieldEqual(c, 0.1)); } TEST_F(Field2DTest, DivideEqualsField2D) { @@ -869,14 +876,14 @@ TEST_F(Field2DTest, DivideEqualsField2D) { b = 2.5; a /= b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); // Check case where field is not unique auto c = a; c /= b; - EXPECT_TRUE(IsField2DEqualBoutReal(a, 2.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(c, 0.8)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(c, 0.8)); } TEST_F(Field2DTest, DivideField2DBoutReal) { @@ -885,7 +892,7 @@ TEST_F(Field2DTest, DivideField2DBoutReal) { a = 3.0; b = a / 2.0; - EXPECT_TRUE(IsField2DEqualBoutReal(b, 1.5)); + EXPECT_TRUE(IsFieldEqual(b, 1.5)); } TEST_F(Field2DTest, DivideBoutRealField2D) { @@ -894,7 +901,7 @@ TEST_F(Field2DTest, DivideBoutRealField2D) { a = 2.5; b = 10.0 / a; - EXPECT_TRUE(IsField2DEqualBoutReal(b, 4.0)); + EXPECT_TRUE(IsFieldEqual(b, 4.0)); } TEST_F(Field2DTest, DivideField2DField2D) { @@ -904,7 +911,7 @@ TEST_F(Field2DTest, DivideField2DField2D) { b = 8.0; c = a / b; - EXPECT_TRUE(IsField2DEqualBoutReal(c, 4.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.0)); } TEST_F(Field2DTest, PowBoutRealField2D) { @@ -912,7 +919,7 @@ TEST_F(Field2DTest, PowBoutRealField2D) { a = 5.0; b = pow(2.0, a); - EXPECT_TRUE(IsField2DEqualBoutReal(b, 32.0)); + EXPECT_TRUE(IsFieldEqual(b, 32.0)); } TEST_F(Field2DTest, PowField2DBoutReal) { @@ -920,7 +927,7 @@ TEST_F(Field2DTest, PowField2DBoutReal) { a = 5.0; b = pow(a, 2.0); - EXPECT_TRUE(IsField2DEqualBoutReal(b, 25.0)); + EXPECT_TRUE(IsFieldEqual(b, 25.0)); } TEST_F(Field2DTest, PowField2DField2D) { @@ -929,21 +936,21 @@ TEST_F(Field2DTest, PowField2DField2D) { b = 6.0; c = pow(a, b); - EXPECT_TRUE(IsField2DEqualBoutReal(c, 64.0)); + EXPECT_TRUE(IsFieldEqual(c, 64.0)); } TEST_F(Field2DTest, Sqrt) { Field2D field; field = 16.0; - EXPECT_TRUE(IsField2DEqualBoutReal(sqrt(field), 4.0)); + EXPECT_TRUE(IsFieldEqual(sqrt(field), 4.0)); } TEST_F(Field2DTest, Abs) { Field2D field; field = -31.0; - EXPECT_TRUE(IsField2DEqualBoutReal(abs(field), 31.0)); + EXPECT_TRUE(IsFieldEqual(abs(field), 31.0)); } TEST_F(Field2DTest, Exp) { @@ -951,7 +958,7 @@ TEST_F(Field2DTest, Exp) { field = 2.5; const BoutReal expected = 12.182493960703473; - EXPECT_TRUE(IsField2DEqualBoutReal(exp(field), expected)); + EXPECT_TRUE(IsFieldEqual(exp(field), expected)); } TEST_F(Field2DTest, Log) { @@ -959,7 +966,7 @@ TEST_F(Field2DTest, Log) { field = 12.182493960703473; const BoutReal expected = 2.5; - EXPECT_TRUE(IsField2DEqualBoutReal(log(field), expected)); + EXPECT_TRUE(IsFieldEqual(log(field), expected)); } TEST_F(Field2DTest, LogExp) { @@ -967,37 +974,37 @@ TEST_F(Field2DTest, LogExp) { field = 2.5; const BoutReal expected = 2.5; - EXPECT_TRUE(IsField2DEqualBoutReal(log(exp(field)), expected)); + EXPECT_TRUE(IsFieldEqual(log(exp(field)), expected)); } TEST_F(Field2DTest, Sin) { Field2D field; field = PI / 2.0; - EXPECT_TRUE(IsField2DEqualBoutReal(sin(field), 1.0)); + EXPECT_TRUE(IsFieldEqual(sin(field), 1.0)); field = PI; - EXPECT_TRUE(IsField2DEqualBoutReal(sin(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(sin(field), 0.0)); } TEST_F(Field2DTest, Cos) { Field2D field; field = PI / 2.0; - EXPECT_TRUE(IsField2DEqualBoutReal(cos(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(cos(field), 0.0)); field = PI; - EXPECT_TRUE(IsField2DEqualBoutReal(cos(field), -1.0)); + EXPECT_TRUE(IsFieldEqual(cos(field), -1.0)); } TEST_F(Field2DTest, Tan) { Field2D field; field = PI / 4.0; - EXPECT_TRUE(IsField2DEqualBoutReal(tan(field), 1.0)); + EXPECT_TRUE(IsFieldEqual(tan(field), 1.0)); field = PI; - EXPECT_TRUE(IsField2DEqualBoutReal(tan(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(tan(field), 0.0)); } TEST_F(Field2DTest, Sinh) { @@ -1005,10 +1012,10 @@ TEST_F(Field2DTest, Sinh) { field = 1.0; const BoutReal expected = 1.1752011936438014; - EXPECT_TRUE(IsField2DEqualBoutReal(sinh(field), expected)); + EXPECT_TRUE(IsFieldEqual(sinh(field), expected)); field = -1.0; - EXPECT_TRUE(IsField2DEqualBoutReal(sinh(field), -expected)); + EXPECT_TRUE(IsFieldEqual(sinh(field), -expected)); } TEST_F(Field2DTest, Cosh) { @@ -1016,10 +1023,10 @@ TEST_F(Field2DTest, Cosh) { field = 1.0; const BoutReal expected = 1.5430806348152437; - EXPECT_TRUE(IsField2DEqualBoutReal(cosh(field), expected)); + EXPECT_TRUE(IsFieldEqual(cosh(field), expected)); field = -1.0; - EXPECT_TRUE(IsField2DEqualBoutReal(cosh(field), expected)); + EXPECT_TRUE(IsFieldEqual(cosh(field), expected)); } TEST_F(Field2DTest, Tanh) { @@ -1027,10 +1034,10 @@ TEST_F(Field2DTest, Tanh) { field = 1.0; const BoutReal expected = 0.761594155955764; - EXPECT_TRUE(IsField2DEqualBoutReal(tanh(field), expected)); + EXPECT_TRUE(IsFieldEqual(tanh(field), expected)); field = -1.0; - EXPECT_TRUE(IsField2DEqualBoutReal(tanh(field), -expected)); + EXPECT_TRUE(IsFieldEqual(tanh(field), -expected)); } TEST_F(Field2DTest, Floor) { @@ -1042,7 +1049,7 @@ TEST_F(Field2DTest, Floor) { const BoutReal floor_value = 50.0; - EXPECT_TRUE(IsField2DEqualBoutReal(floor(field, floor_value), floor_value)); + EXPECT_TRUE(IsFieldEqual(floor(field, floor_value), floor_value)); } TEST_F(Field2DTest, Min) { @@ -1107,18 +1114,18 @@ TEST_F(Field2DTest, Swap) { ddt(second) = 2.4; // Basic sanity check - EXPECT_TRUE(IsField2DEqualBoutReal(first, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(second, 2.0)); + EXPECT_TRUE(IsFieldEqual(first, 1.0)); + EXPECT_TRUE(IsFieldEqual(second, 2.0)); // swap is marked noexcept, so absolutely should not throw! ASSERT_NO_THROW(swap(first, second)); // Values - EXPECT_TRUE(IsField2DEqualBoutReal(first, 2.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(second, 1.0)); + EXPECT_TRUE(IsFieldEqual(first, 2.0)); + EXPECT_TRUE(IsFieldEqual(second, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(ddt(first), 2.4)); - EXPECT_TRUE(IsField2DEqualBoutReal(ddt(second), 1.1)); + EXPECT_TRUE(IsFieldEqual(ddt(first), 2.4)); + EXPECT_TRUE(IsFieldEqual(ddt(second), 1.1)); // Mesh properties EXPECT_EQ(first.getMesh(), &second_mesh); @@ -1156,9 +1163,9 @@ TEST_F(Field2DTest, MoveCtor) { Field2D second{std::move(first)}; // Values - EXPECT_TRUE(IsField2DEqualBoutReal(second, 1.0)); + EXPECT_TRUE(IsFieldEqual(second, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(ddt(second), 1.1)); + EXPECT_TRUE(IsFieldEqual(ddt(second), 1.1)); // Mesh properties EXPECT_EQ(second.getMesh(), mesh); @@ -1180,7 +1187,7 @@ TEST_F(Field2DTest, FillField) { fillField(f, {{1., 1., 1., 1., 1.}, {1., 1., 1., 1., 1.}, {1., 1., 1., 1., 1.}}); - EXPECT_TRUE(IsField3DEqualBoutReal(f, 1.)); + EXPECT_TRUE(IsFieldEqual(f, 1.)); fillField(f, {{0., 1., 2., 3., 4.}, {0., 1., 2., 3., 4.}, {0., 1., 2., 3., 4.}}); @@ -1188,7 +1195,7 @@ TEST_F(Field2DTest, FillField) { g.allocate(); BOUT_FOR_SERIAL(i, g.getRegion("RGN_ALL")) { g[i] = i.y(); } - EXPECT_TRUE(IsField2DEqualField2D(f, g)); + EXPECT_TRUE(IsFieldEqual(f, g)); } #pragma GCC diagnostic pop diff --git a/tests/unit/field/test_field3d.cxx b/tests/unit/field/test_field3d.cxx index fc54a2aa50..f7260739c8 100644 --- a/tests/unit/field/test_field3d.cxx +++ b/tests/unit/field/test_field3d.cxx @@ -18,7 +18,14 @@ #include /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; // Reuse the "standard" fixture for FakeMesh using Field3DTest = FakeMeshFixture; @@ -972,21 +979,21 @@ TEST_F(Field3DTest, InvalidateGuards) { TEST_F(Field3DTest, CreateFromBoutReal) { Field3D field(1.0); - EXPECT_TRUE(IsField3DEqualBoutReal(field, 1.0)); + EXPECT_TRUE(IsFieldEqual(field, 1.0)); } TEST_F(Field3DTest, CreateFromField3D) { Field3D field(99.0); Field3D result(field); - EXPECT_TRUE(IsField3DEqualBoutReal(result, 99.0)); + EXPECT_TRUE(IsFieldEqual(result, 99.0)); } TEST_F(Field3DTest, CreateFromField2D) { Field2D field(99.0); Field3D result(field); - EXPECT_TRUE(IsField3DEqualBoutReal(result, 99.0)); + EXPECT_TRUE(IsFieldEqual(result, 99.0)); } TEST_F(Field3DTest, AssignFromBoutReal) { @@ -994,14 +1001,14 @@ TEST_F(Field3DTest, AssignFromBoutReal) { field = 2.0; - EXPECT_TRUE(IsField3DEqualBoutReal(field, 2.0)); + EXPECT_TRUE(IsFieldEqual(field, 2.0)); } TEST_F(Field3DTest, AssignFromInvalid) { Field3D field; EXPECT_NO_THROW(field = std::nan("")); - EXPECT_TRUE(IsField3DEqualBoutReal(field, std::nan(""))); + EXPECT_TRUE(IsFieldEqual(field, std::nan(""))); } TEST_F(Field3DTest, AssignFromField2D) { @@ -1010,7 +1017,7 @@ TEST_F(Field3DTest, AssignFromField2D) { field = field2; - EXPECT_TRUE(IsField3DEqualBoutReal(field, 2.0)); + EXPECT_TRUE(IsFieldEqual(field, 2.0)); #if CHECK > 0 Field2D field3; @@ -1050,7 +1057,7 @@ TEST_F(Field3DTest, AssignFromField3D) { field2 = -99.0; field = field2; - EXPECT_TRUE(IsField3DEqualBoutReal(field, -99.0)); + EXPECT_TRUE(IsFieldEqual(field, -99.0)); Field3D field3; EXPECT_NO_THROW(field = field3); @@ -1064,8 +1071,8 @@ TEST_F(Field3DTest, UnaryMinus) { field = 2.0; field = -field; - EXPECT_TRUE(IsField3DEqualBoutReal(field, -2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(-field, 2.0)); + EXPECT_TRUE(IsFieldEqual(field, -2.0)); + EXPECT_TRUE(IsFieldEqual(-field, 2.0)); } TEST_F(Field3DTest, AddEqualsBoutReal) { @@ -1074,14 +1081,14 @@ TEST_F(Field3DTest, AddEqualsBoutReal) { a = 1.0; a += 5.0; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 6.0)); + EXPECT_TRUE(IsFieldEqual(a, 6.0)); // Check case where field is not unique auto c = a; c += 5.0; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 6.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 11.0)); + EXPECT_TRUE(IsFieldEqual(a, 6.0)); + EXPECT_TRUE(IsFieldEqual(c, 11.0)); } TEST_F(Field3DTest, AddEqualsField2D) { @@ -1092,14 +1099,14 @@ TEST_F(Field3DTest, AddEqualsField2D) { b = 3.0; a += b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); // Check case where field is not unique auto c = a; c += b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 5.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 8.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(c, 8.0)); } TEST_F(Field3DTest, AddEqualsField3D) { @@ -1109,14 +1116,14 @@ TEST_F(Field3DTest, AddEqualsField3D) { b = 3.0; a += b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); // Check case where field is not unique auto c = a; c += b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 5.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 8.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(c, 8.0)); } TEST_F(Field3DTest, AddEqualsField3DField3DStagger) { @@ -1144,7 +1151,7 @@ TEST_F(Field3DTest, AddField3DBoutReal) { a = 1.0; b = a + 2.0; - EXPECT_TRUE(IsField3DEqualBoutReal(b, 3.0)); + EXPECT_TRUE(IsFieldEqual(b, 3.0)); } TEST_F(Field3DTest, AddBoutRealField3D) { @@ -1153,7 +1160,7 @@ TEST_F(Field3DTest, AddBoutRealField3D) { a = 1.0; b = 3.0 + a; - EXPECT_TRUE(IsField3DEqualBoutReal(b, 4.0)); + EXPECT_TRUE(IsFieldEqual(b, 4.0)); } TEST_F(Field3DTest, AddField2DField3D) { @@ -1164,7 +1171,7 @@ TEST_F(Field3DTest, AddField2DField3D) { b = 2.0; c = a + b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 3.0)); } TEST_F(Field3DTest, AddField3DField2D) { @@ -1175,7 +1182,7 @@ TEST_F(Field3DTest, AddField3DField2D) { b = 2.0; c = a + b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 3.0)); } TEST_F(Field3DTest, AddField3DField3D) { @@ -1185,7 +1192,7 @@ TEST_F(Field3DTest, AddField3DField3D) { b = 2.0; c = a + b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 3.0)); } TEST_F(Field3DTest, AddField3DField3DStagger) { @@ -1221,14 +1228,14 @@ TEST_F(Field3DTest, MultiplyEqualsBoutReal) { a = 2.0; a *= 1.5; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 3.0)); + EXPECT_TRUE(IsFieldEqual(a, 3.0)); // Check case where field is not unique auto c = a; c *= 1.5; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 3.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 4.5)); + EXPECT_TRUE(IsFieldEqual(a, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.5)); } TEST_F(Field3DTest, MultiplyEqualsField2D) { @@ -1239,14 +1246,14 @@ TEST_F(Field3DTest, MultiplyEqualsField2D) { b = 4.0; a *= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); // Check case where field is not unique auto c = a; c *= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 10.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 40.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(c, 40.0)); } TEST_F(Field3DTest, MultiplyEqualsField3D) { @@ -1256,14 +1263,14 @@ TEST_F(Field3DTest, MultiplyEqualsField3D) { b = 4.0; a *= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); // Check case where field is not unique auto c = a; c *= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 10.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 40.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(c, 40.0)); } TEST_F(Field3DTest, MultiplyEqualsField3DField3DStagger) { @@ -1291,7 +1298,7 @@ TEST_F(Field3DTest, MultiplyField3DBoutReal) { a = 1.5; b = a * 2.0; - EXPECT_TRUE(IsField3DEqualBoutReal(b, 3.0)); + EXPECT_TRUE(IsFieldEqual(b, 3.0)); } TEST_F(Field3DTest, MultiplyBoutRealField3D) { @@ -1300,7 +1307,7 @@ TEST_F(Field3DTest, MultiplyBoutRealField3D) { a = 2.5; b = 3.0 * a; - EXPECT_TRUE(IsField3DEqualBoutReal(b, 7.5)); + EXPECT_TRUE(IsFieldEqual(b, 7.5)); } TEST_F(Field3DTest, MultiplyField2DField3D) { @@ -1311,7 +1318,7 @@ TEST_F(Field3DTest, MultiplyField2DField3D) { b = 4.0; c = a * b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 16.0)); + EXPECT_TRUE(IsFieldEqual(c, 16.0)); } TEST_F(Field3DTest, MultiplyField3DField2D) { @@ -1322,7 +1329,7 @@ TEST_F(Field3DTest, MultiplyField3DField2D) { b = 8.0; c = a * b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 64.0)); + EXPECT_TRUE(IsFieldEqual(c, 64.0)); } TEST_F(Field3DTest, MultiplyField3DField3D) { @@ -1332,7 +1339,7 @@ TEST_F(Field3DTest, MultiplyField3DField3D) { b = 8.0; c = a * b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 32.0)); + EXPECT_TRUE(IsFieldEqual(c, 32.0)); } TEST_F(Field3DTest, MultiplyField3DField3DStagger) { @@ -1368,14 +1375,14 @@ TEST_F(Field3DTest, SubtractEqualsBoutReal) { a = 1.0; a -= 5.0; - EXPECT_TRUE(IsField3DEqualBoutReal(a, -4.0)); + EXPECT_TRUE(IsFieldEqual(a, -4.0)); // Check case where field is not unique auto c = a; c -= 5.0; - EXPECT_TRUE(IsField3DEqualBoutReal(a, -4.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, -9.0)); + EXPECT_TRUE(IsFieldEqual(a, -4.0)); + EXPECT_TRUE(IsFieldEqual(c, -9.0)); } TEST_F(Field3DTest, SubtractEqualsField2D) { @@ -1386,14 +1393,14 @@ TEST_F(Field3DTest, SubtractEqualsField2D) { b = 7.0; a -= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); // Check case where field is not unique auto c = a; c -= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, -5.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, -12.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(c, -12.0)); } TEST_F(Field3DTest, SubtractEqualsField3D) { @@ -1403,14 +1410,14 @@ TEST_F(Field3DTest, SubtractEqualsField3D) { b = 7.0; a -= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); // Check case where field is not unique auto c = a; c -= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, -5.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, -12.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(c, -12.0)); } TEST_F(Field3DTest, SubtractEqualsField3DField3DStagger) { @@ -1438,7 +1445,7 @@ TEST_F(Field3DTest, SubtractField3DBoutReal) { a = 10.0; b = a - 2.0; - EXPECT_TRUE(IsField3DEqualBoutReal(b, 8.0)); + EXPECT_TRUE(IsFieldEqual(b, 8.0)); } TEST_F(Field3DTest, SubtractBoutRealField3D) { @@ -1447,7 +1454,7 @@ TEST_F(Field3DTest, SubtractBoutRealField3D) { a = 10.0; b = 3.0 - a; - EXPECT_TRUE(IsField3DEqualBoutReal(b, -7.0)); + EXPECT_TRUE(IsFieldEqual(b, -7.0)); } TEST_F(Field3DTest, SubtractField2DField3D) { @@ -1458,7 +1465,7 @@ TEST_F(Field3DTest, SubtractField2DField3D) { b = 20.0; c = a - b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, -10.0)); + EXPECT_TRUE(IsFieldEqual(c, -10.0)); } TEST_F(Field3DTest, SubtractField3DField2D) { @@ -1469,7 +1476,7 @@ TEST_F(Field3DTest, SubtractField3DField2D) { b = 20.0; c = a - b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, -10.0)); + EXPECT_TRUE(IsFieldEqual(c, -10.0)); } TEST_F(Field3DTest, SubtractField3DField3D) { @@ -1479,7 +1486,7 @@ TEST_F(Field3DTest, SubtractField3DField3D) { b = 20.0; c = a - b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, -10.0)); + EXPECT_TRUE(IsFieldEqual(c, -10.0)); } TEST_F(Field3DTest, SubtractField3DField3DStagger) { @@ -1515,14 +1522,14 @@ TEST_F(Field3DTest, DivideEqualsBoutReal) { a = 2.5; a /= 5.0; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 0.5)); + EXPECT_TRUE(IsFieldEqual(a, 0.5)); // Check case where field is not unique auto c = a; c /= 5.0; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 0.5)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 0.1)); + EXPECT_TRUE(IsFieldEqual(a, 0.5)); + EXPECT_TRUE(IsFieldEqual(c, 0.1)); } TEST_F(Field3DTest, DivideEqualsField2D) { @@ -1533,14 +1540,14 @@ TEST_F(Field3DTest, DivideEqualsField2D) { b = 2.5; a /= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); // Check case where field is not unique auto c = a; c /= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 0.8)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(c, 0.8)); } TEST_F(Field3DTest, DivideEqualsField3D) { @@ -1550,14 +1557,14 @@ TEST_F(Field3DTest, DivideEqualsField3D) { b = 2.5; a /= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); // Check case where field is not unique auto c = a; c /= b; - EXPECT_TRUE(IsField3DEqualBoutReal(a, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 0.8)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(c, 0.8)); } TEST_F(Field3DTest, DivideEqualsField3DField3DStagger) { @@ -1585,7 +1592,7 @@ TEST_F(Field3DTest, DivideField3DBoutReal) { a = 3.0; b = a / 2.0; - EXPECT_TRUE(IsField3DEqualBoutReal(b, 1.5)); + EXPECT_TRUE(IsFieldEqual(b, 1.5)); } TEST_F(Field3DTest, DivideBoutRealField3D) { @@ -1594,7 +1601,7 @@ TEST_F(Field3DTest, DivideBoutRealField3D) { a = 2.5; b = 10.0 / a; - EXPECT_TRUE(IsField3DEqualBoutReal(b, 4.0)); + EXPECT_TRUE(IsFieldEqual(b, 4.0)); } TEST_F(Field3DTest, DivideField2DField3D) { @@ -1605,7 +1612,7 @@ TEST_F(Field3DTest, DivideField2DField3D) { b = 8.0; c = a / b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 4.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.0)); } TEST_F(Field3DTest, DivideField3DField2D) { @@ -1616,7 +1623,7 @@ TEST_F(Field3DTest, DivideField3DField2D) { b = 8.0; c = a / b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 4.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.0)); } TEST_F(Field3DTest, DivideField3DField3D) { @@ -1626,7 +1633,7 @@ TEST_F(Field3DTest, DivideField3DField3D) { b = 8.0; c = a / b; - EXPECT_TRUE(IsField3DEqualBoutReal(c, 4.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.0)); } TEST_F(Field3DTest, DivideField3DField3DStagger) { @@ -1661,7 +1668,7 @@ TEST_F(Field3DTest, PowBoutRealField3D) { a = 5.0; b = pow(2.0, a); - EXPECT_TRUE(IsField3DEqualBoutReal(b, 32.0)); + EXPECT_TRUE(IsFieldEqual(b, 32.0)); } TEST_F(Field3DTest, PowField3DBoutReal) { @@ -1669,7 +1676,7 @@ TEST_F(Field3DTest, PowField3DBoutReal) { a = 5.0; b = pow(a, 2.0); - EXPECT_TRUE(IsField3DEqualBoutReal(b, 25.0)); + EXPECT_TRUE(IsFieldEqual(b, 25.0)); } TEST_F(Field3DTest, PowField3DFieldPerp) { @@ -1682,7 +1689,7 @@ TEST_F(Field3DTest, PowField3DFieldPerp) { b = 6.0; c = pow(a, b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 64.0)); + EXPECT_TRUE(IsFieldEqual(c, 64.0)); } TEST_F(Field3DTest, PowField3DField2D) { @@ -1693,7 +1700,7 @@ TEST_F(Field3DTest, PowField3DField2D) { b = 6.0; c = pow(a, b); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 64.0)); + EXPECT_TRUE(IsFieldEqual(c, 64.0)); } TEST_F(Field3DTest, PowField3DField3D) { @@ -1702,21 +1709,21 @@ TEST_F(Field3DTest, PowField3DField3D) { b = 6.0; c = pow(a, b); - EXPECT_TRUE(IsField3DEqualBoutReal(c, 64.0)); + EXPECT_TRUE(IsFieldEqual(c, 64.0)); } TEST_F(Field3DTest, Sqrt) { Field3D field; field = 16.0; - EXPECT_TRUE(IsField3DEqualBoutReal(sqrt(field), 4.0)); + EXPECT_TRUE(IsFieldEqual(sqrt(field), 4.0)); } TEST_F(Field3DTest, Abs) { Field3D field; field = -31.0; - EXPECT_TRUE(IsField3DEqualBoutReal(abs(field), 31.0)); + EXPECT_TRUE(IsFieldEqual(abs(field), 31.0)); } TEST_F(Field3DTest, Exp) { @@ -1724,7 +1731,7 @@ TEST_F(Field3DTest, Exp) { field = 2.5; const BoutReal expected = 12.182493960703473; - EXPECT_TRUE(IsField3DEqualBoutReal(exp(field), expected)); + EXPECT_TRUE(IsFieldEqual(exp(field), expected)); } TEST_F(Field3DTest, Log) { @@ -1732,7 +1739,7 @@ TEST_F(Field3DTest, Log) { field = 12.182493960703473; const BoutReal expected = 2.5; - EXPECT_TRUE(IsField3DEqualBoutReal(log(field), expected)); + EXPECT_TRUE(IsFieldEqual(log(field), expected)); } TEST_F(Field3DTest, LogExp) { @@ -1740,37 +1747,37 @@ TEST_F(Field3DTest, LogExp) { field = 2.5; const BoutReal expected = 2.5; - EXPECT_TRUE(IsField3DEqualBoutReal(log(exp(field)), expected)); + EXPECT_TRUE(IsFieldEqual(log(exp(field)), expected)); } TEST_F(Field3DTest, Sin) { Field3D field; field = PI / 2.0; - EXPECT_TRUE(IsField3DEqualBoutReal(sin(field), 1.0)); + EXPECT_TRUE(IsFieldEqual(sin(field), 1.0)); field = PI; - EXPECT_TRUE(IsField3DEqualBoutReal(sin(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(sin(field), 0.0)); } TEST_F(Field3DTest, Cos) { Field3D field; field = PI / 2.0; - EXPECT_TRUE(IsField3DEqualBoutReal(cos(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(cos(field), 0.0)); field = PI; - EXPECT_TRUE(IsField3DEqualBoutReal(cos(field), -1.0)); + EXPECT_TRUE(IsFieldEqual(cos(field), -1.0)); } TEST_F(Field3DTest, Tan) { Field3D field; field = PI / 4.0; - EXPECT_TRUE(IsField3DEqualBoutReal(tan(field), 1.0)); + EXPECT_TRUE(IsFieldEqual(tan(field), 1.0)); field = PI; - EXPECT_TRUE(IsField3DEqualBoutReal(tan(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(tan(field), 0.0)); } TEST_F(Field3DTest, Sinh) { @@ -1778,10 +1785,10 @@ TEST_F(Field3DTest, Sinh) { field = 1.0; const BoutReal expected = 1.1752011936438014; - EXPECT_TRUE(IsField3DEqualBoutReal(sinh(field), expected)); + EXPECT_TRUE(IsFieldEqual(sinh(field), expected)); field = -1.0; - EXPECT_TRUE(IsField3DEqualBoutReal(sinh(field), -expected)); + EXPECT_TRUE(IsFieldEqual(sinh(field), -expected)); } TEST_F(Field3DTest, Cosh) { @@ -1789,10 +1796,10 @@ TEST_F(Field3DTest, Cosh) { field = 1.0; const BoutReal expected = 1.5430806348152437; - EXPECT_TRUE(IsField3DEqualBoutReal(cosh(field), expected)); + EXPECT_TRUE(IsFieldEqual(cosh(field), expected)); field = -1.0; - EXPECT_TRUE(IsField3DEqualBoutReal(cosh(field), expected)); + EXPECT_TRUE(IsFieldEqual(cosh(field), expected)); } TEST_F(Field3DTest, Tanh) { @@ -1800,10 +1807,10 @@ TEST_F(Field3DTest, Tanh) { field = 1.0; const BoutReal expected = 0.761594155955764; - EXPECT_TRUE(IsField3DEqualBoutReal(tanh(field), expected)); + EXPECT_TRUE(IsFieldEqual(tanh(field), expected)); field = -1.0; - EXPECT_TRUE(IsField3DEqualBoutReal(tanh(field), -expected)); + EXPECT_TRUE(IsFieldEqual(tanh(field), -expected)); } TEST_F(Field3DTest, Floor) { @@ -1815,7 +1822,7 @@ TEST_F(Field3DTest, Floor) { const BoutReal floor_value = 50.0; - EXPECT_TRUE(IsField3DEqualBoutReal(floor(field, floor_value), floor_value)); + EXPECT_TRUE(IsFieldEqual(floor(field, floor_value), floor_value)); } TEST_F(Field3DTest, Min) { @@ -1879,7 +1886,7 @@ TEST_F(Field3DTest, DC) { field[i] = i.z(); } - EXPECT_TRUE(IsField2DEqualBoutReal(DC(field), 3.0)); + EXPECT_TRUE(IsFieldEqual(DC(field), 3.0)); } TEST_F(Field3DTest, Swap) { @@ -1918,24 +1925,24 @@ TEST_F(Field3DTest, Swap) { ddt(second) = 2.4; // Basic sanity check - EXPECT_TRUE(IsField3DEqualBoutReal(first, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(second, 2.0)); + EXPECT_TRUE(IsFieldEqual(first, 1.0)); + EXPECT_TRUE(IsFieldEqual(second, 2.0)); // swap is marked noexcept, so absolutely should not throw! ASSERT_NO_THROW(swap(first, second)); // Values - EXPECT_TRUE(IsField3DEqualBoutReal(first, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(second, 1.0)); + EXPECT_TRUE(IsFieldEqual(first, 2.0)); + EXPECT_TRUE(IsFieldEqual(second, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(first.yup(), 2.2)); - EXPECT_TRUE(IsField3DEqualBoutReal(first.ydown(), 1.2)); + EXPECT_TRUE(IsFieldEqual(first.yup(), 2.2)); + EXPECT_TRUE(IsFieldEqual(first.ydown(), 1.2)); - EXPECT_TRUE(IsField3DEqualBoutReal(second.yup(), 1.5)); - EXPECT_TRUE(IsField3DEqualBoutReal(second.ydown(), 0.5)); + EXPECT_TRUE(IsFieldEqual(second.yup(), 1.5)); + EXPECT_TRUE(IsFieldEqual(second.ydown(), 0.5)); - EXPECT_TRUE(IsField3DEqualBoutReal(ddt(first), 2.4)); - EXPECT_TRUE(IsField3DEqualBoutReal(ddt(second), 1.1)); + EXPECT_TRUE(IsFieldEqual(ddt(first), 2.4)); + EXPECT_TRUE(IsFieldEqual(ddt(second), 1.1)); // Mesh properties EXPECT_EQ(first.getMesh(), &second_mesh); @@ -1977,12 +1984,12 @@ TEST_F(Field3DTest, MoveCtor) { Field3D second{std::move(first)}; // Values - EXPECT_TRUE(IsField3DEqualBoutReal(second, 1.0)); + EXPECT_TRUE(IsFieldEqual(second, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(second.yup(), 1.5)); - EXPECT_TRUE(IsField3DEqualBoutReal(second.ydown(), 0.5)); + EXPECT_TRUE(IsFieldEqual(second.yup(), 1.5)); + EXPECT_TRUE(IsFieldEqual(second.ydown(), 0.5)); - EXPECT_TRUE(IsField3DEqualBoutReal(ddt(second), 1.1)); + EXPECT_TRUE(IsFieldEqual(ddt(second), 1.1)); // Mesh properties EXPECT_EQ(second.getMesh(), mesh); @@ -2020,7 +2027,7 @@ TEST_F(Field3DTest, FillField) { {1., 1., 1., 1., 1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1.}}}); - EXPECT_TRUE(IsField3DEqualBoutReal(f, 1.)); + EXPECT_TRUE(IsFieldEqual(f, 1.)); fillField(f, {{{0., 1., 2., 3., 4., 5., 6.}, {0., 1., 2., 3., 4., 5., 6.}, @@ -2044,7 +2051,7 @@ TEST_F(Field3DTest, FillField) { g.allocate(); BOUT_FOR_SERIAL(i, g.getRegion("RGN_ALL")) { g[i] = i.z(); } - EXPECT_TRUE(IsField3DEqualField3D(f, g)); + EXPECT_TRUE(IsFieldEqual(f, g)); } // Restore compiler warnings diff --git a/tests/unit/field/test_fieldperp.cxx b/tests/unit/field/test_fieldperp.cxx index f986a9968b..b9c1ba7092 100644 --- a/tests/unit/field/test_fieldperp.cxx +++ b/tests/unit/field/test_fieldperp.cxx @@ -17,7 +17,14 @@ #include /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; /// Test fixture to make sure the global mesh is our fake one using FieldPerpTest = FakeMeshFixture; @@ -657,14 +664,14 @@ TEST_F(FieldPerpTest, InvalidateGuards) { TEST_F(FieldPerpTest, CreateFromBoutReal) { FieldPerp field(1.0); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(field, 1.0)); + EXPECT_TRUE(IsFieldEqual(field, 1.0)); } TEST_F(FieldPerpTest, CreateFromFieldPerp) { FieldPerp field(99.0); FieldPerp result(field); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(result, 99.0)); + EXPECT_TRUE(IsFieldEqual(result, 99.0)); } TEST_F(FieldPerpTest, AssignFromBoutReal) { @@ -672,14 +679,14 @@ TEST_F(FieldPerpTest, AssignFromBoutReal) { field = 2.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(field, 2.0)); + EXPECT_TRUE(IsFieldEqual(field, 2.0)); } TEST_F(FieldPerpTest, AssignFromInvalid) { FieldPerp field; EXPECT_NO_THROW(field = std::nan("")); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(field, std::nan(""))); + EXPECT_TRUE(IsFieldEqual(field, std::nan(""))); } TEST_F(FieldPerpTest, UnaryMinus) { @@ -689,7 +696,7 @@ TEST_F(FieldPerpTest, UnaryMinus) { field = 2.0; field = -field; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(field, -2.0)); + EXPECT_TRUE(IsFieldEqual(field, -2.0)); } TEST_F(FieldPerpTest, AddEqualsBoutReal) { @@ -699,14 +706,14 @@ TEST_F(FieldPerpTest, AddEqualsBoutReal) { a = 1.0; a += 5.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 6.0)); + EXPECT_TRUE(IsFieldEqual(a, 6.0)); // Check case where field is not unique auto c = a; c += 5.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 6.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 11.0)); + EXPECT_TRUE(IsFieldEqual(a, 6.0)); + EXPECT_TRUE(IsFieldEqual(c, 11.0)); } TEST_F(FieldPerpTest, AddEqualsFieldPerp) { @@ -718,14 +725,14 @@ TEST_F(FieldPerpTest, AddEqualsFieldPerp) { b = 3.0; a += b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); // Check case where field is not unique auto c = a; c += b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 5.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 8.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(c, 8.0)); } TEST_F(FieldPerpTest, AddEqualsField2D) { @@ -740,14 +747,14 @@ TEST_F(FieldPerpTest, AddEqualsField2D) { a.setIndex(1); EXPECT_NO_THROW(a += b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); // Check case where field is not unique auto c = a; c += b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 5.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 8.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(c, 8.0)); } TEST_F(FieldPerpTest, AddEqualsField3D) { @@ -762,14 +769,14 @@ TEST_F(FieldPerpTest, AddEqualsField3D) { a.setIndex(1); EXPECT_NO_THROW(a += b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); // Check case where field is not unique auto c = a; c += b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 5.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 8.0)); + EXPECT_TRUE(IsFieldEqual(a, 5.0)); + EXPECT_TRUE(IsFieldEqual(c, 8.0)); } TEST_F(FieldPerpTest, AddFieldPerpBoutReal) { @@ -779,7 +786,7 @@ TEST_F(FieldPerpTest, AddFieldPerpBoutReal) { a = 1.0; b = a + 2.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 3.0)); + EXPECT_TRUE(IsFieldEqual(b, 3.0)); } TEST_F(FieldPerpTest, AddBoutRealFieldPerp) { @@ -789,7 +796,7 @@ TEST_F(FieldPerpTest, AddBoutRealFieldPerp) { a = 1.0; b = 3.0 + a; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 4.0)); + EXPECT_TRUE(IsFieldEqual(b, 4.0)); } TEST_F(FieldPerpTest, AddFieldPerpFieldPerp) { @@ -801,7 +808,7 @@ TEST_F(FieldPerpTest, AddFieldPerpFieldPerp) { b = 2.0; c = a + b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 3.0)); } TEST_F(FieldPerpTest, AddFieldPerpField2D) { @@ -813,7 +820,7 @@ TEST_F(FieldPerpTest, AddFieldPerpField2D) { b = 2.0; c = a + b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 3.0)); } TEST_F(FieldPerpTest, AddFieldPerpField3D) { @@ -825,7 +832,7 @@ TEST_F(FieldPerpTest, AddFieldPerpField3D) { b = 2.0; c = a + b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 3.0)); } TEST_F(FieldPerpTest, MultiplyEqualsBoutReal) { @@ -835,14 +842,14 @@ TEST_F(FieldPerpTest, MultiplyEqualsBoutReal) { a = 2.0; a *= 1.5; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 3.0)); + EXPECT_TRUE(IsFieldEqual(a, 3.0)); // Check case where field is not unique auto c = a; c *= 1.5; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 3.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 4.5)); + EXPECT_TRUE(IsFieldEqual(a, 3.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.5)); } TEST_F(FieldPerpTest, MultiplyEqualsFieldPerp) { @@ -854,14 +861,14 @@ TEST_F(FieldPerpTest, MultiplyEqualsFieldPerp) { b = 4.0; a *= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); // Check case where field is not unique auto c = a; c *= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 10.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 40.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(c, 40.0)); } TEST_F(FieldPerpTest, MultiplyEqualsField2D) { @@ -876,14 +883,14 @@ TEST_F(FieldPerpTest, MultiplyEqualsField2D) { a.setIndex(1); EXPECT_NO_THROW(a *= b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); // Check case where field is not unique auto c = a; c *= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 10.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 40.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(c, 40.0)); } TEST_F(FieldPerpTest, MultiplyEqualsField3D) { @@ -898,14 +905,14 @@ TEST_F(FieldPerpTest, MultiplyEqualsField3D) { a.setIndex(1); EXPECT_NO_THROW(a *= b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); // Check case where field is not unique auto c = a; c *= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 10.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 40.0)); + EXPECT_TRUE(IsFieldEqual(a, 10.0)); + EXPECT_TRUE(IsFieldEqual(c, 40.0)); } TEST_F(FieldPerpTest, MultiplyFieldPerpBoutReal) { @@ -915,7 +922,7 @@ TEST_F(FieldPerpTest, MultiplyFieldPerpBoutReal) { a = 1.5; b = a * 2.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 3.0)); + EXPECT_TRUE(IsFieldEqual(b, 3.0)); } TEST_F(FieldPerpTest, MultiplyBoutRealFieldPerp) { @@ -925,7 +932,7 @@ TEST_F(FieldPerpTest, MultiplyBoutRealFieldPerp) { a = 2.5; b = 3.0 * a; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 7.5)); + EXPECT_TRUE(IsFieldEqual(b, 7.5)); } TEST_F(FieldPerpTest, MultiplyFieldPerpFieldPerp) { @@ -937,7 +944,7 @@ TEST_F(FieldPerpTest, MultiplyFieldPerpFieldPerp) { b = 8.0; c = a * b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 32.0)); + EXPECT_TRUE(IsFieldEqual(c, 32.0)); } TEST_F(FieldPerpTest, MultiplyFieldPerpField2D) { @@ -949,7 +956,7 @@ TEST_F(FieldPerpTest, MultiplyFieldPerpField2D) { b = 8.0; c = a * b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 32.0)); + EXPECT_TRUE(IsFieldEqual(c, 32.0)); } TEST_F(FieldPerpTest, MultiplyFieldPerpField3D) { @@ -961,7 +968,7 @@ TEST_F(FieldPerpTest, MultiplyFieldPerpField3D) { b = 8.0; c = a * b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 32.0)); + EXPECT_TRUE(IsFieldEqual(c, 32.0)); } TEST_F(FieldPerpTest, SubtractEqualsBoutReal) { @@ -971,14 +978,14 @@ TEST_F(FieldPerpTest, SubtractEqualsBoutReal) { a = 1.0; a -= 5.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -4.0)); + EXPECT_TRUE(IsFieldEqual(a, -4.0)); // Check case where field is not unique auto c = a; c -= 5.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -4.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, -9.0)); + EXPECT_TRUE(IsFieldEqual(a, -4.0)); + EXPECT_TRUE(IsFieldEqual(c, -9.0)); } TEST_F(FieldPerpTest, SubtractEqualsFieldPerp) { @@ -990,14 +997,14 @@ TEST_F(FieldPerpTest, SubtractEqualsFieldPerp) { b = 7.0; a -= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); // Check case where field is not unique auto c = a; c -= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -5.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, -12.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(c, -12.0)); } TEST_F(FieldPerpTest, SubtractEqualsField2D) { @@ -1012,14 +1019,14 @@ TEST_F(FieldPerpTest, SubtractEqualsField2D) { a.setIndex(1); EXPECT_NO_THROW(a -= b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); // Check case where field is not unique auto c = a; c -= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -5.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, -12.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(c, -12.0)); } TEST_F(FieldPerpTest, SubtractEqualsField3D) { @@ -1034,14 +1041,14 @@ TEST_F(FieldPerpTest, SubtractEqualsField3D) { a.setIndex(1); EXPECT_NO_THROW(a -= b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); // Check case where field is not unique auto c = a; c -= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, -5.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, -12.0)); + EXPECT_TRUE(IsFieldEqual(a, -5.0)); + EXPECT_TRUE(IsFieldEqual(c, -12.0)); } TEST_F(FieldPerpTest, SubtractFieldPerpBoutReal) { @@ -1051,7 +1058,7 @@ TEST_F(FieldPerpTest, SubtractFieldPerpBoutReal) { a = 10.0; b = a - 2.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 8.0)); + EXPECT_TRUE(IsFieldEqual(b, 8.0)); } TEST_F(FieldPerpTest, SubtractBoutRealFieldPerp) { @@ -1061,7 +1068,7 @@ TEST_F(FieldPerpTest, SubtractBoutRealFieldPerp) { a = 10.0; b = 3.0 - a; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, -7.0)); + EXPECT_TRUE(IsFieldEqual(b, -7.0)); } TEST_F(FieldPerpTest, SubtractFieldPerpFieldPerp) { @@ -1073,7 +1080,7 @@ TEST_F(FieldPerpTest, SubtractFieldPerpFieldPerp) { b = 20.0; c = a - b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, -10.0)); + EXPECT_TRUE(IsFieldEqual(c, -10.0)); } TEST_F(FieldPerpTest, SubtractFieldPerpField2D) { @@ -1085,7 +1092,7 @@ TEST_F(FieldPerpTest, SubtractFieldPerpField2D) { b = 20.0; c = a - b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, -10.0)); + EXPECT_TRUE(IsFieldEqual(c, -10.0)); } TEST_F(FieldPerpTest, SubtractFieldPerpField3D) { @@ -1097,7 +1104,7 @@ TEST_F(FieldPerpTest, SubtractFieldPerpField3D) { b = 20.0; c = a - b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, -10.0)); + EXPECT_TRUE(IsFieldEqual(c, -10.0)); } TEST_F(FieldPerpTest, DivideEqualsBoutReal) { @@ -1107,14 +1114,14 @@ TEST_F(FieldPerpTest, DivideEqualsBoutReal) { a = 2.5; a /= 5.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 0.5)); + EXPECT_TRUE(IsFieldEqual(a, 0.5)); // Check case where field is not unique auto c = a; c /= 5.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 0.5)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 0.1)); + EXPECT_TRUE(IsFieldEqual(a, 0.5)); + EXPECT_TRUE(IsFieldEqual(c, 0.1)); } TEST_F(FieldPerpTest, DivideEqualsFieldPerp) { @@ -1126,14 +1133,14 @@ TEST_F(FieldPerpTest, DivideEqualsFieldPerp) { b = 2.5; a /= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); // Check case where field is not unique auto c = a; c /= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 2.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 0.8)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(c, 0.8)); } TEST_F(FieldPerpTest, DivideEqualsField2D) { @@ -1148,14 +1155,14 @@ TEST_F(FieldPerpTest, DivideEqualsField2D) { a.setIndex(1); EXPECT_NO_THROW(a /= b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); // Check case where field is not unique auto c = a; c /= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 2.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 0.8)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(c, 0.8)); } TEST_F(FieldPerpTest, DivideEqualsField3D) { @@ -1170,14 +1177,14 @@ TEST_F(FieldPerpTest, DivideEqualsField3D) { a.setIndex(1); EXPECT_NO_THROW(a /= b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); // Check case where field is not unique auto c = a; c /= b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(a, 2.0)); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 0.8)); + EXPECT_TRUE(IsFieldEqual(a, 2.0)); + EXPECT_TRUE(IsFieldEqual(c, 0.8)); } TEST_F(FieldPerpTest, DivideFieldPerpBoutReal) { @@ -1187,7 +1194,7 @@ TEST_F(FieldPerpTest, DivideFieldPerpBoutReal) { a = 3.0; b = a / 2.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 1.5)); + EXPECT_TRUE(IsFieldEqual(b, 1.5)); } TEST_F(FieldPerpTest, DivideBoutRealFieldPerp) { @@ -1197,7 +1204,7 @@ TEST_F(FieldPerpTest, DivideBoutRealFieldPerp) { a = 2.5; b = 10.0 / a; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 4.0)); + EXPECT_TRUE(IsFieldEqual(b, 4.0)); } TEST_F(FieldPerpTest, DivideFieldPerpFieldPerp) { @@ -1209,7 +1216,7 @@ TEST_F(FieldPerpTest, DivideFieldPerpFieldPerp) { b = 8.0; c = a / b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 4.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.0)); } TEST_F(FieldPerpTest, DivideFieldPerpField2D) { @@ -1221,7 +1228,7 @@ TEST_F(FieldPerpTest, DivideFieldPerpField2D) { b = 8.0; c = a / b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 4.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.0)); } TEST_F(FieldPerpTest, DivideFieldPerpField3D) { @@ -1233,7 +1240,7 @@ TEST_F(FieldPerpTest, DivideFieldPerpField3D) { b = 8.0; c = a / b; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 4.0)); + EXPECT_TRUE(IsFieldEqual(c, 4.0)); } TEST_F(FieldPerpTest, PowBoutRealFieldPerp) { @@ -1244,7 +1251,7 @@ TEST_F(FieldPerpTest, PowBoutRealFieldPerp) { a = 5.0; b = pow(2.0, a); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 32.0)); + EXPECT_TRUE(IsFieldEqual(b, 32.0)); } TEST_F(FieldPerpTest, PowFieldPerpBoutReal) { @@ -1254,7 +1261,7 @@ TEST_F(FieldPerpTest, PowFieldPerpBoutReal) { a = 5.0; b = pow(a, 2.0); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(b, 25.0)); + EXPECT_TRUE(IsFieldEqual(b, 25.0)); } TEST_F(FieldPerpTest, PowFieldPerpFieldPerp) { @@ -1266,7 +1273,7 @@ TEST_F(FieldPerpTest, PowFieldPerpFieldPerp) { b = 6.0; c = pow(a, b); - EXPECT_TRUE(IsFieldPerpEqualBoutReal(c, 64.0)); + EXPECT_TRUE(IsFieldEqual(c, 64.0)); } TEST_F(FieldPerpTest, Sqrt) { @@ -1274,7 +1281,7 @@ TEST_F(FieldPerpTest, Sqrt) { field.setIndex(0); field = 16.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(sqrt(field), 4.0)); + EXPECT_TRUE(IsFieldEqual(sqrt(field), 4.0)); } TEST_F(FieldPerpTest, Abs) { @@ -1282,7 +1289,7 @@ TEST_F(FieldPerpTest, Abs) { field.setIndex(0); field = -31.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(abs(field), 31.0)); + EXPECT_TRUE(IsFieldEqual(abs(field), 31.0)); } TEST_F(FieldPerpTest, Exp) { @@ -1291,7 +1298,7 @@ TEST_F(FieldPerpTest, Exp) { field = 2.5; const BoutReal expected = 12.182493960703473; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(exp(field), expected)); + EXPECT_TRUE(IsFieldEqual(exp(field), expected)); } TEST_F(FieldPerpTest, Log) { @@ -1300,7 +1307,7 @@ TEST_F(FieldPerpTest, Log) { field = 12.182493960703473; const BoutReal expected = 2.5; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(log(field), expected)); + EXPECT_TRUE(IsFieldEqual(log(field), expected)); } TEST_F(FieldPerpTest, LogExp) { @@ -1309,7 +1316,7 @@ TEST_F(FieldPerpTest, LogExp) { field = 2.5; const BoutReal expected = 2.5; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(log(exp(field)), expected)); + EXPECT_TRUE(IsFieldEqual(log(exp(field)), expected)); } TEST_F(FieldPerpTest, Sin) { @@ -1317,10 +1324,10 @@ TEST_F(FieldPerpTest, Sin) { field.setIndex(0); field = PI / 2.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(sin(field), 1.0)); + EXPECT_TRUE(IsFieldEqual(sin(field), 1.0)); field = PI; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(sin(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(sin(field), 0.0)); } TEST_F(FieldPerpTest, Cos) { @@ -1328,10 +1335,10 @@ TEST_F(FieldPerpTest, Cos) { field.setIndex(0); field = PI / 2.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(cos(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(cos(field), 0.0)); field = PI; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(cos(field), -1.0)); + EXPECT_TRUE(IsFieldEqual(cos(field), -1.0)); } TEST_F(FieldPerpTest, Tan) { @@ -1339,10 +1346,10 @@ TEST_F(FieldPerpTest, Tan) { field.setIndex(0); field = PI / 4.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(tan(field), 1.0)); + EXPECT_TRUE(IsFieldEqual(tan(field), 1.0)); field = PI; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(tan(field), 0.0)); + EXPECT_TRUE(IsFieldEqual(tan(field), 0.0)); } TEST_F(FieldPerpTest, Sinh) { @@ -1351,10 +1358,10 @@ TEST_F(FieldPerpTest, Sinh) { field = 1.0; const BoutReal expected = 1.1752011936438014; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(sinh(field), expected)); + EXPECT_TRUE(IsFieldEqual(sinh(field), expected)); field = -1.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(sinh(field), -expected)); + EXPECT_TRUE(IsFieldEqual(sinh(field), -expected)); } TEST_F(FieldPerpTest, Cosh) { @@ -1363,10 +1370,10 @@ TEST_F(FieldPerpTest, Cosh) { field = 1.0; const BoutReal expected = 1.5430806348152437; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(cosh(field), expected)); + EXPECT_TRUE(IsFieldEqual(cosh(field), expected)); field = -1.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(cosh(field), expected)); + EXPECT_TRUE(IsFieldEqual(cosh(field), expected)); } TEST_F(FieldPerpTest, Tanh) { @@ -1375,10 +1382,10 @@ TEST_F(FieldPerpTest, Tanh) { field = 1.0; const BoutReal expected = 0.761594155955764; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(tanh(field), expected)); + EXPECT_TRUE(IsFieldEqual(tanh(field), expected)); field = -1.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(tanh(field), -expected)); + EXPECT_TRUE(IsFieldEqual(tanh(field), -expected)); } TEST_F(FieldPerpTest, Floor) { @@ -1391,7 +1398,7 @@ TEST_F(FieldPerpTest, Floor) { const BoutReal floor_value = 50.0; - EXPECT_TRUE(IsFieldPerpEqualBoutReal(floor(field, floor_value), floor_value)); + EXPECT_TRUE(IsFieldEqual(floor(field, floor_value), floor_value)); } TEST_F(FieldPerpTest, Min) { diff --git a/tests/unit/field/test_vector2d.cxx b/tests/unit/field/test_vector2d.cxx index a6ec890c34..7e5e032885 100644 --- a/tests/unit/field/test_vector2d.cxx +++ b/tests/unit/field/test_vector2d.cxx @@ -10,7 +10,14 @@ #include "vector3d.hxx" /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; /// Test fixture to make sure the global mesh is our fake one class Vector2DTest : public ::testing::Test { @@ -191,9 +198,9 @@ TEST_F(Vector2DTest, AssignFromBoutReal) { vector = 0.0; - EXPECT_TRUE(IsField2DEqualBoutReal(vector.x, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.y, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.z, 0.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 0.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 0.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 0.0)); } TEST_F(Vector2DTest, AssignFromVector2D) { @@ -208,9 +215,9 @@ TEST_F(Vector2DTest, AssignFromVector2D) { vector2 = vector1; - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.x, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.y, 2.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.z, 3.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, 1.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, 2.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, 3.0)); EXPECT_EQ(vector1.getLocation(), vector2.getLocation()); } @@ -226,9 +233,9 @@ TEST_F(Vector2DTest, CreateFromVector2D) { Vector2D vector2{vector1}; - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.x, 4.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.y, 5.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.z, 6.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, 4.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, 5.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, 6.0)); EXPECT_EQ(vector1.getLocation(), vector2.getLocation()); } @@ -242,9 +249,9 @@ TEST_F(Vector2DTest, UnaryMinus) { vector2 = -vector1; - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.x, -7.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.y, -8.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.z, -9.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, -7.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, -8.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, -9.0)); } TEST_F(Vector2DTest, AddEqualsVector2D) { @@ -260,9 +267,9 @@ TEST_F(Vector2DTest, AddEqualsVector2D) { vector2 += vector1; - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.x, 11.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.y, 13.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.z, 15.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, 11.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, 13.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, 15.0)); } TEST_F(Vector2DTest, AddVector2DVector2D) { @@ -278,9 +285,9 @@ TEST_F(Vector2DTest, AddVector2DVector2D) { Vector2D result = vector1 + vector2; - EXPECT_TRUE(IsField2DEqualBoutReal(result.x, 17.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.y, 19.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.z, 21.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 17.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 19.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 21.0)); } TEST_F(Vector2DTest, AddVector2DVector3D) { @@ -296,9 +303,9 @@ TEST_F(Vector2DTest, AddVector2DVector3D) { Vector3D result = vector1 + vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 7.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 9.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 11.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 7.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 9.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 11.0)); } TEST_F(Vector2DTest, MinusEqualsVector2D) { @@ -314,9 +321,9 @@ TEST_F(Vector2DTest, MinusEqualsVector2D) { vector2 -= vector1; - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.x, -97.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.y, -99.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector2.z, -101.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, -97.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, -99.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, -101.0)); } TEST_F(Vector2DTest, MinusVector2DVector2D) { @@ -332,9 +339,9 @@ TEST_F(Vector2DTest, MinusVector2DVector2D) { Vector2D result = vector1 - vector2; - EXPECT_TRUE(IsField2DEqualBoutReal(result.x, -3.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.y, -1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.z, 1.0)); + EXPECT_TRUE(IsFieldEqual(result.x, -3.0)); + EXPECT_TRUE(IsFieldEqual(result.y, -1.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 1.0)); } TEST_F(Vector2DTest, MinusVector2DVector3D) { @@ -350,9 +357,9 @@ TEST_F(Vector2DTest, MinusVector2DVector3D) { Vector3D result = vector1 - vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 7.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 9.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 11.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 7.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 9.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 11.0)); } TEST_F(Vector2DTest, MultiplyEqualsBoutReal) { @@ -365,9 +372,9 @@ TEST_F(Vector2DTest, MultiplyEqualsBoutReal) { vector *= real; - EXPECT_TRUE(IsField2DEqualBoutReal(vector.x, 16.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.y, 20.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.z, 24.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 16.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 20.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 24.0)); } TEST_F(Vector2DTest, MultiplyEqualsField2D) { @@ -380,9 +387,9 @@ TEST_F(Vector2DTest, MultiplyEqualsField2D) { vector *= field; - EXPECT_TRUE(IsField2DEqualBoutReal(vector.x, 160.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.y, 200.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.z, 240.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 160.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 200.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 240.0)); } TEST_F(Vector2DTest, MultiplyVector2DBoutReal) { @@ -395,9 +402,9 @@ TEST_F(Vector2DTest, MultiplyVector2DBoutReal) { Vector2D result = vector * real; - EXPECT_TRUE(IsField2DEqualBoutReal(result.x, 2.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.y, 4.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.z, 6.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 2.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 4.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 6.0)); } TEST_F(Vector2DTest, MultiplyVector2DField2D) { @@ -410,9 +417,9 @@ TEST_F(Vector2DTest, MultiplyVector2DField2D) { Vector2D result = vector * field; - EXPECT_TRUE(IsField2DEqualBoutReal(result.x, 3.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.y, 6.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.z, 9.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 3.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 6.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 9.0)); } TEST_F(Vector2DTest, MultiplyVector2DField3D) { @@ -425,9 +432,9 @@ TEST_F(Vector2DTest, MultiplyVector2DField3D) { Vector3D result = vector * field; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 4.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 8.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 12.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 4.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 8.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 12.0)); } TEST_F(Vector2DTest, DivideEqualsBoutReal) { @@ -440,9 +447,9 @@ TEST_F(Vector2DTest, DivideEqualsBoutReal) { vector /= real; - EXPECT_TRUE(IsField2DEqualBoutReal(vector.x, 0.1)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.y, 0.2)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.z, 0.3)); + EXPECT_TRUE(IsFieldEqual(vector.x, 0.1)); + EXPECT_TRUE(IsFieldEqual(vector.y, 0.2)); + EXPECT_TRUE(IsFieldEqual(vector.z, 0.3)); } TEST_F(Vector2DTest, DivideEqualsConstField2D) { @@ -455,9 +462,9 @@ TEST_F(Vector2DTest, DivideEqualsConstField2D) { vector /= field; - EXPECT_TRUE(IsField2DEqualBoutReal(vector.x, 0.2)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.y, 0.4)); - EXPECT_TRUE(IsField2DEqualBoutReal(vector.z, 0.6)); + EXPECT_TRUE(IsFieldEqual(vector.x, 0.2)); + EXPECT_TRUE(IsFieldEqual(vector.y, 0.4)); + EXPECT_TRUE(IsFieldEqual(vector.z, 0.6)); } TEST_F(Vector2DTest, DivideVector2DBoutReal) { @@ -470,9 +477,9 @@ TEST_F(Vector2DTest, DivideVector2DBoutReal) { Vector2D result = vector / real; - EXPECT_TRUE(IsField2DEqualBoutReal(result.x, 0.5)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.y, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.z, 1.5)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.5)); + EXPECT_TRUE(IsFieldEqual(result.y, 1.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 1.5)); } TEST_F(Vector2DTest, DivideVector2DField2D) { @@ -485,9 +492,9 @@ TEST_F(Vector2DTest, DivideVector2DField2D) { Vector2D result = vector / field; - EXPECT_TRUE(IsField2DEqualBoutReal(result.x, 0.25)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.y, 0.5)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.z, 0.75)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.25)); + EXPECT_TRUE(IsFieldEqual(result.y, 0.5)); + EXPECT_TRUE(IsFieldEqual(result.z, 0.75)); } TEST_F(Vector2DTest, DivideVector2DField3D) { @@ -500,9 +507,9 @@ TEST_F(Vector2DTest, DivideVector2DField3D) { Vector3D result = vector / field; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 3.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 1.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 2.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 3.0)); } TEST_F(Vector2DTest, Cross2D3D) { @@ -518,9 +525,9 @@ TEST_F(Vector2DTest, Cross2D3D) { auto result = cross(vector1, vector2); - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 0.0)); } TEST_F(Vector2DTest, Cross2D2D) { @@ -536,9 +543,9 @@ TEST_F(Vector2DTest, Cross2D2D) { auto result = cross(vector1, vector2); - EXPECT_TRUE(IsField2DEqualBoutReal(result.x, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.y, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(result.z, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 0.0)); } TEST_F(Vector2DTest, Dot2D3DCoCo) { @@ -554,7 +561,7 @@ TEST_F(Vector2DTest, Dot2D3DCoCo) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector2DTest, Dot2D2DCoCo) { @@ -570,7 +577,7 @@ TEST_F(Vector2DTest, Dot2D2DCoCo) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField2DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector2DTest, Dot2D3DCoContra) { @@ -587,7 +594,7 @@ TEST_F(Vector2DTest, Dot2D3DCoContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 28.0)); + EXPECT_TRUE(IsFieldEqual(result, 28.0)); } TEST_F(Vector2DTest, Dot2D2DCoContra) { @@ -604,7 +611,7 @@ TEST_F(Vector2DTest, Dot2D2DCoContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField2DEqualBoutReal(result, 28.0)); + EXPECT_TRUE(IsFieldEqual(result, 28.0)); } TEST_F(Vector2DTest, Dot2D3DContraContra) { @@ -622,7 +629,7 @@ TEST_F(Vector2DTest, Dot2D3DContraContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector2DTest, Dot2D2DContraContra) { @@ -640,7 +647,7 @@ TEST_F(Vector2DTest, Dot2D2DContraContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField2DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector2DTest, AbsCo) { @@ -651,7 +658,7 @@ TEST_F(Vector2DTest, AbsCo) { auto result = abs(vector1); - EXPECT_TRUE(IsField2DEqualBoutReal(result, 24.819347291981714)); + EXPECT_TRUE(IsFieldEqual(result, 24.819347291981714)); } TEST_F(Vector2DTest, AbsContra) { @@ -663,5 +670,5 @@ TEST_F(Vector2DTest, AbsContra) { auto result = abs(vector1); - EXPECT_TRUE(IsField2DEqualBoutReal(result, 24.819347291981714)); + EXPECT_TRUE(IsFieldEqual(result, 24.819347291981714)); } diff --git a/tests/unit/field/test_vector3d.cxx b/tests/unit/field/test_vector3d.cxx index eae149755d..d67fd2f085 100644 --- a/tests/unit/field/test_vector3d.cxx +++ b/tests/unit/field/test_vector3d.cxx @@ -9,7 +9,14 @@ #include "vector3d.hxx" /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; /// Test fixture to make sure the global mesh is our fake one class Vector3DTest : public ::testing::Test { @@ -190,9 +197,9 @@ TEST_F(Vector3DTest, AssignFromBoutReal) { vector = 0.0; - EXPECT_TRUE(IsField3DEqualBoutReal(vector.x, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.y, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.z, 0.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 0.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 0.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 0.0)); } TEST_F(Vector3DTest, AssignFromVector2D) { @@ -208,9 +215,9 @@ TEST_F(Vector3DTest, AssignFromVector2D) { vector2 = vector1; - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.x, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.y, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.z, 3.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, 1.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, 2.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, 3.0)); EXPECT_EQ(vector1.getLocation(), vector2.getLocation()); } @@ -226,9 +233,9 @@ TEST_F(Vector3DTest, AssignFromVector3D) { vector2 = vector1; - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.x, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.y, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.z, 3.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, 1.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, 2.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, 3.0)); EXPECT_EQ(vector1.getLocation(), vector2.getLocation()); } @@ -244,9 +251,9 @@ TEST_F(Vector3DTest, CreateFromVector3D) { Vector3D vector2{vector1}; - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.x, 4.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.y, 5.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.z, 6.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, 4.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, 5.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, 6.0)); EXPECT_EQ(vector1.getLocation(), vector2.getLocation()); } @@ -260,9 +267,9 @@ TEST_F(Vector3DTest, UnaryMinus) { vector2 = -vector1; - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.x, -7.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.y, -8.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.z, -9.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, -7.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, -8.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, -9.0)); } TEST_F(Vector3DTest, AddEqualsVector3D) { @@ -278,9 +285,9 @@ TEST_F(Vector3DTest, AddEqualsVector3D) { vector2 += vector1; - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.x, 11.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.y, 13.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.z, 15.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, 11.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, 13.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, 15.0)); } TEST_F(Vector3DTest, AddVector3DVector2D) { @@ -296,9 +303,9 @@ TEST_F(Vector3DTest, AddVector3DVector2D) { Vector3D result = vector1 + vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 17.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 19.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 21.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 17.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 19.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 21.0)); } TEST_F(Vector3DTest, AddVector3DVector3D) { @@ -314,9 +321,9 @@ TEST_F(Vector3DTest, AddVector3DVector3D) { Vector3D result = vector1 + vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 7.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 9.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 11.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 7.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 9.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 11.0)); } TEST_F(Vector3DTest, MinusEqualsVector3D) { @@ -332,9 +339,9 @@ TEST_F(Vector3DTest, MinusEqualsVector3D) { vector2 -= vector1; - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.x, -97.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.y, -99.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector2.z, -101.0)); + EXPECT_TRUE(IsFieldEqual(vector2.x, -97.0)); + EXPECT_TRUE(IsFieldEqual(vector2.y, -99.0)); + EXPECT_TRUE(IsFieldEqual(vector2.z, -101.0)); } TEST_F(Vector3DTest, MinusVector3DVector2D) { @@ -350,9 +357,9 @@ TEST_F(Vector3DTest, MinusVector3DVector2D) { Vector3D result = vector1 - vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, -3.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, -1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 1.0)); + EXPECT_TRUE(IsFieldEqual(result.x, -3.0)); + EXPECT_TRUE(IsFieldEqual(result.y, -1.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 1.0)); } TEST_F(Vector3DTest, MinusVector3DVector3D) { @@ -368,9 +375,9 @@ TEST_F(Vector3DTest, MinusVector3DVector3D) { Vector3D result = vector1 - vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 7.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 9.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 11.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 7.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 9.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 11.0)); } TEST_F(Vector3DTest, MultiplyEqualsBoutReal) { @@ -383,9 +390,9 @@ TEST_F(Vector3DTest, MultiplyEqualsBoutReal) { vector *= real; - EXPECT_TRUE(IsField3DEqualBoutReal(vector.x, 16.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.y, 20.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.z, 24.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 16.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 20.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 24.0)); } TEST_F(Vector3DTest, MultiplyEqualsField2D) { @@ -398,9 +405,9 @@ TEST_F(Vector3DTest, MultiplyEqualsField2D) { vector *= field; - EXPECT_TRUE(IsField3DEqualBoutReal(vector.x, 160.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.y, 200.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.z, 240.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 160.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 200.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 240.0)); } TEST_F(Vector3DTest, MultiplyVector3DBoutReal) { @@ -413,9 +420,9 @@ TEST_F(Vector3DTest, MultiplyVector3DBoutReal) { Vector3D result = vector * real; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 4.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 6.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 2.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 4.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 6.0)); } TEST_F(Vector3DTest, MultiplyVector3DField2D) { @@ -428,9 +435,9 @@ TEST_F(Vector3DTest, MultiplyVector3DField2D) { Vector3D result = vector * field; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 3.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 6.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 9.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 3.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 6.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 9.0)); } TEST_F(Vector3DTest, MultiplyVector3DField3D) { @@ -443,9 +450,9 @@ TEST_F(Vector3DTest, MultiplyVector3DField3D) { Vector3D result = vector * field; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 4.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 8.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 12.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 4.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 8.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 12.0)); } TEST_F(Vector3DTest, DivideEqualsBoutReal) { @@ -458,9 +465,9 @@ TEST_F(Vector3DTest, DivideEqualsBoutReal) { vector /= real; - EXPECT_TRUE(IsField3DEqualBoutReal(vector.x, 0.1)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.y, 0.2)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.z, 0.3)); + EXPECT_TRUE(IsFieldEqual(vector.x, 0.1)); + EXPECT_TRUE(IsFieldEqual(vector.y, 0.2)); + EXPECT_TRUE(IsFieldEqual(vector.z, 0.3)); } TEST_F(Vector3DTest, DivideEqualsConstField2D) { @@ -473,9 +480,9 @@ TEST_F(Vector3DTest, DivideEqualsConstField2D) { vector /= field; - EXPECT_TRUE(IsField3DEqualBoutReal(vector.x, 0.2)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.y, 0.4)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.z, 0.6)); + EXPECT_TRUE(IsFieldEqual(vector.x, 0.2)); + EXPECT_TRUE(IsFieldEqual(vector.y, 0.4)); + EXPECT_TRUE(IsFieldEqual(vector.z, 0.6)); } TEST_F(Vector3DTest, DivideVector3DBoutReal) { @@ -488,9 +495,9 @@ TEST_F(Vector3DTest, DivideVector3DBoutReal) { Vector3D result = vector / real; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 0.5)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 1.5)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.5)); + EXPECT_TRUE(IsFieldEqual(result.y, 1.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 1.5)); } TEST_F(Vector3DTest, DivideVector3DField2D) { @@ -503,9 +510,9 @@ TEST_F(Vector3DTest, DivideVector3DField2D) { Vector3D result = vector / field; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 0.25)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 0.5)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 0.75)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.25)); + EXPECT_TRUE(IsFieldEqual(result.y, 0.5)); + EXPECT_TRUE(IsFieldEqual(result.z, 0.75)); } TEST_F(Vector3DTest, DivideVector3DField3D) { @@ -518,9 +525,9 @@ TEST_F(Vector3DTest, DivideVector3DField3D) { Vector3D result = vector / field; - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 2.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 3.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 1.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 2.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 3.0)); } TEST_F(Vector3DTest, ToCovariant) { @@ -532,9 +539,9 @@ TEST_F(Vector3DTest, ToCovariant) { vector.toCovariant(); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.x, 48.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.y, 52.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.z, 52.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 48.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 52.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 52.0)); } TEST_F(Vector3DTest, ToContravariant) { @@ -546,9 +553,9 @@ TEST_F(Vector3DTest, ToContravariant) { vector.toContravariant(); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.x, 48.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.y, 52.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(vector.z, 52.0)); + EXPECT_TRUE(IsFieldEqual(vector.x, 48.0)); + EXPECT_TRUE(IsFieldEqual(vector.y, 52.0)); + EXPECT_TRUE(IsFieldEqual(vector.z, 52.0)); } TEST_F(Vector3DTest, Cross3D3D) { @@ -564,9 +571,9 @@ TEST_F(Vector3DTest, Cross3D3D) { auto result = cross(vector1, vector2); - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 0.0)); } TEST_F(Vector3DTest, Cross3D2D) { @@ -582,9 +589,9 @@ TEST_F(Vector3DTest, Cross3D2D) { auto result = cross(vector1, vector2); - EXPECT_TRUE(IsField3DEqualBoutReal(result.x, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.y, 0.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(result.z, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.x, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.y, 0.0)); + EXPECT_TRUE(IsFieldEqual(result.z, 0.0)); } TEST_F(Vector3DTest, Dot3D3DCoContra) { @@ -601,7 +608,7 @@ TEST_F(Vector3DTest, Dot3D3DCoContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 28.0)); + EXPECT_TRUE(IsFieldEqual(result, 28.0)); } TEST_F(Vector3DTest, Dot3D2DCoContra) { @@ -618,7 +625,7 @@ TEST_F(Vector3DTest, Dot3D2DCoContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 28.0)); + EXPECT_TRUE(IsFieldEqual(result, 28.0)); } TEST_F(Vector3DTest, Dot3D3DCoCo) { @@ -634,7 +641,7 @@ TEST_F(Vector3DTest, Dot3D3DCoCo) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector3DTest, Dot3D2DCoCo) { @@ -650,7 +657,7 @@ TEST_F(Vector3DTest, Dot3D2DCoCo) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector3DTest, Dot3D3DContraContra) { @@ -668,7 +675,7 @@ TEST_F(Vector3DTest, Dot3D3DContraContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector3DTest, Dot3D2DContraContra) { @@ -686,7 +693,7 @@ TEST_F(Vector3DTest, Dot3D2DContraContra) { auto result = vector1 * vector2; - EXPECT_TRUE(IsField3DEqualBoutReal(result, 308.0)); + EXPECT_TRUE(IsFieldEqual(result, 308.0)); } TEST_F(Vector3DTest, AbsCo) { @@ -697,7 +704,7 @@ TEST_F(Vector3DTest, AbsCo) { auto result = abs(vector1); - EXPECT_TRUE(IsField3DEqualBoutReal(result, 24.819347291981714)); + EXPECT_TRUE(IsFieldEqual(result, 24.819347291981714)); } TEST_F(Vector3DTest, AbsContra) { @@ -709,5 +716,5 @@ TEST_F(Vector3DTest, AbsContra) { auto result = abs(vector1); - EXPECT_TRUE(IsField3DEqualBoutReal(result, 24.819347291981714)); + EXPECT_TRUE(IsFieldEqual(result, 24.819347291981714)); } diff --git a/tests/unit/include/bout/test_region.cxx b/tests/unit/include/bout/test_region.cxx index a8496e232c..4e7d59be02 100644 --- a/tests/unit/include/bout/test_region.cxx +++ b/tests/unit/include/bout/test_region.cxx @@ -15,7 +15,14 @@ #include /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; /// Test fixture to make sure the global mesh is our fake one using RegionTest = FakeMeshFixture; diff --git a/tests/unit/include/test_derivs.cxx b/tests/unit/include/test_derivs.cxx index dadd9e8910..65f0fc503a 100644 --- a/tests/unit/include/test_derivs.cxx +++ b/tests/unit/include/test_derivs.cxx @@ -13,6 +13,9 @@ #include #include +// The unit tests use the global mesh +using namespace bout::globals; + // Some basic sanity checks for the derivative kernels. Checks the // derivatives of sin(R) where R = {X, Y, Z} for each R // individually. To make this as fast as possible, we use only a @@ -64,7 +67,7 @@ class DerivativesTest // This must be a balance between getting any kind of accuracy and // each derivative running in ~1ms or less - constexpr int grid_size{64}; + constexpr int grid_size{128}; const BoutReal box_length{TWOPI / grid_size}; // Set all the variables for this direction @@ -112,6 +115,9 @@ class DerivativesTest // C++17 makes this nicer with std::invoke input = makeField([&](Index& i) { return std::sin((i.*dir)() * box_length); }, mesh); + // Make the velocity field + velocity = makeField([&](Index& UNUSED(i)) { return 2.0; }, mesh); + // Get the expected result for this order of derivative // Again, could be nicer in C++17 with std::get(GetParam()) switch (std::get<1>(GetParam())) { @@ -129,6 +135,14 @@ class DerivativesTest [&](Index& i) { return std::sin((i.*dir)() * box_length) * pow(box_length, 4); }, mesh); break; + // For now advection derivatives (upwind, flux) can have the same expected + // result as the velocity field is constant + case DERIV::Upwind: + case DERIV::Flux: + expected = makeField( + [&](Index& i) { return 2.0 * std::cos((i.*dir)() * box_length) * box_length; }, + mesh); + break; default: throw BoutException("Sorry, don't we test that type of derivative yet!"); } @@ -141,13 +155,15 @@ class DerivativesTest DerivativeStore::getInstance().initialise(Options::getRoot()); }; - Field3D input; + Field3D input, velocity; Field3D expected; // Region not including the guard cells in current direction REGION region; }; +using DerivativesTestAdvection = DerivativesTest; + // Get all the available methods for this direction and turn it from a // collection of strings to a collection of tuples of the direction, // order, and strings so that the test fixture knows which direction @@ -225,16 +241,63 @@ INSTANTIATE_TEST_CASE_P(FourthZ, DerivativesTest, DIRECTION::Z)), methodDirectionTupleToString); +// Instantiate the test for X, Y, Z for upwind derivatives +INSTANTIATE_TEST_CASE_P(UpwindX, DerivativesTestAdvection, + ::testing::ValuesIn(getMethodsForDirection(DERIV::Upwind, + DIRECTION::X)), + methodDirectionTupleToString); + +INSTANTIATE_TEST_CASE_P(UpwindY, DerivativesTestAdvection, + ::testing::ValuesIn(getMethodsForDirection(DERIV::Upwind, + DIRECTION::Y)), + methodDirectionTupleToString); + +INSTANTIATE_TEST_CASE_P(UpwindZ, DerivativesTestAdvection, + ::testing::ValuesIn(getMethodsForDirection(DERIV::Upwind, + DIRECTION::Z)), + methodDirectionTupleToString); + +// Instantiate the test for X, Y, Z for flux derivatives +INSTANTIATE_TEST_CASE_P(FluxX, DerivativesTestAdvection, + ::testing::ValuesIn(getMethodsForDirection(DERIV::Flux, + DIRECTION::X)), + methodDirectionTupleToString); + +INSTANTIATE_TEST_CASE_P(FluxY, DerivativesTestAdvection, + ::testing::ValuesIn(getMethodsForDirection(DERIV::Flux, + DIRECTION::Y)), + methodDirectionTupleToString); + +INSTANTIATE_TEST_CASE_P(FluxZ, DerivativesTestAdvection, + ::testing::ValuesIn(getMethodsForDirection(DERIV::Flux, + DIRECTION::Z)), + methodDirectionTupleToString); + // All standard derivatives have the same signature, so we can use a // single test, just instantiate it for each direction/order combination TEST_P(DerivativesTest, Sanity) { auto derivative = DerivativeStore::getInstance().getStandardDerivative( - std::get<2>(GetParam()), std::get<0>(GetParam()), STAGGER::None, std::get<1>(GetParam())); + std::get<2>(GetParam()), std::get<0>(GetParam()), STAGGER::None, + std::get<1>(GetParam())); Field3D result{mesh}; result.allocate(); derivative(input, result, region); - EXPECT_TRUE(IsField3DEqualField3D(result, expected, "RGN_NOBNDRY", - derivatives_tolerance)); + EXPECT_TRUE(IsFieldEqual(result, expected, "RGN_NOBNDRY", derivatives_tolerance)); +} + +// All advection (upwind/flux) derivatives have the same signature, so we can use a +// single test, just instantiate it for each direction/order combination +TEST_P(DerivativesTestAdvection, Sanity) { + auto derivative = DerivativeStore::getInstance().getFlowDerivative( + std::get<2>(GetParam()), std::get<0>(GetParam()), STAGGER::None, + std::get<1>(GetParam())); + + Field3D result{mesh}; + result.allocate(); + derivative(velocity, input, result, region); + + EXPECT_TRUE( + IsFieldEqual(result, expected, "RGN_NOBNDRY", derivatives_tolerance)); } diff --git a/tests/unit/mesh/parallel/test_shiftedmetric.cxx b/tests/unit/mesh/parallel/test_shiftedmetric.cxx index cd224592e2..37d13f6179 100644 --- a/tests/unit/mesh/parallel/test_shiftedmetric.cxx +++ b/tests/unit/mesh/parallel/test_shiftedmetric.cxx @@ -4,7 +4,14 @@ #include "test_extras.hxx" #include "bout/paralleltransform.hxx" -extern Mesh* mesh; +// The unit tests use the global mesh +using namespace bout::globals; + +namespace bout{ +namespace globals{ +extern Mesh *mesh; +} // namespace globals +} // namespace bout class ShiftedMetricTest : public ::testing::Test { public: @@ -105,7 +112,7 @@ TEST_F(ShiftedMetricTest, ToFieldAligned) { {4., 5., 1., 2., 3.}, {2., 3., 4., 5., 1.}}}); - EXPECT_TRUE(IsField3DEqualField3D(shifted.toFieldAligned(input), expected, "RGN_ALL", + EXPECT_TRUE(IsFieldEqual(shifted.toFieldAligned(input), expected, "RGN_ALL", FFTTolerance)); } @@ -139,7 +146,7 @@ TEST_F(ShiftedMetricTest, FromFieldAligned) { {5., 1., 2., 3., 4.}}}); // Loosen tolerance a bit due to FFTs - EXPECT_TRUE(IsField3DEqualField3D(shifted.fromFieldAligned(input), expected, "RGN_ALL", + EXPECT_TRUE(IsFieldEqual(shifted.fromFieldAligned(input), expected, "RGN_ALL", FFTTolerance)); } @@ -279,11 +286,11 @@ TEST_F(ShiftedMetricTest, CalcYUpDown) { {0., 0., 0., 0., 0.}}}); EXPECT_TRUE( - IsField3DEqualField3D(input.ynext(1), expected_up_1, "RGN_YUP", FFTTolerance)); + IsFieldEqual(input.ynext(1), expected_up_1, "RGN_YUP", FFTTolerance)); EXPECT_TRUE( - IsField3DEqualField3D(input.ynext(2), expected_up_2, "RGN_YUP2", FFTTolerance)); + IsFieldEqual(input.ynext(2), expected_up_2, "RGN_YUP2", FFTTolerance)); EXPECT_TRUE( - IsField3DEqualField3D(input.ynext(-1), expected_down_1, "RGN_YDOWN", FFTTolerance)); + IsFieldEqual(input.ynext(-1), expected_down_1, "RGN_YDOWN", FFTTolerance)); EXPECT_TRUE( - IsField3DEqualField3D(input.ynext(-2), expected_down2, "RGN_YDOWN2", FFTTolerance)); + IsFieldEqual(input.ynext(-2), expected_down2, "RGN_YDOWN2", FFTTolerance)); } diff --git a/tests/unit/mesh/test_boundary_factory.cxx b/tests/unit/mesh/test_boundary_factory.cxx index c21a37c7a4..15f69686f6 100644 --- a/tests/unit/mesh/test_boundary_factory.cxx +++ b/tests/unit/mesh/test_boundary_factory.cxx @@ -6,7 +6,14 @@ #include "test_extras.hxx" /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; class TestBoundary : public BoundaryOp { public: diff --git a/tests/unit/mesh/test_coordinates.cxx b/tests/unit/mesh/test_coordinates.cxx index 91781334b9..4ce7b04fd5 100644 --- a/tests/unit/mesh/test_coordinates.cxx +++ b/tests/unit/mesh/test_coordinates.cxx @@ -7,7 +7,13 @@ #include "test_extras.hxx" /// Global mesh -extern Mesh *mesh; +namespace bout { +namespace globals { +extern Mesh* mesh; +} +} // namespace bout + +using bout::globals::mesh; using CoordinatesTest = FakeMeshFixture; @@ -30,8 +36,8 @@ TEST_F(CoordinatesTest, Jacobian) { EXPECT_NO_THROW(coords.jacobian()); - EXPECT_TRUE(IsField3DEqualBoutReal(coords.J, 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(coords.Bxy, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.J, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.Bxy, 1.0)); } TEST_F(CoordinatesTest, CalcContravariant) { @@ -45,12 +51,12 @@ TEST_F(CoordinatesTest, CalcContravariant) { coords.calcCovariant(); output_info.enable(); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g_11, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g_22, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g_33, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g_12, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g_13, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g_23, 0.0)); + EXPECT_TRUE(IsFieldEqual(coords.g_11, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.g_22, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.g_33, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.g_12, 0.0)); + EXPECT_TRUE(IsFieldEqual(coords.g_13, 0.0)); + EXPECT_TRUE(IsFieldEqual(coords.g_23, 0.0)); } TEST_F(CoordinatesTest, CalcCovariant) { @@ -64,10 +70,10 @@ TEST_F(CoordinatesTest, CalcCovariant) { coords.calcContravariant(); output_info.enable(); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g11, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g22, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g33, 1.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g12, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g13, 0.0)); - EXPECT_TRUE(IsField2DEqualBoutReal(coords.g23, 0.0)); + EXPECT_TRUE(IsFieldEqual(coords.g11, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.g22, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.g33, 1.0)); + EXPECT_TRUE(IsFieldEqual(coords.g12, 0.0)); + EXPECT_TRUE(IsFieldEqual(coords.g13, 0.0)); + EXPECT_TRUE(IsFieldEqual(coords.g23, 0.0)); } diff --git a/tests/unit/mesh/test_interpolation.cxx b/tests/unit/mesh/test_interpolation.cxx index f48b5c5c52..a4ad6ffe9d 100644 --- a/tests/unit/mesh/test_interpolation.cxx +++ b/tests/unit/mesh/test_interpolation.cxx @@ -19,7 +19,14 @@ /////// /// Global mesh +namespace bout{ +namespace globals{ extern Mesh *mesh; +} // namespace globals +} // namespace bout + +// The unit tests use the global mesh +using namespace bout::globals; /// Test fixture to make sure the global mesh is our fake one class Field3DInterpToTest : public ::testing::Test { diff --git a/tests/unit/mesh/test_paralleltransform.cxx b/tests/unit/mesh/test_paralleltransform.cxx index 6550243b2a..3996db516f 100644 --- a/tests/unit/mesh/test_paralleltransform.cxx +++ b/tests/unit/mesh/test_paralleltransform.cxx @@ -3,7 +3,11 @@ #include "test_extras.hxx" #include "bout/paralleltransform.hxx" +namespace bout { +namespace globals { extern Mesh* mesh; +} +} // namespace bout using ParallelTransformTest = FakeMeshFixture; @@ -15,23 +19,23 @@ TEST_F(ParallelTransformTest, IdentityCalcYUpDown) { transform.calcYUpDown(field); - EXPECT_TRUE(IsField3DEqualBoutReal(field.yup(), 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(field.ydown(), 1.0)); + EXPECT_TRUE(IsFieldEqual(field.yup(), 1.0)); + EXPECT_TRUE(IsFieldEqual(field.ydown(), 1.0)); } TEST_F(ParallelTransformTest, IdentityCalcYUpDownTwoSlices) { ParallelTransformIdentity transform{}; - mesh->ystart = 2; + bout::globals::mesh->ystart = 2; Field3D field{1.0}; transform.calcYUpDown(field); - EXPECT_TRUE(IsField3DEqualBoutReal(field.yup(0), 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(field.yup(1), 1.0)); + EXPECT_TRUE(IsFieldEqual(field.yup(0), 1.0)); + EXPECT_TRUE(IsFieldEqual(field.yup(1), 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(field.ydown(0), 1.0)); - EXPECT_TRUE(IsField3DEqualBoutReal(field.ydown(1), 1.0)); + EXPECT_TRUE(IsFieldEqual(field.ydown(0), 1.0)); + EXPECT_TRUE(IsFieldEqual(field.ydown(1), 1.0)); } diff --git a/tests/unit/test_extras.cxx b/tests/unit/test_extras.cxx index 1766f177b5..8d34359418 100644 --- a/tests/unit/test_extras.cxx +++ b/tests/unit/test_extras.cxx @@ -17,78 +17,6 @@ ::testing::AssertionResult IsSubString(const std::string &str, } } -::testing::AssertionResult IsField3DEqualBoutReal(const Field3D &field, BoutReal number, - BoutReal tolerance) { - const auto ®ion = field.getMesh()->getRegion3D("RGN_ALL"); - BOUT_FOR_SERIAL(i, region) { - if (fabs(field[i] - number) > tolerance) { - return ::testing::AssertionFailure() - << "Field3D(" << i.x() << ", " << i.y() << ", " << i.z() - << ") == " << field[i] << "; Expected: " << number; - } - } - - return ::testing::AssertionSuccess(); -} - -::testing::AssertionResult IsField3DEqualField3D(const Field3D& lhs, const Field3D& rhs, - const std::string& region_name, - BoutReal tolerance) { - const auto& region = lhs.getMesh()->getRegion3D(region_name); - BOUT_FOR_SERIAL(i, region) { - if (std::abs(lhs[i] - rhs[i]) > tolerance) { - return ::testing::AssertionFailure() - << "Field3D(" << i.x() << ", " << i.y() << ", " << i.z() << ") == " << lhs[i] - << "; Expected: " << rhs[i]; - } - } - - return ::testing::AssertionSuccess(); -} - -::testing::AssertionResult IsField2DEqualBoutReal(const Field2D &field, BoutReal number, - BoutReal tolerance) { - const auto ®ion = field.getMesh()->getRegion2D("RGN_ALL"); - BOUT_FOR_SERIAL(i, region) { - if (fabs(field[i] - number) > tolerance) { - return ::testing::AssertionFailure() - << "Field2D(" << i.x() << ", " << i.y() << ") == " << field[i] - << "; Expected: " << number; - } - } - - return ::testing::AssertionSuccess(); -} - -::testing::AssertionResult IsField2DEqualField2D(const Field2D& lhs, const Field2D& rhs, - const std::string& region_name, - BoutReal tolerance) { - const auto& region = lhs.getMesh()->getRegion2D(region_name); - BOUT_FOR_SERIAL(i, region) { - if (std::abs(lhs[i] - rhs[i]) > tolerance) { - return ::testing::AssertionFailure() - << "Field2D(" << i.x() << ", " << i.y() << ") == " << lhs[i] - << "; Expected: " << rhs[i]; - } - } - - return ::testing::AssertionSuccess(); -} - -::testing::AssertionResult IsFieldPerpEqualBoutReal(const FieldPerp &field, - BoutReal number, BoutReal tolerance) { - const auto ®ion = field.getMesh()->getRegionPerp("RGN_ALL"); - BOUT_FOR_SERIAL(i, region) { - if (fabs(field[i] - number) > tolerance) { - return ::testing::AssertionFailure() - << "FieldPerp(" << i.x() << ", " << i.z() << ") == " << field[i] - << "; Expected: " << number; - } - } - - return ::testing::AssertionSuccess(); -} - void fillField(Field3D& f, std::vector>> values) { f.allocate(); Ind3D i{0}; diff --git a/tests/unit/test_extras.hxx b/tests/unit/test_extras.hxx index f83b14f35d..734edd6e10 100644 --- a/tests/unit/test_extras.hxx +++ b/tests/unit/test_extras.hxx @@ -21,26 +21,6 @@ static constexpr BoutReal FFTTolerance{1.e-12}; ::testing::AssertionResult IsSubString(const std::string &str, const std::string &substring); -/// Is \p field equal to \p number, with a tolerance of \p tolerance? -::testing::AssertionResult IsField3DEqualBoutReal(const Field3D &field, BoutReal number, - BoutReal tolerance = BoutRealTolerance); - -::testing::AssertionResult IsField3DEqualField3D(const Field3D &lhs, const Field3D &rhs, - const std::string& region = "RGN_ALL", - BoutReal tolerance = BoutRealTolerance); - -/// Is \p field equal to \p number, with a tolerance of \p tolerance? -::testing::AssertionResult IsField2DEqualBoutReal(const Field2D &field, BoutReal number, - BoutReal tolerance = BoutRealTolerance); - -::testing::AssertionResult IsField2DEqualField2D(const Field2D &lhs, const Field2D &rhs, - const std::string& region = "RGN_ALL", - BoutReal tolerance = BoutRealTolerance); - -/// Is \p field equal to \p number, with a tolerance of \p tolerance? -::testing::AssertionResult IsFieldPerpEqualBoutReal(const FieldPerp &field, BoutReal number, - BoutReal tolerance = BoutRealTolerance); - void fillField(Field3D& f, std::vector>> values); void fillField(Field2D& f, std::vector> values); @@ -51,11 +31,12 @@ using EnableIfField = typename std::enable_if::value>: /// Returns a field filled with the result of \p fill_function at each point /// Arbitrary arguments can be passed to the field constructor template > -T makeField(std::function fill_function, Args... args) { +T makeField(const std::function& fill_function, + Args&&... args) { T result{std::forward(args)...}; result.allocate(); - for (auto i: result) { + for (auto i : result) { result[i] = fill_function(i); } @@ -68,6 +49,66 @@ inline std::ostream& operator<< (std::ostream &out, const SpecificInd &index) return out << index.ind; } +/// Helpers to get the type of a Field as a string +auto inline getFieldType(MAYBE_UNUSED(const Field2D& field)) -> std::string { + return "Field2D"; +} +auto inline getFieldType(MAYBE_UNUSED(const Field3D& field)) -> std::string { + return "Field3D"; +} +auto inline getFieldType(MAYBE_UNUSED(const FieldPerp& field)) -> std::string { + return "FieldPerp"; +} + +/// Helpers to get the (x, y, z) index values, along with the +/// single-index of a Field index +auto inline getIndexXYZ(const Ind2D& index) -> std::string { + std::stringstream ss; + ss << index.x() << ", " << index.y() << "; [" << index.ind << "]"; + return ss.str(); +} +auto inline getIndexXYZ(const Ind3D& index) -> std::string { + std::stringstream ss; + ss << index.x() << ", " << index.y() << ", " << index.z() << "; [" << index.ind << "]"; + return ss.str(); +} +auto inline getIndexXYZ(const IndPerp& index) -> std::string { + std::stringstream ss; + ss << index.x() << ", " << index.y() << ", " << index.z() << "; [" << index.ind << "]"; + return ss.str(); +} + +/// Is \p field equal to \p reference, with a tolerance of \p tolerance? +template , typename = EnableIfField> +auto IsFieldEqual(const T& field, const U& reference, + const std::string& region = "RGN_ALL", + BoutReal tolerance = BoutRealTolerance) -> ::testing::AssertionResult { + for (auto i : field.getRegion(region)) { + if (fabs(field[i] - reference[i]) > tolerance) { + return ::testing::AssertionFailure() + << getFieldType(field) << "(" << getIndexXYZ(i) << ") == " << field[i] + << "; Expected: " << reference[i]; + } + } + return ::testing::AssertionSuccess(); +} + +/// Is \p field equal to \p reference, with a tolerance of \p tolerance? +/// Overload for BoutReals +template > +auto IsFieldEqual(const T& field, BoutReal reference, + const std::string& region = "RGN_ALL", + BoutReal tolerance = BoutRealTolerance) -> ::testing::AssertionResult { + for (auto i : field.getRegion(region)) { + if (fabs(field[i] - reference) > tolerance) { + return ::testing::AssertionFailure() + << getFieldType(field) << "(" << getIndexXYZ(i) << ") == " << field[i] + << "; Expected: " << reference; + } + } + return ::testing::AssertionSuccess(); +} + class Options; /// FakeMesh has just enough information to create fields @@ -208,19 +249,19 @@ class FakeMeshFixture : public ::testing::Test { public: FakeMeshFixture() { // Delete any existing mesh - if (mesh != nullptr) { - delete mesh; - mesh = nullptr; + if (bout::globals::mesh != nullptr) { + delete bout::globals::mesh; + bout::globals::mesh = nullptr; } - mesh = new FakeMesh(nx, ny, nz); + bout::globals::mesh = new FakeMesh(nx, ny, nz); output_info.disable(); - mesh->createDefaultRegions(); + bout::globals::mesh->createDefaultRegions(); output_info.enable(); } ~FakeMeshFixture() { - delete mesh; - mesh = nullptr; + delete bout::globals::mesh; + bout::globals::mesh = nullptr; } static constexpr int nx = 3; diff --git a/tools/pylib/_boutcore_build/helper.cxx.in b/tools/pylib/_boutcore_build/helper.cxx.in index 9e6ffc1076..2007c06e65 100644 --- a/tools/pylib/_boutcore_build/helper.cxx.in +++ b/tools/pylib/_boutcore_build/helper.cxx.in @@ -6,6 +6,7 @@ cat < #include #include +#include #include EOF for ftype in $fields @@ -163,7 +164,7 @@ void c_set_f2d_part_(Field2D * f2d, const double data,int xs,int xe, int dx,int } Mesh * c_get_global_mesh(){ - return mesh; + return bout::globals::mesh; } void c_mesh_normalise(Mesh * msh, double norm){ diff --git a/tools/pylib/_boutcore_build/helper.h.in b/tools/pylib/_boutcore_build/helper.h.in index ec86ee7e82..24c26bdf04 100644 --- a/tools/pylib/_boutcore_build/helper.h.in +++ b/tools/pylib/_boutcore_build/helper.h.in @@ -93,7 +93,7 @@ public: solver->setModel(this); bout_monitor = new BoutMonitor(); solver->addMonitor(bout_monitor, Solver::BACK); - solver->outputVars(dump); + solver->outputVars(bout::globals::dump); }; void free(){ delete solver; @@ -123,7 +123,7 @@ void throw_BoutException(std::string err){ } Datafile * c_get_global_datafile(){ - return &dump; + return &bout::globals::dump; } EOF