CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Inverse Distance Matrix Evaluation at the Boundary in an OpenFOAM Function

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 9, 2023, 03:29
Smile 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
khoder Alshaar is on a distinguished road
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());
}
My question is related to the last line of the function

Code:
    U.primitiveFieldRef() = inv(U.internalField());
Could you please explain to me what it does besides the fact that it calculates the inverse of a tensor? what is the function of primitiveFieldRef() and .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];
Thank you!
khoder Alshaar is offline   Reply With Quote

Reply

Tags
boundary conditions, gradient


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
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


All times are GMT -4. The time now is 23:41.