57 const DynamicList<List<point>>& faces,
62 OBJstream
os(fileName +
".obj");
64 if (Pstream::parRun())
67 List<DynamicList<List<point>>> allProcFaces(Pstream::nProcs());
68 allProcFaces[Pstream::myProcNo()] = faces;
69 Pstream::gatherList(allProcFaces);
71 if (Pstream::master())
73 Info<<
"Writing file: " << fileName <<
endl;
75 for (
const DynamicList<List<point>>& procFaces : allProcFaces)
77 for (
const List<point>& facePts : procFaces)
79 os.write(face(
identity(facePts.size())), facePts);
86 Info<<
"Writing file: " << fileName <<
endl;
88 for (
const List<point>& facePts : faces)
90 os.write(face(
identity(facePts.size())), facePts);
98 DynamicList<List<point>>& facePts,
104 cutCellIso cutCell(
mesh,
f);
105 cutFaceIso cutFace(
mesh,
f);
109 cutCell.calcSubCell(cellI, 0.0);
111 alpha1[cellI] =
max(
min(cutCell.VolumeOfFluid(), 1), 0);
113 if (writeOBJ && (
mag(cutCell.faceArea()) >= 1
e-14))
115 facePts.append(cutCell.facePoints());
122 if (
mesh.boundary()[patchi].size() > 0)
124 const label start =
mesh.boundary()[patchi].patch().start();
128 forAll(alphap, patchFacei)
130 const label facei = patchFacei + start;
131 cutFace.calcSubFace(facei, 0.0);
133 mag(cutFace.subFaceArea())/magSfp[patchFacei];
140int main(
int argc,
char *argv[])
144 "Uses cutCellIso to create a volume fraction field from an "
152 "Alternative setAlphaFieldDict dictionary"
159 const word
dictName(
"setAlphaFieldDict");
162 IOdictionary setAlphaFieldDict(
dictIO);
164 Info<<
"Reading " << setAlphaFieldDict.name() <<
endl;
166 const word fieldName = setAlphaFieldDict.get<word>(
"field");
167 const bool invert = setAlphaFieldDict.getOrDefault(
"invert",
false);
168 const bool writeOBJ = setAlphaFieldDict.getOrDefault(
"writeOBJ",
false);
170 Info<<
"Reading field " << fieldName <<
nl <<
endl;
184 autoPtr<implicitFunction>
func = implicitFunction::New
186 setAlphaFieldDict.get<word>(
"type"),
197 DynamicList<List<point>> facePts;
199 setAlpha(
alpha1, facePts,
f, writeOBJ);
203 isoFacesToFile(facePts, fieldName +
"0");
206 ISstream::defaultPrecision(18);
219 <<
", 1-max(alpha1): " << 1 -
gMax(
alpha)
const volScalarField & alpha1
OBJstream os(runTime.globalPath()/outputName)
const word dictName("faMeshDefinition")
constexpr scalar pi(M_PI)
Type gSum(const FieldField< Field, Type > &f)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
void func(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
Type gMin(const FieldField< Field, Type > &f)
Type gMax(const FieldField< Field, Type > &f)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.