-
Notifications
You must be signed in to change notification settings - Fork 15
[com1]: Add source line as start condition (initial) #1311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -484,6 +484,8 @@ def prepareReleaseEntrainment(cfg, rel, inputSimLines): | |
| inputSimLines["releaseLine"]["thicknessSource"] = ["csv file"] * len( | ||
| inputSimLines["releaseLine"]["Name"] | ||
| ) | ||
| elif cfg["GENERAL"]["constMassFlow"] != "": | ||
| inputSimLines["releaseLine"]["massFlowTot"] = cfg["GENERAL"].getfloat("constMassFlow") | ||
| elif cfg["INPUT"]["relThFile"] == "": | ||
| # otherwise release thickness is read from ini or shape file | ||
| releaseLine = setThickness(cfg, inputSimLines["releaseLine"], "relTh") | ||
|
|
@@ -642,6 +644,7 @@ def prepareInputData(inputSimFiles, cfg): | |
| releaseLine["thickness"] = "from raster" | ||
| log.info("Set %s for relThField" % relRasterPath) | ||
| # get line from release area polygon | ||
| # TODO: use this for sourceline? | ||
| if cfg["GENERAL"].getboolean("timeDependentRelease"): | ||
| releaseLine["type"] = "time dependent Release" | ||
|
qltysh[bot] marked this conversation as resolved.
|
||
| timeDepRelValues, _ = gI.getTimeDepRelCsv(cfg["INPUT"]["timeDepRelCsv"]) | ||
|
|
@@ -1188,19 +1191,43 @@ def initializeSimulation(cfg, outDir, demOri, inputSimLines, logName): | |
| releaseLine = inputSimLines["releaseLine"] | ||
| # create release area raster if not read from file | ||
| if inputSimLines["releaseLine"]["initializedFrom"] == "shapefile": | ||
| # check if release features overlap between features | ||
| geoTrans.prepareArea(releaseLine, dem, thresholdPointInPoly, combine=True, checkOverlap=True) | ||
| # if release shp file is a line, find cells taht are crossed by the line | ||
| if inputSimLines["releaseLine"]["shapeTypeName"] in ["POLYLINE", "POLYLINEZ"]: | ||
| releaseLine = geoTrans.getCellsAlongLine(demOri["header"], releaseLine, addBuffer=False) | ||
| if cfg["GENERAL"]["constMassFlow"] != "": | ||
| # compute release mass per raster cell and timestep | ||
| releaseLine["massFlowCell"] = ( | ||
| releaseLine["massFlowTot"] | ||
| / np.nansum(releaseLine["cellsCrossed"]) | ||
| * cfg["GENERAL"].getfloat("dt") | ||
| ) | ||
| # compute thickness per release cell: mass / area / density | ||
| releaseLine["rasterData"] = ( | ||
| releaseLine["cellsCrossed"].reshape(dem["header"]["nrows"], dem["header"]["ncols"]) | ||
| * releaseLine["massFlowCell"] | ||
| / dem["areaRaster"] | ||
| / cfg["GENERAL"].getfloat("rho") | ||
| ) | ||
| else: | ||
| releaseLine["rasterData"] = ( | ||
| releaseLine["cellsCrossed"].reshape(dem["header"]["nrows"], dem["header"]["ncols"]) | ||
| * releaseLine["thickness"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) | ||
|
|
||
|
qltysh[bot] marked this conversation as resolved.
|
||
| # if no release thickness field or function - set release according to shapefile or ini file | ||
| # this is a list of release rasters that we want to combine | ||
| releaseLine = geoTrans.prepareArea( | ||
| releaseLine, | ||
| dem, | ||
| np.sqrt(2), | ||
| thList=releaseLine["thickness"], | ||
| combine=True, | ||
| checkOverlap=False, | ||
| ) | ||
| else: | ||
| # check if release features overlap between features | ||
| geoTrans.prepareArea(releaseLine, dem, thresholdPointInPoly, combine=True, checkOverlap=True) | ||
|
|
||
| # if no release thickness field or function - set release according to shapefile or ini file | ||
| # this is a list of release rasters that we want to combine | ||
| releaseLine = geoTrans.prepareArea( | ||
| releaseLine, | ||
| dem, | ||
| np.sqrt(2), | ||
| thList=releaseLine["thickness"], | ||
| combine=True, | ||
| checkOverlap=False, | ||
| ) | ||
|
|
||
| # set relRaster | ||
| relRaster = releaseLine["rasterData"] | ||
|
|
@@ -1628,6 +1655,7 @@ def initializeParticles(cfg, releaseLine, dem, inputSimLines="", logName="", rel | |
| not cfg.getboolean("iniStep") | ||
| and not cfg.getboolean("initialiseParticlesFromFile") | ||
| and len(relThField) == 0 | ||
| and not releaseLine["shapeTypeName"] in ["POLYLINE", "POLYLINEZ"] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ): | ||
| if debugPlot: | ||
|
qltysh[bot] marked this conversation as resolved.
|
||
| xyParticlesAll = {"x": particles["x"], "y": particles["y"]} | ||
|
|
@@ -2263,6 +2291,20 @@ def DFAIterate(cfg, particles, fields, dem, inputSimLines, outDir, cuSimName, si | |
| particles, fields, zPartArray0 = debF.initializeTimeDepRelease( | ||
| cfg, inputSimLines, particles, fields, dem, zPartArray0, t | ||
| ) | ||
| elif inputSimLines["releaseLine"]["shapeTypeName"] in ["POLYLINE", "POLYLINEZ"]: | ||
| particlesRelease = com1DFA.initializeParticles( | ||
| cfgGen, | ||
| inputSimLines["releaseLine"], | ||
| dem, | ||
| ) | ||
| particles = particleTools.mergeParticleDict(particles, particlesRelease) | ||
| zPartArray0 = np.append(zPartArray0, copy.deepcopy(particlesRelease["z"])) | ||
| particles = DFAfunC.getNeighborsC(particles, dem) | ||
| # update fields (compute grid values) | ||
| if fields["computeTA"]: | ||
| particles = DFAfunC.computeTrajectoryAngleC(particles, zPartArray0) | ||
| particles, fields = DFAfunC.updateFieldsC(cfg["GENERAL"], particles, dem, fields) | ||
|
|
||
| # Perform computations | ||
| particles, fields, zPartArray0, tCPU, dem = computeEulerTimeStep( | ||
| cfgGen, | ||
|
|
@@ -2746,6 +2788,7 @@ def computeEulerTimeStep( | |
| # loop version of the compute force | ||
| log.debug("Compute Force C") | ||
| particles, force, fields = DFAfunC.computeForceC(cfg, particles, fields, dem, frictType, resistanceType) | ||
|
|
||
| tCPUForce = time.time() - startTime | ||
| tCPU["timeForce"] = tCPU["timeForce"] + tCPUForce | ||
| # compute lateral force (SPH component of the calculation) | ||
|
|
@@ -2797,7 +2840,6 @@ def computeEulerTimeStep( | |
| particles, zPartArray0, reportAreaInfo = releaseSecRelArea( | ||
| cfg, particles, fields, dem, zPartArray0, reportAreaInfo | ||
| ) | ||
|
|
||
| # get particles location (neighbours for sph) | ||
| startTime = time.time() | ||
| log.debug("get Neighbours C") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# TODO: use this for sourceline? [ripgrep:TODO]