Line data Source code
1 : #pragma once 2 : 3 : #include "GeneralUserObject.h" 4 : 5 : class AuxiliarySystem; 6 : 7 : /* Base class for clustering in cardinal. */ 8 : class ClusteringUserObjectBase : public GeneralUserObject 9 : { 10 : 11 : public: 12 : static InputParameters validParams(); 13 : ClusteringUserObjectBase(const InputParameters & parameters); 14 : 15 30 : virtual void execute() override {}; 16 : virtual void initialize() override; 17 36 : virtual void finalize() override {}; 18 : 19 : /** 20 : * A purely virtual function which must be overridden in derived classes. 21 : * It applies the clustering logic for two elements in the derived class 22 : * @param[in] base_element the current element 23 : * @param[in] neighbor_elem the current neighbour of base_element 24 : * @return whether the two elements should be added to a cluster or not 25 : */ 26 : virtual bool evaluate(libMesh::Elem * base_element, libMesh::Elem * neighbor_elem) const = 0; 27 : 28 : protected: 29 : /** 30 : * Get the metric data from the auxiliary system for an element. 31 : * @param[in] elem 32 : * @return value of the _metric_variable 33 : */ 34 : Real getMetricData(const libMesh::Elem * elem) const; 35 : 36 : /// Mesh reference 37 : libMesh::MeshBase & _mesh; 38 : 39 : /// Name of the metric variable based on which clustering is done 40 : const AuxVariableName _metric_variable_name; 41 : 42 : /// Metric variable 43 : const MooseVariableBase & _metric_variable; 44 : 45 : /// AuxiliarySystem reference 46 : AuxiliarySystem & _auxiliary_system; 47 : 48 : /// DOF map 49 : const libMesh::DofMap & _dof_map; 50 : 51 : /// Metric variable index 52 : const unsigned int _metric_variable_index; 53 : 54 : /// libmesh numeric vector with serialized solutions 55 : NumericVector<Real> & _serialized_metric_solution; 56 : };