[yt-svn] commit/yt-3.0: MatthewTurk: Polar coordinates initial field info for FLASH

Bitbucket commits-noreply at bitbucket.org
Tue Aug 21 12:14:39 PDT 2012


1 new commit in yt-3.0:


https://bitbucket.org/yt_analysis/yt-3.0/changeset/7a264cfb2505/
changeset:   7a264cfb2505
branch:      yt-3.0
user:        MatthewTurk
date:        2012-08-21 21:14:28
summary:     Polar coordinates initial field info for FLASH
affected #:  2 files

diff -r 544d6fe4efe4bdc8421fddcbabe0c2f34c02fcdd -r 7a264cfb25050fa21fe962a91eb1cb11af3d3dd0 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -44,7 +44,7 @@
     io_registry
 
 from .fields import FLASHFieldInfo, add_flash_field, KnownFLASHFields, \
-    CylindricalFLASHFieldInfo
+    CylindricalFLASHFieldInfo, PolarFLASHFieldInfo
 from yt.data_objects.field_info_container import FieldInfoContainer, NullFunc, \
      ValidateDataField
 
@@ -408,6 +408,8 @@
             self._setup_cartesian_coordinates()
         elif self.geometry == "cylindrical":
             self._setup_cylindrical_coordinates()
+        elif self.geometry == "polar":
+            self._setup_polar_coordinates()
         else:
             raise YTGeometryNotSupported(self.geometry)
 
@@ -443,6 +445,9 @@
             self.domain_left_edge[2] = 0.0
             self.domain_right_edge[2] = 2.0 * na.pi
 
+    def _setup_polar_coordinates(self):
+        pass
+
     @property
     def _fieldinfo_fallback(self):
         geom = self.parameters.get("geometry", "cartesian")
@@ -450,6 +455,8 @@
             return FLASHFieldInfo
         elif geom == "cylindrical":
             return CylindricalFLASHFieldInfo
+        elif geom == "polar":
+            return PolarFLASHFieldInfo
         else:
             raise RuntimeError
 


diff -r 544d6fe4efe4bdc8421fddcbabe0c2f34c02fcdd -r 7a264cfb25050fa21fe962a91eb1cb11af3d3dd0 yt/frontends/flash/fields.py
--- a/yt/frontends/flash/fields.py
+++ b/yt/frontends/flash/fields.py
@@ -47,6 +47,9 @@
 CylindricalFLASHFieldInfo = FieldInfoContainer.create_with_fallback(FLASHFieldInfo)
 add_cyl_field = CylindricalFLASHFieldInfo.add_field
 
+PolarFLASHFieldInfo = FieldInfoContainer.create_with_fallback(FLASHFieldInfo)
+add_pol_field = PolarFLASHFieldInfo.add_field
+
 # Common fields in FLASH: (Thanks to John ZuHone for this list)
 #
 # dens gas mass density (g/cc) --
@@ -309,3 +312,40 @@
 def _CylindricalVolume(field, data):
     return data["dtheta"] * data["r"] * data["dr"] * data["dz"]
 add_cyl_field("CellVolume", function=_CylindricalVolume)
+
+## Polar fields
+
+add_pol_field("dx", function=_unknown_coord)
+add_pol_field("dy", function=_unknown_coord)
+add_pol_field("x", function=_unknown_coord)
+add_pol_field("y", function=_unknown_coord)
+
+def _dr(field, data):
+    return na.ones(data.ActiveDimensions, dtype='float64') * data.dds[0]
+add_pol_field('dr', function=_dr, display_field=False,
+          validators=[ValidateSpatial(0)])
+
+def _dtheta(field, data):
+    return na.ones(data.ActiveDimensions, dtype='float64') * data.dds[1]
+add_pol_field('dtheta', function=_dtheta,
+          display_field=False, validators=[ValidateSpatial(0)])
+
+def _coordR(field, data):
+    dim = data.ActiveDimensions[0]
+    return (na.ones(data.ActiveDimensions, dtype='float64')
+                   * na.arange(data.ActiveDimensions[0])[:,None,None]
+            +0.5) * data['dr'] + data.LeftEdge[0]
+add_pol_field('r', function=_coordR, display_field=False,
+          validators=[ValidateSpatial(0)])
+
+def _coordTheta(field, data):
+    dim = data.ActiveDimensions[2]
+    return (na.ones(data.ActiveDimensions, dtype='float64')
+                   * na.arange(data.ActiveDimensions[1])[None,:,None]
+            +0.5) * data['dtheta'] + data.LeftEdge[1]
+add_pol_field('theta', function=_coordTheta, display_field=False,
+          validators=[ValidateSpatial(0)])
+
+def _CylindricalVolume(field, data):
+    return data["dtheta"] * data["r"] * data["dr"] * data["dz"]
+add_pol_field("CellVolume", function=_CylindricalVolume)

Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list