Go to the documentation of this file.
55 const word& modelType,
65 fieldNames_.setSize(3);
66 fieldNames_[0] =
word(
"U");
67 fieldNames_[1] =
word(
"k");
68 fieldNames_[2] =
word(
"epsilon");
69 applied_.setSize(fieldNames_.size(),
false);
87 Info <<
"eqn.psi() name is " << eqn.
psi().name() <<
endl;
93 Info <<
"canopy volVectorField is " <<
nl << canopy <<
endl;
114 if (eqn.
psi().name() ==
word(
"U")) {
136 <<
"Missing landuse classes for canopySource in constant/fvOptions"
141 <<
"No source patches given for landuse data"
147 vector translationVector(0, 0, 0);
148 translationVector = coeffs_.lookupOrDefault(
"translateRaster", translationVector,
false,
false);
155 if(!raster.
read(rasterPath.c_str()))
157 <<
"Cannot read raster file: " << rasterPath
160 raster.
translate(
double(translationVector.
x()),
double(translationVector.
y()));
162 Info <<
" Reading raster: " << rasterPath <<
endl
163 <<
" (x1, y1, x2, y2): ("
164 << raster.
xll <<
", " << raster.
yll <<
", " << raster.
xur <<
", " << raster.
yur
165 <<
") (nrows, ncols): (" << raster.
nrows <<
" ," << raster.
ncols
177 <<
" ---------------------Landuse categories--------------------" <<
endl;
178 Info <<
" name\tcode\tCd\tLAI\tz0\theight\tLADmax" <<
endl;
183 landuseTable_.insert(lu.
code(), lu);
185 <<
"\t" << lu.
LAI() <<
"\t" << lu.
z0() <<
"\t" << lu.
height()
202 coeffs_.lookup(
"sourcePatches") >> sourcePatches_;
205 readFromDisk_ = coeffs_.lookupOrDefault(
"readFromDisk",
false,
false,
false);
207 readLanduseFromRaster_ = coeffs_.lookupOrDefault(
"readLanduseFromRaster",
false,
false,
false);
208 readCanopyHeightFromRaster_ = coeffs_.lookupOrDefault(
"readCanopyHeightFromRaster",
false,
false,
false);
209 writeFields_ = coeffs_.lookupOrDefault(
"writeFields",
false,
false,
false);
211 readLanduseClasses();
213 if (readLanduseFromRaster_ ) {
215 coeffs_.lookup(
"landuseRasterFileName") >> landuseRasterFileName;
216 landuseRaster_ = readRaster(landuseRasterFileName);
219 if (readCanopyHeightFromRaster_ ) {
220 fileName canopyHeightRasterFileName;
221 coeffs_.lookup(
"canopyHeightRasterFileName") >> canopyHeightRasterFileName;
222 canopyHeightRaster_ = readRaster(canopyHeightRasterFileName);
226 if (!readLanduseFromRaster_) {
228 coeffs_.lookup(
"patchLanduse") >> patchLanduseList;
229 if((patchLanduseList.
size() != sourcePatches_.size()))
231 <<
"Wrong number of rows in patchLanduse,"
232 <<
"should be equal to number of source patches "
235 forAll(sourcePatches_, i) {
236 label patchID = mesh_.boundaryMesh().findPatchID(sourcePatches_[i]);
239 <<
"Cannot find landuse source patch: "
243 label patchLanduseCode = patchLanduseList[i];
245 patchLanduseTable_.insert(patchID, landuseTable_[lu.
code()]);
267 refCast<Foam::nutkAtmRoughWallFunctionFvPatchScalarField>(
nut.boundaryField()[patch]);
273 forAll(patchLanduse,facei)
277 if (readLanduseFromRaster_) {
280 lu = landuseTable_[
label(landuseRaster_.getValue(
double(
x),
double(
y)))];
283 lu = patchLanduseTable_[patch];
286 if (!landuse_from_disk_)
287 patchLanduse[facei] = scalar(lu.
code());
290 patchZ0[facei] = lu.
z0();
294 nutZ0[facei] = patchZ0[facei];
303 scalar
x =
mesh.
C()[celli].x();
304 scalar
y =
mesh.
C()[celli].y();
307 if (readLanduseFromRaster_)
308 lu = landuseTable_[
label(landuseRaster_.getValue(
double(
x),
double(
y)))];
310 lu = patchLanduseTable_[patch];
315 if (readCanopyHeightFromRaster_
317 && canopyHeightRaster_.inside(
double(
x),
double(
y))) {
318 height = canopyHeightRaster_.getValue(
double(
x),
double(
y));
323 Info <<
"after read canopy height , the height of lu is " <<
endl << height <<
endl;
326 if (patchDistance < 0)
327 cout<<
"patchDistance: " << patchDistance<<
'\n';
328 if (patchDistance < height && height > 0)
345 sourcePatchIDs.
insert(patch);
348 Info <<
"calculatePatchDistance volScalarField d is " <<
nl << d <<
endl;
367 mesh_.time().timeName(),
375 landuse_from_disk_ =
true;
376 Info <<
" Reading existing landuse field" <<
endl;
384 mesh_.time().timeName(),
394 landuse_from_disk_ =
false;
402 mesh_.time().timeName(),
409 calculatedFvPatchScalarField::typeName
417 mesh_.time().timeName(),
425 z0_from_disk_ =
true;
426 Info <<
" Reading existing z0 field" <<
endl;
434 mesh_.time().timeName(),
444 z0_from_disk_ =
false;
452 mesh_.time().timeName(),
459 calculatedFvPatchScalarField::typeName
467 mesh_.time().timeName(),
475 LAD_from_disk_ =
true;
476 Info <<
" Reading existing LAD field" <<
endl;
484 mesh_.time().timeName(),
495 LAD_from_disk_ =
false;
503 mesh_.time().timeName(),
510 calculatedFvPatchScalarField::typeName
521 mesh_.time().timeName(),
528 calculatedFvPatchScalarField::typeName
537 mesh_.time().timeName(),
552 forAll(sourcePatches_, sp) {
553 word patchName = sourcePatches_[sp];
555 label patchID = mesh_.boundaryMesh().findPatchID(patchName);
559 "void Foam::fv::canopySource::setPatchLanduse("
569 calculatePatchDistance(patchID, d);
571 setPatchLanduse(patchID, landuse(), LAD(), z0(),
nut, d);
575 forAll(landuse->internalField(),celli) {
576 label landuseCode(landuse->internalField()[celli]);
577 if (landuseCode != -1) {
579 canopy[celli] = lu.
Cd() * LAD->internalField()[celli];
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
A class for handling words, derived from string.
A class for handling file names.
const volScalarField & y() const
void calculatePatchDistance(label patch, volScalarField &d)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
#define forAll(list, i)
Loop across all elements in list.
bool read(const dictionary &dict)
Read dictionary.
bool read(const char *, int32_t &)
scalar LAD(scalar z, scalar treeHeight)
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Switch readLanduseFromRaster_
Dimension set for the base types.
dimensioned< scalar > mag(const dimensioned< Type > &)
const GeometricField< Type, fvPatchField, volMesh > & psi() const
void translate(const double &x, const double &y)
This boundary condition provides a turbulent kinematic viscosity for atmospheric velocity profiles....
A special matrix type and solver, designed for finite volume solutions of scalar equations.
void setPatchLanduse(label patch, volScalarField &landuse, volScalarField &LAD, volScalarField &z0, volScalarField &nut, volScalarField &d)
canopySource(const canopySource &)
Disallow default bitwise copy construct.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Finite volume options abtract base class. Provides a base set of controls, e.g.
Pre-declare SubField and related Field type.
A patch is a list of labels that address the faces in the global face list.
int read(const char fileName[])
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
InternalField & internalField()
Return internal field.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
A list of keyword definitions, which are a keyword followed by any number of values (e....
Macros for easy insertion into run-time selection tables.
Generic dimensioned Type class.
Mesh data needed to do the Finite Volume discretisation.
virtual bool read(const dictionary &dict)
Read source dictionary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
defineTypeNameAndDebug(option, 0)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
Raster readRaster(fileName rasterPath)
const volVectorField & C() const
Return cell centres as volVectorField.
const vectorField::subField faceCentres() const
Return face centres.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void addSup(const volScalarField &rho, fvMatrix< vector > &eqn, const label fieldi)
Source terms to momentum equation (for solvers with and without explicit density)
bool insert(const Key &key)
Insert a new entry.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
void reset(T *=0)
If object pointer already set, delete object and set to given.
HashTable< landuseClass, label > landuseTable_
wordList toc() const
Return the table of contents.
void size(const label)
Override size to be inconsistent with allocated storage.
tmp< GeometricField< Type, fvPatchField, volMesh > > Sp(const volScalarField &sp, const GeometricField< Type, fvPatchField, volMesh > &vf)
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Generic GeometricField class.
word name(const complex &)
Return a string representation of a complex.
void readLanduseClasses()