13 #include <Eigen/Dense> 18 #include "libmesh/parallel_eigen.h" 25 MooseEnum orders(
"CONSTANT FIRST SECOND THIRD FOURTH");
27 "patch_polynomial_order",
29 "Polynomial order used in least squares fitting of material property " 30 "over the local patch of elements connected to a given node");
35 { rm_params.
set<
unsigned short>(
"layers") = 2; });
45 _patch_polynomial_order(
46 static_cast<unsigned
int>(getParam<
MooseEnum>(
"patch_polynomial_order"))),
48 _q(_multi_index.size())
54 const std::vector<dof_id_type> & elem_ids)
const 58 mooseError(
"There are not enough sample points to recover the nodal value, try reducing the " 59 "polynomial order or using a higher-order quadrature scheme.");
64 for (
auto elem_id : elem_ids)
66 A += libmesh_map_find(
_Ae, elem_id);
67 b += libmesh_map_find(
_be, elem_id);
87 for (
unsigned int c = 0; c <
_multi_index[r].size(); c++)
110 Ae += p * p.transpose();
123 _Ae.insert(npr._Ae.begin(), npr._Ae.end());
124 _be.insert(npr._be.begin(), npr._be.end());
135 std::unordered_map<processor_id_type, std::vector<dof_id_type>> query_ids;
137 for (
auto elem : evaluable_elem_range)
139 query_ids[elem->processor_id()].push_back(elem->id());
141 typedef std::pair<RealEigenMatrix, RealEigenVector> AbPair;
145 const std::vector<dof_id_type> & elem_ids,
146 std::vector<AbPair> & ab_pairs)
150 const auto elem_id = elem_ids[i];
151 ab_pairs.emplace_back(libmesh_map_find(
_Ae, elem_id), libmesh_map_find(
_be, elem_id));
157 const std::vector<dof_id_type> & elem_ids,
158 const std::vector<AbPair> & ab_pairs)
162 const auto elem_id = elem_ids[i];
163 const auto & [Ae, be] = ab_pairs[i];
169 libMesh::Parallel::pull_parallel_vector_data<AbPair>(
std::map< dof_id_type, RealEigenVector > _be
The element-level b vector.
static InputParameters validParams()
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
const MooseArray< Point > & _q_point
static InputParameters validParams()
std::map< dof_id_type, RealEigenMatrix > _Ae
The element-level A matrix.
RealEigenVector evaluateBasisFunctions(const Point &q_point) const
Compute the P vector at a given point i.e.
const Parallel::Communicator & _communicator
virtual Real nodalPatchRecovery(const Point &p, const std::vector< dof_id_type > &elem_ids) const
Solve the least-squares problem.
virtual void execute() override
Execute method.
uint8_t processor_id_type
unsigned int size() const
The number of elements that can currently be stored in the array.
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
NodalPatchRecoveryBase(const InputParameters ¶meters)
const std::vector< std::vector< unsigned int > > _multi_index
The multi-index table.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
R polynomial(const C &c, const T x)
Evaluate a polynomial with the coefficients c at x.
virtual Real computeValue()=0
Compute the quantity to recover using nodal patch recovery.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > RealEigenMatrix
virtual void finalize() override
Finalize.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
const Elem *const & _current_elem
The current element pointer (available during execute())
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
std::vector< std::vector< unsigned int > > multiIndex(unsigned int dim, unsigned int order)
generate a complete multi index table for given dimension and order i.e.
virtual void threadJoin(const UserObject &) override
Must override.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
const libMesh::ConstElemRange & getEvaluableElementRange()
In general, {evaluable elements} >= {local elements} U {algebraic ghosting elements}.
processor_id_type processor_id() const
const unsigned int _q
Number of basis functions.
void ErrorVector unsigned int
auto index_range(const T &sizable)
Base class for user-specific data.