Skip to content

Commit

Permalink
More updates for SlabSL
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Mar 28, 2024
1 parent 7d43090 commit 6369058
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 39 deletions.
5 changes: 4 additions & 1 deletion expui/BasisFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ namespace BasisClasses
else if ( !name.compare("flatdisk") ) {
basis = std::make_shared<FlatDisk>(conf);
}
else if ( !name.compare("slabSL") ) {
basis = std::make_shared<Slab>(conf);
}
else if ( !name.compare("cube") ) {
basis = std::make_shared<Cube>(conf);
}
Expand All @@ -193,7 +196,7 @@ namespace BasisClasses
else {
std::string msg("I don't know about the basis named: ");
msg += name;
msg += ". Known types are currently 'sphereSL', 'cylinder' and 'flatdisk'";
msg += ". Known types are currently 'sphereSL', 'cylinder', 'flatdisk', 'slabSL', 'field', and 'velocity'";
throw std::runtime_error(msg);
}
}
Expand Down
5 changes: 4 additions & 1 deletion expui/BiorthBasis.H
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,10 @@ namespace BasisClasses
int knots;

//! SLGridSlab mesh size
int NGRID = 100;
int ngrid = 1000;

//! Target model type for SLGridSlab
std::string type = "isothermal";

//! Scale height for slab
double hslab;
Expand Down
48 changes: 39 additions & 9 deletions expui/BiorthBasis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ namespace BasisClasses
int ldim = (lmax+1)*(lmax+2)/2;

// Allocate the coefficient storage
cf->store.resize((lmax+1)*(lmax+2)/2, nmax);
cf->store.resize((lmax+1)*(lmax+2)/2*nmax);

// Make the coefficient map
cf->coefs = std::make_shared<CoefClasses::SphStruct::coefType>
Expand Down Expand Up @@ -1906,6 +1906,8 @@ namespace BasisClasses
"nminy",
"hslab",
"zmax",
"ngrid",
"type",
"knots",
"verbose",
"check",
Expand All @@ -1924,8 +1926,8 @@ namespace BasisClasses

void Slab::initialize()
{
nminx = std::numeric_limits<int>::max();
nminy = std::numeric_limits<int>::max();
nminx = 0;
nminy = 0;

nmaxx = 6;
nmaxy = 6;
Expand Down Expand Up @@ -1959,7 +1961,9 @@ namespace BasisClasses
if (conf["nmaxz"]) nmaxz = conf["nmaxz"].as<int>();

if (conf["hslab"]) hslab = conf["hslab"].as<double>();
if (conf["zmax "]) zmax = conf["zmax" ].as<double>();
if (conf["zmax" ]) zmax = conf["zmax" ].as<double>();
if (conf["ngrid"]) ngrid = conf["ngrid"].as<int>();
if (conf["type" ]) type = conf["type" ].as<std::string>();

if (conf["knots"]) knots = conf["knots"].as<int>();

Expand All @@ -1978,14 +1982,14 @@ namespace BasisClasses

// Finally, make the basis
//
SLGridSlab::mpi = 1;
SLGridSlab::mpi = 0;
SLGridSlab::ZBEG = 0.0;
SLGridSlab::ZEND = 0.1;
SLGridSlab::H = hslab;

int nnmax = (nmaxx > nmaxy) ? nmaxx : nmaxy;

ortho = std::make_shared<SLGridSlab>(nnmax, nmaxz, NGRID, zmax);
ortho = std::make_shared<SLGridSlab>(nnmax, nmaxz, ngrid, zmax, type);

// Orthogonality sanity check
//
Expand Down Expand Up @@ -2043,12 +2047,12 @@ namespace BasisClasses
{
auto cc = dynamic_cast<CoefClasses::SlabStruct*>(coef.get());
auto d = cc->coefs->dimensions();
if (d[0] != 2*nmaxx+1 or d[1] != 2*nmaxy+1 or d[2] != 2*nmaxz+1) {
if (d[0] != 2*nmaxx+1 or d[1] != 2*nmaxy+1 or d[2] != nmaxz) {
std::ostringstream sout;
sout << "Slab::set_coefs: the basis has (2*nmaxx+1, 2*nmaxy+1, 2*nmaxz+1)=("
sout << "Slab::set_coefs: the basis has (2*nmaxx+1, 2*nmaxy+1, nmaxz)=("
<< 2*nmaxx+1 << ", "
<< 2*nmaxy+1 << ", "
<< 2*nmaxz+1
<< nmaxz
<< "). The coef structure has dimension=("
<< d[0] << ", " << d[1] << ", " << d[2] << ")";

Expand Down Expand Up @@ -2723,6 +2727,32 @@ namespace BasisClasses
throw std::runtime_error(msg);
}

// Assume position arrays in rows by default
//
int rows = p.rows();
int cols = p.cols();

bool ambiguous = false;

if (cols==3 or cols==6) {
if (rows>cols or rows != 6 or rows != 3) PosVelRows = false;
else ambiguous = true;
}

if (rows==3 or rows==6) {
if (cols>rows or cols != 6 or cols != 3) PosVelRows = true;
else ambiguous = true;
}

if (ambiguous and myid==0) {
std::cout << "---- BiorthBasis::addFromArray: dimension deduction "
<< "is ambiguous. Assuming that ";
if (PosVelRows) std::cout << "positions are in rows" << std::endl;
else std::cout << "positions are in columns" << std::endl;
std::cout << "---- BiorthBasis::addFromArray: reset 'posvelrows' flag "
<< "if this assumption is wrong." << std::endl;
}

std::vector<double> p1(3), v1(3, 0);

if (PosVelRows) {
Expand Down
3 changes: 2 additions & 1 deletion expui/CoefStruct.H
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ namespace CoefClasses
nx = 2*nmaxx + 1;
ny = 2*nmaxy + 1;
nz = nmaxz;
store.resize(nx*ny*nz);
dim = nx * ny * nz;
store.resize(dim);
coefs = std::make_shared<coefType>(store.data(), nx, ny, nz);
}

Expand Down
4 changes: 3 additions & 1 deletion expui/Coefficients.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ namespace CoefClasses
Eigen::VectorXcd in;
stanza.getDataSet("coefficients").read(in);

Eigen::TensorMap<Eigen3d> dat(in.data(), 2*NmaxX+1, 2*NmaxY+1, 2*NmaxZ+1);
Eigen::TensorMap<Eigen3d> dat(in.data(), 2*NmaxX+1, 2*NmaxY+1, NmaxZ);

// Pack the data into the coefficient variable
//
Expand Down Expand Up @@ -2094,6 +2094,8 @@ namespace CoefClasses
coefs = std::make_shared<SphCoefs>(h5file, stride, tmin, tmax);
} else if (geometry.compare("cylinder")==0) {
coefs = std::make_shared<CylCoefs>(h5file, stride, tmin, tmax);
} else if (geometry.compare("slab")==0) {
coefs = std::make_shared<SlabCoefs>(h5file, stride, tmin, tmax);
} else if (geometry.compare("cube")==0) {
coefs = std::make_shared<CubeCoefs>(h5file, stride, tmin, tmax);
} else if (geometry.compare("table")==0) {
Expand Down
Loading

0 comments on commit 6369058

Please sign in to comment.