Skip to content

Commit

Permalink
Working
Browse files Browse the repository at this point in the history
Rename flags back as Parthenon doesn't treat Metadata::Conserved
as special so it can mean the fluid version only.

Overhaul B field init to use the same functions for cell- and
face-centered fields, just changing how A->B happens.

Fix for face CT in spherical systems: set \Delta B2 = 0 on the
zero-size faces at poles explicitly.
  • Loading branch information
Ben Prather committed Aug 29, 2023
1 parent e472f63 commit 0a93b0f
Show file tree
Hide file tree
Showing 48 changed files with 1,059 additions and 1,176 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ convergence.txt
core.*
frames_*/
logs/
*.log

# KHARMA/Parthenon outputs
*.phdf
Expand Down
8 changes: 4 additions & 4 deletions kharma/b_cd/b_cd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ std::shared_ptr<KHARMAPackage> Initialize(ParameterInput *pin, std::shared_ptr<P
// B field as usual
// TODO allow for implicit B here
Metadata m = Metadata({Metadata::Real, Metadata::Cell, Metadata::Independent, Metadata::FillGhost,
Metadata::Restart, Metadata::GetUserFlag("GRConserved"), Metadata::Conserved,
Metadata::Restart, Metadata::Conserved, Metadata::Conserved,
Metadata::WithFluxes, Metadata::Vector}, s_vector);
pkg->AddField("cons.B", m);
m = Metadata({Metadata::Real, Metadata::Cell, Metadata::Derived,
Metadata::Restart, Metadata::GetUserFlag("GRPrimitive"), Metadata::Vector}, s_vector);
Metadata::Restart, Metadata::GetUserFlag("Primitive"), Metadata::Vector}, s_vector);
pkg->AddField("prims.B", m);

// Constraint damping scalar field psi. Prim and cons forms correspond to B field forms,
// i.e. differ by a factor of gdet. This is apparently marginally more stable in some
// circumstances.
m = Metadata({Metadata::Real, Metadata::Cell, Metadata::Independent, Metadata::FillGhost,
Metadata::Restart, Metadata::GetUserFlag("GRConserved"), Metadata::Conserved, Metadata::WithFluxes});
Metadata::Restart, Metadata::Conserved, Metadata::Conserved, Metadata::WithFluxes});
pkg->AddField("cons.psi_cd", m);
m = Metadata({Metadata::Real, Metadata::Cell, Metadata::Derived,
Metadata::Restart, Metadata::GetUserFlag("GRPrimitive")});
Metadata::Restart, Metadata::GetUserFlag("Primitive")});
pkg->AddField("prims.psi_cd", m);

// We only update the divB field for output
Expand Down
13 changes: 1 addition & 12 deletions kharma/b_cd/b_cd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using namespace parthenon;
*
* This requires only the values at cell centers, and preserves a cell-centered divergence representation
*
* This implementation includes conversion from "GRPrimitive" to "conserved" B and back,
* This implementation includes conversion from "primitive" to "conserved" B and back,
* i.e. between field strength and flux via multiplying by gdet.
*/
namespace B_CD {
Expand All @@ -56,17 +56,6 @@ namespace B_CD {
*/
std::shared_ptr<KHARMAPackage> Initialize(ParameterInput *pin, std::shared_ptr<Packages_t>& packages);

/**
* Seed an axisymmetric initialization with magnetic field proportional to fluid density,
* or density and radius, to create a SANE or MAD flow
* Note this function expects a normalized P for which rho_max==1
*
* @param rin is the interior radius of the torus
* @param min_rho_q is the minimum density at which there will be magnetic vector potential
* @param b_field_type is one of "sane" "ryan" "r3s3" or "gaussian", described below (TODO test or remove opts)
*/
TaskStatus SeedBField(MeshBlockData<Real> *rc, ParameterInput *pin);

/**
* Get the primitive variables, which in Parthenon's nomenclature are "derived".
* Also applies floors to the calculated primitives, and fixes up any inversion errors.
Expand Down
171 changes: 0 additions & 171 deletions kharma/b_cd/seed_B_cd.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions kharma/b_cleanup/b_cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ std::shared_ptr<KHARMAPackage> B_Cleanup::Initialize(ParameterInput *pin, std::s
MetadataFlag areWeImplicit = (implicit_b) ? Metadata::GetUserFlag("Implicit")
: Metadata::GetUserFlag("Explicit");

// Flags for B fields. "GRPrimitive" form is field, "conserved" is flux
std::vector<MetadataFlag> flags_prim = {Metadata::Real, Metadata::Cell, Metadata::Derived, Metadata::GetUserFlag("GRPrimitive"),
// Flags for B fields. "primitive" form is field, "conserved" is flux
std::vector<MetadataFlag> flags_prim = {Metadata::Real, Metadata::Cell, Metadata::Derived, Metadata::GetUserFlag("Primitive"),
Metadata::Restart, Metadata::GetUserFlag("MHD"), areWeImplicit, Metadata::Vector};
std::vector<MetadataFlag> flags_cons = {Metadata::Real, Metadata::Cell, Metadata::Independent, Metadata::GetUserFlag("GRConserved"), Metadata::Conserved,
std::vector<MetadataFlag> flags_cons = {Metadata::Real, Metadata::Cell, Metadata::Independent, Metadata::Conserved, Metadata::Conserved,
Metadata::WithFluxes, Metadata::FillGhost, Metadata::GetUserFlag("MHD"), areWeImplicit, Metadata::Vector};

auto m = Metadata(flags_prim, s_vector);
Expand Down
Loading

0 comments on commit 0a93b0f

Please sign in to comment.