1. Matthew Turk
  2. enzo-dev-problem-types

Commits

Matthew Turk  committed 9ceb959

Adding a few more methods, including add_field, and an example invocation of
add_field.

  • Participants
  • Parent commits c4f2065
  • Branches week-of-code

Comments (0)

Files changed (3)

File src/enzo/ProblemType.C

View file
  • Ignore whitespace
     return;
 }
 
+int FieldContainer::needs(std::string field_name)
+{
+    if (this->default_values.count(field_name) == 0) return FALSE;
+    else return TRUE;
+}
+
 float& FieldContainer::operator[](std::string field_name)
 {
     if (this->field_values.count(field_name) == 0)

File src/enzo/ProblemType.h

View file
  • Ignore whitespace
 
 #include <string>
 
+class FieldContainer
+{
+    public:
+        float &operator[](std::string);
+        void add_field(std::string, float default_value);
+        void reset();
+        int needs(std::string field_name);
+    private:
+        std::map<std::string, float> field_values;
+        std::map<std::string, float> default_values;
+};
+
 class EnzoProblemType
 {
 /* These will be overridden in the public namespace by implementations */
             HierarchyEntry &TopGrid, TopGridData &MetaData)
     {return SUCCESS;}
     int AddDataLabel(const char *FieldName);
+    virtual void SetupFields(FieldContainer &Fields)
+    {return;}
 
 protected:
     //.. constructor
 //! failsafe version to select the plug-in
 EnzoProblemType *select_problem_type( std::string problem_type_name );
 
-class FieldContainer
-{
-    public:
-        float &operator[](std::string);
-        void add_field(std::string, float default_value);
-        void reset();
-    private:
-        std::map<std::string, float> field_values;
-        std::map<std::string, float> default_values;
-};
 
 
 #endif

File src/enzo/ProblemType_RotatingCylinder.C

View file
  • Ignore whitespace
     } 
 
 
+    void SetupFields(FieldContainer &Fields)
+    {
+        Fields.add_field("Density", 0.0);
+        Fields.add_field("TotalEnergy", 0.0);
+        Fields.add_field("GasEnergy", 0.0);
+        Fields.add_field("x-velocity", 0.0);
+        Fields.add_field("y-velocity", 0.0);
+        Fields.add_field("Metal_Density", 0.0);
+    }
+
 };
 
+
 //.. register:
 namespace{
     EnzoProblemType_creator_concrete<ProblemType_RotatingCylinder>