50template<
class ReadGeoField,
class MappedGeoField>
57 const typename MappedGeoField::value_type& nullValue,
61 typedef typename MappedGeoField::value_type Type;
69 tetFields.
resize(fieldObjects.size());
75 << ReadGeoField::typeName <<
' ' <<
io.name() <<
endl;
77 ReadGeoField readField(
io,
mesh);
92 readField.registerObject()
102 fld.setSize(map.
size(), nullValue);
105 label index = map[pointi];
109 label celli = index-1;
110 fld[pointi] = readField[celli];
114 const label facei = -index-1;
115 const label patchi =
mesh.boundaryMesh().patchID(facei);
118 label localFacei =
mesh.boundaryMesh()[patchi].whichFace
122 fld[pointi] = readField.boundaryField()[patchi][localFacei];
140 tetFields[i].correctBoundaryConditions();
147int main(
int argc,
char *argv[])
155 "Convert polyMesh results to tetDualMesh"
170 Info<<
"Create tetDualMesh for time = "
188 "pointDualAddressing",
196 if (pointDualAddressing.size() != tetDualMesh.
nPoints())
199 <<
"Size " << pointDualAddressing.size()
200 <<
" of addressing map " << pointDualAddressing.objectPath()
201 <<
" differs from number of points in mesh "
209 label nPatchFaces = 0;
211 forAll(pointDualAddressing, pointi)
213 label index = pointDualAddressing[pointi];
225 label facei = -index-1;
226 if (facei <
mesh.nInternalFaces())
229 <<
"Face " << facei <<
" from index " << index
230 <<
" is not a boundary face."
231 <<
" nInternalFaces:" <<
mesh.nInternalFaces()
244 Info<<
"tetDualMesh points : " << tetDualMesh.
nPoints()
245 <<
" of which mapped to" <<
nl
246 <<
" cells : " << nCells <<
nl
247 <<
" patch faces : " << nPatchFaces <<
nl
248 <<
" not mapped : " << nUnmapped <<
nl
257 ReadAndMapFields<volScalarField, pointScalarField>
268 ReadAndMapFields<volVectorField, pointVectorField>
279 ReadAndMapFields<volSphericalTensorField, pointSphericalTensorField>
290 ReadAndMapFields<volSymmTensorField, pointSymmTensorField>
301 ReadAndMapFields<volTensorField, pointTensorField>
311 tetDualMesh.objectRegistry::write();
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
@ NO_READ
Nothing to be read.
@ MUST_READ
Reading required.
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void resize(const label newLen)
Adjust size of PtrList.
void size(const label n)
Older name for setAddressableSize.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addNote(const string ¬e)
Add extra notes for the usage information.
Generic dimensioned Type class.
Mesh data needed to do the Finite Volume discretisation.
const fileName & facesInstance() const
Return the current instance directory for faces.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
label nPoints() const noexcept
Number of mesh points.
static void addOptions_singleTime()
Add single-time timeSelector options to argList::validOptions().
static bool setTimeIfPresent(Time &runTime, const argList &args, const bool forceInitial=false)
Set the runTime based on -constant (if present), -time (value), or -latestTime.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
IOList< label > labelIOList
IO for a List of label.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.