Line data Source code
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 : 12 : #include "MooseMesh.h" 13 : #include "MooseApp.h" 14 : 15 : #include "libmesh/point.h" 16 : 17 : /** 18 : * Peridynamics mesh class 19 : */ 20 : class PeridynamicsMesh : public MooseMesh 21 : { 22 : public: 23 : static InputParameters validParams(); 24 : 25 : PeridynamicsMesh(const InputParameters & parameters); 26 248 : PeridynamicsMesh(const PeridynamicsMesh & /* other_mesh */) = default; 27 : 28 : PeridynamicsMesh & operator=(const PeridynamicsMesh & other_mesh) = delete; 29 : virtual std::unique_ptr<MooseMesh> safeClone() const override; 30 : virtual void buildMesh() override; 31 : virtual unsigned int dimension() const override; 32 : 33 : /** 34 : * Function to return number of PD nodes 35 : * @return Total number of PD nodes 36 : */ 37 : dof_id_type nPDNodes() const; 38 : 39 : /** 40 : * Function to return number of PD Edge elements 41 : * @return Total number of PD bonds 42 : */ 43 : dof_id_type nPDBonds() const; 44 : 45 : /** 46 : * Function to assign values to member variables (PD mesh data) of this class 47 : * this function will be called in the PD mesh generator class 48 : * @param fe_mesh The finite element mesh based on which the peridynamics mesh will be created 49 : * @param converted_elem_id The IDs of finite elements to be converted to peridynamics mesh 50 : */ 51 : void createPeridynamicsMeshData(MeshBase & fe_mesh, 52 : std::set<dof_id_type> converted_elem_id, 53 : std::multimap<SubdomainID, SubdomainID> bonding_block_pairs, 54 : std::multimap<SubdomainID, SubdomainID> non_bonding_block_pairs); 55 : 56 : /** 57 : * Function to return neighbor nodes indices for node node_id 58 : * @param node_id The querying node index 59 : * @return List of neighbor IDs 60 : */ 61 : std::vector<dof_id_type> getNeighbors(dof_id_type node_id); 62 : 63 : /** 64 : * Function to return the local neighbor index of node_j from node_i's neighbor list 65 : * @param node_i The ID of the node providing the neighbor list for query 66 : * @param node_j The ID of the node querying the neighbor index 67 : * @return The local index in the neighbor list 68 : */ 69 : dof_id_type getNeighborIndex(dof_id_type node_i, dof_id_type node_j); 70 : 71 : /** 72 : * Function to return the bond number connected with node node_id 73 : * @param node_id The querying node index 74 : * @return List of associated bond IDs 75 : */ 76 : std::vector<dof_id_type> getBonds(dof_id_type node_id); 77 : 78 : /** 79 : * Function to return indices of neighbors used in formulation of bond-associated 80 : * deformation gradient for bond connecting node_id and neighbor_id 81 : * @param node_id The ID of the node providing the neighbor list 82 : * @param neighbor_id The ID of the node querying the neighbor list 83 : * @return The neighbor list for calculation of bond-associated deformation gradient for the 84 : * neighbor 85 : */ 86 : std::vector<dof_id_type> getBondDeformationGradientNeighbors(dof_id_type node_id, 87 : dof_id_type neighbor_id); 88 : 89 : /** 90 : * Function to return block ID for node node_id 91 : * @param node_id The querying node index 92 : * @return The block ID of a node 93 : */ 94 : SubdomainID getNodeBlockID(dof_id_type node_id); 95 : 96 : /** 97 : * Function to set block ID for all PD nodes 98 : * @param id The subdomain ID for all PD nodes 99 : */ 100 : void setNodeBlockID(SubdomainID id); 101 : 102 : /** 103 : * Function to return coordinates for node node_id 104 : * @param node_id The querying node index 105 : * @return The coordinates of a node 106 : */ 107 : Point getNodeCoord(dof_id_type node_id); 108 : 109 : /** 110 : * Function to return the correspondence between PD node IDs and FE element IDs 111 : * @return The coordinates of a node 112 : */ 113 : std::vector<dof_id_type> getPDNodeIDToFEElemIDMap(); 114 : 115 : /** 116 : * Function to return nodal volume for node node_id 117 : * @param node_id The querying node index 118 : * @return The volume of a node 119 : */ 120 : Real getNodeVolume(dof_id_type node_id); 121 : 122 : /** 123 : * Function to return summation of neighbor nodal volumes for node node_id 124 : * @param node_id The querying node index 125 : * @return The summation of the volume of all the neighbors 126 : */ 127 : Real getHorizonVolume(dof_id_type node_id); 128 : 129 : /** 130 : * Function to return the volume of a horizon subset for bond-associated deformation gradient 131 : * calculation for bond connecting node node_id and its neighbor neighbor_id 132 : * @param node_id The ID of the node 133 : * @param neighbor_id The ID of the querying neighbor in the list of node node_id 134 : * @return The horizon subset volume 135 : */ 136 : Real getHorizonSubsetVolume(dof_id_type node_id, dof_id_type neighbor_id); 137 : 138 : /** 139 : * Function to return the summation of all horizon subset volumes for node node_id 140 : * @param node_id The querying node index 141 : * @return The summation of all horizon subset volumes 142 : */ 143 : Real getHorizonSubsetVolumeSum(dof_id_type node_id); 144 : 145 : /** 146 : * Function to return the volume fraction of a horizon subset used for bond-associated deformation 147 : * gradient calculation for bond connecting node node_id and its neighbor neighbor_id 148 : * @param node_id The ID of the node 149 : * @param neighbor_id The ID of the querying neighbor in the list of node node_id 150 : * @return The horizon subset volume fraction for neighbor neighbor_id of node node_id 151 : */ 152 : Real getHorizonSubsetVolumeFraction(dof_id_type node_id, dof_id_type neighbor_id); 153 : 154 : /** 155 : * Function to return the average spacing between node node_id with its most adjacent neighbors 156 : * @param node_id The querying node index 157 : * @return The node average spacing 158 : */ 159 : Real getNodeAverageSpacing(dof_id_type node_id); 160 : 161 : /** 162 : * Function to return horizon size 163 : * @param node_id The querying node index 164 : * @return The horizon radius 165 : */ 166 : Real getHorizon(dof_id_type node_id); 167 : 168 : /** 169 : * Function to return offset for boundary nodes 170 : * @param node_id The querying node index 171 : * @return The offset 172 : */ 173 : Real getBoundaryOffset(dof_id_type node_id); 174 : 175 : /** 176 : * Function to return normalized weight for neighbor neighbor_id of node node_id based on 177 : * predefined weight function 178 : * @param node_id The ID of the node 179 : * @param neighbor_id The ID of the querying neighbor in the list of node node_id 180 : * @return The normalized weight for neighbor neighbor_id of node node_id 181 : */ 182 : Real getNeighborWeight(dof_id_type node_id, dof_id_type neighbor_id); 183 : 184 : protected: 185 : ///@{ Horizon size control parameters 186 : const Real _horizon_radius; 187 : const bool _has_horizon_number; 188 : const Real _horizon_number; 189 : const Real _bah_ratio; 190 : ///@} 191 : 192 : ///@{ Information for crack generation 193 : const bool _has_cracks; 194 : std::vector<Point> _cracks_start; 195 : std::vector<Point> _cracks_end; 196 : std::vector<Real> _cracks_width; 197 : ///@} 198 : 199 : /// Mesh dimension 200 : unsigned int & _dim; 201 : 202 : /// Number of total material points 203 : unsigned int & _n_pdnodes; 204 : 205 : /// Number of total bonds 206 : unsigned int & _n_pdbonds; 207 : 208 : ///@{ Data associated with each peridynamics node 209 : std::vector<Point> _pdnode_coord; 210 : std::vector<Real> & _pdnode_average_spacing; 211 : std::vector<Real> & _pdnode_horizon_radius; 212 : std::vector<Real> & _pdnode_vol; 213 : std::vector<Real> & _pdnode_horizon_vol; 214 : std::vector<SubdomainID> & _pdnode_blockID; 215 : std::vector<dof_id_type> & _pdnode_elemID; 216 : ///@} 217 : 218 : /// Neighbor lists for each material point determined using the horizon 219 : std::vector<std::vector<dof_id_type>> & _pdnode_neighbors; 220 : 221 : /// Bond lists associated with material points 222 : std::vector<std::vector<dof_id_type>> & _pdnode_bonds; 223 : 224 : /// Neighbor lists for deformation gradient calculation using bond-associated horizon 225 : std::vector<std::vector<std::vector<dof_id_type>>> & _dg_neighbors; 226 : 227 : /// Volume of horizon subsets for bond-associated deformation gradients at a node 228 : std::vector<std::vector<Real>> & _pdnode_sub_vol; 229 : 230 : /// Summation of volumes of all horizon subsets at a node 231 : std::vector<Real> & _pdnode_sub_vol_sum; 232 : 233 : /// Offset of each boundary node to its original FE element boundary edge or face 234 : std::map<dof_id_type, Real> & _boundary_node_offset; 235 : 236 : /// normalizer for calculating weighted values at a node from elemental values within its horizon 237 : std::vector<Real> & _pdnode_weight_normalizer; 238 : 239 : /** 240 : * Function to create neighbors and other data for each material point with given horizon 241 : * @param bonding_block_pairs ID pairs of blocks to be connected via interfacial bonds 242 : * @param non_bonding_block_pairs ID pairs of blocks not to be connected 243 : */ 244 : void createNodeHorizBasedData(std::multimap<SubdomainID, SubdomainID> bonding_block_pairs, 245 : std::multimap<SubdomainID, SubdomainID> non_bonding_block_pairs); 246 : 247 : /** 248 : * Function to check existence of interface between two blocks 249 : * @param blockID_i & blockID_j IDs of two querying blocks 250 : * @param blockID_pairs ID pairs of neighboring blocks 251 : */ 252 : bool checkInterface(SubdomainID pdnode_blockID_i, 253 : SubdomainID pdnode_blockID_j, 254 : std::multimap<SubdomainID, SubdomainID> blockID_pairs); 255 : 256 : /** 257 : * Function to create node neighbors and other data for each material point based on 258 : * NEIGHBOR_HORIZON based horizon partition for deformation gradient calculation 259 : */ 260 : void createNeighborHorizonBasedData(); 261 : 262 : /** 263 : * Function to check whether a material point falls within a given rectangular crack geometry 264 : * @param point The querying point 265 : * @param rec_p1 The center of one edge of a rectangle 266 : * @param rec_p2 The center of the opposite edge of the retangle 267 : * @param rec_height The distance between the rest two edges of the rectangle 268 : * @param tol Acceptable tolerence 269 : * @return Whether the given point is within the given rectangule 270 : */ 271 : bool 272 : checkPointInsideRectangle(Point point, Point rec_p1, Point rec_p2, Real rec_height, Real tol = 0); 273 : 274 : /** 275 : * Function to check whether a bond crosses crack surface 276 : * @param crack_p1 Crack starting point 277 : * @param crack_p2 Crack ending point 278 : * @param crack_width Crack width 279 : * @param bond_p1 Bond starting point 280 : * @param bond_p2 Bond ending point 281 : * @return Whether the given bond crosses the given crack surface 282 : */ 283 : bool checkCrackIntersectBond( 284 : Point crack_p1, Point crack_p2, Real crack_width, Point bond_p1, Point bond_p2); 285 : 286 : /** 287 : * Function to check whether a segment crosses another segment 288 : * @param seg1_p1 The starting point of segment 1 289 : * @param seg1_p2 The ending point of segment 1 290 : * @param seg2_p1 The starting point of segment 2 291 : * @param seg2_p2 The ending point of segment 2 292 : * @return Whether the given segements cross each other 293 : */ 294 : bool checkSegmentIntersectSegment(Point seg1_p1, Point seg1_p2, Point seg2_p1, Point seg2_p2); 295 : };