Go to the documentation of this file.
55 const word& modelType,
108 if (eqn.
psi().name() ==
word(
"U")) {
128 if(landuseTable_.size() == 0)
130 <<
"Missing landuse classes for canopySource in constant/fvOptions"
133 if(sourcePatches_.size() == 0 && !readLanduseFromRaster_)
135 <<
"No source patches given for landuse data"
141 vector translationVector(0, 0, 0);
142 translationVector = coeffs_.lookupOrDefault(
"translateRaster", translationVector,
false,
false);
149 if(!raster.
read(rasterPath.c_str()))
151 <<
"Cannot read raster file: " << rasterPath
154 raster.
translate(
double(translationVector.x()),
double(translationVector.y()));
156 Info <<
" Reading raster: " << rasterPath <<
endl
157 <<
" (x1, y1, x2, y2): ("
158 << raster.
xll <<
", " << raster.
yll <<
", " << raster.
xur <<
", " << raster.
yur
159 <<
") (nrows, ncols): (" << raster.
nrows <<
" ," << raster.
ncols
177 landuseTable_.insert(lu.
code(), lu);
179 <<
"\t" << lu.
LAI() <<
"\t" << lu.
z0() <<
"\t" << lu.
height()
196 coeffs_.lookup(
"sourcePatches") >> sourcePatches_;
199 readFromDisk_ = coeffs_.lookupOrDefault(
"readFromDisk",
false,
false,
false);
201 readLanduseFromRaster_ = coeffs_.lookupOrDefault(
"readLanduseFromRaster",
false,
false,
false);
202 readCanopyHeightFromRaster_ = coeffs_.lookupOrDefault(
"readCanopyHeightFromRaster",
false,
false,
false);
203 writeFields_ = coeffs_.lookupOrDefault(
"writeFields",
false,
false,
false);
205 readLanduseClasses();
207 if (readLanduseFromRaster_ ) {
209 coeffs_.lookup(
"landuseRasterFileName") >> landuseRasterFileName;
210 landuseRaster_ = readRaster(landuseRasterFileName);
213 if (readCanopyHeightFromRaster_ ) {
214 fileName canopyHeightRasterFileName;
215 coeffs_.lookup(
"canopyHeightRasterFileName") >> canopyHeightRasterFileName;
216 canopyHeightRaster_ = readRaster(canopyHeightRasterFileName);
220 if (!readLanduseFromRaster_) {
222 coeffs_.lookup(
"patchLanduse") >> patchLanduseList;
223 if((patchLanduseList.
size() != sourcePatches_.size()))
225 <<
"Wrong number of rows in patchLanduse,"
226 <<
"should be equal to number of source patches "
229 forAll(sourcePatches_, i) {
230 label patchID = mesh_.boundaryMesh().findPatchID(sourcePatches_[i]);
233 <<
"Cannot find landuse source patch: "
237 label patchLanduseCode = patchLanduseList[i];
239 patchLanduseTable_.insert(patchID, landuseTable_[lu.
code()]);
261 refCast<Foam::nutkAtmRoughWallFunctionFvPatchScalarField>(
nut.boundaryField()[patch]);
267 forAll(patchLanduse,facei)
271 if (readLanduseFromRaster_) {
274 lu = landuseTable_[
label(landuseRaster_.getValue(
double(
x),
double(
y)))];
277 lu = patchLanduseTable_[patch];
280 if (!landuse_from_disk_)
281 patchLanduse[facei] = scalar(lu.
code());
284 patchZ0[facei] = lu.
z0();
288 nutZ0[facei] = patchZ0[facei];
297 scalar
x =
mesh.
C()[celli].x();
298 scalar
y =
mesh.
C()[celli].y();
301 if (readLanduseFromRaster_)
302 lu = landuseTable_[
label(landuseRaster_.getValue(
double(
x),
double(
y)))];
304 lu = patchLanduseTable_[patch];
306 if (readCanopyHeightFromRaster_
308 && canopyHeightRaster_.inside(
double(
x),
double(
y))) {
309 height = canopyHeightRaster_.getValue(
double(
x),
double(
y));
316 if (patchDistance < 0)
317 cout<<
"patchDistance: " << patchDistance<<
'\n';
318 if (patchDistance < height && height > 0)
331 sourcePatchIDs.insert(patch);
352 mesh_.time().timeName(),
360 landuse_from_disk_ =
true;
361 Info <<
" Reading existing landuse field" <<
endl;
369 mesh_.time().timeName(),
379 landuse_from_disk_ =
false;
387 mesh_.time().timeName(),
394 calculatedFvPatchScalarField::typeName
402 mesh_.time().timeName(),
410 z0_from_disk_ =
true;
411 Info <<
" Reading existing z0 field" <<
endl;
419 mesh_.time().timeName(),
429 z0_from_disk_ =
false;
437 mesh_.time().timeName(),
444 calculatedFvPatchScalarField::typeName
452 mesh_.time().timeName(),
460 LAD_from_disk_ =
true;
461 Info <<
" Reading existing LAD field" <<
endl;
469 mesh_.time().timeName(),
480 LAD_from_disk_ =
false;
488 mesh_.time().timeName(),
495 calculatedFvPatchScalarField::typeName
506 mesh_.time().timeName(),
513 calculatedFvPatchScalarField::typeName
522 mesh_.time().timeName(),
537 forAll(sourcePatches_, sp) {
538 word patchName = sourcePatches_[sp];
540 label patchID = mesh_.boundaryMesh().findPatchID(patchName);
544 "void Foam::fv::canopySource::setPatchLanduse("
554 calculatePatchDistance(patchID, d);
556 setPatchLanduse(patchID, landuse(), LAD(), z0(),
nut, d);
560 forAll(landuse->internalField(),celli) {
561 label landuseCode(landuse->internalField()[celli]);
562 if (landuseCode != -1) {
564 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.
scalar LAD(scalar z, scalar treeHeight)
bool active() const
Return const access to the source active flag.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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)
tmp< fvMatrix< Type > > Sp(const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)
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.
Pre-declare SubField and related Field type.
A patch is a list of labels that address the faces in the global face list.
wordList fieldNames_
Field names to apply source to - populated by derived models.
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)
void setSize(const label)
Reset size of List.
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)
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.
wordList toc() const
Return the table of contents.
void size(const label)
Override size to be inconsistent with allocated storage.
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
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()