Loading...
Searching...
No Matches
setFields.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2022-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Application
28 setFields
29
30Group
31 grpPreProcessingUtilities
32
33Description
34 Set values on a selected set of cells/patch-faces via a dictionary.
35
36\*---------------------------------------------------------------------------*/
37
38#include "argList.H"
39#include "timeSelector.H"
40#include "Time.H"
41#include "fvMesh.H"
42#include "faMesh.H"
43#include "topoSetSource.H"
44#include "cellSet.H"
45#include "faceSet.H"
46#include "volFields.H"
47#include "areaFields.H"
48#include "coupledFvPatch.H"
49#include "coupledFaPatch.H"
50#include "regionProperties.H"
51
52using namespace Foam;
53
54// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55
56//- Simple tuple of field type and name (read from stream)
57class fieldDescription
58{
59 word type_;
60 word name_;
61
62public:
63
64 const word& type() const noexcept { return type_; }
65 const word& name() const noexcept { return name_; }
66
67 explicit fieldDescription(Istream& is)
68 {
69 is >> type_;
70 is >> name_;
71
72 // Eg, read as "volScalarFieldValue", but change to "volScalarField"
73 if (type_.ends_with("Value"))
74 {
75 type_.erase(type_.size()-5);
76 }
77 }
78};
79
80
81// Consume unused field information
82template<class Type>
83bool consumeUnusedType(const fieldDescription& fieldDesc, Istream& is)
84{
87 //? typedef GeometricField<Type, faePatchField, areaMesh> fieldType3;
88 //? typedef GeometricField<Type, fvsPatchField, volMesh> fieldType4;
89
90 const bool isExpectedType
91 (
92 fieldDesc.type() == fieldType1::typeName
93 || fieldDesc.type() == fieldType2::typeName
94 );
95
96 if (isExpectedType)
97 {
98 (void) pTraits<Type>(is);
99 }
100
101 return isExpectedType;
102}
103
104
105// Consume unused field information
106static bool consumeUnused(const fieldDescription& fieldDesc, Istream& is)
107{
108 return
109 (
110 consumeUnusedType<scalar>(fieldDesc, is)
111 || consumeUnusedType<vector>(fieldDesc, is)
112 || consumeUnusedType<sphericalTensor>(fieldDesc, is)
113 || consumeUnusedType<symmTensor>(fieldDesc, is)
114 || consumeUnusedType<tensor>(fieldDesc, is)
115 );
116}
117
118
119// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120
121// Setting volume fields
122template<class Type>
123bool setCellFieldType
124(
125 const fieldDescription& fieldDesc,
126 const fvMesh& mesh,
127 const labelUList& selectedCells,
128 Istream& is
129)
130{
132
133 const bool isExpectedType
134 (
135 fieldDesc.type() == fieldType::typeName
136 );
137
138 if (!isExpectedType)
139 {
140 return false;
141 }
142
143 // Get value from stream
144 const Type fieldValue = pTraits<Type>(is);
145
146
147 // Check the current time directory
148 IOobject fieldHeader
149 (
150 fieldDesc.name(),
151 mesh.thisDb().time().timeName(),
152 mesh.thisDb(),
156 );
157
158 bool found = fieldHeader.typeHeaderOk<fieldType>(true);
159
160 if (!found)
161 {
162 // Fallback to "constant" directory
163 fieldHeader.resetHeader();
164 fieldHeader.instance() = mesh.thisDb().time().constant();
165 found = fieldHeader.typeHeaderOk<fieldType>(true);
166 }
167
168 // Field exists
169 if (found)
170 {
171 Info<< " - set internal values of "
172 << fieldHeader.headerClassName()
173 << ": " << fieldDesc.name()
174 << " = " << fieldValue << endl;
175
176 fieldType field(fieldHeader, mesh, false);
177
178 if (isNull(selectedCells) || (selectedCells.size() == field.size()))
179 {
180 field.primitiveFieldRef() = fieldValue;
181 }
182 else
183 {
184 for (const label celli : selectedCells)
185 {
186 field[celli] = fieldValue;
187 }
188 }
189
190 // Make boundary fields consistent - treat like zeroGradient
191 for (auto& pfld : field.boundaryFieldRef())
192 {
193 pfld = pfld.patchInternalField();
194 }
195
196 // Handle any e.g. halo-swaps
197 field.boundaryFieldRef().template evaluateCoupled<coupledFvPatch>();
198
199 if (!field.write())
200 {
202 << "Failed writing field " << field.name() << endl;
203 }
204 }
205 else
206 {
207 Warning
208 << "Field " << fieldDesc.name() << " not found" << endl;
209 }
210
211 return isExpectedType;
212}
213
214
215// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216
217// Setting finite-area face fields
218template<class Type>
219bool setAreaFieldType
220(
221 const fieldDescription& fieldDesc,
222 const faMesh& mesh,
223 const labelUList& selectedFaces,
224 Istream& is
225)
226{
228
229 const bool isExpectedType
230 (
231 fieldDesc.type() == fieldType::typeName
232 );
233
234 if (!isExpectedType)
235 {
236 return false;
237 }
238
239 // Get value from stream
240 const Type fieldValue = pTraits<Type>(is);
241
242
243 // Check the current time directory
244 IOobject fieldHeader
245 (
246 fieldDesc.name(),
247 mesh.thisDb().time().timeName(),
248 mesh.thisDb(),
252 );
253
254 bool found = fieldHeader.typeHeaderOk<fieldType>(true);
255
256 if (!found)
257 {
258 // Fallback to "constant" directory
259 fieldHeader.resetHeader();
260 fieldHeader.instance() = mesh.thisDb().time().constant(),
261 found = fieldHeader.typeHeaderOk<fieldType>(true);
262 }
263
264 // Field exists
265 if (found)
266 {
267 Info<< " - set internal values of "
268 << fieldHeader.headerClassName()
269 << ": " << fieldDesc.name()
270 << " = " << fieldValue << endl;
271
272 fieldType field(fieldHeader, mesh);
273
274 if (isNull(selectedFaces) || selectedFaces.size() == field.size())
275 {
276 field.primitiveFieldRef() = fieldValue;
277 }
278 else
279 {
280 for (const label facei : selectedFaces)
281 {
282 field[facei] = fieldValue;
283 }
284 }
285
286 // Handle any e.g. halo-swaps
287 field.boundaryFieldRef().template evaluateCoupled<coupledFaPatch>();
288
289 if (!field.write())
290 {
292 << "Failed writing field " << field.name() << endl;
293 }
294 }
295 else
296 {
297 Warning
298 << "Field " << fieldDesc.name() << " not found" << endl;
299 }
300
301 return isExpectedType;
302}
303
304
305// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306
307// Setting volume boundary fields
308template<class Type>
309bool setFaceFieldType
310(
311 const fieldDescription& fieldDesc,
312 const fvMesh& mesh,
313 const labelUList& selectedFaces,
314 Istream& is
315)
316{
318
319 const bool isExpectedType
320 (
321 fieldDesc.type() == fieldType::typeName
322 );
323
324 if (!isExpectedType)
325 {
326 return false;
327 }
328
329 // Get value from stream
330 const Type fieldValue = pTraits<Type>(is);
331
332
333 // Check the current time directory
334 IOobject fieldHeader
335 (
336 fieldDesc.name(),
337 mesh.thisDb().time().timeName(),
338 mesh.thisDb(),
342 );
343
344 bool found = fieldHeader.typeHeaderOk<fieldType>(true);
345
346 if (!found)
347 {
348 // Fallback to "constant" directory
349 fieldHeader.resetHeader();
350 fieldHeader.instance() = mesh.thisDb().time().constant();
351 found = fieldHeader.typeHeaderOk<fieldType>(true);
352 }
353
354 // Field exists
355 if (found)
356 {
357 Info<< " - set boundary values of "
358 << fieldHeader.headerClassName()
359 << ": " << fieldDesc.name()
360 << " = " << fieldValue << endl;
361
362 fieldType field(fieldHeader, mesh);
363
364 // Create flat list of selected faces and their value.
365 Field<Type> allBoundaryValues(mesh.nBoundaryFaces());
366 for (const auto& pfld : field.boundaryField())
367 {
369 (
370 allBoundaryValues,
371 pfld.size(),
372 pfld.patch().offset()
373 ) = pfld;
374 }
375
376 // Override
377 unsigned hasWarned = 0;
378 labelList nChanged
379 (
380 returnReduce(field.boundaryField().size(), maxOp<label>()),
381 Zero
382 );
383
384 for (const label facei : selectedFaces)
385 {
386 const label bFacei = facei-mesh.nInternalFaces();
387
388 if (bFacei < 0)
389 {
390 if (!(hasWarned & 1))
391 {
392 hasWarned |= 1;
394 << "Ignoring internal face " << facei
395 << ". Suppressing further warnings." << endl;
396 }
397 }
398 else if (bFacei >= mesh.nBoundaryFaces())
399 {
400 if (!(hasWarned & 2))
401 {
402 hasWarned |= 2;
404 << "Ignoring out-of-range face " << facei
405 << ". Suppressing further warnings." << endl;
406 }
407 }
408 else
409 {
410 const label patchi = mesh.boundaryMesh().patchID()[bFacei];
411
412 allBoundaryValues[bFacei] = fieldValue;
413 ++nChanged[patchi];
414 }
415 }
416
418
419 auto& fieldBf = field.boundaryFieldRef();
420
421 // Reassign.
422 forAll(field.boundaryField(), patchi)
423 {
424 if (nChanged[patchi] > 0)
425 {
426 Info<< " On patch "
427 << field.boundaryField()[patchi].patch().name()
428 << " set " << nChanged[patchi] << " values" << endl;
429
430 fieldBf[patchi] == SubField<Type>
431 (
432 allBoundaryValues,
433 fieldBf[patchi].size(),
434 fieldBf[patchi].patch().offset()
435 );
436 }
437 }
438
439 // Handle any e.g. halo-swaps
440 field.boundaryFieldRef().template evaluateCoupled<coupledFvPatch>();
441
442 if (!field.write())
443 {
445 << "Failed writing field " << field.name() << endl;
446 }
447 }
448 else
449 {
450 Warning
451 << "Field " << fieldDesc.name() << " not found" << endl;
452 }
453
454 return isExpectedType;
455}
456
457
458// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
459
460// Dispatcher for setting volume fields
461struct setCellField
462{
463 autoPtr<setCellField> clone() const { return nullptr; } // placeholder
464
465 static bool apply
466 (
467 const fieldDescription& fieldDesc,
468 const fvMesh& m,
469 const labelUList& selectedCells,
470 Istream& is
471 )
472 {
473 return
474 (
475 setCellFieldType<scalar>(fieldDesc, m, selectedCells, is)
476 || setCellFieldType<vector>(fieldDesc, m, selectedCells, is)
477 || setCellFieldType<sphericalTensor>(fieldDesc, m, selectedCells, is)
478 || setCellFieldType<symmTensor>(fieldDesc, m, selectedCells, is)
479 || setCellFieldType<tensor>(fieldDesc, m, selectedCells, is)
480 );
481 }
482
483 class iNew
484 {
485 const fvMesh& mesh_;
486 const labelUList& selected_;
487
488 public:
489
490 iNew(const fvMesh& mesh, const labelUList& selectedCells) noexcept
491 :
492 mesh_(mesh),
493 selected_(selectedCells)
494 {}
495
496 autoPtr<setCellField> operator()(Istream& is) const
497 {
498 const fieldDescription fieldDesc(is);
499
500 bool ok = setCellField::apply(fieldDesc, mesh_, selected_, is);
501
502 if (!ok)
503 {
504 ok = consumeUnused(fieldDesc, is);
505
506 if (ok)
507 {
508 // Not meant for us
509 Info<< "Skip " << fieldDesc.type()
510 << " for finite-volume" << nl;
511 }
512 else
513 {
515 << "Unsupported field type: "
516 << fieldDesc.type() << endl;
517 }
518 }
519
520 return nullptr; // Irrelevant return value
521 }
522 };
523};
524
525
526// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
527
528// Dispatcher for setting volume boundary fields
529struct setFaceField
530{
531 autoPtr<setFaceField> clone() const { return nullptr; } // placeholder
532
533 static bool apply
534 (
535 const fieldDescription& fieldDesc,
536 const fvMesh& m,
537 const labelUList& selectedFaces,
538 Istream& is
539 )
540 {
541 return
542 (
543 setFaceFieldType<scalar>(fieldDesc, m, selectedFaces, is)
544 || setFaceFieldType<vector>(fieldDesc, m, selectedFaces, is)
545 || setFaceFieldType<sphericalTensor>(fieldDesc, m, selectedFaces, is)
546 || setFaceFieldType<symmTensor>(fieldDesc, m, selectedFaces, is)
547 || setFaceFieldType<tensor>(fieldDesc, m, selectedFaces, is)
548 );
549 }
550
551 class iNew
552 {
553 const fvMesh& mesh_;
554 const labelUList& selected_;
555
556 public:
557
558 iNew(const fvMesh& mesh, const labelUList& selectedFaces) noexcept
559 :
560 mesh_(mesh),
561 selected_(selectedFaces)
562 {}
563
564 autoPtr<setFaceField> operator()(Istream& is) const
565 {
566 const fieldDescription fieldDesc(is);
567
568 bool ok = setFaceField::apply(fieldDesc, mesh_, selected_, is);
569
570 if (!ok)
571 {
572 ok = consumeUnused(fieldDesc, is);
573
574 if (ok)
575 {
576 // Not meant for us
577 Info<< "Skip " << fieldDesc.type()
578 << " for finite-volume" << nl;
579 }
580 else
581 {
583 << "Unsupported field type: "
584 << fieldDesc.type() << endl;
585 }
586 }
587
588 return nullptr; // Irrelevant return value
589 }
590 };
591};
592
593
594// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
595
596// Dispatcher for setting area face fields
597struct setAreaField
598{
599 autoPtr<setAreaField> clone() const { return nullptr; } // placeholder
600
601 static bool apply
602 (
603 const fieldDescription& fieldDesc,
604 const faMesh& m,
605 const labelUList& selectedFaces,
606 Istream& is
607 )
608 {
609 return
610 (
611 setAreaFieldType<scalar>(fieldDesc, m, selectedFaces, is)
612 || setAreaFieldType<vector>(fieldDesc, m, selectedFaces, is)
613 || setAreaFieldType<sphericalTensor>(fieldDesc, m, selectedFaces, is)
614 || setAreaFieldType<symmTensor>(fieldDesc, m, selectedFaces, is)
615 || setAreaFieldType<tensor>(fieldDesc, m, selectedFaces, is)
616 );
617 }
618
619 class iNew
620 {
621 const faMesh& mesh_;
622 const labelUList& selected_;
623
624 public:
625
626 iNew(const faMesh& mesh, const labelUList& selectedFaces) noexcept
627 :
628 mesh_(mesh),
629 selected_(selectedFaces)
630 {}
631
632 autoPtr<setAreaField> operator()(Istream& is) const
633 {
634 const fieldDescription fieldDesc(is);
635
636 bool ok = setAreaField::apply(fieldDesc, mesh_, selected_, is);
637
638 if (!ok)
639 {
640 ok = consumeUnused(fieldDesc, is);
641
642 if (ok)
643 {
644 // Not meant for us
645 Info<< "Skip " << fieldDesc.type()
646 << " for finite-volume" << nl;
647 }
648 else
649 {
651 << "Unsupported field type: "
652 << fieldDesc.type() << endl;
653 }
654 }
655
656 return nullptr; // Irrelevant return value
657 }
658 };
659};
660
661
662// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
663
664int main(int argc, char *argv[])
665{
666 argList::noFunctionObjects(); // Never use function objects
667
668 timeSelector::addOptions_singleTime(); // Single-time options
669
671 (
672 "Set values on a selected set of cells/patch-faces via a dictionary"
673 );
674
675 argList::addOption("dict", "file", "Alternative setFieldsDict");
676
678 (
679 "no-finite-area",
680 "Suppress handling of finite-area mesh/fields"
681 );
682
683 #include "addRegionOption.H"
684 #include "addAllFaRegionOptions.H"
685
686 // -------------------------
687
688 #include "setRootCase.H"
689 #include "createTime.H"
690
691 // Set time from specified time options, or no-op
693
694 #include "createNamedMesh.H"
695
696 // Handle area region selections
697 #include "getAllFaRegionOptions.H"
698
699 if (args.found("no-finite-area"))
700 {
701 areaRegionNames.clear(); // For consistency
702 }
703
704 // ------------------------------------------------------------------------
705
706 PtrList<faMesh> faMeshes;
707
708 // Setup all area meshes on this region
709 if (!areaRegionNames.empty()) // ie, !args.found("no-finite-area")
710 {
711 faMeshes.resize(areaRegionNames.size());
712
713 label nGoodRegions(0);
714
715 for (const word& areaName : areaRegionNames)
716 {
717 autoPtr<faMesh> faMeshPtr = faMesh::TryNew(areaName, mesh);
718
719 if (faMeshPtr)
720 {
721 faMeshes.set(nGoodRegions++, std::move(faMeshPtr));
722 }
723 }
724
725 faMeshes.resize(nGoodRegions);
726 }
727
728 if (faMeshes.size() == 1)
729 {
730 Info<< "Using finite-area mesh";
731 if
732 (
733 const word& name = polyMesh::regionName(faMeshes[0].name());
734 !name.empty()
735 )
736 {
737 Info<< " [" << name << "]";
738 }
739 Info<< nl;
740 }
741 else if (faMeshes.size() > 1)
742 {
743 Info<< "Detected finite-area meshes:";
744 for (const faMesh& areaMesh : faMeshes)
745 {
746 Info<< " [" << areaMesh.name() << "]";
747 }
748 Info<< nl;
749 }
750
751 const word dictName("setFieldsDict");
753
754 Info<< "Reading " << dictIO.name() << nl << endl;
755
756 IOdictionary setFieldsDict(dictIO);
757
758
759 // Note.
760 // The PtrList + iNew mechanism is used to trigger the callbacks
761 // and perform the desired actions. The contents of the PtrList
762 // itself are actually irrelevant.
763
764
765 // Default field values
766 if
767 (
768 const auto* eptr
769 = setFieldsDict.findEntry("defaultFieldValues", keyType::LITERAL)
770 )
771 {
772 ITstream& is = eptr->stream();
773
774 Info<< "Setting volume field default values" << endl;
775
776 PtrList<setCellField> defaultFieldValues
777 (
778 is,
779 setCellField::iNew(mesh, labelList::null())
780 );
781
782 for (const faMesh& areaMesh : faMeshes)
783 {
784 Info<< "Setting area field default values";
785
786 if
787 (
788 const word& name = polyMesh::regionName(areaMesh.name());
789 !name.empty()
790 )
791 {
792 Info<< " [" << name << "]";
793 }
794 Info<< endl;
795
796 is.rewind();
797
798 PtrList<setAreaField> defaultAreaFieldValues
799 (
800 is,
801 setAreaField::iNew(areaMesh, labelList::null())
802 );
803 }
804 Info<< endl;
805 }
806
807
808 Info<< "Setting field region values" << nl << endl;
809
810 PtrList<entry> regions(setFieldsDict.lookup("regions"));
811
812 for (const entry& region : regions)
813 {
815 topoSetSource::New(region.keyword(), mesh, region.dict());
816
817 if (source().setType() == topoSetSource::CELLSET_SOURCE)
818 {
820 (
821 mesh,
822 "cellSet",
823 mesh.nCells()/10+1 // Reasonable size estimate.
824 );
825
826 source->applyToSet(topoSetSource::NEW, subset);
827
828 labelList selectedCells(subset.sortedToc());
829
830 {
832 stats[0] = selectedCells.size();
833 stats[1] = mesh.nCells();
834 reduce(stats, sumOp<label>());
835
836 Info<< " Selected " << stats[0] << '/' << stats[1]
837 << " cells" << nl;
838 }
839
840 ITstream& is = region.dict().lookup("fieldValues");
841
842 PtrList<setCellField> fieldValues
843 (
844 is,
845 setCellField::iNew(mesh, selectedCells)
846 );
847 }
848 else if (source().setType() == topoSetSource::FACESET_SOURCE)
849 {
851 (
852 mesh,
853 "faceSet",
854 mesh.nBoundaryFaces()/10+1
855 );
856
857 source->applyToSet(topoSetSource::NEW, subset);
858
859 labelList selectedFaces(subset.sortedToc());
860
861 Info<< " Selected " << selectedFaces.size()
862 << " faces" << nl;
863
864 ITstream& is = region.dict().lookup("fieldValues");
865
866 PtrList<setFaceField> fieldValues
867 (
868 is,
869 setFaceField::iNew(mesh, selectedFaces)
870 );
871
872 for (const faMesh& areaMesh : faMeshes)
873 {
874 const labelUList& faceLabels = areaMesh.faceLabels();
875
876 // Transcribe from mesh faces to finite-area addressing
877 labelList areaFaces(faceLabels.size());
878
879 label nUsed = 0;
880 forAll(faceLabels, facei)
881 {
882 const label meshFacei = faceLabels[facei];
883
884 if (subset.test(meshFacei))
885 {
886 areaFaces[nUsed] = facei;
887 ++nUsed;
888 }
889 }
890 areaFaces.resize(nUsed);
891
892 {
894 stats[0] = areaFaces.size();
895 stats[1] = faceLabels.size();
896 reduce(stats, sumOp<label>());
897
898 Info<< " Selected " << stats[0] << '/' << stats[1]
899 << " area faces for " << areaMesh.name() << endl;
900 }
901
902 is.rewind();
903
904 PtrList<setAreaField> fieldValues
905 (
906 is,
907 setAreaField::iNew(areaMesh, areaFaces)
908 );
909 }
910 }
911 }
912
913
914 Info<< "\nEnd\n" << endl;
915
916 return 0;
917}
918
919
920// ************************************************************************* //
bool found
Required Classes.
Required Classes.
labelList faceLabels(nFaceLabels)
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
static constexpr label size() noexcept
Return the number of elements in the FixedList.
Definition FixedList.H:619
Generic GeometricField class.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
An input stream of tokens.
Definition ITstream.H:56
virtual void rewind() override
Rewind the stream so that it may be read again. Same as seek(0).
Definition ITstream.H:638
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
static const List< label > & null() noexcept
Definition List.H:138
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
Definition PtrList.H:171
void resize(const label newLen)
Adjust size of PtrList.
Definition PtrList.C:124
SubField is a Field obtained as a section of another Field, without its own allocation....
Definition SubField.H:58
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
label size() const noexcept
The number of entries in the list.
Definition UPtrListI.H:106
Mesh data needed to do the Finite Area discretisation.
Definition areaFaMesh.H:50
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition argList.C:562
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition argList.C:389
static void addOption(const word &optName, const string &param="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Definition argList.C:400
static void addNote(const string &note)
Add extra notes for the usage information.
Definition argList.C:477
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A collection of cell labels.
Definition cellSet.H:50
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
static autoPtr< faMesh > TryNew(const word &areaName, const polyMesh &pMesh)
Read construction from polyMesh if all files are available.
Definition faMeshNew.C:188
A list of face labels.
Definition faceSet.H:50
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
@ LITERAL
String literal.
Definition keyType.H:82
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
static const word & regionName(const word &region)
The mesh region name or word::null if polyMesh::defaultRegion.
Definition polyMesh.C:796
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.
@ FACESET_SOURCE
Faces as set.
@ CELLSET_SOURCE
Cells as set.
@ NEW
Create a new set and ADD elements to it.
static autoPtr< topoSetSource > New(const word &topoSetSourceType, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected topoSetSource.
A class for handling words, derived from Foam::string.
Definition word.H:66
rDeltaTY field()
dynamicFvMesh & mesh
engineTime & runTime
Required Classes.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
const word dictName("faMeshDefinition")
auto & name
wordList areaRegionNames
return returnReduce(nRefine-oldNRefine, sumOp< label >())
#define WarningInFunction
Report a warning using Foam::Warning.
const std::string patch
OpenFOAM patch number as a std::string.
type
Types of root.
Definition Roots.H:53
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
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).
Definition zero.H:127
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
bool isNull(const T *ptr) noexcept
True if ptr is a pointer (of type T) to the nullObject.
Definition nullObject.H:248
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
IOobject dictIO
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299