58 const UList<List<point>>& faces,
63 OBJstream
os(fileName +
".obj");
65 if (Pstream::parRun())
68 List<List<List<point>>> allProcFaces(Pstream::nProcs());
69 allProcFaces[Pstream::myProcNo()] = faces;
70 Pstream::gatherList(allProcFaces);
72 if (Pstream::master())
74 Info<<
"Writing file: " << fileName <<
endl;
76 for (
const auto& procFaces : allProcFaces)
78 for (
const auto& facePts : procFaces)
80 os.writeFace(facePts);
87 Info<<
"Writing file: " << fileName <<
endl;
89 for (
const auto& facePts : faces)
91 os.writeFace(facePts);
99 DynamicList<List<point>>& facePts,
105 cutCellIso cutCell(
mesh,
f);
106 cutFaceIso cutFace(
mesh,
f);
110 cutCell.calcSubCell(cellI, 0.0);
112 alpha1[cellI] =
clamp(cutCell.VolumeOfFluid(), zero_one{});
114 if (writeOBJ && (
mag(cutCell.faceArea()) >= 1
e-14))
116 facePts.append(cutCell.facePoints());
123 if (
mesh.boundary()[patchi].size() > 0)
125 const label start =
mesh.boundary()[patchi].patch().start();
129 forAll(alphap, patchFacei)
131 const label facei = patchFacei + start;
132 cutFace.calcSubFace(facei, 0.0);
134 mag(cutFace.subFaceArea())/magSfp[patchFacei];
141int main(
int argc,
char *argv[])
143 argList::noFunctionObjects();
145 timeSelector::addOptions_singleTime();
149 "Uses cutCellIso to create a volume fraction field from an "
157 "Alternative setAlphaFieldDict dictionary"
169 const word
dictName(
"setAlphaFieldDict");
172 IOdictionary setAlphaFieldDict(
dictIO);
174 Info<<
"Reading " << setAlphaFieldDict.name() <<
endl;
176 const word fieldName = setAlphaFieldDict.get<word>(
"field");
177 const bool invert = setAlphaFieldDict.getOrDefault(
"invert",
false);
178 const bool writeOBJ = setAlphaFieldDict.getOrDefault(
"writeOBJ",
false);
180 Info<<
"Reading field " << fieldName <<
nl <<
endl;
194 autoPtr<implicitFunction> func = implicitFunction::New
196 setAlphaFieldDict.get<word>(
"type"),
207 DynamicList<List<point>> facePts;
209 setAlpha(
alpha1, facePts,
f, writeOBJ);
213 isoFacesToFile(facePts, fieldName +
"0");
216 ISstream::defaultPrecision(18);
232 Info<<
"sum(alpha*V):" << total
233 <<
", 1-max(alpha1): " << 1 -
limits.max()
constexpr scalar pi(M_PI)
const volScalarField & alpha1
OBJstream os(runTime.globalPath()/outputName)
const word dictName("faMeshDefinition")
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Type gWeightedSum(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted sum (integral) of a field, using the mag() of the weights.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.