OGS
ProcessLib::ComponentTransport::LookupTable Struct Reference

Detailed Description

Definition at line 49 of file LookupTable.h.

#include <LookupTable.h>

Public Member Functions

 LookupTable (std::vector< Field > input_fields_, std::map< std::string, std::vector< double > > tabular_data_)
 
void lookup (std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, std::size_t const n_nodes) const
 
std::size_t getTableEntryID (std::vector< double > const &entry_input) const
 

Public Attributes

std::vector< Field > const input_fields
 
std::map< std::string, std::vector< double > > const tabular_data
 

Constructor & Destructor Documentation

◆ LookupTable()

ProcessLib::ComponentTransport::LookupTable::LookupTable ( std::vector< Field > input_fields_,
std::map< std::string, std::vector< double > > tabular_data_ )
inline

Definition at line 51 of file LookupTable.h.

54 : input_fields(std::move(input_fields_)),
55 tabular_data(std::move(tabular_data_))
56 {
57 }
std::map< std::string, std::vector< double > > const tabular_data
Definition LookupTable.h:66
std::vector< Field > const input_fields
Definition LookupTable.h:65

Member Function Documentation

◆ getTableEntryID()

std::size_t ProcessLib::ComponentTransport::LookupTable::getTableEntryID ( std::vector< double > const & entry_input) const

point_id_groups stores indices where the elements equal to the given value.

need to intersect point_id_groups with respect to different input fields to find out an entry id where all the field data align with the entry inputs.

Definition at line 139 of file LookupTable.cpp.

141{
142 std::vector<std::size_t> intersected_vec =
145 input_fields[0].point_id_groups[BaseLib::findIndex(
146 input_fields[0].seed_points, entry_input[0])];
147
151 for (std::size_t i = 1; i < input_fields.size(); ++i)
152 {
153 std::vector<std::size_t> const vec =
154 input_fields[i].point_id_groups[BaseLib::findIndex(
155 input_fields[i].seed_points, entry_input[i])];
156
157 intersection(intersected_vec, vec);
158 }
159
160 return intersected_vec[0];
161}
std::size_t findIndex(Container const &container, typename Container::value_type const &element)
Definition Algorithm.h:238
static void intersection(std::vector< std::size_t > &vec1, std::vector< std::size_t > const &vec2)

References BaseLib::findIndex(), input_fields, and ProcessLib::ComponentTransport::intersection().

Referenced by lookup().

◆ lookup()

void ProcessLib::ComponentTransport::LookupTable::lookup ( std::vector< GlobalVector * > const & x,
std::vector< GlobalVector * > const & x_prev,
std::size_t const n_nodes ) const

Definition at line 61 of file LookupTable.cpp.

64{
65 using EntryInput = std::vector<double>;
66
67 for (std::size_t node_id = 0; node_id < n_nodes; ++node_id)
68 {
69 std::vector<InterpolationPoint> interpolation_points;
70 EntryInput base_entry_input;
71 for (auto const& input_field : input_fields)
72 {
73 // process id and variable id are equivalent in the case the
74 // staggered coupling scheme is adopted.
75 auto const process_id = input_field.variable_id;
76 auto const& variable_name = input_field.name;
77 double input_field_value =
78 variable_name.find("_prev") == std::string::npos
79 ? x[process_id]->get(node_id)
80 : x_prev[process_id]->get(node_id);
81 input_field_value =
82 (std::abs(input_field_value) + input_field_value) / 2;
83 auto bounding_seed_points =
84 input_field.getBoundingSeedPoints(input_field_value);
85
86 InterpolationPoint interpolation_point{bounding_seed_points,
87 input_field_value};
88 interpolation_points.push_back(interpolation_point);
89
90 base_entry_input.push_back(bounding_seed_points.first);
91 }
92
93 auto const base_entry_id = getTableEntryID(base_entry_input);
94
95 // collect bounding entry ids
96 EntryInput bounding_entry_input{base_entry_input};
97 std::vector<std::size_t> bounding_entry_ids;
98 for (std::size_t i = 0; i < interpolation_points.size(); ++i)
99 {
100 bounding_entry_input[i] =
101 interpolation_points[i].bounding_points.second;
102 bounding_entry_ids.push_back(getTableEntryID(bounding_entry_input));
103 bounding_entry_input[i] =
104 interpolation_points[i].bounding_points.first;
105 }
106
107 for (auto const& input_field : input_fields)
108 {
109 if (input_field.name.find("_prev") != std::string::npos)
110 {
111 continue;
112 }
113
114 auto const output_field_name = input_field.name + "_new";
115 auto const base_value =
116 tabular_data.at(output_field_name)[base_entry_id];
117 auto new_value = base_value;
118
119 // linear interpolation
120 for (std::size_t i = 0; i < interpolation_points.size(); ++i)
121 {
122 auto const interpolation_point_value =
123 tabular_data.at(output_field_name)[bounding_entry_ids[i]];
124 auto const slope =
125 (interpolation_point_value - base_value) /
126 (interpolation_points[i].bounding_points.second -
127 interpolation_points[i].bounding_points.first);
128
129 new_value +=
130 slope * (interpolation_points[i].value -
131 interpolation_points[i].bounding_points.first);
132 }
133
134 x[input_field.variable_id]->set(node_id, new_value);
135 }
136 }
137}
std::size_t getTableEntryID(std::vector< double > const &entry_input) const

References getTableEntryID(), input_fields, and tabular_data.

Member Data Documentation

◆ input_fields

std::vector<Field> const ProcessLib::ComponentTransport::LookupTable::input_fields

Definition at line 65 of file LookupTable.h.

Referenced by getTableEntryID(), and lookup().

◆ tabular_data

std::map<std::string, std::vector<double> > const ProcessLib::ComponentTransport::LookupTable::tabular_data

Definition at line 66 of file LookupTable.h.

Referenced by lookup().


The documentation for this struct was generated from the following files: