https://mooseframework.inl.gov
MultiAppGeneralFieldNearestLocationTransfer.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 
13 #include "KDTree.h"
15 
22 
23 {
24 public:
26 
28 
29  void initialSetup() override;
30 
31 protected:
32  virtual void prepareEvaluationOfInterpValues(const unsigned int var_index) override;
33 
34  virtual void
35  evaluateInterpValues(const std::vector<std::pair<Point, unsigned int>> & incoming_points,
36  std::vector<std::pair<Real, Real>> & outgoing_vals) override;
37 
39  bool inBlocks(const std::set<SubdomainID> & blocks,
40  const MooseMesh & mesh,
41  const Elem * elem) const override;
42 
43 private:
44  bool usesMooseAppCoordTransform() const override { return true; }
45  /*
46  * Build KD-Trees for each local app
47  * @param var_index the index of the variable being transferred
48  * @details fills _local_kdtrees, _local_points and _local_values
49  * Indexing is: local apps (outer-indexing) OR positions (if using nearest_positions),
50  * local nodes (inner-indexing)
51  */
52  void buildKDTrees(const unsigned int var_index);
53 
54  /*
55  * Evaluate interpolation values for incoming points
56  * @param incoming_points all the points at which we need values
57  * @param outgoing_vals vector containing the values and distances from point to nearest node
58  */
60  const std::vector<std::pair<Point, unsigned int>> & incoming_points,
61  std::vector<std::pair<Real, Real>> & outgoing_vals);
62 
65  void computeNumSources();
66 
68  unsigned int getAppIndex(unsigned int kdtree_index, unsigned int app_index) const;
69 
71  unsigned int getNumAppsPerTree() const;
72 
74  unsigned int getNumDivisions() const;
75 
77  Point getPointInLocalSourceFrame(unsigned int i_from, const Point & pt) const;
78 
87  bool checkRestrictionsForSource(const Point & pt,
88  const unsigned int valid_mesh_div,
89  const unsigned int i_from) const;
90 
92  std::vector<std::shared_ptr<KDTree>> _local_kdtrees;
93 
95  std::vector<std::vector<std::shared_ptr<KDTree>>> _local_positions_kdtrees;
96 
98  std::vector<std::vector<Point>> _local_points;
99 
101  std::vector<std::vector<Real>> _local_values;
102 
104  unsigned int _num_nearest_points;
105 
107  const bool _group_subapps;
108 
110  std::vector<bool> _source_is_nodes;
111 
113  std::vector<bool> _use_zero_dof_for_value;
114 
116  unsigned int _num_sources;
117 };
bool inBlocks(const std::set< SubdomainID > &blocks, const MooseMesh &mesh, const Elem *elem) const override
const bool _group_subapps
Whether to group data when creating the nearest-point regions.
char ** blocks
unsigned int getAppIndex(unsigned int kdtree_index, unsigned int app_index) const
Get the index of the app in the loop over the trees and the apps contributing data to each tree...
std::vector< bool > _use_zero_dof_for_value
Whether we can just use the local zero-indexed dof to get the value from the solution.
Point getPointInLocalSourceFrame(unsigned int i_from, const Point &pt) const
Transform a point towards the local frame.
MeshBase & mesh
std::vector< bool > _source_is_nodes
Whether the source of the values is at nodes (true) or centroids (false) for each variable...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
unsigned int getNumAppsPerTree() const
Number of applications which contributed nearest-locations to each KD-tree.
An interface that allows the marking of invalid solutions during a solve.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
bool usesMooseAppCoordTransform() const override
Whether this transfer handles non-translation-based transformations, e.g.
std::vector< std::vector< Point > > _local_points
All the nodes that meet the spatial restrictions in all the local source apps.
std::vector< std::vector< Real > > _local_values
Values of the variable being transferred at all the points in _local_points.
std::vector< std::shared_ptr< KDTree > > _local_kdtrees
KD-Trees for all the local source apps.
void evaluateInterpValuesNearestNode(const std::vector< std::pair< Point, unsigned int >> &incoming_points, std::vector< std::pair< Real, Real >> &outgoing_vals)
bool checkRestrictionsForSource(const Point &pt, const unsigned int valid_mesh_div, const unsigned int i_from) const
Examine all spatial restrictions that could preclude this source from being a valid source for this p...
virtual void evaluateInterpValues(const std::vector< std::pair< Point, unsigned int >> &incoming_points, std::vector< std::pair< Real, Real >> &outgoing_vals) override
std::vector< std::vector< std::shared_ptr< KDTree > > > _local_positions_kdtrees
KD-Trees for nodes nearest to a given position on each local source app.
virtual void prepareEvaluationOfInterpValues(const unsigned int var_index) override
Performs a geometric interpolation based on the values at the nearest nodes to a target location in t...
const InputParameters & parameters() const
Get the parameters of the object.
unsigned int getNumDivisions() const
Number of divisions (nearest-positions or source mesh divisions) used when building KD-Trees...
void initialSetup() override
Method called at the beginning of the simulation for checking integrity or doing one-time setup...
void computeNumSources()
Pre-compute the number of sources Number of KDTrees used to hold the locations and variable value dat...
It is a general field transfer.
bool inBlocks(const std::set< SubdomainID > &blocks, const Elem *elem) const