Go to the documentation of this file.
50 const word& fieldTypeDesc,
58 if (fieldTypeDesc != fieldType::typeName +
"Value")
63 word fieldName(fieldValueStream);
75 if (!fieldHeader.typeHeaderOk<fieldType>(
true))
87 if (fieldHeader.typeHeaderOk<fieldType>(
true))
89 Info<<
" Setting internal values of "
90 << fieldHeader.headerClassName()
91 <<
" " << fieldName <<
endl;
93 fieldType
field(fieldHeader,
mesh,
false);
97 if (selectedCells.size() ==
field.size())
99 field.primitiveFieldRef() = value;
103 forAll(selectedCells, celli)
105 field[selectedCells[celli]] = value;
110 Boundary& fieldBf =
field.boundaryFieldRef();
114 fieldBf[patchi] = fieldBf[patchi].patchInternalField();
120 <<
"Failed writing field " << fieldName <<
endl;
126 <<
"Field " << fieldName <<
" not found" <<
endl;
159 selectedCells_(selectedCells)
165 selectedCells_(std::move(selectedCells))
170 word fieldType(fieldValues);
175 setCellFieldType<scalar>
176 (fieldType, mesh_, selectedCells_, fieldValues)
177 || setCellFieldType<vector>
178 (fieldType, mesh_, selectedCells_, fieldValues)
179 || setCellFieldType<sphericalTensor>
180 (fieldType, mesh_, selectedCells_, fieldValues)
181 || setCellFieldType<symmTensor>
182 (fieldType, mesh_, selectedCells_, fieldValues)
183 || setCellFieldType<tensor>
184 (fieldType, mesh_, selectedCells_, fieldValues)
189 <<
"field type " << fieldType <<
" not currently supported"
200 bool setFaceFieldType
202 const word& fieldTypeDesc,
210 if (fieldTypeDesc != fieldType::typeName +
"Value")
215 word fieldName(fieldValueStream);
227 if (!fieldHeader.typeHeaderOk<fieldType>(
true))
239 if (fieldHeader.typeHeaderOk<fieldType>(
true))
241 Info<<
" Setting patchField values of "
242 << fieldHeader.headerClassName()
243 <<
" " << fieldName <<
endl;
256 field.boundaryField()[patchi].size(),
257 field.boundaryField()[patchi].patch().start()
259 ) =
field.boundaryField()[patchi];
263 bool hasWarned =
false;
271 label facei = selectedFaces[i];
278 <<
"Ignoring internal face " << facei
279 <<
". Suppressing further warnings." <<
endl;
285 allBoundaryValues[bFacei] = value;
294 Boundary& fieldBf =
field.boundaryFieldRef();
299 if (nChanged[patchi] > 0)
302 <<
field.boundaryField()[patchi].patch().name()
303 <<
" set " << nChanged[patchi] <<
" values" <<
endl;
307 fieldBf[patchi].size(),
308 fieldBf[patchi].
patch().start()
323 <<
"Field " << fieldName <<
" not found" <<
endl;
356 selectedFaces_(selectedFaces)
362 selectedFaces_(std::move(selectedFaces))
367 word fieldType(fieldValues);
372 setFaceFieldType<scalar>
373 (fieldType, mesh_, selectedFaces_, fieldValues)
374 || setFaceFieldType<vector>
375 (fieldType, mesh_, selectedFaces_, fieldValues)
376 || setFaceFieldType<sphericalTensor>
377 (fieldType, mesh_, selectedFaces_, fieldValues)
378 || setFaceFieldType<symmTensor>
379 (fieldType, mesh_, selectedFaces_, fieldValues)
380 || setFaceFieldType<tensor>
381 (fieldType, mesh_, selectedFaces_, fieldValues)
386 <<
"field type " << fieldType <<
" not currently supported"
399 int main(
int argc,
char *argv[])
403 "Set values on a selected set of cells/patch-faces via a dictionary"
420 if (setFieldsDict.found(
"defaultFieldValues"))
422 Info<<
"Setting field default values" <<
endl;
425 setFieldsDict.lookup(
"defaultFieldValues"),
432 Info<<
"Setting field region values" <<
endl;
438 const entry& region = regions[regionI];
A keyword and a list of tokens is an 'entry'.
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
List< label > labelList
A List of labels.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const
Return name.
A class for handling words, derived from Foam::string.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const keyType & keyword() const
Return keyword.
label nInternalFaces() const
Number of internal faces.
static word timeName(const scalar t, const int precision=precision_)
static void addNote(const string ¬e)
Add extra notes for the usage information.
const word dictName("blockMeshDict")
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const =0
Apply specified action to the topoSet.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Create a new set and ADD elements to it.
#define forAll(list, i)
Loop across all elements in list.
SubField is a Field obtained as a section of another Field.
const labelList & patchID() const
Per boundary face label the patch index.
label nCells() const
Number of mesh cells.
Generic templated field type.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
messageStream Info
Information stream (uses stdout - output is on the master only)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
label nBoundaryFaces() const
Number of boundary faces (== nFaces - nInternalFaces)
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
Mesh data needed to do the Finite Volume discretisation.
A collection of cell labels.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const std::string patch
OpenFOAM patch number as a std::string.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const Time & time() const
Return the top-level database.
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
const word & constant() const
Return constant name.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
#define WarningInFunction
Report a warning using Foam::Warning.