Skip to content
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ set(HERMES_SOURCES
src/evolve_energy.cxx
src/evolve_pressure.cxx
src/evolve_momentum.cxx
src/external_apar.cxx
src/guarded_options.cxx
src/isothermal.cxx
src/quasineutral.cxx
Expand Down Expand Up @@ -138,6 +139,7 @@ set(HERMES_SOURCES
include/evolve_energy.hxx
include/evolve_momentum.hxx
include/evolve_pressure.hxx
include/external_apar.hxx
include/fixed_density.hxx
include/fixed_fraction_ions.hxx
include/fixed_velocity.hxx
Expand Down
1 change: 1 addition & 0 deletions hermes-3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "include/evolve_energy.hxx"
#include "include/evolve_momentum.hxx"
#include "include/evolve_pressure.hxx"
#include "include/external_apar.hxx"
#include "include/fixed_density.hxx"
#include "include/fixed_fraction_ions.hxx"
#include "include/fixed_fraction_radiation.hxx"
Expand Down
29 changes: 29 additions & 0 deletions include/external_apar.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once
#ifndef EXTERNAL_APAR_H
#define EXTERNAL_APAR_H

#include "component.hxx"

/// Adds an external contribution to the Apar flutter
///
struct ExternalApar : public Component {
ExternalApar(std::string name, Options& alloptions, Solver* UNUSED(solver));

/// Saves the added field to output
void outputVars(Options& state) override;

private:
/// Adds to the Apar_flutter field
///
/// - fields
/// - Apar_flutter
void transform_impl(GuardedOptions& state) override;

Field3D external_apar; ///< The external field
};

namespace {
RegisterComponent<ExternalApar> registercomponentexternalapar("external_apar");
}

#endif // EXTERNAL_APAR_H
2 changes: 1 addition & 1 deletion src/electromagnetic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void Electromagnetic::transform_impl(GuardedOptions& state) {
// Ensure that guard cells are communicated
Apar.getMesh()->communicate(Apar_flutter);

set(state["fields"]["Apar_flutter"], Apar_flutter);
add(state["fields"]["Apar_flutter"], Apar_flutter);

#if 0
// Create a vector A from covariant components
Expand Down
37 changes: 37 additions & 0 deletions src/external_apar.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../include/external_apar.hxx"

#include <bout/constants.hxx>
#include <bout/mesh.hxx>

ExternalApar::ExternalApar(std::string name, Options& alloptions,
Solver* UNUSED(solver))
: Component({readWrite("fields:Apar_flutter")}) {

// Read a 3D field from the input e.g. mesh file
// Store in member variable
bout::globals::mesh->get(external_apar, "external_apar");

// Normalise
const Options& units = alloptions["units"];
const BoutReal rho_s0 = units["meters"];
const BoutReal Bnorm = units["Tesla"];
external_apar /= Bnorm * rho_s0;
}

void ExternalApar::transform_impl(GuardedOptions& state) {
// Add the field member variable to Apar_flutter
add(state["fields"]["Apar_flutter"], external_apar);
}

void ExternalApar::outputVars(Options& state) {
// Normalisations
auto Bnorm = get<BoutReal>(state["Bnorm"]);
auto rho_s0 = get<BoutReal>(state["rho_s0"]);

set_with_attrs(state["external_apar"], external_apar,
{{"units", "Tm"},
{"conversion", Bnorm * rho_s0},
{"standard_name", "External Apar"},
{"long_name", "External Apar"},
{"source", "external_apar"}});
}
Loading