101 std::cout <<
"Update static wall properties. ";
106 wallDistance_.resize(this->gridGeometry().elementMapper().size(), std::numeric_limits<Scalar>::max());
107 neighborIdx_.resize(this->gridGeometry().elementMapper().size());
108 cellCenter_.resize(this->gridGeometry().elementMapper().size(), GlobalPosition(0.0));
109 velocity_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0));
110 velocityMaximum_.resize(this->gridGeometry().elementMapper().size(), DimVector(0.0));
111 velocityGradients_.resize(this->gridGeometry().elementMapper().size(), DimMatrix(0.0));
114 flowNormalAxis_.resize(this->gridGeometry().elementMapper().size(), 0);
115 wallNormalAxis_.resize(this->gridGeometry().elementMapper().size(), 1);
120 std::vector<unsigned int> wallElements;
121 std::vector<GlobalPosition> wallPositions;
122 std::vector<unsigned int> wallNormalAxisTemp;
124 const auto gridView = this->gridGeometry().gridView();
125 auto fvGeometry =
localView(this->gridGeometry());
127 for (
const auto& element : elements(gridView))
129 fvGeometry.bindElement(element);
130 for (
const auto& scvf : scvfs(fvGeometry))
133 if (!scvf.boundary())
138 wallElements.push_back(this->gridGeometry().elementMapper().index(element));
139 wallPositions.push_back(scvf.center());
140 wallNormalAxisTemp.push_back(scvf.directionIndex());
144 std::cout <<
"NumWallIntersections=" << wallPositions.size() << std::endl;
145 if (wallPositions.size() == 0)
146 DUNE_THROW(Dune::InvalidStateException,
147 "No wall intersections have been found. Make sure that the isOnWall(globalPos) is working properly.");
151 for (
const auto& element : elements(gridView))
153 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
154 cellCenter_[elementIdx] = element.geometry().center();
155 for (
unsigned int i = 0; i < wallPositions.size(); ++i)
157 static const int problemWallNormalAxis
159 int searchAxis = problemWallNormalAxis;
162 if (problemWallNormalAxis < 0 || problemWallNormalAxis >= dim)
164 searchAxis = wallNormalAxisTemp[i];
167 GlobalPosition global = element.geometry().center();
168 global -= wallPositions[i];
171 && abs(global[searchAxis]) < global.two_norm() + 1e-8
172 && abs(global[searchAxis]) > global.two_norm() - 1e-8)
183 for (
const auto& element : elements(gridView))
185 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
186 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
192 for (
const auto& intersection : intersections(gridView, element))
194 if (intersection.boundary())
197 unsigned int neighborIdx = this->gridGeometry().elementMapper().index(intersection.outside());
198 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
230 std::cout <<
"Update dynamic wall properties." << std::endl;
232 DUNE_THROW(Dune::InvalidStateException,
233 "You have to call updateStaticWallProperties() once before you call updateDynamicWallProperties().");
235 static const int flowNormalAxis
239 velocityMaximum_.assign(this->gridGeometry().elementMapper().size(), DimVector(1e-16));
240 velocityMinimum_.assign(this->gridGeometry().elementMapper().size(), DimVector(std::numeric_limits<Scalar>::max()));
243 for (
const auto& element : elements(this->gridGeometry().gridView()))
245 auto fvGeometry =
localView(this->gridGeometry());
246 fvGeometry.bindElement(element);
247 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
250 DimVector velocityTemp(0.0);
251 for (
auto&& scvf : scvfs(fvGeometry))
253 const int dofIdxFace = scvf.dofIndex();
254 const auto numericalSolutionFace = curSol[GridGeometry::faceIdx()][dofIdxFace][Indices::velocity(scvf.directionIndex())];
255 velocityTemp[scvf.directionIndex()] += numericalSolutionFace;
257 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
258 velocity_[elementIdx][dimIdx] = velocityTemp[dimIdx] * 0.5;
262 for (
const auto& element : elements(this->gridGeometry().gridView()))
264 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
267 Scalar maxVelocity = 0.0;
268 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
270 for (
unsigned int velIdx = 0; velIdx < dim; ++velIdx)
291 if (0 <= flowNormalAxis && flowNormalAxis < dim)
295 else if (abs(maxVelocity) < abs(
velocity_[elementIdx][dimIdx]))
297 maxVelocity = abs(
velocity_[elementIdx][dimIdx]);
302 auto fvGeometry =
localView(this->gridGeometry());
303 fvGeometry.bindElement(element);
304 for (
auto&& scvf : scvfs(fvGeometry))
307 unsigned int scvfNormDim = scvf.directionIndex();
310 for (
unsigned int velIdx = 0; velIdx < dim; ++velIdx)
312 if (!asImp_().boundaryTypes(element, scvf).isDirichlet(Indices::velocity(velIdx)))
315 Scalar dirichletVelocity = asImp_().dirichlet(element, scvf)[Indices::velocity(velIdx)];
317 unsigned int neighborIdx =
neighborIdx_[elementIdx][scvfNormDim][0];
318 if (scvf.center()[scvfNormDim] <
cellCenter_[elementIdx][scvfNormDim])
322 = (
velocity_[neighborIdx][velIdx] - dirichletVelocity)
323 / (
cellCenter_[neighborIdx][scvfNormDim] - scvf.center()[scvfNormDim]);
328 std::vector<int> bjsNumFaces(dim, 0);
329 std::vector<unsigned int> bjsNeighbor(dim, 0);
330 DimVector bjsVelocityAverage(0.0);
331 DimVector normalNormCoordinate(0.0);
332 unsigned int velIdx = Indices::velocity(scvfNormDim);
333 const int numSubFaces = scvf.pairData().size();
334 for(
int localSubFaceIdx = 0; localSubFaceIdx < numSubFaces; ++localSubFaceIdx)
336 const auto& lateralFace = fvGeometry.scvf(scvf.insideScvIdx(), scvf.pairData()[localSubFaceIdx].localLateralFaceIdx);
339 unsigned int normalNormDim = lateralFace.directionIndex();
340 if (lateralFace.boundary() && (asImp_().boundaryTypes(element, lateralFace).isBeaversJoseph(Indices::velocity(velIdx))))
342 unsigned int neighborIdx =
neighborIdx_[elementIdx][normalNormDim][0];
343 if (lateralFace.center()[normalNormDim] <
cellCenter_[elementIdx][normalNormDim])
344 neighborIdx =
neighborIdx_[elementIdx][normalNormDim][1];
346 const SubControlVolume& scv = fvGeometry.scv(scvf.insideScvIdx());
348 if (bjsNumFaces[normalNormDim] > 0 && neighborIdx != bjsNeighbor[normalNormDim])
349 DUNE_THROW(Dune::InvalidStateException,
"Two different neighborIdx should not occur");
350 bjsNeighbor[normalNormDim] = neighborIdx;
351 normalNormCoordinate[normalNormDim] = lateralFace.center()[normalNormDim];
352 bjsNumFaces[normalNormDim]++;
355 for (
unsigned dirIdx = 0; dirIdx < dim; ++dirIdx)
357 if (bjsNumFaces[dirIdx] == 0)
360 unsigned int neighborIdx = bjsNeighbor[dirIdx];
361 bjsVelocityAverage[dirIdx] /= bjsNumFaces[dirIdx];
364 = (
velocity_[neighborIdx][velIdx] - bjsVelocityAverage[dirIdx])
365 / (
cellCenter_[neighborIdx][dirIdx] - normalNormCoordinate[dirIdx]);
372 for (
const auto& element : elements(this->gridGeometry().gridView()))
374 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
376 Dune::FieldMatrix<Scalar, GridView::dimension, GridView::dimension> stressTensor(0.0);
377 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
379 for (
unsigned int velIdx = 0; velIdx < dim; ++velIdx)
386 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
388 for (
unsigned int velIdx = 0; velIdx < dim; ++velIdx)
394 Dune::FieldMatrix<Scalar, GridView::dimension, GridView::dimension> vorticityTensor(0.0);
395 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
397 for (
unsigned int velIdx = 0; velIdx < dim; ++velIdx)
399 vorticityTensor[dimIdx][velIdx] = 0.5 *
velocityGradients_[elementIdx][dimIdx][velIdx]
404 for (
unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
406 for (
unsigned int velIdx = 0; velIdx < dim; ++velIdx)
412 auto fvGeometry =
localView(this->gridGeometry());
413 fvGeometry.bindElement(element);
414 for (
auto&& scv : scvs(fvGeometry))
416 const int dofIdx = scv.dofIndex();
419 const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx];
423 VolumeVariables volVars;
424 volVars.update(elemSol, asImp_(), element, scv);