278 | | }}} |
279 | | |
280 | | |
| 278 | ... |
| 279 | }}} |
| 280 | |
| 281 | There are a lot of other ways we could modify this simple example to have the clump be located anywhere, to have a density profile that is smoothed at the edge, to be a different temperature, or move with a particular velocity, etc... Fortunately, clumps are a commonly used astrophysical object and there is a clump object module to assist users in easily creating clumps. For example the above module could be rewritten as: |
| 282 | |
| 283 | {{{ |
| 284 | MODULE Problem |
| 285 | USE GlobalDeclarations |
| 286 | USE DataDeclarations |
| 287 | USE Clumps |
| 288 | USE Ambients |
| 289 | IMPLICIT NONE |
| 290 | SAVE |
| 291 | PUBLIC ProblemModuleInit, ProblemGridInit, & |
| 292 | ProblemBeforeStep, ProblemAfterStep, ProblemSetErrFlag, ProblemBeforeGlobalStep |
| 293 | PRIVATE REAL(KIND=qPREC) :: rho, radius |
| 294 | |
| 295 | CONTAINS |
| 296 | |
| 297 | SUBROUTINE ProblemModuleInit() |
| 298 | TYPE(AmbientDef), POINTER :: Ambient |
| 299 | TYPE(ClumpDef), POINTER :: Clump |
| 300 | NAMELIST/ProblemData/ rho, radius |
| 301 | OPEN(UNIT=PROBLEM_DATA_HANDLE, FILE='problem.data', STATUS="OLD") |
| 302 | READ(PROBLEM_DATA_HANDLE,NML=ProblemData) |
| 303 | CLOSE(PROBLEM_DATA_HANDLE) |
| 304 | CALL CreateAmbient(Ambient) |
| 305 | CALL CreateClump(Clump) |
| 306 | Clump%density=rho |
| 307 | Clump%radius=radius |
| 308 | CALL UpdateClump(Clump) |
| 309 | END SUBROUTINE |
| 310 | |
| 311 | SUBROUTINE ProblemGridInit(Info) |
| 312 | TYPE(InfoDef), POINTER :: Info |
| 313 | END SUBROUTINE |
| 314 | |
| 315 | ... |
| 316 | }}} |
| 317 | |
| 318 | So what is going on here? First we've added USE statements for the Clumps and Ambients modules. Then in our ProblemModuleInit() routine we've declared an ambientdef and a clumpdef pointer. Then in CreateAmbient() we create an ambient object with the default properties - density = 1, pressure = 1, velocity = 0, etc... which sets the entire grid to be uniform. Then we create a clump object and modify its properties (density, and radius) before updated the clump object. And we're done. |
| 319 | |
| 320 | |
| 321 | And if we want to get more complicated - we can modify other clump attributes. |