-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
430 changed files
with
139,268 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .fvc import * | ||
from .fvc import * | ||
from .operators import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from .grad import * | ||
from .interpolate import * | ||
from .interpolate import * | ||
from .interpolateGrad import * | ||
from .interpolateCellGrad import * | ||
from .div import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
""" | ||
_____ _____ _____ _____ _____ _____ | High-order Python FOAM | ||
| | |___| _ |_ _| __| | _ | | | Python Version: 3.10 | ||
| | . | __| | | __| | | | | | | | Code Version: 0.0 | ||
|__|__|___|__| |_ |__| |_____|__|__|_|_|_| | License: GPLv3 | ||
|___| | ||
Description | ||
Explicit calculation of gradient at cell centres | ||
""" | ||
__author__ = 'Ivan Batistić & Philip Cardiff' | ||
__email__ = 'ibatistic@fsb.hr, philip.cardiff@ucd.ie' | ||
__all__ = ['div'] | ||
|
||
|
||
import os | ||
from src.foam.foamFileParser import * | ||
from petsc4py import PETSc | ||
from src.finiteVolume.fvMatrices.fvc.operators.interpolate import interpolate | ||
|
||
ADD = PETSc.InsertMode.ADD_VALUES | ||
|
||
class div(): | ||
|
||
@classmethod | ||
def construct(self, GaussPointsValues, gamma, cellPsi): | ||
|
||
mesh = cellPsi._mesh | ||
nCells = mesh.nCells | ||
|
||
# Read PETSc options file | ||
OptDB = PETSc.Options() | ||
|
||
# Create empty left left-hand side matrix | ||
A = PETSc.Mat() | ||
A.create(comm=PETSc.COMM_WORLD) | ||
A.setSizes((nCells, nCells)) | ||
A.setType(PETSc.Mat.Type.AIJ) | ||
A.setUp() | ||
|
||
# Create solution vector | ||
source = A.createVecLeft() | ||
source.set(0.0) | ||
source.setUp() | ||
|
||
# First loop over internal faces | ||
for faceI in range(mesh.nInternalFaces): | ||
|
||
# Face magnitude | ||
magSf = mesh.magSf[faceI] | ||
|
||
# Face normal | ||
nf = mesh.nf[faceI] | ||
|
||
faceGaussPointsAndWeights = cellPsi._facesGaussPointsAndWeights[faceI] | ||
|
||
# Loop over Gauss points | ||
for i, gp in enumerate(faceGaussPointsAndWeights[1]): | ||
|
||
# Gauss point gp weight | ||
gpW = faceGaussPointsAndWeights[0][i] | ||
|
||
# Owner and neighbour of current face | ||
cellP = mesh._owner[faceI] | ||
cellN = mesh._neighbour[faceI] | ||
value = gpW * magSf * (GaussPointsValues[faceI][i] @ nf) | ||
|
||
source.setValues(cellP, value, ADD) | ||
source.setValues(cellN, -value, ADD) | ||
|
||
# Loop over boundary faces | ||
for patch in cellPsi._boundaryConditionsDict: | ||
startFace = mesh.boundary[patch]['startFace'] | ||
nFaces = mesh.boundary[patch]['nFaces'] | ||
|
||
# Loop over patch faces | ||
for faceI in range(startFace, startFace + nFaces): | ||
|
||
# Face magnitude | ||
magSf = mesh.magSf[faceI] | ||
|
||
# Face normal | ||
nf = mesh.nf[faceI] | ||
|
||
faceGaussPointsAndWeights = cellPsi._facesGaussPointsAndWeights[faceI] | ||
|
||
# Loop over Gauss points | ||
for i, gp in enumerate(faceGaussPointsAndWeights[1]): | ||
# Gauss point gp weight | ||
gpW = faceGaussPointsAndWeights[0][i] | ||
|
||
# Owner and neighbour of current face | ||
cellP = mesh._owner[faceI] | ||
value = gpW * magSf * (GaussPointsValues[faceI][i] @ nf) | ||
|
||
source.setValues(cellP, value, ADD) | ||
|
||
# Finish matrix assembly | ||
A.assemble() | ||
source.assemble() | ||
|
||
#source.view() | ||
return source, A |
Oops, something went wrong.