17 MooseEnum orders(
"CONSTANT FIRST SECOND THIRD FOURTH");
20 "Polynomial order used in least squares fitting of material property " 21 "over the local patch of elements connected to a given node");
33 _patch_polynomial_order(
34 isParamValid(
"patch_polynomial_order")
35 ? static_cast<unsigned
int>(getParam<
MooseEnum>(
"patch_polynomial_order"))
36 : static_cast<unsigned
int>(_var.order())),
38 _multi_index(
multiIndex(_mesh.dimension(), _patch_polynomial_order))
43 mooseWarning(
"Specified 'patch_polynomial_order' is lower than the AuxVariable's order");
50 meshhelper.allow_renumbering(
false);
51 for (
const auto & elem :
52 as_range(meshhelper.semilocal_elements_begin(), meshhelper.semilocal_elements_end()))
57 std::vector<std::vector<unsigned int>>
60 std::vector<std::vector<unsigned int>> n_choose_k;
61 std::vector<unsigned int> row;
62 std::string bitmask(K, 1);
69 for (
unsigned int i = 0; i <
N; ++i)
73 n_choose_k.push_back(row);
74 }
while (std::prev_permutation(bitmask.begin(), bitmask.end()));
79 std::vector<std::vector<unsigned int>>
83 std::vector<std::vector<unsigned int>> multi_index;
84 std::vector<std::vector<unsigned int>> n_choose_k;
85 std::vector<unsigned int> row(
dim, 0);
86 multi_index.push_back(row);
89 for (
unsigned int q = 1; q <= order; q++)
92 multi_index.push_back(row);
95 for (
unsigned int q = 1; q <= order; q++)
98 for (
unsigned int r = 0; r < n_choose_k.size(); r++)
101 for (
unsigned int c = 1; c < n_choose_k[0].size(); c++)
102 row.push_back(n_choose_k[r][c] - n_choose_k[r][c - 1] - 1);
103 multi_index.push_back(row);
118 for (
unsigned int c = 0; c <
_multi_index[0].size(); c++)
150 std::unordered_set<unsigned int> needed_mat_props;
152 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
168 mooseError(
"The nodal patch recovery option, which calculates the Zienkiewicz-Zhu patch " 169 "recovery for nodal variables (family = LAGRANGE), is not currently implemented for " 170 "parallel runs. Run in serial if you must use the nodal patch capability");
176 const std::map<dof_id_type, std::vector<dof_id_type>> & node_to_elem_map =
_mesh.
nodeToElemMap();
177 auto node_to_elem_pair = node_to_elem_map.find(
_current_node->id());
178 mooseAssert(node_to_elem_pair != node_to_elem_map.end(),
"Missing entry in node to elem map");
179 std::vector<dof_id_type> elem_ids = node_to_elem_pair->second;
182 if (elem_ids.size() == 1)
185 for (
auto & n :
_mesh.
elemPtr(elem_id)->node_ref_range())
187 node_to_elem_pair = node_to_elem_map.find(n.id());
188 std::vector<dof_id_type> elem_ids_candidate = node_to_elem_pair->second;
189 if (elem_ids_candidate.size() > elem_ids.size())
190 elem_ids = elem_ids_candidate;
196 mooseError(
"There are not enough sample points to recover the nodal value, try reducing the " 197 "polynomial order or using a higher-order quadrature scheme.");
200 for (
auto elem_id : elem_ids)
237 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
NodalPatchRecovery(const InputParameters ¶meters)
void setActiveMaterialProperties(const std::unordered_set< unsigned int > &mat_prop_ids, const THREAD_ID tid)
Record and set the material properties required by the current computing thread.
virtual void addGhostedElem(dof_id_type elem_id) override
Will make sure that all dofs connected to elem_id are ghosted to this processor.
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseVector< T3 > &vec)
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
virtual Elem * elemPtr(const dof_id_type i)
MooseMesh & _mesh
Mesh this kernel is active on.
virtual void setNodalValue(const OutputType &value, unsigned int idx=0)=0
const Node *const & _current_node
Current node (valid only for nodal kernels)
void resize(const unsigned int n)
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
const Parallel::Communicator & _communicator
void clearActiveMaterialProperties(const THREAD_ID tid)
Clear the active material properties.
virtual const dof_id_type & nodalDofIndex() const =0
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
FEProblemBase & _fe_problem
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
void outer_product(const DenseVector< Number > &a, const DenseVector< Number > &b)
virtual 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 compute()
Computes the value and stores it in the solution vector.
processor_id_type size() const
unsigned int size() const
The number of elements that can currently be stored in the array.
virtual Real computeValue()=0
Compute and return the value of the aux variable.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
virtual void accumulateBVector(Real val)
calculate the patch load vector as ^n P^Tval where n is the number of quadrature points in the elemen...
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrix< T3 > &mat)
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 void compute() override
solve the equation Ac = B where c is the coefficients vector from least square fitting nodal value is...
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
NumericVector< Number > & _solution
reference to the solution vector of auxiliary system
CompareTypes< Number, T2 >::supertype dot(const DenseVector< T2 > &vec) const
virtual void swapBackMaterials(const THREAD_ID tid)
static InputParameters validParams()
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void reinitMaterials(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
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.
void resize(const unsigned int new_m, const unsigned int new_n)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
unsigned int _qp
Quadrature point index.
static InputParameters validParams()
const unsigned int _patch_polynomial_order
polynomial order, default is variable order
virtual void set(const numeric_index_type i, const Number value)=0
virtual void accumulateAMatrix()
Calculate the patch stiffness matrix as ^n P^TP where n is the number of quadrature points in the ele...
const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
virtual void reinitPatch()
reserve space for A, B, P, and prepare required material properties
processor_id_type processor_id() const
const MooseArray< Point > & _q_point
Active quadrature points.
std::vector< std::vector< unsigned int > > _multi_index
virtual void computePVector(Point q_point)
compute the P vector at given point i.e.
void svd_solve(const DenseVector< Number > &rhs, DenseVector< Number > &x, Real rcond=std::numeric_limits< Real >::epsilon()) const
void ErrorVector unsigned int
bool isNodal() const
Nodal or elemental kernel?
virtual std::vector< std::vector< unsigned int > > nChooseK(unsigned int N, unsigned int K)
Find out how many different ways you can choose K items from N items set without repetition and witho...
const std::map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected...
The "SwapBackSentinel" class's destructor guarantees that FEProblemBase::swapBackMaterials{Face,Neighbor}() is called even when an exception is thrown from FEProblemBase::reinitMaterials{Face,Neighbor}.
DenseVector< Number > _coef