|
[Sponsors] |
Create vector from cell center to cell vertex |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 12, 2021, 06:22 |
Create vector from cell center to cell vertex
|
#1 |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 7 |
Hello everybody,
for a new hybrid turbulence model I want to code a new subgrid length scale delta where delta is defined as follows: delta = (1 / sqrt(3)) * max | (I_n - I_m) | where n,m = 1,8 and stand for the vertices of a cell. I_n is defined as follows and is the cross product of the vorticity vector and the vector from the cell center to the cell vertex: I_n = n x r_n Now I am looking for an efficient way of defining the new subgrid length scale. Since the vectors of the cell center to the cell vertices are constant I thought about saving them in a list in the createFields part and then call them in the solver. But I don't know how to realize it yet why I am asking you for your help. How do you think could the code be implemented and be structured? I am looking forward for your help. If you need additional information please let me know. Many thanks and best regards, Daniel |
|
May 17, 2021, 04:37 |
|
#2 |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 7 |
Anyone with an idea how to create vectors from cell center to cell vertices?
|
|
May 17, 2021, 06:56 |
|
#3 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
For each cell you can assess the labels of the points building the cell. See e.g. Point labels associated with a cell
The rest is up to you |
|
May 17, 2021, 12:21 |
|
#4 |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 7 |
My current implementation looks like this but I get some errors when creating the vectors r_n and I_n and r_m / I_m respectively.
Code:
template<class BasicTurbulenceModel> tmp<volScalarField> SAEDES<BasicTurbulenceModel>::deltaOmega ( ) const { volVectorField vorticity = fvc::curl(this->U()); volScalarField magVorticity = mag(vorticity); volVectorField vorticityUnit = vorticity / magVorticity; const polyMesh& pMesh = this->mesh(); const pointField& p = pMesh.points(); volVectorField cellCenter = this->mesh().C(); forAll(cellCenter, celli) { const labelList& cellPts = this->mesh().cellPoints()[celli]; forAll(cellPts, pointi) { vector rn[pointi](cellCenter[celli].x() - p[cellPts[pointi]].x(), cellCenter[celli].y() - p[cellPts[pointi]].y(), cellCenter[celli].z() - p[cellPts[pointi]].z()); volVectorField In[pointi] = (vorticityUnit[celli] ^ rn[pointi]); forAll(cellPts, pointj) { vector rm[pointj](cellCenter[celli].x() - p[cellPts[pointj]].x(), cellCenter[celli].y() - p[cellPts[pointj]].y(), cellCenter[celli].z() - p[cellPts[pointj]].z()); volVectorField Im[pointj] = (vorticityUnit[celli] ^ rn[pointj]); } } volScalarField maxI[celli] = max(mag(In - Im)); } return 1.0 / sqrt(3.0) * maxI; } I get following errors when creating I_m: - array must be initialized with a brace-enclosed initializer And some more errors when creating r_m and r_n respectively: - array must be initialized with a brace-enclosed initializer - expression list treated as compound expression in initializer [-fpermissive] - value computed is not used [-Wunused-value] Do you have an idea what the problem could be? Many thanks for your help. Best regards, Daniel |
|
May 17, 2021, 13:24 |
|
#5 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
Try to Google for the constructors of a vector and vectorfield in openfoam.
|
|
May 24, 2021, 10:56 |
|
#6 |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 7 |
Thanks for your help, it is working now!
|
|
May 24, 2021, 11:04 |
|
#7 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
Can you post your solution here to help others who have the same problem
|
|
May 24, 2021, 11:07 |
|
#8 |
Member
Daniel
Join Date: May 2018
Posts: 43
Rep Power: 7 |
Sure, maybe not the "best" implementation but it is working
Code:
template<class BasicTurbulenceModel> tmp<volScalarField> kOSSTEDES<BasicTurbulenceModel>::deltaOmega ( ) const { volVectorField vorticity = fvc::curl(this->U()); volScalarField magVorticity = mag(vorticity); volVectorField vorticityUnit = vorticity / magVorticity; const polyMesh& pMesh = this->mesh(); const pointField& p = pMesh.points(); volVectorField cellCenter = this->mesh().C(); List<vector> In(8, vector::zero); List<vector> Im(8, vector::zero); volScalarField maxI ( IOobject ( "magI", this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), this->mesh(), dimensionedScalar("magI", dimensionSet(0, 1, 0, 0, 0, 0, 0), 0) ); scalar previousMaxI = 0.0; forAll(cellCenter, celli) { const labelList& cellPts = this->mesh().cellPoints()[celli]; forAll(cellPts, pointi) { label cellP = cellPts[pointi]; vector pnt = p[cellP]; vector rn(cellCenter[celli] - pnt); forAll(cellPts, pointj) { label cellP = cellPts[pointj]; vector pnt = p[cellP]; vector rm(cellCenter[celli] - pnt); In[pointj] = vorticityUnit[celli] ^ rn; Im[pointj] = vorticityUnit[celli] ^ rm; } maxI[celli] = max(max(mag(In - Im)), previousMaxI); previousMaxI = maxI[celli]; } } return 1.0 / sqrt(3.0) * maxI; |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 11:04 |
UDF in case with DPM modle | POSTHU | Fluent UDF and Scheme Programming | 0 | March 3, 2021 07:21 |
[blockMesh] --> foam fatal error: | lillo763 | OpenFOAM Meshing & Mesh Conversion | 0 | March 5, 2014 10:27 |
Actuator disk model | audrich | FLUENT | 0 | September 21, 2009 07:06 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 04:41 |