When specifying a source term using fvOptions in OpenFOAM, we can select the selectionMode (how to set the source region) from the following four options:
- points
- cellSet
- cellZone
- all
These options are defined in theĀ cellSetOption class along with the other common parameters among the fvOptions such as timeStart and duration. Let’s check out the meaning of each option along with its source code.
selectionMode 1: points |
In this case, we specify some points as shown in the following example. The source region consists of theĀ individual cells that contain the specified points.
- Example of description
1 2 3 4 5 6 |
selectionMode points; points ( (-0.01 0.01 0) (0.03 -0.015 0) ); |
- Source code
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
void Foam::fv::cellSetOption::setCellSet() { switch (selectionMode_) { case smPoints: { Info<< indent << "- selecting cells using points" << endl; labelHashSet selectedCells; forAll(points_, i) { label celli = mesh_.findCell(points_[i]); if (celli >= 0) { selectedCells.insert(celli); } label globalCelli = returnReduce(celli, maxOp<label>()); if (globalCelli < 0) { WarningInFunction << "Unable to find owner cell for point " << points_[i] << endl; } } cells_ = selectedCells.toc(); break; } |
selectionMode 2: cellSet |
In this case, we preliminarily create a cellSet corresponding to the source region using OpenFOAM’s utilities such as setSet and specify the created cellSet name.
- Example of description
1 2 |
selectionMode cellSet; cellSet cSet1; |
- Source code
124 125 126 127 128 129 130 131 132 133 |
case smCellSet: { Info<< indent << "- selecting cells using cellSet " << cellSetName_ << endl; cellSet selectedCells(mesh_, cellSetName_); cells_ = selectedCells.toc(); break; } |
selectionMode 3: cellZone |
In this case, we preliminarily create a cellZone corresponding to the source region using OpenFOAM’s utilities such as setSet and specify the created cellZone name.
- Example of description
1 2 |
selectionMode cellZone; cellZone cZone1; |
- Source code
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
case smCellZone: { Info<< indent << "- selecting cells using cellZone " << cellSetName_ << endl; label zoneID = mesh_.cellZones().findZoneID(cellSetName_); if (zoneID == -1) { FatalErrorInFunction << "Cannot find cellZone " << cellSetName_ << endl << "Valid cellZones are " << mesh_.cellZones().names() << exit(FatalError); } cells_ = mesh_.cellZones()[zoneID]; break; } |
selectionMode 4: all |
The source region is the entire computational domain.
- Example of description
1 |
selectionMode all; |
- Source code
151 152 153 154 155 156 157 |
case smAll: { Info<< indent << "- selecting all cells" << endl; cells_ = identity(mesh_.nCells()); break; } |