50 const word& fieldTypeDesc,
58 if (fieldTypeDesc != fieldType::typeName +
"Value")
63 word fieldName(fieldValueStream);
69 mesh.time().timeName(),
75 if (!fieldHeader.typeHeaderOk<fieldType>(
true))
80 mesh.time().constant(),
87 if (fieldHeader.typeHeaderOk<fieldType>(
true))
89 Info<<
" Setting internal values of "
90 << fieldHeader.headerClassName()
91 <<
" " << fieldName <<
endl;
93 fieldType
field(fieldHeader,
mesh,
false);
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"
202 const word& fieldTypeDesc,
210 if (fieldTypeDesc != fieldType::typeName +
"Value")
215 word fieldName(fieldValueStream);
221 mesh.time().timeName(),
227 if (!fieldHeader.typeHeaderOk<fieldType>(
true))
232 mesh.time().constant(),
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()
258 -
mesh.nInternalFaces()
259 ) =
field.boundaryField()[patchi];
263 bool hasWarned =
false;
271 label facei = selectedFaces[i];
272 if (
mesh.isInternalFace(facei))
278 <<
"Ignoring internal face " << facei
279 <<
". Suppressing further warnings." <<
endl;
284 label bFacei = facei-
mesh.nInternalFaces();
285 allBoundaryValues[bFacei] = value;
286 nChanged[
mesh.boundaryMesh().patchID()[bFacei]]++;
292 auto& fieldBf =
field.boundaryFieldRef();
297 if (nChanged[patchi] > 0)
300 <<
field.boundaryField()[patchi].patch().name()
301 <<
" set " << nChanged[patchi] <<
" values" <<
endl;
305 fieldBf[patchi].size(),
306 fieldBf[patchi].
patch().start()
307 -
mesh.nInternalFaces()
315 <<
"Failed writing field " <<
field.name() <<
exit(FatalError);
321 <<
"Field " << fieldName <<
" not found" <<
endl;
354 selectedFaces_(selectedFaces)
360 selectedFaces_(std::move(selectedFaces))
365 word fieldType(fieldValues);
370 setFaceFieldType<scalar>
371 (fieldType, mesh_, selectedFaces_, fieldValues)
372 || setFaceFieldType<vector>
373 (fieldType, mesh_, selectedFaces_, fieldValues)
374 || setFaceFieldType<sphericalTensor>
375 (fieldType, mesh_, selectedFaces_, fieldValues)
376 || setFaceFieldType<symmTensor>
377 (fieldType, mesh_, selectedFaces_, fieldValues)
378 || setFaceFieldType<tensor>
379 (fieldType, mesh_, selectedFaces_, fieldValues)
384 <<
"field type " << fieldType <<
" not currently supported"
397int main(
int argc,
char *argv[])
401 "Set values on a selected set of cells/patch-faces via a dictionary"
404 argList::addOption(
"dict",
"file",
"Alternative setFieldsDict");
418 if (setFieldsDict.found(
"defaultFieldValues"))
420 Info<<
"Setting field default values" <<
endl;
423 setFieldsDict.lookup(
"defaultFieldValues"),
430 Info<<
"Setting field region values" <<
endl;
436 const entry& region = regions[regionI];
441 if (source().setType() == topoSetSource::CELLSET_SOURCE)
459 setCellField::iNew(
mesh, selectedCellSet.sortedToc())
462 else if (source().setType() == topoSetSource::FACESET_SOURCE)
468 mesh.nBoundaryFaces()/10+1
480 setFaceField::iNew(
mesh, selectedFaceSet.sortedToc())
Generic templated field type.
Generic GeometricField class.
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,...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
SubField is a Field obtained as a section of another Field, without its own allocation....
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A collection of cell labels.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
A keyword and a list of tokens is an 'entry'.
const keyType & keyword() const noexcept
Return keyword.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
Mesh data needed to do the Finite Volume discretisation.
A traits class, which is primarily used for primitives.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word dictName("faMeshDefinition")
#define WarningInFunction
Report a warning using Foam::Warning.
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.