42 const word& fieldTypeDesc,
50 if (fieldTypeDesc != fieldType::typeName +
"Value")
55 word fieldName(fieldValueStream);
67 if (!fieldHeader.headerOk())
79 if (fieldHeader.headerOk())
81 Info<<
" Setting internal values of " 82 << fieldHeader.headerClassName()
83 <<
" " << fieldName <<
endl;
85 fieldType field(fieldHeader, mesh);
89 if (selectedCells.
size() == field.size())
91 field.primitiveFieldRef() = value;
95 forAll(selectedCells, celli)
97 field[selectedCells[celli]] = value;
102 Boundary& fieldBf = field.boundaryFieldRef();
112 <<
"Failed writing field " << fieldName <<
endl;
118 <<
"Field " << fieldName <<
" not found" <<
endl;
151 selectedCells_(selectedCells)
156 word fieldType(fieldValues);
161 setCellFieldType<scalar>
162 (fieldType, mesh_, selectedCells_, fieldValues)
163 || setCellFieldType<vector>
164 (fieldType, mesh_, selectedCells_, fieldValues)
165 || setCellFieldType<sphericalTensor>
166 (fieldType, mesh_, selectedCells_, fieldValues)
167 || setCellFieldType<symmTensor>
168 (fieldType, mesh_, selectedCells_, fieldValues)
169 || setCellFieldType<tensor>
170 (fieldType, mesh_, selectedCells_, fieldValues)
175 <<
"field type " << fieldType <<
" not currently supported" 186 bool setFaceFieldType
188 const word& fieldTypeDesc,
196 if (fieldTypeDesc != fieldType::typeName +
"Value")
201 word fieldName(fieldValueStream);
213 if (!fieldHeader.headerOk())
225 if (fieldHeader.headerOk())
227 Info<<
" Setting patchField values of " 228 << fieldHeader.headerClassName()
229 <<
" " << fieldName <<
endl;
231 fieldType field(fieldHeader, mesh);
243 field.boundaryField()[
patchi].patch().start()
245 ) = field.boundaryField()[
patchi];
249 bool hasWarned =
false;
257 label facei = selectedFaces[i];
264 <<
"Ignoring internal face " << facei
265 <<
". Suppressing further warnings." <<
endl;
271 allBoundaryValues[bFacei] = value;
280 Boundary& fieldBf = field.boundaryFieldRef();
288 << field.boundaryField()[
patchi].patch().name()
289 <<
" set " << nChanged[
patchi] <<
" values" <<
endl;
294 fieldBf[
patchi].patch().start()
309 <<
"Field " << fieldName <<
" not found" <<
endl;
342 selectedFaces_(selectedFaces)
347 word fieldType(fieldValues);
352 setFaceFieldType<scalar>
353 (fieldType, mesh_, selectedFaces_, fieldValues)
354 || setFaceFieldType<vector>
355 (fieldType, mesh_, selectedFaces_, fieldValues)
356 || setFaceFieldType<sphericalTensor>
357 (fieldType, mesh_, selectedFaces_, fieldValues)
358 || setFaceFieldType<symmTensor>
359 (fieldType, mesh_, selectedFaces_, fieldValues)
360 || setFaceFieldType<tensor>
361 (fieldType, mesh_, selectedFaces_, fieldValues)
366 <<
"field type " << fieldType <<
" not currently supported" 379 int main(
int argc,
char *argv[])
386 Info<<
"Reading setFieldsDict\n" <<
endl;
400 if (setFieldsDict.found(
"defaultFieldValues"))
402 Info<<
"Setting field default values" <<
endl;
405 setFieldsDict.lookup(
"defaultFieldValues"),
412 Info<<
"Setting field region values" <<
endl;
418 const entry& region = regions[regionI];
441 setCellField::iNew(mesh, selectedCellSet.
toc())
462 setFaceField::iNew(mesh, selectedFaceSet.
toc())
const labelList & patchID() const
Per boundary face label the patch index.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
Traits class for primitives.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
Generic GeometricField class.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
Pre-declare related SubField type.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Pre-declare SubField and related Field type.
A class for handling words, derived from string.
const keyType & keyword() const
Return keyword.
const word & constant() const
Return constant name.
List< label > labelList
A List of labels.
List< Key > toc() const
Return the table of contents.
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
label size() const
Return the number of elements in the UList.
#define WarningInFunction
Report a warning using Foam::Warning.
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.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual void applyToSet(const setAction action, topoSet &) const =0
label nInternalFaces() const
const Time & time() const
Return the top-level database.
A keyword and a list of tokens is an 'entry'.
label size() const
Return the number of elements in the UPtrList.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.