19 #include "libmesh/meshfree_interpolation.h" 20 #include "libmesh/numeric_vector.h" 21 #include "libmesh/system.h" 22 #include "libmesh/radial_basis_interpolation.h" 32 params.
addClassDescription(
"Transfer postprocessor data from sub-application into field data on " 33 "the parent application.");
35 "variable",
"The auxiliary variable to store the transferred values in.");
36 params.
addRequiredParam<PostprocessorName>(
"postprocessor",
"The Postprocessor to interpolate.");
38 "num_points", 3,
"The number of nearest points to use for interpolation.");
40 "power", 2,
"The polynomial power to use for calculation of the decay in the interpolation.");
42 MooseEnum interp_type(
"inverse_distance radial_basis",
"inverse_distance");
44 params.
addParam<
MooseEnum>(
"interp_type", interp_type,
"The algorithm to use for interpolation.");
48 "Radius to use for radial_basis interpolation. If negative " 49 "then the radius is taken as the max distance between " 57 _postprocessor(getParam<PostprocessorName>(
"postprocessor")),
58 _to_var_name(getParam<AuxVariableName>(
"variable")),
59 _num_points(getParam<unsigned
int>(
"num_points")),
60 _power(getParam<
Real>(
"power")),
61 _interp_type(getParam<
MooseEnum>(
"interp_type")),
62 _radius(getParam<
Real>(
"radius")),
66 paramError(
"to_multi_app",
"Unused parameter; only from-MultiApp transfers are implemented");
72 paramError(
"variable",
"Must be either CONSTANT MONOMIAL or FIRST LAGRANGE");
80 TIME_SECTION(
"MultiAppPostprocessorInterpolationTransfer::execute()",
82 "Transferring/interpolating postprocessors");
88 mooseError(
"Interpolation from a variable to a MultiApp postprocessors has not been " 89 "implemented. Use MultiAppVariableValueSamplePostprocessorTransfer!");
95 std::unique_ptr<InverseDistanceInterpolation<LIBMESH_DIM>> idi;
100 idi = std::make_unique<InverseDistanceInterpolation<LIBMESH_DIM>>(
110 std::vector<Point> & src_pts(idi->get_source_points());
111 std::vector<Number> & src_vals(idi->get_source_vals());
113 std::vector<std::string> field_vars;
115 idi->set_field_variables(field_vars);
118 mooseAssert(
_to_transforms.size() == 1,
"There should only be one transform here");
131 src_pts.push_back(to_coord_transform.mapBack(
139 idi->prepare_for_use();
145 unsigned int sys_num = to_sys->
number();
152 std::vector<std::string>
vars;
159 for (
const auto & node :
as_range(
mesh.localNodesBegin(),
mesh.localNodesEnd()))
161 if (node->n_dofs(sys_num, var_num) > 0)
163 std::vector<Point> pts;
164 std::vector<Number> vals;
166 pts.push_back(*node);
169 idi->interpolate_field_data(
vars, pts, vals);
174 dof_id_type dof = node->dof_number(sys_num, var_num, 0);
183 for (
const auto & elem :
184 as_range(
mesh.getMesh().local_elements_begin(),
mesh.getMesh().local_elements_end()))
187 if (elem->n_dofs(sys_num, var_num) > 0)
189 std::vector<Point> pts;
190 std::vector<Number> vals;
192 pts.push_back(elem->vertex_average());
195 idi->interpolate_field_data(
vars, pts, vals);
199 dof_id_type dof = elem->dof_number(sys_num, var_num, 0);
std::vector< std::unique_ptr< MultiAppCoordTransform > > _to_transforms
const std::shared_ptr< MultiApp > getFromMultiApp() const
Get the MultiApp to transfer data from.
MooseEnum _current_direction
registerMooseObject("MooseApp", MultiAppPostprocessorInterpolationTransfer)
Real _radius
Radius to consider for inverse interpolation.
const Parallel::Communicator & _communicator
MooseEnum _interp_type
Type of interpolation method.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Transfers from postprocessors in child apps of a MultiApp in different locations in parent app mesh...
unsigned int variable_number(std::string_view var) const
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
unsigned int number() const
void errorIfObjectExecutesOnTransferInSourceApp(const std::string &object_name) const
Error if executing this MooseObject on EXEC_TRANSFER in a source multiapp (from_multiapp, e.g.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
virtual void execute() override
Execute the transfer.
AuxVariableName _to_var_name
Variable in the main application to fill with the interpolation of the postprocessors.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
static libMesh::System * find_sys(libMesh::EquationSystems &es, const std::string &var_name)
Small helper function for finding the system containing the variable.
std::unique_ptr< NumericVector< Number > > solution
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
static InputParameters validParams()
Real _power
Exponent for power-law decrease of the interpolation coefficients.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for all MultiAppTransfer objects.
std::vector< std::unique_ptr< MultiAppCoordTransform > > _from_transforms
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
unsigned int _num_points
Number of points to consider for the interpolation.
virtual void set(const numeric_index_type i, const T value)=0
PostprocessorName _postprocessor
Postprocessor in the child apps to transfer the data from.
static InputParameters validParams()
MultiAppPostprocessorInterpolationTransfer(const InputParameters ¶meters)
void ErrorVector unsigned int
bool _nodal
Whether the target variable is nodal or elemental.