Commit 3760ccd6 authored by Anne Gunn's avatar Anne Gunn
Browse files

Change the build_xxx_splines methods to accept a const reference parameter

to the data vector rather than a vector parameter. Vectors are, as all
types are, passed by value in C++. Using a vector directly as a parameter
causes the data to be copied. Using a reference to the vector neatly
avoids that problem.

Also tucked fmt/format.h into its rightful place in the include list
since Axel says there's no absolute rule about it being an exception.
parent b241294e
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "domain.h"
#include "error.h"
#include "fix_deform.h"
#include "fmt/format.h"
#include "force.h"
#include "group.h"
#include "irregular.h"
@@ -38,8 +39,6 @@
#include "neighbor.h"
#include "respa.h"
#include "update.h"
#include "fmt/format.h"


using namespace LAMMPS_NS;
using namespace FixConst;
@@ -778,7 +777,7 @@ int FixBocs::read_F_table( char *filename, int p_basis_type )
  return numEntries;
}

int FixBocs::build_linear_splines( std::vector<std::vector<double>> data ) {
int FixBocs::build_linear_splines(std::vector<std::vector<double>> const &data) {
  std::string message;
  //message = fmt::format("INFO: entering build_linear_splines, spline_length = {}", spline_length);
  //error->message(FLERR, message.c_str());
@@ -799,7 +798,7 @@ int FixBocs::build_linear_splines( std::vector<std::vector<double>> data ) {
  return spline_length;
}

int FixBocs::build_cubic_splines(std::vector<std::vector<double>> data )
int FixBocs::build_cubic_splines(std::vector<std::vector<double>> const &data )
{
  std::string message;
  //message = fmt::format("INFO: entering build_cubic_splines, spline_length = {}", spline_length);
+2 −2
Original line number Diff line number Diff line
@@ -151,8 +151,8 @@ class FixBocs : public Fix {
  void nhc_press_integrate();

  int read_F_table(char *, int);
  int build_linear_splines(std::vector<std::vector<double>>);
  int build_cubic_splines(std::vector<std::vector<double>>);
  int build_linear_splines(std::vector<std::vector<double>> const &);
  int build_cubic_splines(std::vector<std::vector<double>> const &);

  virtual void nve_x();            // may be overwritten by child classes
  virtual void nve_v();