Update Code Architecture and Organization authored by Alain O' Miniussi's avatar Alain O' Miniussi
## Global view ## Global view
The main purpose of a fargo3D simulation is to track the evolution of a planetary system embedded in a disk of gas. Those two entities will be represented by a **GasDisk** and **PlanetarySystem** class respectively. A single simulation will instantiate one object of each. The main purpose of a fargo3D simulation is to track the evolution of a planetary system embedded in a disk of gas. Those two entities will be represented by a **Disk** and **PlanetarySystem** class respectively. A single simulation will instantiate one object of each.
That simulation is driven by an instance of the **SimulationDriver** class (currently implementing a simple [Command pattern](https://en.wikipedia.org/wiki/Command_pattern), but might evolve into a [Template Method](https://en.wikipedia.org/wiki/Template_method_pattern). It behave like a function object with perform one step of the simulation at each call. That simulation is driven by an instance of the **SimulationDriver** class (currently implementing a simple [Command pattern](https://en.wikipedia.org/wiki/Command_pattern), but might evolve into a [Template Method](https://en.wikipedia.org/wiki/Template_method_pattern). It behave like a function object with perform one step of the simulation at each call.
...@@ -12,21 +12,21 @@ The main sequence diagram can be seen as follow: ...@@ -12,21 +12,21 @@ The main sequence diagram can be seen as follow:
```plantuml ```plantuml
participant main participant main
participant driver participant driver
participant gasDisk participant disk
participant planets participant planets
database storage database storage
main -> gasDisk : load initial state main -> disk : load initial state
main -> driver : create main -> driver : create
loop monitor loop monitor
loop time steps loop time steps
main -> driver : next step main -> driver : next step
driver -> gasDisk : sub step 1 driver -> disk : sub step 1
driver -> gasDisk : sub step <N> driver -> disk : sub step <N>
gasDisk -> planets : rotate gasDisk -> planets : rotate
driver -> main : done driver -> main : done
end end
main -> gasDisk : write state main -> disk : write state
gasDisk -> storage : dump fields disk -> storage : dump fields
main -> planets : monitor main -> planets : monitor
planets -> storage : write position and masses planets -> storage : write position and masses
main -> storage : write disk info main -> storage : write disk info
...@@ -42,13 +42,13 @@ class SystemPhysic <<(S,#FF7700)>> { ...@@ -42,13 +42,13 @@ class SystemPhysic <<(S,#FF7700)>> {
class DiskPhysic <<S,#FF7700)>> { class DiskPhysic <<S,#FF7700)>> {
} }
class DiskGrid << (S,#FF7700) >> { class GridDispatch << (S,#FF7700) >> {
int nbRadius, nbLayer, nbSector int nbRadius, nbLayer, nbSector
real minRadius, maxRadius real minRadius, maxRadius
mpi::communicator comm mpi::communicator comm
} }
class PolarGrid { class ScalarField {
string name string name
real[] field real[] field
} }
...@@ -62,14 +62,14 @@ class PlanetarySystem { ...@@ -62,14 +62,14 @@ class PlanetarySystem {
void rotate(real dt) void rotate(real dt)
void monitor(fileName) void monitor(fileName)
} }
class GasDisk { class Disk {
void applyBoundariesConditions() void applyBoundariesConditions()
void setGhosts() void setGhosts()
void read(fileName) void read(fileName)
void write(fileName) void write(fileName)
void monitor(fileName) void monitor(fileName)
} }
class GasDisk::Velocity { class VectorField {
} }
class SimuProgress { class SimuProgress {
real physicalTime real physicalTime
...@@ -108,21 +108,21 @@ planetary system ...@@ -108,21 +108,21 @@ planetary system
physical properties physical properties
and behavior and behavior
end note end note
D3.SimulationDriver o--> fargOCA.GasDisk D3.SimulationDriver o--> fargOCA.Disk
D3.SimulationDriver o--> fargOCA.SimuProgress D3.SimulationDriver o--> fargOCA.SimuProgress
fargOCA.PlanetarySystem "1"*-->"many" fargOCA.Planet fargOCA.PlanetarySystem "1"*-->"many" fargOCA.Planet
fargOCA.PlanetarySystem o--> fargOCA.SystemPhysic fargOCA.PlanetarySystem o--> fargOCA.SystemPhysic
fargOCA.PolarGrid o-->"1" fargOCA.DiskGrid fargOCA.ScalarField o-->"1" fargOCA.GridDispatch
fargOCA.GasDisk o-->"1" fargOCA.DiskGrid fargOCA.Disk o-->"1" fargOCA.GridDispatch
fargOCA.GasDisk o-->"1" fargOCA.DiskPhysic fargOCA.Disk o-->"1" fargOCA.DiskPhysic
fargOCA.GasDisk o-->"1" fargOCA.PlanetarySystem fargOCA.Disk o-->"1" fargOCA.PlanetarySystem
fargOCA.GasDisk *--> fargOCA.PolarGrid: pressure\n soundSpeed\n density\n viscosity fargOCA.Disk *--> fargOCA.PolarGrid: pressure\n soundSpeed\n density\n viscosity
fargOCA.GasDisk "1"*-->"1" fargOCA.GasDisk::Velocity fargOCA.Disk "1"*-->"1" fargOCA.VectorField
fargOCA.GasDisk::Velocity *--> fargOCA.PolarGrid: radial\n phi\n theta fargOCA.VectorField *--> fargOCA.ScalarField: radial\n phi\n theta
``` ```
## The polar grid object. ## The ScalarField object.
The most part of the program is spent manipulating **PolarGrid**[^2] instances. A polar grid is basically a 3D field of continuous floating point data organized on a grid with as `[nr radial][ni layer][ns sector]` if we use $`nr*ni*ns`$ grids. The most part of the program is spent manipulating **ScalarField**[^2] instances. A scalar field is basically a 3D field of continuous floating point data organized on a grid with as `[nr radial][ni layer][ns sector]` if we use $`nr*ni*ns`$ grids.
This object only store the data as a [std::valarray<double>](http://www.cplusplus.com/reference/valarray/)[^4] object field, but also export it as an old fashioned C pointer[^3]. This object only store the data as a [std::valarray<double>](http://www.cplusplus.com/reference/valarray/)[^4] object field, but also export it as an old fashioned C pointer[^3].
...@@ -134,7 +134,7 @@ The "almost" is important, as in the short term, it will allow close to trivial ...@@ -134,7 +134,7 @@ The "almost" is important, as in the short term, it will allow close to trivial
* **DiskPhysic** provide the physical parameter of the disk. It is close to a direct mapping of the user provided property tree. * **DiskPhysic** provide the physical parameter of the disk. It is close to a direct mapping of the user provided property tree.
* **SystemPhysic** paly a similar role for the planetary system. * **SystemPhysic** paly a similar role for the planetary system.
* **DiskGrid** is . It describe discretization of the (possibly flat) cylinder containing the gas. That include the grid points, aperture, etc.. and some usefull pre computed values. More than one **DiskGrid** object exist when the grid resolution is modified and a polar grid need to be re-mapped. * **GridDispatch** is . It describe discretisation of the (possibly flat) cylinder containing the gas. That include the grid points, aperture, etc.. and some useful pre computed values. More than one **GridDispatch** object exist when the grid resolution is modified and a polar grid need to be re-mapped.
## Boundaries Conditions ## Boundaries Conditions
...@@ -146,7 +146,6 @@ Boundaries condition are implemented through **BoundariesHandler** [function obj ...@@ -146,7 +146,6 @@ Boundaries condition are implemented through **BoundariesHandler** [function obj
------- -------
[^1]: In particular, the diagram does not detail the configuration aspects in details. [^1]: In particular, the diagram does not detail the configuration aspects in details.
[^2]: Not a very smart name, but **Field** was already used at the time. It might change in the future.
[^3]: Mostly for backward compatibility/laziness/lack of time. [^3]: Mostly for backward compatibility/laziness/lack of time.
[^4]: Intel has [special optimizations](https://software.intel.com/en-us/articles/using-improved-stdvalarray-with-intelr-c-compiler) for `std::valarray`, has not been tested yet. [^4]: Intel has [special optimizations](https://software.intel.com/en-us/articles/using-improved-stdvalarray-with-intelr-c-compiler) for `std::valarray`, has not been tested yet.
[^5]: Also called "callback". [^5]: Also called "callback".
\ No newline at end of file