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 "AutomaticMortarGeneration.h" 13 : #include "MooseHashing.h" 14 : 15 : #include "libmesh/parallel_object.h" 16 : 17 : #include <unordered_map> 18 : #include <set> 19 : 20 : class SubProblem; 21 : class MortarExecutorInterface; 22 : 23 : class MortarData : public libMesh::ParallelObject 24 : { 25 : public: 26 : MortarData(const libMesh::ParallelObject & other); 27 : 28 : /** 29 : * Create mortar generation object 30 : * @param boundary_key The primary-secondary boundary pair on which the AMG objects lives 31 : * @param subdomain_key The primary-secondary subdomain pair on which the AMG objects lives 32 : * @param subproblem A reference to the subproblem 33 : * @param on_displaced Whether the AMG object lives on the displaced mesh 34 : * @param periodic Whether the AMG object will be used for enforcing periodic constraints. Note 35 : * that this changes the direction of the projection normals so one AMG object cannot be used to 36 : * enforce both periodic and non-periodic constraints 37 : * @param debug whether to output mortar segment mesh exodus file for debugging purposes 38 : * @param correct_edge_dropping edge dropping treatment selection 39 : * @param minimum_projection_angle minimum projection angle allowed for building mortar segment 40 : * mesh 41 : */ 42 : void createMortarInterface(const std::pair<BoundaryID, BoundaryID> & boundary_key, 43 : const std::pair<SubdomainID, SubdomainID> & subdomain_key, 44 : SubProblem & subproblem, 45 : bool on_displaced, 46 : bool periodic, 47 : const bool debug, 48 : const bool correct_edge_dropping, 49 : const Real minimum_projection_angle); 50 : 51 : /** 52 : * Getter to retrieve the AutomaticMortarGeneration object corresponding to the boundary and 53 : * subdomain keys. If the AutomaticMortarGeneration object does not yet exist, then we error 54 : */ 55 : const AutomaticMortarGeneration & 56 : getMortarInterface(const std::pair<BoundaryID, BoundaryID> & boundary_key, 57 : const std::pair<SubdomainID, SubdomainID> & /*subdomain_key*/, 58 : bool on_displaced) const; 59 : 60 : /** 61 : * Non-const getter to retrieve the AutomaticMortarGeneration object corresponding to the boundary 62 : * and subdomain keys. If the AutomaticMortarGeneration object does not yet exist, then we error 63 : */ 64 : AutomaticMortarGeneration & 65 : getMortarInterface(const std::pair<BoundaryID, BoundaryID> & boundary_key, 66 : const std::pair<SubdomainID, SubdomainID> & /*subdomain_key*/, 67 : bool on_displaced); 68 : 69 : /** 70 : * Return all automatic mortar generation objects on either the displaced or undisplaced mesh 71 : */ 72 : const std::unordered_map<std::pair<BoundaryID, BoundaryID>, AutomaticMortarGeneration> & 73 108677 : getMortarInterfaces(bool on_displaced) const 74 : { 75 108677 : if (on_displaced) 76 54333 : return _displaced_mortar_interfaces; 77 : else 78 54344 : return _mortar_interfaces; 79 : } 80 : 81 : /** 82 : * Returns the mortar covered subdomains 83 : */ 84 55939 : const std::set<SubdomainID> & getMortarSubdomainIDs() const { return _mortar_subdomain_coverage; } 85 : 86 : /** 87 : * Returns the mortar covered boundaries 88 : */ 89 : const std::set<BoundaryID> & getMortarBoundaryIDs() const { return _mortar_boundary_coverage; } 90 : 91 : /** 92 : * Builds mortar segment meshes for each mortar interface 93 : */ 94 : void update(); 95 : 96 : /** 97 : * Returns whether any of the AutomaticMortarGeneration objects are running on a displaced mesh 98 : */ 99 130466 : bool hasDisplacedObjects() const { return _displaced_mortar_interfaces.size(); } 100 : 101 : /** 102 : * Returns whether we have **any** active AutomaticMortarGeneration objects 103 : */ 104 61047 : bool hasObjects() const { return _mortar_interfaces.size(); } 105 : 106 : /** 107 : * Returns the higher dimensional subdomain ids of the interior parents of the given lower-d 108 : * subdomain id 109 : */ 110 : const std::set<SubdomainID> & getHigherDimSubdomainIDs(SubdomainID lower_d_subdomain_id) const; 111 : 112 : /** 113 : * \em Adds \p mei to the container of objects that will have their \p mortarSetup method called 114 : * as soon as the mortar mesh has been generated for the first time 115 : */ 116 : void notifyWhenMortarSetup(MortarExecutorInterface * mei); 117 : 118 : /** 119 : * \em Removes \p mei from the container of objects that will have their \p mortarSetup method 120 : * called as soon as the mortar mesh has been generated for the first time 121 : */ 122 : void dontNotifyWhenMortarSetup(MortarExecutorInterface * mei); 123 : 124 : /** 125 : * @return whether we have performed an initial mortar mesh construction 126 : */ 127 56104 : bool initialized() const { return _mortar_initd; } 128 : 129 : private: 130 : /** 131 : * Builds mortar segment mesh from specific AutomaticMortarGeneration object 132 : */ 133 : void update(AutomaticMortarGeneration & amg); 134 : 135 : typedef std::pair<BoundaryID, BoundaryID> MortarKey; 136 : 137 : /// Map from primary-secondary (in that order) boundary ID pair to the corresponding 138 : /// undisplaced AutomaticMortarGeneration object 139 : std::unordered_map<MortarKey, AutomaticMortarGeneration> _mortar_interfaces; 140 : 141 : /// Map from primary-secondary (in that order) boundary ID pair to the corresponding 142 : /// displaced AutomaticMortarGeneration object 143 : std::unordered_map<MortarKey, AutomaticMortarGeneration> _displaced_mortar_interfaces; 144 : 145 : /// A set containing the subdomain ids covered by all the mortar interfaces in this MortarData 146 : /// object 147 : std::set<SubdomainID> _mortar_subdomain_coverage; 148 : 149 : /// A set containing the boundary ids covered by all the mortar interfaces in this MortarData 150 : /// object 151 : std::set<BoundaryID> _mortar_boundary_coverage; 152 : 153 : /// Map from undisplaced AMG key to whether the undisplaced AMG object is enforcing periodic constraints 154 : std::unordered_map<MortarKey, bool> _periodic_map; 155 : 156 : /// Map from displaced AMG key to whether the displaced AMG object is enforcing periodic constraints 157 : std::unordered_map<MortarKey, bool> _displaced_periodic_map; 158 : 159 : /// Map from undisplaced AMG key to whether the undisplaced AMG object is to output mortar segment mesh 160 : std::unordered_map<MortarKey, bool> _debug_flag_map; 161 : 162 : /// Map from displaced AMG key to whether the displaced AMG object is to output mortar segment mesh 163 : std::unordered_map<MortarKey, bool> _displaced_debug_flag_map; 164 : 165 : /// Map from lower dimensional subdomain ids to corresponding higher simensional subdomain ids 166 : /// (e.g. the ids of the interior parents) 167 : std::unordered_map<SubdomainID, std::set<SubdomainID>> _lower_d_sub_to_higher_d_subs; 168 : 169 : /// A container of objects for whom the \p mortarSetup method will be called after the mortar mesh 170 : /// has been setup for the first time 171 : std::set<MortarExecutorInterface *> _mei_objs; 172 : 173 : /// Whether we have performed any mortar mesh construction 174 : bool _mortar_initd; 175 : };