Chi-Tech
chi_ffinter_line_initialize.cc
Go to the documentation of this file.
1#include "chi_ffinter_line.h"
2
3#include "mesh/Cell/cell.h"
4
8
9#include "chi_runtime.h"
10#include "chi_log.h"
11
12//###################################################################
13/**Initializes the data structures necessary for interpolation. This is
14 * independent of the physics and hence is a routine on its own.*/
17{
18 Chi::log.Log0Verbose1() << "Initializing line interpolator.";
19 //================================================== Check for empty FF-list
20 if (field_functions_.empty())
21 throw std::logic_error("Unassigned field function in line "
22 "field function interpolator.");
23
24 //================================================== Create points;
25 const chi_mesh::Vector3 vif = pf_ - pi_;
26 delta_d_ = vif.Norm() / (number_of_points_ - 1);
27
28 const auto omega = vif.Normalized();
29
30 interpolation_points_.push_back(pi_);
31 for (int k=1; k<(number_of_points_); k++)
32 interpolation_points_.push_back(pi_ + omega * delta_d_ * k);
33
34 //====================================================== Loop over contexts
35 const size_t num_ff = field_functions_.size();
36 for (size_t ff=0; ff<num_ff; ff++)
37 {
38 ff_contexts_.emplace_back();
39 auto& ff_context = ff_contexts_.back();
40
41 ff_context.ref_ff = field_functions_[ff];
42 const auto& sdm = ff_context.ref_ff->GetSpatialDiscretization();
43 const auto& grid = sdm.Grid();
44
45 ff_context.interpolation_points_ass_cell.assign(number_of_points_, 0);
46 ff_context.interpolation_points_has_ass_cell.assign(number_of_points_, false);
47
48 //================================================== Find a home for each
49 // point
50 for (const auto& cell : grid.local_cells)
51 {
52 for (int p=0; p < number_of_points_; p++)
53 {
54 const auto& point = interpolation_points_[p];
55 if (grid.CheckPointInsideCell(cell, point))
56 {
57 ff_context.interpolation_points_ass_cell[p] = cell.local_id_;
58 ff_context.interpolation_points_has_ass_cell[p] = true;
59 }
60 }//for point p
61 }//for cell
62 }//for ff
63
64 Chi::log.Log0Verbose1() << "Finished initializing interpolator.";
65}
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream Log0Verbose1()
Definition: chi_log.h:234
std::vector< chi_physics::FieldFunctionGridBasedPtr > field_functions_
std::vector< chi_mesh::Vector3 > interpolation_points_
std::vector< FieldFunctionContext > ff_contexts_
Vector3 Normalized() const
double Norm() const