Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/bout/field_factory.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class FieldFactory;
#ifndef BOUT_FIELD_FACTORY_H
#define BOUT_FIELD_FACTORY_H

#include "bout/mesh.hxx"

#include "bout/sys/expressionparser.hxx"

#include "bout/field2d.hxx"
Expand All @@ -43,8 +41,9 @@ class FieldFactory;
#include <map>
#include <string>

// Utility routines to create generators from values
class Mesh;

// Utility routines to create generators from values
FieldGeneratorPtr generator(BoutReal value);
FieldGeneratorPtr generator(BoutReal* ptr);

Expand Down Expand Up @@ -95,6 +94,8 @@ public:

/// Get the Singleton object
static FieldFactory* get();
/// Set the Mesh on the singleton
static FieldFactory* setMesh(Mesh* mesh);

/// clean the cache of parsed strings
void cleanCache();
Expand Down
7 changes: 0 additions & 7 deletions include/bout/mesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ public:
/// @param[in] opt Input options. Default is "mesh" section
static Mesh* create(Options* opt = nullptr);

/// Loads the mesh values
///
/// Currently need to create and load mesh in separate calls
/// because creating Fields uses the global "mesh" pointer
/// which isn't created until Mesh is constructed
virtual int load() { return 1; }

/// Add output variables to \p output_options
/// These are used for post-processing
virtual void outputVars([[maybe_unused]] Options& output_options) {}
Expand Down
8 changes: 3 additions & 5 deletions manual/sphinx/developer_docs/mesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ Loading a mesh
The `Mesh constructor <Mesh::Mesh>` takes `GridDataSource` and
`Options` objects. You can also call `Mesh::create` with just one of
these objects, which will call out to the `MeshFactory` singleton to
create a mesh "automatically". This is the way that it is done in
:doc:`bout++.cxx <../_breathe_autogen/file/bout_09_09_8cxx>`. Once you
have instantiated a `Mesh` object, you can then call `Mesh::load` to
read in all the appropriate variables from the `GridDataSource`::
create a mesh, reading in all the appropriate variables from the
`GridDataSource` and/or `Options`. This is the way that it is done in
:doc:`bout++.cxx <../_breathe_autogen/file/bout_09_09_8cxx>`::

mesh = Mesh::create(); ///< Create the mesh
mesh->load(); ///< Load from sources. Required for Field initialisation

For post-processing of the results, it’s useful to have mesh
quantities in the dump files along with the results. To do this,
Expand Down
3 changes: 0 additions & 3 deletions src/bout++.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ int BoutInitialise(int& argc, char**& argv) {

// Create the mesh
bout::globals::mesh = Mesh::create();
// Load from sources. Required for Field initialisation
bout::globals::mesh->load();

// time_report options are used in BoutFinalise, i.e. after we
// check for unused options
Expand Down Expand Up @@ -312,7 +310,6 @@ template <class Factory>
// We might need a global mesh for some types, so best make one
bout::globals::mpi = new MpiWrapper();
bout::globals::mesh = Mesh::create();
bout::globals::mesh->load();

// An empty Options that we'll later check for used values
Options help_options;
Expand Down
5 changes: 5 additions & 0 deletions src/field/field_factory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,9 @@ FieldFactory* FieldFactory::get() {
return &instance;
}

FieldFactory* FieldFactory::setMesh(Mesh* mesh) {
get()->fieldmesh = mesh;
return get();
}

void FieldFactory::cleanCache() { cache.clear(); }
Loading
Loading