Skip to content
Merged
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
99 changes: 58 additions & 41 deletions src/mesh/boundary_factory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <bout/options.hxx>
#include <bout/utils.hxx>

#include <array>
#include <list>
#include <map>
#include <string>
Expand Down Expand Up @@ -228,91 +229,107 @@ BoundaryOpBase* BoundaryFactory::createFromOptions(const string& varname,

string prefix("bndry_");

string side;
std::array<string, 5> sides;
Comment thread
ZedThree marked this conversation as resolved.
Comment thread
dschwoerer marked this conversation as resolved.
Comment thread
dschwoerer marked this conversation as resolved.
sides[0] = region->label;
switch (region->location) {
case BNDRY_XIN: {
side = "xin";
sides[1] = "xin";
break;
}
case BNDRY_XOUT: {
side = "xout";
sides[1] = "xout";
break;
}
case BNDRY_YDOWN: {
side = "ydown";
sides[1] = "ydown";
break;
}
case BNDRY_YUP: {
side = "yup";
sides[1] = "yup";
break;
}
case BNDRY_PAR_FWD_XIN: {
side = "par_yup_xin";
sides[1] = "par_yup_xin";
break;
}
case BNDRY_PAR_FWD_XOUT: {
side = "par_yup_xout";
sides[1] = "par_yup_xout";
break;
}
case BNDRY_PAR_BKWD_XIN: {
side = "par_ydown_xin";
sides[1] = "par_ydown_xin";
break;
}
case BNDRY_PAR_BKWD_XOUT: {
side = "par_ydown_xout";
sides[1] = "par_ydown_xout";
break;
}
default: {
side = "all";
sides[1] = "all";
break;
}
}

switch (region->location) {
case BNDRY_PAR_FWD_XIN:
case BNDRY_PAR_BKWD_XIN: {
sides[2] = "par_xin";
break;
}
case BNDRY_PAR_BKWD_XOUT:
case BNDRY_PAR_FWD_XOUT: {
sides[2] = "par_xout";
break;
}
default: {
sides[2] = "all";
break;
}
}
switch (region->location) {
case BNDRY_PAR_FWD_XIN:
case BNDRY_PAR_FWD_XOUT: {
sides[3] = "par_yup";
break;
}
case BNDRY_PAR_BKWD_XIN:
case BNDRY_PAR_BKWD_XOUT: {
sides[3] = "par_ydown";
break;
}
default: {
sides[3] = "all";
break;
}
}

sides[4] = region->isParallel ? "par_all" : "all";

// Get options
Options* options = Options::getRoot();

// Get variable options
Options* varOpts = options->getSection(varname);
string set;

/// First try looking for (var, region)
if (varOpts->isSet(prefix + region->label)) {
varOpts->get(prefix + region->label, set, "");
return create(set, region);
}

/// Then (var, side)
if (varOpts->isSet(prefix + side)) {
varOpts->get(prefix + side, set, "");
return create(set, region);
}

/// Then (var, all)
if (region->isParallel) {
if (varOpts->isSet(prefix + "par_all")) {
varOpts->get(prefix + "par_all", set, "");
return create(set, region);
}
} else {
if (varOpts->isSet(prefix + "all")) {
varOpts->get(prefix + "all", set, "");
/// First try looking for (var, ...)
for (const auto& side : sides) {
if (varOpts->isSet(prefix + side)) {
varOpts->get(prefix + side, set, "");
return create(set, region);
}
}

// Get the "all" options
varOpts = options->getSection("all");

/// Then (all, region)
if (varOpts->isSet(prefix + region->label)) {
varOpts->get(prefix + region->label, set, "");
return create(set, region);
}

/// Then (all, side)
if (varOpts->isSet(prefix + side)) {
varOpts->get(prefix + side, set, "");
return create(set, region);
/// First try looking for (all, ...)
for (const auto& side : sides) {
if (varOpts->isSet(prefix + side)) {
varOpts->get(prefix + side, set,
region->isParallel ? "parallel_dirichlet_o2" : "dirichlet");
return create(set, region);
}
}

/// Then (all, all)
Expand Down
Loading