31#include "ITHACAsurfacetools.H"
36namespace ITHACAsurfacetools
40List<label> surfaceIndexInt(T& field,
const label patchInt,
43 List<label>* result =
new List<label>;
45 for (
size_t i = 0; i < field.mesh().boundaryMesh()[patchInt].size(); i++)
47 result->append(field.mesh().boundaryMesh()[patchInt].faceCells()[i]);
53template List<label> surfaceIndexInt(volScalarField& field,
54 const label patchInt,
const label patchExt);
55template List<label> surfaceIndexInt(volVectorField& field,
56 const label patchInt,
const label patchExt);
57template List<label> surfaceIndexInt(volTensorField& field,
58 const label patchInt,
const label patchExt);
61List<label> surfaceIndexExt(T& field,
const label patchInt,
64 return surfaceIndexInt(field, patchExt, patchInt);
67template List<label> surfaceIndexExt(volScalarField& field,
68 const label patchInt,
const label patchExt);
69template List<label> surfaceIndexExt(volVectorField& field,
70 const label patchInt,
const label patchExt);
71template List<label> surfaceIndexExt(volTensorField& field,
72 const label patchInt,
const label patchExt);
74template<
typename T,
typename V>
75void surfaceValuesInt(T& field,
const label patchInt,
const label patchExt,
78 List<label> indexes = surfaceIndexInt(field, patchInt, patchExt);
80 for (
size_t i = 0; i < indexes.size(); i++)
82 result.append(field[indexes[i]]);
86template void surfaceValuesInt(volScalarField& field,
const label patchInt,
87 const label patchExt, List<scalar>& result);
88template void surfaceValuesInt(volVectorField& field,
const label patchInt,
89 const label patchExt, List<Foam::Vector<scalar >>& result);
90template void surfaceValuesInt(volTensorField& field,
const label patchInt,
91 const label patchExt, List<Foam::Tensor<scalar >>& result);
93template<
typename T,
typename V>
94void surfaceValuesExt(T& field,
const label patchInt,
const label patchExt,
97 surfaceValuesInt(field, patchExt, patchInt, result);
100template void surfaceValuesExt(volScalarField& field,
const label patchInt,
101 const label patchExt, List<scalar>& result);
102template void surfaceValuesExt(volVectorField& field,
const label patchInt,
103 const label patchExt, List<Foam::Vector<scalar >>& result);
104template void surfaceValuesExt(volTensorField& field,
const label patchInt,
105 const label patchExt, List<Foam::Tensor<scalar >>& result);
108Foam::Vector<scalar> surfaceFindMirrorPoint(T& field,
const label patchInt,
109 const label patchExt,
const label cellID)
111 Foam::Vector<scalar> result = * (
new Foam::Vector<scalar>);
112 List<label> indexesInt = surfaceIndexInt(field, patchInt, patchExt);
113 result = 2.0 * field.mesh().boundaryMesh()[patchInt].faceCentres()[cellID] -
114 field.mesh().C()[indexesInt[cellID]];
118template Foam::Vector<scalar> surfaceFindMirrorPoint(volScalarField& field,
119 const label patchInt,
const label patchExt,
const label cellID);
120template Foam::Vector<scalar> surfaceFindMirrorPoint(volVectorField& field,
121 const label patchInt,
const label patchExt,
const label cellID);
122template Foam::Vector<scalar> surfaceFindMirrorPoint(volTensorField& field,
123 const label patchInt,
const label patchExt,
const label cellID);
126label surfaceFindClosest(T& field,
const label patchInt,
const label patchExt,
127 Foam::Vector<scalar> point)
131 List<label> indexesExt = surfaceIndexExt(field, patchInt, patchExt);
132 dist = mag(point - field.mesh().C()[indexesExt[0]]);
134 for (
int i = 1; i < indexesExt.size(); i++)
136 scalar temp = mag(point - field.mesh().C()[indexesExt[i]]);
145 result = indexesExt[result];
149template label surfaceFindClosest(volScalarField& field,
const label patchInt,
150 const label patchExt, Foam::Vector<scalar> point);
151template label surfaceFindClosest(volVectorField& field,
const label patchInt,
152 const label patchExt, Foam::Vector<scalar> point);
153template label surfaceFindClosest(volTensorField& field,
const label patchInt,
154 const label patchExt, Foam::Vector<scalar> point);
156template<
typename T,
typename V>
157void surfaceAverage(T& field,
const label patchInt,
const label patchExt,
160 List<label> indexesInt = surfaceIndexInt(field, patchInt, patchExt);
163 for (
int i = 0; i < indexesInt.size(); i++)
165 Foam::Vector<scalar> mirror = surfaceFindMirrorPoint(field, patchInt, patchExt,
167 label closest = surfaceFindClosest(field, patchInt, patchExt, mirror);
168 result.append(0.5 * field[closest] + 0.5 * field[indexesInt[i]]);
172template void surfaceAverage(volScalarField& field,
const label patchInt,
173 const label patchExt, List<scalar>& result);
174template void surfaceAverage(volVectorField& field,
const label patchInt,
175 const label patchExt, List<Foam::Vector<scalar >>& result);
176template void surfaceAverage(volTensorField& field,
const label patchInt,
177 const label patchExt, List<Foam::Tensor<scalar >>& result);
179template<
typename T,
typename V>
180void surfaceJump(T& field,
const label patchInt,
const label patchExt,
183 List<label> indexesInt = surfaceIndexInt(field, patchInt, patchExt);
186 for (
int i = 0; i < indexesInt.size(); i++)
188 Foam::Vector<scalar> mirror = surfaceFindMirrorPoint(field, patchInt, patchExt,
190 label closest = surfaceFindClosest(field, patchInt, patchExt, mirror);
191 result.append(field[closest] - field[indexesInt[i]]);
195template void surfaceJump(volScalarField& field,
const label patchInt,
196 const label patchExt, List<scalar>& result);
197template void surfaceJump(volVectorField& field,
const label patchInt,
198 const label patchExt, List<Foam::Vector<scalar >>& result);
199template void surfaceJump(volTensorField& field,
const label patchInt,
200 const label patchExt, List<Foam::Tensor<scalar >>& result);
Namespace to implement some useful assign operation of OF fields.