https://mooseframework.inl.gov
MultiAppGeneralFieldKDTreeTransferBase.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 
20 {
21 public:
23 
25 
26  void initialSetup() override;
27 
28  // Use solution invalid output for these warnings
30 
31 protected:
32  virtual void prepareEvaluationOfInterpValues(const unsigned int var_index) override;
33 
35  bool inBlocks(const std::set<SubdomainID> & blocks,
36  const MooseMesh & mesh,
37  const Elem * elem) const override;
38 
39  bool usesMooseAppCoordTransform() const override { return true; }
40  /*
41  * Build KD-Trees for each local app
42  * @param var_index the index of the variable being transferred
43  * @details fills _local_kdtrees, _local_points and _local_values
44  * Indexing is: local apps (outer-indexing) OR positions (if using nearest_positions),
45  * local nodes (inner-indexing)
46  */
47  virtual void buildKDTrees(const unsigned int var_index) = 0;
48 
51  void computeNumSources();
52 
60  unsigned int getAppIndex(unsigned int kdtree_index, unsigned int app_index_in_tree) const;
61 
63  unsigned int getNumAppsPerTree() const;
64 
66  unsigned int getNumDivisions() const;
67 
75  Point getPointInSourceKDTreeFrame(unsigned int i_source, const Point & pt) const;
76 
86  bool checkRestrictionsForSource(const Point & pt,
87  const unsigned int valid_mesh_div,
88  const unsigned int i_from) const;
89 
101  void evaluateNearestNodeFromKDTrees(const Point & pt,
102  unsigned int source_index,
103  std::pair<Real, Real> & outgoing_val,
104  bool & point_found);
105 
107  std::vector<std::shared_ptr<KDTree>> _local_kdtrees;
108 
110  std::vector<std::vector<std::shared_ptr<KDTree>>> _local_positions_kdtrees;
111 
113  std::vector<std::vector<Point>> _local_points;
114 
116  std::vector<std::vector<Real>> _local_values;
117 
119  unsigned int _num_nearest_points;
120 
122  const bool _group_subapps;
123 
125  unsigned int _num_sources;
126 };
void initialSetup() override
Method called at the beginning of the simulation for checking integrity or doing one-time setup...
unsigned int getNumDivisions() const
Number of divisions (nearest-positions or source mesh divisions) used when building KD-Trees...
const bool _group_subapps
Whether to group data when creating the nearest-point regions.
Base class for working with KDTrees in transfers, whether for interpolation or extrapolation.
void computeNumSources()
Pre-compute the number of sources Number of KDTrees used to hold the locations and variable value dat...
char ** blocks
Point getPointInSourceKDTreeFrame(unsigned int i_source, const Point &pt) const
Transform a point into the frame used for KD-tree queries.
unsigned int getAppIndex(unsigned int kdtree_index, unsigned int app_index_in_tree) const
Get the index of the app when inside of a KD-Tree source loop, where multiple applications could be l...
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool inBlocks(const std::set< SubdomainID > &blocks, const MooseMesh &mesh, const Elem *elem) const override
unsigned int _num_sources
Number of KD-Trees to create.
MultiAppGeneralFieldKDTreeTransferBase(const InputParameters &parameters)
void evaluateNearestNodeFromKDTrees(const Point &pt, unsigned int source_index, std::pair< Real, Real > &outgoing_val, bool &point_found)
Search all local KD-trees for the nearest node/element and update outgoing_val.
unsigned int getNumAppsPerTree() const
Number of applications which contributed nearest-locations to each KD-tree.
virtual void prepareEvaluationOfInterpValues(const unsigned int var_index) override
bool usesMooseAppCoordTransform() const override
Whether this transfer handles non-translation-based transformations, e.g.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:93
virtual void buildKDTrees(const unsigned int var_index)=0
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...
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.
unsigned int _num_nearest_points
Number of points to consider.
std::vector< std::vector< Real > > _local_values
Values of the variable being transferred at all the points in _local_points.
std::vector< std::vector< Point > > _local_points
All the nodes that meet the spatial restrictions in all the local source apps.
std::vector< std::shared_ptr< KDTree > > _local_kdtrees
KD-Trees for all the local source apps.
It is a general field transfer.
bool inBlocks(const std::set< SubdomainID > &blocks, const Elem *elem) const