|
[Sponsors] |
Inverse Distance Matrix Evaluation at the Boundary in an OpenFOAM Function |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
Khoder Alshaar
Join Date: May 2021
Posts: 8
Rep Power: 5 ![]() |
Hello,
I'm using an opensource solver with OpenFOAM explicitSolidDynamics, which has the following function in gradientSchemes.C. The function calculates the Inverse Distance Matrix for each domain's owner and neighbor cell of each face: Code:
void gradientSchemes::distanceMatrix ( GeometricField<tensor, fvPatchField, volMesh>& U ) { //Loop through internal faces (finite volume faces within the computational domain): forAll(own_, faceID) { // Get the cell IDs of the owner and neighbor cells for the current face const label& ownCellID = own_[faceID]; const label& neiCellID = nei_[faceID]; // Calculate the vector from the owner cell to the neighbor cell const vector& dOwn = X_[neiCellID] - X_[ownCellID]; const vector& dNei = X_[ownCellID] - X_[neiCellID]; // Update the field U for the owner and neighbor cells with the outer product of the vectors U[ownCellID] += dOwn*dOwn; U[neiCellID] += dNei*dNei; } //Check if the simulation is running in parallel (i.e., multiple processors). if (Pstream::parRun()) { forAll(mesh_.boundary(), patchID) { if (mesh_.boundary()[patchID].coupled()) { vectorField X_nei = X_.boundaryField()[patchID].patchNeighbourField().ref(); forAll(mesh_.boundary()[patchID], facei) { const label& bCellID = mesh_.boundaryMesh()[patchID].faceCells()[facei]; const vector& d = X_nei[facei] - X_[bCellID]; U[bCellID] += d*d; } } } U.correctBoundaryConditions(); } //Compute the inverse of the internal field of `U` and assign it to the primitive field: U.primitiveFieldRef() = inv(U.internalField()); } Code:
U.primitiveFieldRef() = inv(U.internalField()); 2- I understand that a boundary face has only an owner cell and does not have a neighbor cell. In this case, how are these getting evaluated: Code:
const vector& dOwn = X_[neiCellID] - X_[ownCellID]; const vector& dNei = X_[ownCellID] - X_[neiCellID]; |
|
![]() |
![]() |
![]() |
Tags |
boundary cells, boundary faces, gradient, invers |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Table bounds warnings at: END OF TIME STEP | CFXer | CFX | 4 | July 16, 2020 23:44 |
OpenFOAM 4.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 2 | October 6, 2017 05:40 |
Error - Solar absorber - Solar Thermal Radiation | MichaelK | CFX | 12 | September 1, 2016 05:15 |
Basic Nozzle-Expander Design | karmavatar | CFX | 20 | March 20, 2016 08:44 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 07:00 |