From 5053c8f753e6cd9d98ea34e4161f82f1716e1b15 Mon Sep 17 00:00:00 2001 From: Ben Dudson Date: Fri, 6 Feb 2026 09:16:44 -0800 Subject: [PATCH] initial_profiles: Use FieldFactory singleton Rather than creating a new FieldFactory, use the singleton object. This allows users to register new generators and use them to intialise variables. --- src/field/initialprofiles.cxx | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/field/initialprofiles.cxx b/src/field/initialprofiles.cxx index 2c34caa6e1..6a437dbe02 100644 --- a/src/field/initialprofiles.cxx +++ b/src/field/initialprofiles.cxx @@ -1,23 +1,10 @@ /************************************************************************** * Sets initial profiles * - * ChangeLog - * ========= - * - * 2011-02-12 Ben Dudson - * * Changed to use new options system. For now the structure of the - * options is the same, but this could be modified more easily in future - * - * 2010-05-12 Ben Dudson - * - * * Changed random numbers to use a hash of the parameters - * so that the phase doesn't vary with number of processors or grid size - * User can vary phase to give a different random sequence - * ************************************************************************** - * Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu + * Copyright 2010 - 2026 BOUT++ contributors * - * Contact: Ben Dudson, bd512@york.ac.uk + * Contact: Ben Dudson, dudson2@llnl.gov * * This file is part of BOUT++. * @@ -49,12 +36,10 @@ void initial_profile(const std::string& name, Field3D& var) { Options* varOpts = Options::getRoot()->getSection(name); - FieldFactory f(localmesh); - std::string function; VAROPTION(varOpts, function, "0.0"); - var = f.create3D(function, varOpts, nullptr, var.getLocation()); + var = FieldFactory::get()->create3D(function, varOpts, localmesh, var.getLocation()); // Optionally scale the variable BoutReal scale; @@ -68,12 +53,10 @@ void initial_profile(const std::string& name, Field2D& var) { Options* varOpts = Options::getRoot()->getSection(name); - FieldFactory f(localmesh); - std::string function; VAROPTION(varOpts, function, "0.0"); - var = f.create2D(function, varOpts, nullptr, var.getLocation()); + var = FieldFactory::get()->create2D(function, varOpts, localmesh, var.getLocation()); // Optionally scale the variable BoutReal scale;