1 #ifndef QweakSimFieldMap_h
2 #define QweakSimFieldMap_h
50 template <
class value_t =
float,
unsigned int value_n = 1>
62 const std::vector<coord_t>& max,
63 const std::vector<coord_t>& step) {
122 mycerr <<
"QweakSimFieldMap::SetDimensions: "
123 <<
"Dimensions of the grid should be strictly positive!" <<
myendl;
133 std::vector<coord_t>(
fNDim,max),
134 std::vector<coord_t>(
fNDim,step));
138 const std::vector<coord_t>& max,
139 const std::vector<coord_t>& step) {
143 if (min.size() !=
fNDim || min.size() !=
fNDim || step.size() !=
fNDim)
return;
146 for (
size_t i = 0; i <
fMin.size(); i++) {
149 fSize[i] =
static_cast<unsigned int>(int_part) + (frac_part > 0.5 ? 1 : 0);
154 for (
unsigned int i = 0; i < value_n; i++) {
157 }
catch (std::bad_alloc) {
158 mycerr <<
"QweakSimFieldMap:SetMinimumMaximumStep: "
159 <<
"could not allocate memory for values!" <<
myendl;
176 {
return fWrap.at(dim); }
179 {
fWrap.at(dim) = wrap; }
181 if (wrap.size() !=
fNDim)
return;
187 {
return fRedux.at(dim); }
190 {
fRedux.at(dim) = redux; }
192 for (
unsigned int dim = 0; dim <
fNDim; dim++)
196 if (redux.size() !=
fNDim)
return;
211 unsigned int* cover =
new unsigned int[
fSize[dim]];
212 unsigned int* total =
new unsigned int[fSize[dim]];
213 for (
unsigned int i = 0; i < fSize[dim]; i++) {
218 value_t value[value_n];
219 unsigned int* cell_index =
new unsigned int[
fNDim];
220 for (
unsigned int linear_index = 0; linear_index <
fMaximumEntries; linear_index++) {
221 Cell(linear_index,cell_index);
222 total[cell_index[dim]]++;
223 if (
Get(linear_index,value) && value[0] != 0)
224 cover[cell_index[dim]]++;
228 for (
size_t i = 0; i < fSize[dim]; i++) {
230 Coord(cell_index,coord);
231 mycout <<
"bin " << i <<
", coord " << coord[dim] <<
": "
232 << double(cover[i]) / double(total[i]) * 100 <<
"%"<<
myendl;
251 mycerr <<
"QweakSimFieldMap::Set(coord_t&,value_t&): "
252 <<
"only valid for one-dimensional values." <<
myendl;
256 mycerr <<
"QweakSimFieldMap::Set(coord_t&,value_t&): "
257 <<
"only valid for one-dimensional grids." <<
myendl;
260 return Set(&coord, &value);
265 mycerr <<
"QweakSimFieldMap::Set(coord_t*,value_t&): "
266 <<
"only valid for one-dimensional values." <<
myendl;
269 return Set(coord, &value);
273 unsigned int* cell_index =
new unsigned int[
fNDim];
275 if (!
Check(cell_index))
return false;
277 bool written =
false;
278 unsigned int linear_index;
279 for (
unsigned int dim = 0; dim <
fNDim; dim++) {
281 if (
fWrap[dim] == 0)
continue;
283 if ((cell_index[dim] <
fWrap[dim]) ||
284 (
fSize[dim] - cell_index[dim] - 1 <
fWrap[dim])) {
286 for (
size_t wrap = 0; wrap <
fWrap[dim]; wrap++) {
288 cell_index[dim] = wrap;
289 linear_index =
Index(cell_index);
290 status &=
Set(linear_index, value);
292 cell_index[dim] =
fSize[dim] - wrap - 1;
293 linear_index =
Index(cell_index);
294 status &=
Set(linear_index, value);
302 linear_index =
Index(cell_index);
303 status &=
Set(linear_index, value);
310 bool Set(
const unsigned int linear_index,
const value_t& value) {
312 mycerr <<
"QweakSimFieldMap::Set(unsigned int,value_t&): "
313 <<
"only valid for one-dimensional values." <<
myendl;
316 return Set(linear_index, &value);
319 bool Set(
const unsigned int linear_index,
const value_t* value) {
320 if (!
Check(linear_index))
return false;
321 for (
unsigned int i = 0; i < value_n; i++)
322 fValues[i][linear_index] = value[i];
328 bool Set(
const unsigned int* cell_index,
const value_t& value) {
330 mycerr <<
"QweakSimFieldMap::Set(unsigned int*,value_t&): "
331 <<
"only valid for one-dimensional values." <<
myendl;
334 return Set(cell_index, &value);
337 bool Set(
const unsigned int* cell_index,
const value_t* value) {
338 if (!
Check(cell_index))
return false;
339 return Set(
Index(cell_index),value);
349 mycerr <<
"QweakSimFieldMap::GetValue(coord_t&): "
350 <<
"only valid for one-dimensional fields." <<
myendl;
354 mycerr <<
"QweakSimFieldMap::GetValue(coord_t&): "
355 <<
"only valid for one-dimensional grids." <<
myendl;
359 if (
GetValue(&coord, &value))
return value;
365 mycerr <<
"QweakSimFieldMap::GetValue(coord_t*): "
366 <<
"only valid for one-dimensional fields." <<
myendl;
370 if (
GetValue(coord, &value))
return value;
376 mycerr <<
"QweakSimFieldMap::GetValue(coord_t*,value_t&): "
377 <<
"only valid for one-dimensional fields." <<
myendl;
384 for (
unsigned int i = 0; i < value_n; i++) value[i] = 0.0;
385 if (!
Check(coord)) {
387 mycerr <<
"QweakSimFieldMap::GetValue(coord_t*,value_t*): "
388 <<
"coordinate is out of boundary." <<
myendl;
392 value_t result[value_n];
396 if (!
Linear(coord, result)) {
398 mycerr <<
"QweakSimFieldMap::GetValue(coord_t*,value_t*): "
399 <<
"linear interpolation failed." <<
myendl;
407 mycerr <<
"QweakSimFieldMap::GetValue(coord_t*,value_t*): "
408 <<
"nearest-neighbor interpolation failed." <<
myendl;
414 mycerr <<
"QweakSimFieldMap::GetValue(coord_t*,value_t*): "
415 <<
"unknown interpolation method." <<
myendl;
418 for (
unsigned int i = 0; i < value_n; i++) value[i] = result[i];
427 bool WriteText(std::ostream& stream)
const;
430 std::ofstream file(filename.c_str());
431 if (! file.is_open()) {
432 mycerr <<
"QweakSimFieldMap::WriteTextFile(string&): "
433 <<
"unable to open file " << filename <<
"." <<
myendl;
446 bool ReadText(std::istream& stream);
449 std::ifstream file(filename.c_str());
450 if (! file.is_open()) {
451 mycerr <<
"QweakSimFieldMap::ReadTextFile(string&): "
452 <<
"unable to open file " << filename <<
"." <<
myendl;
456 mycerr <<
"QweakSimFieldMap::ReadTextFile(string&): "
457 <<
"unable to read text stream." <<
myendl;
474 unsigned int* cell_index =
new unsigned int[
fNDim];
475 Cell(coord, cell_index);
476 unsigned int index =
Index(cell_index);
482 unsigned int Index(
const unsigned int* cell_index)
const;
484 unsigned int Index(
const unsigned int* cell_index,
const unsigned int offset)
const;
487 void Cell(
const coord_t coord,
unsigned int& cell_index,
double& cell_local,
const unsigned int dim)
const;
489 void Cell(
const coord_t* coord,
unsigned int* cell_index,
double* cell_local)
const;
491 void Cell(
const coord_t* coord,
unsigned int* cell_index)
const;
493 void Cell(
unsigned int linear_index,
unsigned int* cell_index)
const;
496 void Coord(
const unsigned int* cell_index,
coord_t* coord)
const;
498 void Coord(
const unsigned int linear_index,
coord_t* coord)
const;
505 double* cell_local =
new double[
fNDim];
506 Cell(coord, cell_index, cell_local);
508 for (
unsigned int dim = 0; dim <
fNDim; dim++)
509 if (cell_local[dim] > 0.5) cell_index[dim]++;
521 bool Check(
const unsigned int* cell_index)
const;
523 bool Check(
const unsigned int linear_index)
const;
526 value_t
Get(
const unsigned int* cell_index)
const {
528 mycerr <<
"QweakSimFieldMap::Get(unsigned int*): "
529 <<
"only valid for one-dimensional fields." <<
myendl;
536 value_t
Get(
const unsigned int index)
const {
538 mycerr <<
"QweakSimFieldMap::Get(unsigned int): "
539 <<
"only valid for one-dimensional fields." <<
myendl;
545 bool Get(
const unsigned int index, value_t* value)
const {
546 for (
unsigned int i = 0; i < value_n; i++)
560 template <
class value_t,
unsigned int value_n>
563 value_t* value)
const
566 unsigned int* cell_index =
new unsigned int[fNDim];
567 double* cell_local =
new double[fNDim];
568 Cell(coord, cell_index, cell_local);
570 for (
unsigned int i = 0; i < value_n; i++) value[i] = 0.0;
573 for (
unsigned int offset = 0; offset < (1U << fNDim); offset++) {
574 value_t neighbor[value_n];
575 if (! Get(Index(cell_index,offset), neighbor)) {
576 if (fDebug >= kDebug) {
577 mycout <<
"QweakSimFieldMap::Linear(coord_t*,value_t*): "
578 <<
"neighbor " << offset <<
" could not be found " <<
myendl;
584 for (
unsigned int dim = 0; dim < fNDim; dim++)
585 fac *= ((offset >> dim) & 0x1)? cell_local[dim] : (1 - cell_local[dim]);
587 for (
unsigned int i = 0; i < value_n; i++)
588 value[i] += fac * neighbor[i];
600 template <
class value_t,
unsigned int value_n>
603 value_t* value)
const
606 unsigned int* cell_index =
new unsigned int[fNDim];
607 Nearest(coord, cell_index);
608 bool status = Get(Index(cell_index), value);
618 template <
class value_t,
unsigned int value_n>
621 for (
unsigned int dim = 0; dim < fNDim; dim++) {
622 if (fWrap[dim] == 0 && (coord[dim] < fMin[dim] || coord[dim] > fMax[dim])) {
623 if (fDebug >= kDebug) {
624 mycout <<
"QweakSimFieldMap::Check(coord_t*): "
625 <<
"coord[" << dim <<
"] out of bounds "
626 << fMin[dim] <<
"-" << fMax[dim] <<
"." <<
myendl;
640 template <
class value_t,
unsigned int value_n>
643 for (
unsigned int dim = 0; dim < fNDim; dim++) {
644 if (cell_index[dim] >= fSize[dim]) {
645 if (fDebug >= kDebug) {
646 mycout <<
"QweakSimFieldMap::Check(unsigned int*): "
647 <<
"cell index[" << dim <<
"] " << cell_index[dim] <<
" larger "
648 <<
"than maximum " << fSize[dim] <<
"." <<
myendl;
662 template <
class value_t,
unsigned int value_n>
665 if (linear_index >= fMaximumEntries) {
666 if (fDebug >= kDebug) {
667 mycout <<
"QweakSimFieldMap::Check(unsigned int): "
668 <<
"linear index " << linear_index <<
" larger "
669 <<
"than maximum " << fMaximumEntries <<
"." <<
myendl;
682 template <
class value_t,
unsigned int value_n>
684 const unsigned int* cell_index)
const
686 unsigned int linear_index = 0;
688 for (
unsigned int dim = 0; dim < fNDim; dim++)
690 linear_index += fExtent[dim] * cell_index[dim];
700 template <
class value_t,
unsigned int value_n>
702 const unsigned int* cell_index,
703 const unsigned int pattern)
const
705 unsigned int linear_index = 0;
707 for (
unsigned int dim = 0; dim < fNDim; dim++) {
709 unsigned int offset = (pattern >> dim) & 0x1;
710 linear_index += fExtent[dim] * (cell_index[dim] + offset);
722 template <
class value_t,
unsigned int value_n>
725 unsigned int &cell_index,
727 const unsigned int dim)
const
730 double norm_coord = (coord - fMin[dim]) / fStep[dim];
732 double frac_part, int_part;
733 frac_part = modf(norm_coord, &int_part);
734 cell_local = frac_part;
735 cell_index =
static_cast<int>(int_part);
737 if (fWrap[dim] > 0) cell_index %= (fSize[dim] - fWrap[dim]);
746 template <
class value_t,
unsigned int value_n>
749 unsigned int* cell_index,
750 double* cell_local)
const
753 for (
unsigned int dim = 0; dim < fNDim; dim++)
754 Cell(coord[dim], cell_index[dim], cell_local[dim], dim);
762 template <
class value_t,
unsigned int value_n>
765 unsigned int* cell_index)
const
768 double* cell_local =
new double[fNDim];
769 Cell(coord, cell_index, cell_local);
778 template <
class value_t,
unsigned int value_n>
780 unsigned int linear_index,
781 unsigned int* cell_index)
const
784 for (
int dim = fNDim-1; dim >= 0; dim--) {
785 cell_index[dim] = linear_index / fExtent[dim];
786 linear_index -= cell_index[dim] * fExtent[dim];
795 template <
class value_t,
unsigned int value_n>
797 const unsigned int* cell_index,
800 for (
unsigned int dim = 0; dim < fNDim; dim++)
801 coord[dim] = fMin[dim] + cell_index[dim] * fStep[dim];
809 template <
class value_t,
unsigned int value_n>
811 const unsigned int linear_index,
814 unsigned int* cell_index =
new unsigned int[fNDim];
815 Cell(linear_index,cell_index);
816 Coord(cell_index,coord);
824 template <
class value_t,
unsigned int value_n>
828 mycout <<
"Writing text stream: ";
830 stream << fNDim <<
"\t" << value_n << std::endl;
832 for (
unsigned int dim = 0; dim < fNDim; dim++)
833 stream << dim <<
"\t" << fMin[dim] <<
"\t" << fMax[dim] <<
"\t" << fStep[dim] << std::endl;
835 stream << fValues[0].size() << std::endl;
836 unsigned int entries = fValues[0].size();
837 for (
unsigned int index = 0; index < entries; index++) {
839 for (
unsigned int i = 0; i < value_n; i++) {
840 stream << fValues[i][index] <<
"\t";
844 if (index % (entries / 10) == 0)
845 mycout << index / (entries / 100) <<
"%" << std::flush;
846 if (index % (entries / 10) != 0
847 && index % (entries / 40) == 0)
848 mycout <<
"." << std::flush;
850 stream <<
"end" << std::endl;
860 template <
class value_t,
unsigned int value_n>
864 mycout <<
"Reading text stream: ";
867 stream >> fNDim >> n;
869 mycerr <<
"QweakSimFieldMap::ReadText(istream&): "
870 <<
"incompatible field dimension in stream." <<
myendl;
873 SetDimensions(fNDim);
875 for (
unsigned int dim = 0; dim < fNDim; dim++)
876 stream >> dim >> fMin[dim] >> fMax[dim] >> fStep[dim];
877 SetMinimumMaximumStep(fMin, fMax, fStep);
879 unsigned int entries;
881 for (
unsigned int index = 0; index < entries; index++) {
883 for (
unsigned int i = 0; i < value_n; i++) {
884 stream >> fValues[i][index];
887 if (index % (entries / 10) == 0)
888 mycout << index / (entries / 100) <<
"%" << std::flush;
889 if (index % (entries / 10) != 0
890 && index % (entries / 40) == 0)
891 mycout <<
"." << std::flush;
898 if (end ==
"end")
return true;
900 mycerr <<
"QweakSimFieldMap::ReadText(istream&): "
901 <<
"stream did not end with keyword 'end'." <<
myendl;
917 template <
class value_t,
unsigned int value_n>
920 std::ofstream file(filename.c_str(), std::ios::binary);
921 if (! file.is_open()) {
922 mycerr <<
"QweakSimFieldMap::WriteBinaryFile(string&): "
923 <<
"unable to open file " << filename <<
"." <<
myendl;
927 mycout <<
"Writing binary file: ";
929 uint32_t n = value_n;
930 uint32_t size =
sizeof(value_t);
931 file.write(reinterpret_cast<const char*>(&n),
sizeof(n));
932 file.write(reinterpret_cast<const char*>(&size),
sizeof(size));
934 uint32_t ndim = fNDim;
935 file.write(reinterpret_cast<const char*>(&ndim),
sizeof(ndim));
936 for (
unsigned int dim = 0; dim < fNDim; dim++) {
937 file.write(reinterpret_cast<const char*>(&fMin[dim]),
sizeof(fMin[dim]));
938 file.write(reinterpret_cast<const char*>(&fMax[dim]),
sizeof(fMax[dim]));
939 file.write(reinterpret_cast<const char*>(&fStep[dim]),
sizeof(fStep[dim]));
941 uint32_t entries = fValues[0].size();
942 file.write(reinterpret_cast<const char*>(&entries),
sizeof(entries));
943 for (
unsigned int index = 0; index < entries; index++) {
945 for (
unsigned int i = 0; i < value_n; i++) {
946 value_t value = fValues[i][index];
947 file.write(reinterpret_cast<const char*>(&value),
sizeof(value));
950 if (index % (entries / 10) == 0)
951 mycout << index / (entries / 100) <<
"%" << std::flush;
952 if (index % (entries / 10) != 0
953 && index % (entries / 40) == 0)
954 mycout <<
"." << std::flush;
966 template <
class value_t,
unsigned int value_n>
969 std::ifstream file(filename.c_str(), std::ios::binary);
970 if (! file.is_open()) {
971 mycerr <<
"QweakSimFieldMap::ReadBinaryFile(string&): "
972 <<
"unable to open file " << filename <<
"." <<
myendl;
976 mycout <<
"Reading binary file: ";
978 file.seekg(0, std::ios::end);
980 file.seekg(0, std::ios::beg);
982 file.read(reinterpret_cast<char*>(&n),
sizeof(n));
983 file.read(reinterpret_cast<char*>(&size),
sizeof(size));
985 mycerr <<
"QweakSimFieldMap::ReadBinaryFile(string&): "
986 <<
"incompatible field dimension in stream." <<
myendl;
989 if (size !=
sizeof(value_t)) {
990 mycerr <<
"QweakSimFieldMap::ReadBinaryFile(string&): "
991 <<
"incompatible precision of field values.." <<
myendl;
996 file.read(reinterpret_cast<char*>(&ndim),
sizeof(ndim));
999 for (
unsigned int dim = 0; dim < fNDim; dim++) {
1000 file.read(reinterpret_cast<char*>(&fMin[dim]),
sizeof(fMin[dim]));
1001 file.read(reinterpret_cast<char*>(&fMax[dim]),
sizeof(fMax[dim]));
1002 file.read(reinterpret_cast<char*>(&fStep[dim]),
sizeof(fStep[dim]));
1004 SetMinimumMaximumStep(fMin, fMax, fStep);
1006 uint32_t maximum_entries;
1007 file.read(reinterpret_cast<char*>(&maximum_entries),
sizeof(maximum_entries));
1008 if (maximum_entries != fMaximumEntries) {
1009 mycerr <<
"QweakSimFieldMap::ReadBinaryFile(string&): "
1010 <<
"expected number of entries." <<
myendl;
1013 int value_size =
sizeof(value_t);
1014 unsigned int entries = fValues[0].size();
1015 for (
unsigned int index = 0; index < entries; index++) {
1017 for (
unsigned int i = 0; i < value_n; i++) {
1018 file.read((
char*)(&fValues[i][index]),value_size);
1021 if (index % (entries / 10) == 0)
1022 mycout << index / (entries / 100) <<
"%" << std::flush;
1023 if (index % (entries / 10) != 0
1024 && index % (entries / 40) == 0)
1025 mycout <<
"." << std::flush;
1033 #endif // QweakSimFieldMap_h
EInterpolationMethod GetInterpolationMethod() const
Get the interpolation method.
value_t GetValue(const coord_t &coord) const
Get the interpolated value at coordinate (zero if out of bounds)
int GetDataReductionFactor(const unsigned int dim) const
Get data reduction factor.
std::vector< coord_t > fMax
Maximum in each dimension.
bool Set(const unsigned int *cell_index, const value_t *value)
Set a set of values at a grid point (false if out of bounds)
virtual ~QweakSimFieldMap()
Destructor.
bool InBounds(const coord_t *coord) const
Return true if the coordinate is in bounds.
bool WriteTextScreen() const
Write the grid to screen.
bool NearestNeighbor(const coord_t *coord, value_t *value) const
Nearest-neighbor (unchecked)
value_t Get(const unsigned int index) const
Get a single value by linearized index (unchecked)
value_t Get(const unsigned int *cell_index) const
Get a single value by cell index (unchecked)
coord_t GetMinimum(const unsigned int dim) const
Get minimum in dimension.
enum QweakSimFieldMap::debug_t fDebug
void SetMinimumMaximumStep(const coord_t min, const coord_t max, const coord_t step)
Set minimum, maximum, and step size to single values.
bool ReadText(std::istream &stream)
Read the grid from text.
bool ReadTextFile(const std::string &filename)
Read the grid from text file.
std::vector< value_t > fValues[value_n]
Table with pointers to arrays of values.
unsigned int GetCurrentEntries() const
Get the current number of entries.
std::vector< size_t > fExtent
A multi-dimensional grid of values with interpolation methods.
void Coord(const unsigned int *cell_index, coord_t *coord) const
Return the coordinates based on the cell index (unchecked)
bool WriteBinaryFile(const std::string &filename) const
Write the grid values to binary file.
bool WriteTextFile(const std::string &filename) const
Write the grid to text file.
void SetDataReductionFactor(const unsigned int dim, const unsigned int redux)
Set data reduction factor.
unsigned int GetMaximumEntries() const
Get the maximum number of entries.
bool Check(const coord_t *coord) const
Check for boundaries with coordinate argument.
EInterpolationMethod fInterpolationMethod
Interpolation method.
bool Set(const coord_t *coord, const value_t *value)
Set a set of values at a coordinate (false if not possible)
unsigned int fMaximumEntries
Maximum number of values.
EInterpolationMethod
Allowed interpolation methods.
bool Set(const unsigned int *cell_index, const value_t &value)
Set a single value at a grid point (false if out of bounds)
value_t GetValue(const coord_t *coord) const
Get the interpolated value at coordinate (zero if out of bounds)
unsigned int GetWrapCoordinate(const unsigned int dim) const
Get wrapping coordinate.
coord_t GetMaximum(const unsigned int dim) const
Get maximum in dimension.
bool Get(const unsigned int index, value_t *value) const
Get a vector value by linearized index (unchecked)
QweakSimFieldMap(const std::string &filename)
Constructor with file name.
std::vector< coord_t > fStep
Step size in each dimension.
std::vector< size_t > fRedux
Data reduction factor.
unsigned int fNDim
Number of dimensions in coordinates.
void Cell(const coord_t coord, unsigned int &cell_index, double &cell_local, const unsigned int dim) const
Return the cell index and local coordinates in one dimension (unchecked)
void PrintCoverage(const unsigned int dim)
Print coverage map for all bins in one dimension.
std::vector< size_t > fWrap
Wrap around this coordinate.
void SetMinimumMaximumStep(const std::vector< coord_t > &min, const std::vector< coord_t > &max, const std::vector< coord_t > &step)
Set minimum, maximum, and step size to different values.
bool Set(const coord_t &coord, const value_t &value)
Set a single value at a coordinate (false if not possible)
std::vector< size_t > fSize
Number of points in each dimension.
bool Linear(const coord_t *coord, value_t *value) const
Linear interpolation (unchecked)
std::vector< coord_t > fMin
Minimum in each dimension.
coord_t GetStepSize(const unsigned int dim) const
Get minimum in dimension.
bool Set(const coord_t *coord, const value_t &value)
Set a single value at a coordinate (false if not possible)
bool Set(const unsigned int linear_index, const value_t &value)
Set a single value at a linearized index (false if not possible)
void SetWrapCoordinate(const unsigned int dim, const size_t wrap=1)
Set wrapping coordinate.
unsigned int fCurrentEntries
Number of values read in.
bool GetValue(const coord_t *coord, double *value) const
Get the interpolated value at coordinate (zero if out of bounds)
void SetWrapCoordinate(const std::vector< size_t > &wrap)
bool ReadBinaryFile(const std::string &filename)
Read the grid values from binary file.
void SetDimensions(const unsigned int ndim)
Set the number of coordinate dimensions and resize vectors.
void SetDataReductionFactor(const std::vector< unsigned int > &redux)
void SetDataReductionFactor(const unsigned int redux)
QweakSimFieldMap(const std::vector< coord_t > &min, const std::vector< coord_t > &max, const std::vector< coord_t > &step)
Constructor with minimum, maximum, and step size.
void SetDebugLevel(debug_t debug)
Set debug level.
bool GetValue(const coord_t *coord, double &value) const
Get the interpolated value at coordinate (zero if out of bounds)
unsigned int Index(const coord_t *coord) const
Return the linearized index based on the point coordinates (unchecked)
bool Set(const unsigned int linear_index, const value_t *value)
Set a set of values at a linearized index (false if not possible)
QweakSimFieldMap(const unsigned int ndim=1)
Constructor with number of dimensions.
void Nearest(const coord_t *coord, unsigned int *cell_index) const
Return the cell index closest to the coordinate (could be above) (unchecked)
void SetInterpolationMethod(const EInterpolationMethod method)
Set the interpolation method.
bool WriteText(std::ostream &stream) const
Write the grid as text.