@@ -311,7 +311,7 @@ public:
311311 // Constructor
312312 FieldTanhHat (FieldGeneratorPtr xin, FieldGeneratorPtr widthin,
313313 FieldGeneratorPtr centerin, FieldGeneratorPtr steepnessin)
314- : X(xin), width(widthin), center(centerin), steepness(steepnessin){};
314+ : X(xin), width(widthin), center(centerin), steepness(steepnessin) {};
315315 // Clone containing the list of arguments
316316 FieldGeneratorPtr clone (const std::list<FieldGeneratorPtr> args) override ;
317317 BoutReal generate (const bout::generator::Context& pos) override ;
@@ -326,7 +326,7 @@ private:
326326class FieldWhere : public FieldGenerator {
327327public:
328328 FieldWhere (FieldGeneratorPtr test, FieldGeneratorPtr gt0, FieldGeneratorPtr lt0)
329- : test(test), gt0(gt0), lt0(lt0){};
329+ : test(test), gt0(gt0), lt0(lt0) {};
330330
331331 FieldGeneratorPtr clone (const std::list<FieldGeneratorPtr> args) override {
332332 if (args.size () != 3 ) {
@@ -368,23 +368,26 @@ private:
368368
369369 Field3D get () {
370370 if (!var.isAllocated ()) {
371- this ->mesh ->get (this ->var , this ->name );
371+ // Read variable from mesh
372+ if (this ->mesh ->get (this ->var , this ->name ) != 0 ) {
373+ throw BoutException (" Couldn't read GridVariable '{}'" , this ->name );
374+ }
372375 }
373376 return this ->var ;
374377 }
375378
376379 Mesh* mesh;
377380 std::string name;
378- T var {};
381+ T var{};
379382 };
380383
381384 std::shared_ptr<LazyLoaded> variable;
385+
382386public:
383387 GridVariable (Mesh* mesh, std::string name)
384- : variable(std::make_shared<LazyLoaded>(mesh, std::move(name))) {}
388+ : variable(std::make_shared<LazyLoaded>(mesh, std::move(name))) {}
385389
386- GridVariable (std::shared_ptr<LazyLoaded> variable)
387- : variable(std::move(variable)) {}
390+ GridVariable (std::shared_ptr<LazyLoaded> variable) : variable(std::move(variable)) {}
388391
389392 double generate (const bout::generator::Context& ctx) override {
390393 return variable->get ()(ctx.ix (), ctx.jy (), ctx.kz ());
@@ -398,7 +401,6 @@ public:
398401 }
399402
400403 std::string str () const override { return variable->name ; }
401-
402404};
403405
404406#endif // BOUT_FIELDGENERATORS_H
0 commit comments