|
[Sponsors] |
Inverse Distance Matrix Evaluation at the Boundary in an OpenFOAM Function |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 9, 2023, 04:29 |
Inverse Distance Matrix Evaluation at the Boundary in an OpenFOAM Function
|
#1 |
New Member
Khoder Alshaar
Join Date: May 2021
Posts: 8
Rep Power: 5 |
Hello,
I'm following an open-source toolkit in OpenFoam explicitSolidDynamics, which has the following function in gradientSchemes.C : This function takes a reference to a GeometricField, which represents the Inverse distance matrix. 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 rocessors). 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(); } U.primitiveFieldRef() = inv(U.internalField()); } Code:
U.primitiveFieldRef() = inv(U.internalField()); Also, what happens to the faces at the boundary? For example, a boundary face does not have a neighboring cell, only an owner cell. So how these are evaluated: Code:
const vector& dOwn = X_[neiCellID] - X_[ownCellID]; const vector& dNei = X_[ownCellID] - X_[neiCellID]; |
|
Tags |
boundary conditions, gradient |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Table bounds warnings at: END OF TIME STEP | CFXer | CFX | 4 | July 17, 2020 00:44 |
OpenFOAM 4.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 2 | October 6, 2017 06:40 |
Error - Solar absorber - Solar Thermal Radiation | MichaelK | CFX | 12 | September 1, 2016 06:15 |
Basic Nozzle-Expander Design | karmavatar | CFX | 20 | March 20, 2016 09:44 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |