dune-composites (2.5.1)

conbase_fork.hh
1#ifndef CONBASE_FORK_HH
2#define CONBASE_FORK_HH
3
4#include<dune/pdelab/boilerplate/pdelab.hh>
5
6namespace Dune {
7 namespace PDELab {
8
9 template<typename P, typename GFS, typename CG, bool isFunction>
10 struct ConstraintsAssemblerHelperExterior
11 {
13
27 static void
28 assemble(const P& p, const GFS& gfs, CG& cg, const bool verbose)
29 {
30 // get some types
31 using ES = typename GFS::Traits::EntitySet;
32 //using Element = typename ES::Traits::Element;
33 using Intersection = typename ES::Traits::Intersection;
34
35 ES es = gfs.entitySet();
36
37 // make local function space
38 using LFS = LocalFunctionSpace<GFS>;
39 LFS lfs_e(gfs);
40 LFSIndexCache<LFS> lfs_cache_e(lfs_e);
41 LFS lfs_f(gfs);
42 LFSIndexCache<LFS> lfs_cache_f(lfs_f);
43
44 // get index set
45 //auto& is = es.indexSet();
46
47 // loop once over the grid
48 for (const auto& element : elements(es))
49 {
50
51 //auto id = is.uniqueIndex(element);
52
53 // bind local function space to element
54 lfs_e.bind(element);
55
56 using CL = typename CG::LocalTransformation;
57
58 CL cl_self;
59
60 //using ElementWrapper = ElementGeometry<Element>;
61 using IntersectionWrapper = IntersectionGeometry<Intersection>;
62
63 //TypeTree::applyToTreePair(p,lfs_e,VolumeConstraints<ElementWrapper,CL>(ElementWrapper(element),cl_self));
64
65 // iterate over intersections and call metaprogram
66 unsigned int intersection_index = 0;
67 for (const auto& intersection : intersections(es,element))
68 {
69
70 auto intersection_data = classifyIntersection(es,intersection);
71 auto intersection_type = std::get<0>(intersection_data);
72 //auto& outside_element = std::get<1>(intersection_data);
73
74 switch (intersection_type) {
75
76 case IntersectionType::skeleton:
77 case IntersectionType::periodic:
78 {
79 /*auto idn = is.uniqueIndex(outside_element);
80
81 if(id > idn){
82 // bind local function space to element in neighbor
83 lfs_f.bind(outside_element);
84
85 CL cl_neighbor;
86
87 TypeTree::applyToTreePair(lfs_e,lfs_f,SkeletonConstraints<IntersectionWrapper,CL>(IntersectionWrapper(intersection,intersection_index),cl_self,cl_neighbor));
88
89 if (!cl_neighbor.empty())
90 {
91 lfs_cache_f.update();
92 cg.import_local_transformation(cl_neighbor,lfs_cache_f);
93 }
94
95 }*/
96 break;
97 }
98
99 case IntersectionType::boundary:
100 //if (intersection.boundary())
101 TypeTree::applyToTreePair(p,lfs_e,BoundaryConstraints<IntersectionWrapper,CL>(IntersectionWrapper(intersection,intersection_index),cl_self));
102 break;
103
104 case IntersectionType::processor:
105 //TypeTree::applyToTree(lfs_e,ProcessorConstraints<IntersectionWrapper,CL>(IntersectionWrapper(intersection,intersection_index),cl_self));
106 break;
107
108 }
109 ++intersection_index;
110 }
111
112 if (!cl_self.empty())
113 {
114 lfs_cache_e.update();
115 cg.import_local_transformation(cl_self,lfs_cache_e);
116 }
117
118 }
119
120 // print result
121 if(verbose){
122 std::cout << "constraints:" << std::endl;
123
124 std::cout << cg.size() << " constrained degrees of freedom" << std::endl;
125
126 for (const auto& col : cg)
127 {
128 std::cout << col.first << ": "; // col index
129 for (const auto& row : col.second)
130 std::cout << "(" << row.first << "," << row.second << ") "; // row index , value
131 std::cout << std::endl;
132 }
133 }
134 }
135 }; // end ConstraintsAssemblerHelper
136
137 /*template<typename GFS, typename CG>
138 void constraints_exterior(const GFS& gfs, CG& cg,
139 const bool verbose = false)
140 {
141 NoConstraintsParameters p;
142 ConstraintsAssemblerHelperExterior<NoConstraintsParameters, GFS, CG, false>::assemble(p,gfs,cg,verbose);
143 }*/
144 template<typename P, typename GFS, typename CG>
145 void constraints_exterior(const P& p, const GFS& gfs, CG& cg,
146 const bool verbose = false)
147 {
148 // clear global constraints
149 cg.clear();
150 ConstraintsAssemblerHelperExterior<P, GFS, CG, IsGridFunction<P>::value>::assemble(p,gfs,cg,verbose);
151 }
152
153 template<typename Grid, unsigned int degree, Dune::GeometryType::BasicType gt,typename BCType, typename GV = typename Grid::LeafGridView>
154 class CGCONBaseExterior//<Grid,degree,gt,MeshType::conforming,SolverCategory::overlapping,BCType,GV>
155 {
156 public:
157 typedef ConformingDirichletConstraints CON;
158
159 CGCONBaseExterior (Grid& grid, const BCType& bctype, const GV& gv)
160 {
161 conp = std::shared_ptr<CON>(new CON());
162 }
163
164 CGCONBaseExterior (Grid& grid, const BCType& bctype)
165 {
166 conp = std::shared_ptr<CON>(new CON());
167 }
168
169 template<typename GFS>
170 void postGFSHook (const GFS& gfs) {}
171 CON& getCON() {return *conp;}
172 const CON& getCON() const {return *conp;}
173 template<typename GFS, typename DOF>
174 void make_consistent (const GFS& gfs, DOF& x) const
175 {
176 // make vector consistent; this is needed for all overlapping solvers
177 istl::ParallelHelper<GFS> helper(gfs);
178 helper.maskForeignDOFs(Backend::native(x));
179 Dune::PDELab::AddDataHandle<GFS,DOF> adddh(gfs,x);
180 if (gfs.gridView().comm().size()>1)
181 gfs.gridView().communicate(adddh,Dune::InteriorBorder_All_Interface,Dune::ForwardCommunication);
182 }
183 private:
184 std::shared_ptr<CON> conp;
185 };
186 }
187}
188
189#endif
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Sep 5, 22:35, 2025)