[cig-commits] r17119 - in short/3D/PyLith/trunk: . libsrc/topology
brad at geodynamics.org
brad at geodynamics.org
Wed Aug 25 13:08:56 PDT 2010
Author: brad
Date: 2010-08-25 13:08:55 -0700 (Wed, 25 Aug 2010)
New Revision: 17119
Added:
short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh
short/3D/PyLith/trunk/libsrc/topology/FieldsNew.icc
Modified:
short/3D/PyLith/trunk/TODO
Log:
Started work on new Fields object (FieldsNew). Added some stuff to TODO.
Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO 2010-08-25 19:36:41 UTC (rev 17118)
+++ short/3D/PyLith/trunk/TODO 2010-08-25 20:08:55 UTC (rev 17119)
@@ -23,15 +23,34 @@
Add elasticPrestep() to Formulation
Remove solnIncr, keep setField()
+* Reimplement Fields to use a single section.
+
+ Fields -> SolutionFields
+
+ FieldsNew<int fiberDim> [UniformSection]
+ add(name, label, fiberDim)
+ allocate()
+ section()
+ getField(name)
+
+ FieldMetadata
+ label
+ scale
+ dimensionsOkay
+
+ Field(section, metadata)
+
+
* Optimization
- + Reimplement Fields to use a single section.
- - SolutionFields (RealSection)
- - UniformFields (UniformSection)?
- + May be gotchas associated with Petsc Vec and scatters
+ inline methods (what isn't getting inlined) -Winline
+ Specialized elasticity integrator objects for Quad4, Hex8
- Add for lgdeform, implicit time integration?
+
+* Testing
+ + Need full-scale test with variation in physical properties
+ within a material.
+
* Lumped elasticity formulation for large deformations
----------------------------------------------------------------------
@@ -69,6 +88,36 @@
Make fault nucleation (initial tractions) modular (allow space/time
variation).
+* Time step based on strain rate
+
+ TimeStepStrainRate object
+ strainRateTarget
+ strainRateTolerance
+ maxDt
+ updateInterval
+
+ if (fabs(1.0 - strainRate / strainRateTarget) < tolerance) {
+ assert(strainRate != 0.0);
+ dtNew = dtOld * strainRateTolerance / strainRate;
+ if (dtNew > maxDt)
+ dtNew = maxDt;
+ } // if
+
+ ElasticMaterial
+ strain rate not stored for purely elastic materials
+
+ storeStrainRate()
+ set flag to store strain rate
+ maxStrainRate()
+ compute total strain (if nec)
+ compute strain rate, get maximum
+
+* Explicit time step
+
+ utility code
+ Compute stable explicit time step
+ Write stable time step explicit (CFL, adhoc)
+
* Manual
Are material models consistent with governing equations discussion?
Added: short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsNew.hh 2010-08-25 20:08:55 UTC (rev 17119)
@@ -0,0 +1,145 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/Fields.hh
+ *
+ * @brief Set of fields over a finite-element mesh. All fields are
+ * associated with the same points. We use uniform sections so the
+ * fiber dimension is set at compile time.
+ */
+
+#if !defined(pylith_topology_fields_hh)
+#define pylith_topology_fields_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include "pylith/topology/FieldBase.hh" // USES FieldBase::DomainEnum
+
+#include <string> // USES std::string
+
+// Fields ---------------------------------------------------------------
+/// Container for managing multiple fields over a finite-element mesh.
+template<typename field_type,
+ int fiberDimTotal>
+class pylith::topology::FieldsNew
+{ // Fields
+ friend class TestFieldsMesh; // unit testing
+ friend class TestFieldsSubMesh; // unit testing
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ Fields(const typename field_type::Mesh& mesh,
+ const pylith::topology::FieldBase::DomainEnum domain);
+
+ /// Destructor.
+ virtual
+ ~Fields(void);
+
+ /// Deallocate PETSc and local data structures.
+ virtual
+ void deallocate(void);
+
+ /** Check if fields contains a given field.
+ *
+ * @param name Name of field.
+ * @return True if fields contains field, false otherwise.
+ */
+ bool hasField(const char* name) const;
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field (used in output).
+ */
+ void add(const char* name,
+ const char* label);
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field.
+ * @param fiberDim Fiber dimension for field.
+ */
+ void add(const char* name,
+ const char* label,
+ const int fiberDim);
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ */
+ const field_type& getField(const char* name) const;
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ */
+ field_type& getField(const char* name);
+
+ /** Copy layout to other fields.
+ *
+ * @param name Name of field to use as template for layout.
+ */
+ void copyLayout(const char* name);
+
+ /** Get mesh associated with fields.
+ *
+ * @returns Finite-element mesh.
+ */
+ const typename field_type::Mesh& mesh(void) const;
+
+ /** Return the names of all fields.
+ *
+ * @returns an array of all field names
+ */
+ void fieldNames(int *numNames,
+ char ***outNames);
+
+// PROTECTED STRUCTS ////////////////////////////////////////////////////
+protected :
+
+ struct FieldInfo {
+ int fibration;
+ }; // FieldInfo
+
+// PROTECTED TYPEDEFS ///////////////////////////////////////////////////
+protected :
+
+ typedef std::map< std::string, field_type* > map_type;
+
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+protected :
+
+ map_type _fields;
+ const typename field_type::Mesh& _mesh;
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ Fields(const Fields&); ///< Not implemented
+ const Fields& operator=(const Fields&); ///< Not implemented
+
+}; // Fields
+
+#include "Fields.icc"
+
+#endif // pylith_topology_fields_hh
+
+
+// End of file
Added: short/3D/PyLith/trunk/libsrc/topology/FieldsNew.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsNew.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsNew.icc 2010-08-25 20:08:55 UTC (rev 17119)
@@ -0,0 +1,207 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_fields_hh)
+#error "Fields.icc must be included only from Fields.hh"
+#endif
+
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename field_type>
+pylith::topology::Fields<field_type>::Fields(const typename field_type::Mesh& mesh) :
+ _mesh(mesh)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+template<typename field_type>
+pylith::topology::Fields<field_type>::~Fields(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate PETSc and local data structures.
+template<typename field_type>
+void
+pylith::topology::Fields<field_type>::deallocate(void)
+{ // deallocate
+ const typename map_type::iterator begin = _fields.begin();
+ const typename map_type::iterator end = _fields.end();
+ for (typename map_type::iterator iter=begin; iter != end; ++iter) {
+ delete iter->second; iter->second = 0;
+ } // for
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Check if fields contains a given field.
+template<typename field_type>
+bool
+pylith::topology::Fields<field_type>::hasField(const char* name) const
+{ // hasField
+ typename map_type::const_iterator iter = _fields.find(name);
+ return iter != _fields.end();
+} // hasField
+
+// ----------------------------------------------------------------------
+// Add field.
+template<typename field_type>
+void
+pylith::topology::Fields<field_type>::add(const char* name,
+ const char* label)
+{ // add
+ if (hasField(name)) {
+ std::ostringstream msg;
+ msg << "Could not add field '" << name
+ << "' to fields manager, because it already exists.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ _fields[name] = new field_type(_mesh);
+ _fields[name]->label(label);
+} // add
+
+// ----------------------------------------------------------------------
+// Add field.
+template<typename field_type>
+void
+pylith::topology::Fields<field_type>::add(
+ const char* name,
+ const char* label,
+ const pylith::topology::FieldBase::DomainEnum domain,
+ const int fiberDim)
+{ // add
+ if (hasField(name)) {
+ std::ostringstream msg;
+ msg << "Could not add field '" << name
+ << "' to fields manager, because it already exists.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ _fields[name] = new field_type(_mesh);
+ _fields[name]->label(label);
+ _fields[name]->newSection(domain, fiberDim);
+} // add
+
+// ----------------------------------------------------------------------
+// Delete field.
+template<typename field_type>
+void
+pylith::topology::Fields<field_type>::del(const char* name)
+{ // del
+ typename map_type::iterator iter = _fields.find(name);
+ if (iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Could not find field '" << name
+ << "' in fields manager to delete.";
+ throw std::runtime_error(msg.str());
+ } // if
+ delete iter->second; iter->second = 0;
+ _fields.erase(name);
+} // del
+
+// ----------------------------------------------------------------------
+// Delete field.
+template<typename field_type>
+inline
+void
+pylith::topology::Fields<field_type>::delField(const char* name)
+{ // delField
+ del(name);
+} // delField
+
+// ----------------------------------------------------------------------
+// Get field.
+template<typename field_type>
+const field_type&
+pylith::topology::Fields<field_type>::get(const char* name) const
+{ // get
+ typename map_type::const_iterator iter = _fields.find(name);
+ if (iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Could not find field '" << name
+ << "' in fields manager for retrieval.";
+ throw std::runtime_error(msg.str());
+ } // if
+ return *iter->second;
+} // get
+
+// ----------------------------------------------------------------------
+// Get field.
+template<typename field_type>
+field_type&
+pylith::topology::Fields<field_type>::get(const char* name)
+{ // get
+ typename map_type::iterator iter = _fields.find(name);
+ if (iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Could not find field '" << name
+ << "' in fields manager for retrieval.";
+ throw std::runtime_error(msg.str());
+ } // if
+ return *iter->second;
+} // get
+
+// ----------------------------------------------------------------------
+// Copy layout to other fields.
+template<typename field_type>
+void
+pylith::topology::Fields<field_type>::copyLayout(const char* name)
+{ // copyLayout
+ typename map_type::const_iterator src = _fields.find(name);
+ if (src == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Could not find field '" << name
+ << "' in fields manager for retrieval.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ const typename map_type::iterator begin = _fields.begin();
+ const typename map_type::iterator end = _fields.end();
+ for (typename map_type::iterator iter=begin; iter != end; ++iter)
+ if (iter != src)
+ iter->second->cloneSection(*src->second);
+} // copyLayout
+
+// ----------------------------------------------------------------------
+// Get mesh associated with fields.
+template<typename field_type>
+const typename field_type::Mesh&
+pylith::topology::Fields<field_type>::mesh(void) const
+{ // mesh
+ return _mesh;
+} // mesh
+
+// ----------------------------------------------------------------------
+// Get names of all fields
+template<typename field_type>
+void
+pylith::topology::Fields<field_type>::fieldNames(int *numNames, char ***outNames)
+{ // fieldNames
+ *numNames = _fields.size();
+ PetscErrorCode ierr = PetscMalloc((*numNames) * sizeof(char *), outNames);
+ const typename map_type::const_iterator namesEnd = _fields.end();
+ int i = 0;
+ for (typename map_type::const_iterator name = _fields.begin(); name != namesEnd; ++name) {
+ char *newName;
+
+ ierr = PetscStrallocpy(name->first.c_str(), &newName);
+ (*outNames)[i++] = newName;
+ }
+} // fieldNames
+
+
+// End of file
More information about the CIG-COMMITS
mailing list