https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GriddedData.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "MooseTypes.h"
13#include "MooseError.h"
14#include "MooseUtils.h"
15
16#include <iosfwd>
17#include <string>
18#include <vector>
19
33{
34public:
38 GriddedData(std::string file_name);
39
40 virtual ~GriddedData() = default;
41
42 typedef MooseUtils::SemidynamicVector<Real, 4> GridPoint;
43 typedef MooseUtils::SemidynamicVector<ADReal, 4> ADGridPoint;
44 typedef MooseUtils::SemidynamicVector<unsigned int, 4> GridIndex;
45
53 unsigned int getDim();
54
62 void getAxes(std::vector<int> & axes);
63
68 void getGrid(std::vector<std::vector<Real>> & grid);
69
73 void getFcn(std::vector<Real> & fcn);
74
80 Real evaluateFcn(const GridIndex & ijk);
81
108 static void parse(unsigned int & dim,
109 std::vector<int> & axes,
110 std::vector<std::vector<Real>> & grid,
111 std::vector<Real> & f,
112 std::vector<unsigned int> & step,
113 std::string file_name);
114
115private:
116 unsigned int _dim;
117 std::vector<int> _axes;
118 std::vector<std::vector<Real>> _grid;
119 std::vector<Real> _fcn;
120 std::vector<unsigned int> _step;
128 static bool getSignificantLine(std::ifstream & file_stream, std::string & line);
129
135 static void splitToRealVec(const std::string & input_string, std::vector<Real> & output_vec);
136
137 void updateGrid(unsigned int & dim, const std::vector<Real> & axis_i, const int axis_index);
138};
Container for holding a function defined on a grid of arbitrary dimension.
Definition GriddedData.h:33
static bool getSignificantLine(std::ifstream &file_stream, std::string &line)
Extracts the next line from file_stream that is:
std::vector< Real > _fcn
static void parse(unsigned int &dim, std::vector< int > &axes, std::vector< std::vector< Real > > &grid, std::vector< Real > &f, std::vector< unsigned int > &step, std::string file_name)
parse the file_name extracting information.
static void splitToRealVec(const std::string &input_string, std::vector< Real > &output_vec)
Splits an input_string using space as the separator Converts the resulting items to Real,...
Real evaluateFcn(const GridIndex &ijk)
Evaluates the function at a given grid point.
Definition GriddedData.C:92
unsigned int getDim()
Returns the dimensionality of the grid.
Definition GriddedData.C:61
std::vector< std::vector< Real > > _grid
MooseUtils::SemidynamicVector< Real, 4 > GridPoint
Definition GriddedData.h:42
MooseUtils::SemidynamicVector< unsigned int, 4 > GridIndex
Definition GriddedData.h:44
std::vector< int > _axes
virtual ~GriddedData()=default
void updateGrid(unsigned int &dim, const std::vector< Real > &axis_i, const int axis_index)
std::vector< unsigned int > _step
void getAxes(std::vector< int > &axes)
Yields axes information.
Definition GriddedData.C:67
MooseUtils::SemidynamicVector< ADReal, 4 > ADGridPoint
Definition GriddedData.h:43
void getFcn(std::vector< Real > &fcn)
Yields the values defined at the grid points.
Definition GriddedData.C:85
unsigned int _dim
void getGrid(std::vector< std::vector< Real > > &grid)
Yields the grid.
Definition GriddedData.C:74