1010
1111#include < ParticleReader.H>
1212#include < Coefficients.H>
13+ #include < BiorthBess.H>
1314#include < BasisFactory.H>
1415#include < BiorthCube.H>
1516#include < SLGridMP2.H>
@@ -60,7 +61,6 @@ namespace BasisClasses
6061 virtual std::vector<double >
6162 sph_eval (double r, double costh, double phi) = 0 ;
6263
63-
6464 // ! Evaluate fields in cylindrical coordinates in centered coordinate system
6565 virtual std::vector<double >
6666 cyl_eval (double r, double costh, double phi) = 0 ;
@@ -164,56 +164,24 @@ namespace BasisClasses
164164 };
165165
166166 /* *
167- Uses SLGridSph basis to evaluate expansion coeffients and provide
168- potential and density basis fields
167+ An abstract spherical basis to evaluate expansion coeffients and
168+ provide potential and density basis fields
169169 */
170- class SphericalSL : public BiorthBasis
170+ class Spherical : public BiorthBasis
171171 {
172172
173173 public:
174174
175175 using BasisMap = std::map<std::string, Eigen::VectorXd>;
176176 using BasisArray = std::vector<std::vector<BasisMap>>;
177177
178- private :
178+ protected :
179179
180180 // ! Helper for constructor
181181 void initialize ();
182182
183- std::shared_ptr<SLGridSph> sl;
184- std::shared_ptr<SphericalModelTable> mod;
185-
186- std::string model_file;
187- int lmax, nmax, cmap, numr;
188- double rmin, rmax, rmap;
189-
190- bool NO_L0, NO_L1, EVEN_L, EVEN_M, M0_only;
191-
192- std::vector<Eigen::MatrixXd> potd, dpot, dpt2, dend;
193- std::vector<Eigen::MatrixXd> legs, dlegs, d2legs;
194-
195- Eigen::MatrixXd factorial;
196- Eigen::MatrixXd expcoef;
197- double scale;
198- int N1, N2;
199- int used;
200-
201- using matT = std::vector<Eigen::MatrixXd>;
202- using vecT = std::vector<Eigen::VectorXd>;
203-
204- double totalMass;
205- int npart;
206-
207- Eigen::VectorXd work;
208-
209- // ! For coefficient writing
210- typedef Eigen::Matrix<double , Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>
211- EigenColMajor;
212-
213- protected:
214-
215- // ! Load coefficients into the new CoefStruct
216- virtual void load_coefs (CoefClasses::CoefStrPtr coefs, double time);
183+ // ! Load coefficients for a particular time
184+ virtual void load_coefs (CoefClasses::CoefStrPtr coef, double time);
217185
218186 // ! Set coefficients
219187 virtual void set_coefs (CoefClasses::CoefStrPtr coefs);
@@ -222,7 +190,7 @@ namespace BasisClasses
222190 static const std::set<std::string> valid_keys;
223191
224192 // ! Return readable class name
225- virtual const std::string classname () { return " SphericalSL " ;}
193+ virtual const std::string classname () { return " Spherical " ;}
226194
227195 // ! Subspace index
228196 virtual const std::string harmonic () { return " l" ;}
@@ -239,16 +207,60 @@ namespace BasisClasses
239207 virtual std::vector<double >
240208 cyl_eval (double R, double z, double phi);
241209
210+ // @{
211+ // ! Required basis members
212+
213+ // ! Get potential
214+ virtual void get_pot (Eigen::MatrixXd& tab, double x) = 0;
215+
216+ // ! Get density
217+ virtual void get_dens (Eigen::MatrixXd& tab, double x) = 0;
218+
219+ // ! Get force
220+ virtual void get_force (Eigen::MatrixXd& tab, double x) = 0;
221+
222+ // @}
223+
224+ // @{
225+ // ! Internal parameters and storage
226+ int lmax, nmax, cmap, numr;
227+ double rmin, rmax, rmap;
228+
229+ bool NO_L0, NO_L1, EVEN_L, EVEN_M, M0_only;
230+
231+ std::vector<Eigen::MatrixXd> potd, dpot, dpt2, dend;
232+ std::vector<Eigen::MatrixXd> legs, dlegs, d2legs;
233+
234+ Eigen::MatrixXd factorial;
235+ Eigen::MatrixXd expcoef;
236+ double scale;
237+ int N1, N2;
238+ int used;
239+
240+ using matT = std::vector<Eigen::MatrixXd>;
241+ using vecT = std::vector<Eigen::VectorXd>;
242+
243+ double totalMass;
244+ int npart;
245+
246+ Eigen::VectorXd work;
247+
248+ // ! For coefficient writing
249+ typedef Eigen::Matrix<double , Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>
250+ EigenColMajor;
251+
252+ // @}
253+
242254 public:
243255
244256 // ! Constructor from YAML node
245- SphericalSL (const YAML::Node& conf);
257+ Spherical (const YAML::Node& conf, const std::string& forceID );
246258
247259 // ! Constructor from YAML string
248- SphericalSL (const std::string& confstr);
260+ Spherical (const std::string& confstr, const std::string& forceID );
249261
250262 // ! Destructor
251- virtual ~SphericalSL (void ) {}
263+ virtual ~Spherical (void ) {}
252264
253265 // ! Print and return the cache parameters
254266 static std::map<std::string, std::string>
@@ -276,29 +288,134 @@ namespace BasisClasses
276288 int getNmax () { return nmax; }
277289
278290 // ! Return potential-density pair of a vector of a vector of 1d
279- // ! basis-function grids for SphericalSL, logarithmically spaced
280- // ! between [logxmin, logxmax] (base 10).
281- BasisArray getBasis
282- (double logxmin=-3.0 , double logxmax=0.5 , int numgrid=2000 );
291+ // ! basis-function grids for Spherical [rmin, rmax]
292+ virtual BasisArray getBasis
293+ (double rmin=0.0 , double rax=1.0 , int numgrid=2000 );
283294
284295 // ! Compute the orthogonality of the basis by returning inner
285296 // ! produce matrices
286- std::vector<Eigen::MatrixXd> orthoCheck (int knots=40 )
287- {
288- return sl->orthoCheck (knots);
289- }
297+ virtual std::vector<Eigen::MatrixXd> orthoCheck (int knots) = 0;
290298
291299 // ! Biorthogonality sanity check
292300 bool orthoTest (int knots=100 )
293301 {
294- auto [ret, worst, lworst] = orthoCompute (sl-> orthoCheck (knots));
302+ auto [ret, worst, lworst] = orthoCompute (orthoCheck (knots));
295303 // For the CTest log
296- std::cout << " SphericalSL ::orthoTest: worst=" << worst << std::endl;
304+ std::cout << " Spherical ::orthoTest: worst=" << worst << std::endl;
297305 return ret;
298306 }
299307
300308 };
309+
310+ /* *
311+ Uses SLGridSph basis to evaluate expansion coeffients and provide
312+ potential and density basis fields
313+ */
314+ class SphericalSL : public Spherical
315+ {
316+
317+ protected:
318+
319+ // ! Helper for constructor
320+ void initialize ();
321+
322+ static const std::set<std::string> valid_keys;
323+
324+ std::shared_ptr<SLGridSph> sl;
325+ std::shared_ptr<SphericalModelTable> mod;
326+
327+ std::string model_file;
328+
329+ // ! Return readable class name
330+ const std::string classname () { return " SphericalSL" ;}
331+
332+ // Get potential
333+ void get_pot (Eigen::MatrixXd& tab, double r)
334+ { sl->get_pot (tab, r); }
335+
336+ // Get density
337+ void get_dens (Eigen::MatrixXd& tab, double r)
338+ { sl->get_dens (tab, r); }
339+
340+ // Get force
341+ void get_force (Eigen::MatrixXd& tab, double r)
342+ { sl->get_force (tab, r); }
343+
344+ public:
345+
346+ // ! Constructor from YAML node
347+ SphericalSL (const YAML::Node& conf);
348+
349+ // ! Constructor from YAML string
350+ SphericalSL (const std::string& confstr);
351+
352+ // ! Destructor
353+ virtual ~SphericalSL (void ) {}
354+
355+ // ! Return potential-density pair of a vector of a vector of 1d
356+ // ! basis-function grids for SphericalSL, logarithmically spaced
357+ // ! between [logxmin, logxmax] (base 10).
358+ BasisArray getBasis (double logxmin=-3.0 , double logxmax=0.5 , int numgrid=2000 );
359+
360+ // ! Compute the orthogonality of the basis by returning inner
361+ // ! produce matrices
362+ std::vector<Eigen::MatrixXd> orthoCheck (int knots=40 )
363+ { return sl->orthoCheck (knots); }
364+ };
365+
366+ /* *
367+ Uses Bessel basis to evaluate expansion coeffients and provide
368+ potential and density basis fields
369+ */
370+ class Bessel : public Spherical
371+ {
372+
373+ protected:
374+
375+ // ! Helper for constructor
376+ void initialize ();
377+
378+ static const std::set<std::string> valid_keys;
379+
380+ // ! Return readable class name
381+ const std::string classname () { return " Bessel" ;}
382+
383+ // ! Grid size for Bessel function table
384+ int rnum = 2000 ;
385+
386+ // ! Biorthgonal Bessel function generator
387+ std::shared_ptr<BiorthBess> bess;
388+
389+ // Get potential
390+ void get_pot (Eigen::MatrixXd& tab, double r)
391+ { bess->get_potl (r, tab); }
392+
393+ // Get density
394+ void get_dens (Eigen::MatrixXd& tab, double r)
395+ { bess->get_dens (r, tab); }
396+
397+ // Get force
398+ void get_force (Eigen::MatrixXd& tab, double r)
399+ { bess->get_dpotl (r, tab); }
400+
401+ public:
402+
403+ // ! Constructor from YAML node
404+ Bessel (const YAML::Node& conf);
405+
406+ // ! Constructor from YAML string
407+ Bessel (const std::string& confstr);
408+
409+ // ! Destructor
410+ virtual ~Bessel (void ) {}
411+
412+ // ! Compute the orthogonality of the basis by returning inner
413+ // ! produce matrices
414+ std::vector<Eigen::MatrixXd> orthoCheck (int knots=40 )
415+ { return bess->orthoCheck (knots); }
416+ };
301417
418+
302419 /* *
303420 Uses the BiorthCyl basis to evaluate expansion coeffients and
304421 provide potential and density basis fields
@@ -408,8 +525,7 @@ namespace BasisClasses
408525 // ! Return a vector of a vector of 1d basis-function grids for
409526 // ! FlatDisk, logarithmically spaced between [logxmin, logxmax]
410527 // ! (base 10).
411- BasisArray getBasis
412- (double logxmin=-3.0 , double logxmax=0.5 , int numgrid=2000 );
528+ BasisArray getBasis (double logxmin=-3.0 , double logxmax=0.5 , int numgrid=2000 );
413529
414530 // ! Compute the orthogonality of the basis by returning inner
415531 // ! produce matrices
0 commit comments