47 const word& fieldTypeDesc,
55 if (fieldTypeDesc != fieldType::typeName +
"Value")
60 word fieldName(fieldValueStream);
72 if (!fieldHeader.headerOk())
84 if (fieldHeader.headerOk())
86 Info<<
" Setting internal values of " 87 << fieldHeader.headerClassName()
88 <<
" " << fieldName <<
endl;
90 fieldType
field(fieldHeader, mesh);
96 field.primitiveFieldRef() = value;
100 forAll(selectedCells, celli)
102 field[selectedCells[celli]] = value;
107 Boundary& fieldBf =
field.boundaryFieldRef();
117 <<
"Failed writing field " << fieldName <<
endl;
123 <<
"Field " << fieldName <<
" not found" <<
endl;
156 selectedCells_(selectedCells)
161 word fieldType(fieldValues);
166 setCellFieldType<scalar>
167 (fieldType, mesh_, selectedCells_, fieldValues)
168 || setCellFieldType<vector>
169 (fieldType, mesh_, selectedCells_, fieldValues)
170 || setCellFieldType<sphericalTensor>
171 (fieldType, mesh_, selectedCells_, fieldValues)
172 || setCellFieldType<symmTensor>
173 (fieldType, mesh_, selectedCells_, fieldValues)
174 || setCellFieldType<tensor>
175 (fieldType, mesh_, selectedCells_, fieldValues)
180 <<
"field type " << fieldType <<
" not currently supported" 191 bool setFaceFieldType
193 const word& fieldTypeDesc,
201 if (fieldTypeDesc != fieldType::typeName +
"Value")
206 word fieldName(fieldValueStream);
218 if (!fieldHeader.headerOk())
230 if (fieldHeader.headerOk())
232 Info<<
" Setting patchField values of " 233 << fieldHeader.headerClassName()
234 <<
" " << fieldName <<
endl;
237 fieldType
field(fieldHeader, mesh);
238 typename fieldType::Boundary& fieldBf =
field.boundaryFieldRef();
244 label nNonProcPatches = 0;
255 typename fieldType::Boundary fieldBfCopy
257 fieldType::Internal::null(),
262 bool haveWarnedInternal =
false, haveWarnedProc =
false;
263 labelList nonProcPatchNChangedFaces(nNonProcPatches, 0);
266 const label facei = selectedFaces[i];
270 if (!haveWarnedInternal)
273 <<
"Ignoring internal face " << facei
274 <<
". Suppressing further warnings." <<
endl;
275 haveWarnedInternal =
true;
287 if (patches[i] >= nNonProcPatches)
292 <<
"Ignoring face " << patchFaces[i]
293 <<
" of processor patch " << patches[i]
294 <<
". Suppressing further warnings." <<
endl;
295 haveWarnedProc =
true;
300 fieldBfCopy[patches[i]][patchFaces[i]] = value;
301 nonProcPatchNChangedFaces[patches[i]] ++;
308 nonProcPatchNChangedFaces,
313 nonProcPatchNChangedFaces
319 if (nonProcPatchNChangedFaces[
patchi] > 0)
323 <<
" set " << nonProcPatchNChangedFaces[
patchi]
324 <<
" values" <<
endl;
338 <<
"Field " << fieldName <<
" not found" <<
endl;
371 selectedFaces_(selectedFaces)
376 word fieldType(fieldValues);
381 setFaceFieldType<scalar>
382 (fieldType, mesh_, selectedFaces_, fieldValues)
383 || setFaceFieldType<vector>
384 (fieldType, mesh_, selectedFaces_, fieldValues)
385 || setFaceFieldType<sphericalTensor>
386 (fieldType, mesh_, selectedFaces_, fieldValues)
387 || setFaceFieldType<symmTensor>
388 (fieldType, mesh_, selectedFaces_, fieldValues)
389 || setFaceFieldType<tensor>
390 (fieldType, mesh_, selectedFaces_, fieldValues)
395 <<
"field type " << fieldType <<
" not currently supported" 407 int main(
int argc,
char *argv[])
417 if (setFieldsDict.found(
"defaultFieldValues"))
419 Info<<
"Setting field default values" <<
endl;
422 setFieldsDict.lookup(
"defaultFieldValues"),
428 Info<<
"Setting field region values" <<
endl;
434 const entry& region = regions[regionI];
457 setCellField::iNew(mesh, selectedCellSet.
toc())
478 setFaceField::iNew(mesh, selectedFaceSet.
toc())
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
#define forAll(list, i)
Loop across all elements in list.
const keyType & keyword() const
Return keyword.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label nInternalFaces() const
Templated form of IOobject providing type information for file reading and header type checking...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
Generic GeometricField class.
const Time & time() const
Return the top-level database.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
A class for handling words, derived from string.
const word & constant() const
Return constant name.
List< label > labelList
A List of labels.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
const UCompactListList< label > & polyBFacePatchFaces() const
Return poly-bFace-patch-face addressing.
#define WarningInFunction
Report a warning using Foam::Warning.
const UCompactListList< label > & polyBFacePatches() const
Return poly-bFace-patch addressing.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
A collection of cell labels.
Mesh data needed to do the Finite Volume discretisation.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
List< Key > toc() const
Return the table of contents.
Foam::argList args(argc, argv)
virtual void applyToSet(const setAction action, topoSet &) const =0
A keyword and a list of tokens is an 'entry'.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.