Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that FlatDisk has a background if M0_BACK is selected in PolarBasis #109

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
25 changes: 25 additions & 0 deletions expui/FieldGenerator.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <filesystem>
#include <algorithm>
#include <iomanip>
#include <sstream>
Expand Down Expand Up @@ -259,6 +260,14 @@ namespace Field
const std::string prefix,
const std::string outdir)
{
if (myid==0) {
// Verify existence of directory
bool filepathExists = std::filesystem::is_directory(outdir);
if (not filepathExists)
throw std::runtime_error("FieldGenerator::file_lines: directory <" +
outdir + "> does not exist");
}

auto db = lines(basis, coefs, beg, end, num);

if (myid==0) {
Expand Down Expand Up @@ -505,6 +514,14 @@ namespace Field
const std::string prefix,
const std::string outdir)
{
if (myid==0) {
// Verify existence of directory
bool filepathExists = std::filesystem::is_directory(outdir);
if (not filepathExists)
throw std::runtime_error("FieldGenerator::file_slices: directory <" +
outdir + "> does not exist");
}

auto db = slices(basis, coefs);

if (myid==0) {
Expand Down Expand Up @@ -710,6 +727,14 @@ namespace Field
const std::string prefix,
const std::string outdir)
{
if (myid==0) {
// Verify existence of directory
bool filepathExists = std::filesystem::is_directory(outdir);
if (not filepathExists)
throw std::runtime_error("FieldGenerator::file_volumes: directory <" +
outdir + "> does not exist");
}

auto db = volumes(basis, coefs);

int bunch = db.size()/numprocs;
Expand Down
4 changes: 2 additions & 2 deletions exputil/VtkGrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ void VtkGrid::Add(const std::vector<double>& data, const std::string& name)
//
int I = 0;

for (int i=0; i<nx; i++) {
for (int k=0; k<nz; k++) {
for (int j=0; j<ny; j++) {
for (int k=0; k<nz; k++) {
for (int i=0; i<nx; i++) {
dataSet[newName][I++] = static_cast<float>(data[(k*ny + j)*nx + i]);
}
}
Expand Down
3 changes: 0 additions & 3 deletions pyEXP/FieldWrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,7 @@ void FieldGeneratorClasses(py::module &m) {

See also
--------
<<<<<<< HEAD
=======
points : generate fields at an array of mesh points
>>>>>>> pointMesh
slices : generate fields in a surface slice given by the
initializtion grid
volumes : generate fields in volume given by the initializtion grid
Expand Down
15 changes: 12 additions & 3 deletions src/FlatDisk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void FlatDisk::initialize()
if (dump_basis) ortho->dump_basis(runtag);

// Set background model
if (conf["background"]) setBackground();
if (M0_back) setBackground();
}

FlatDisk::~FlatDisk(void)
Expand All @@ -121,8 +121,17 @@ FlatDisk::~FlatDisk(void)
void FlatDisk::setBackground()
{
try {

YAML::Node Params = conf["background"];
YAML::Node Params;

if (conf["background"]) Params = conf["background"];
else {
Params = conf["diskconf"];
if (myid==0) // Log file message
std::cout << "---- FlatDisk::setBackground: "
<< "M0_BACK set without a 'background' profile" << std::endl
<< "---- FlatDisk::setBackground: "
<< "using 'diskconf' for 'background' profile" << std::endl;
}

std::string name = Params["name"].as<std::string>();
auto params = Params["parameters"];
Expand Down