[cig-commits] r6470 - in short/3D/PyLith/trunk: examples/twotri3
libsrc/materials modulesrc/feassemble modulesrc/topology
pylith/meshio pylith/problems
brad at geodynamics.org
brad at geodynamics.org
Thu Mar 29 18:21:18 PDT 2007
Author: brad
Date: 2007-03-29 18:21:18 -0700 (Thu, 29 Mar 2007)
New Revision: 6470
Modified:
short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
short/3D/PyLith/trunk/libsrc/materials/Material.cc
short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src
short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
short/3D/PyLith/trunk/pylith/meshio/MeshIO.py
short/3D/PyLith/trunk/pylith/problems/Explicit.py
Log:
Fixed creating/getting/zeroing sections. Implemented bindings for IntegratorExplicit::integrateConstant(). Fixed some little bugs.
Modified: short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg 2007-03-29 23:59:29 UTC (rev 6469)
+++ short/3D/PyLith/trunk/examples/twotri3/pylithapp.cfg 2007-03-30 01:21:18 UTC (rev 6470)
@@ -24,6 +24,7 @@
# ----------------------------------------------------------------------
[pylithapp.mesh_generator.importer]
filename = twotri3.mesh
+coordsys.space_dim = 2
# ----------------------------------------------------------------------
# problem
@@ -38,6 +39,7 @@
# ----------------------------------------------------------------------
[pylithapp.eqdeformation.homogeneous.material]
label = elastic material
+id = 1
db.iohandler.filename = matprops.spatialdb
quadrature = pylith.feassemble.quadrature.Quadrature2D
quadrature.cell.shape = triangle
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2007-03-29 23:59:29 UTC (rev 6469)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2007-03-30 01:21:18 UTC (rev 6470)
@@ -63,6 +63,7 @@
for (int iParam=0; iParam < numParams; ++iParam) {
const ALE::Obj<real_section_type> parameter =
_parameters->getReal(paramNames[iParam]);
+
assert(numQuadPts == parameter->getFiberDimension(patch, cell));
const real_section_type::value_type* parameterCell =
parameter->restrict(patch, cell);
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.cc 2007-03-29 23:59:29 UTC (rev 6469)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.cc 2007-03-30 01:21:18 UTC (rev 6470)
@@ -78,6 +78,13 @@
topology->getLabelStratum(patch, "material-id", _id);
const topology_type::label_sequence::iterator cellsEnd = cells->end();
+ // Check to make sure we have cells
+ if (0 == cells->size()) {
+ std::ostringstream msg;
+ msg << "Could not find any cells for material '" << _label << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+
// Create sections to hold parameters for physical properties
delete _parameters; _parameters = new feassemble::ParameterManager(mesh);
const int numQuadPts = quadrature->numQuadPts();
@@ -151,7 +158,7 @@
} // for
for (int iParam=0; iParam < numParams; ++iParam) {
delete[] cellData[iParam]; cellData[iParam] = 0;
- } // fir
+ } // for
delete[] cellData; cellData = 0;
delete[] queryData; queryData = 0;
delete[] paramData; paramData = 0;
Modified: short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src 2007-03-29 23:59:29 UTC (rev 6469)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src 2007-03-30 01:21:18 UTC (rev 6470)
@@ -441,16 +441,57 @@
return
- def integrateConstant(fieldOut, fieldInT, fieldInTmdt, coords):
+ def integrateConstant(self, fieldOut, fieldInT, fieldInTmdt, coords):
"""
- Integrate residual term (b) for dynamic elasticity term for 3-D
- finite elemnts.
+ Integrate constant term (b) for dynamic elasticity term for 3-D
+ finite elements.
"""
- print "WARNING: IntegratorExplicit::integrateConstant not implemented."
+ # create shim for method 'integrateConstant'
+ #embed{ void IntegratorExplicit_integrateConstant(void* objVptr, void* fieldOutVptr, void* fieldInTVptr, void* fieldInTmdtVptr, void* coordsVptr)
+ typedef ALE::Mesh::real_section_type real_section_type;
+
+ try {
+ assert(0 != objVptr);
+ assert(0 != fieldOutVptr);
+ assert(0 != fieldInTVptr);
+ assert(0 != fieldInTmdtVptr);
+ assert(0 != coordsVptr);
+ ALE::Obj<real_section_type>* fieldOut =
+ (ALE::Obj<real_section_type>*) fieldOutVptr;
+ ALE::Obj<real_section_type>* fieldInT =
+ (ALE::Obj<real_section_type>*) fieldInTVptr;
+ ALE::Obj<real_section_type>* fieldInTmdt =
+ (ALE::Obj<real_section_type>*) fieldInTmdtVptr;
+ ALE::Obj<real_section_type>* coords =
+ (ALE::Obj<real_section_type>*) coordsVptr;
+ ((pylith::feassemble::IntegratorExplicit*) objVptr)->integrateConstant(
+ *fieldOut, *fieldInT, *fieldInTmdt, *coords);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (const ALE::Exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.msg().c_str()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+ cdef void* fieldOutVptr
+ cdef void* fieldInTVptr
+ cdef void* fieldInTmdtVptr
+ cdef void* coordsVptr
+ fieldOutVptr = PyCObject_AsVoidPtr(fieldOut)
+ fieldInTVptr = PyCObject_AsVoidPtr(fieldInT)
+ fieldInTmdtVptr = PyCObject_AsVoidPtr(fieldInTmdt)
+ coordsVptr = PyCObject_AsVoidPtr(coords)
+ IntegratorExplicit_integrateConstant(self.thisptr,
+ fieldOutVptr, fieldInTVptr,
+ fieldInTmdtVptr, coordsVptr)
return
- def integrateJacobian(mat, fieldIn, coords):
+ def integrateJacobian(self, mat, fieldIn, coords):
"""
Compute matrix (A) associated with operator.
"""
Modified: short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-03-29 23:59:29 UTC (rev 6469)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.pyxe.src 2007-03-30 01:21:18 UTC (rev 6470)
@@ -43,18 +43,6 @@
MeshPtr_destructor_cpp(obj)
return
-cdef void RealSection_destructor(void* obj):
- """
- Destroy real section.
- """
- #embed{ void RealSection_destructor_cpp(void* pObj)
- typedef ALE::Mesh::real_section_type real_section_type;
- ALE::Obj<real_section_type>* section = (ALE::Obj<real_section_type>*) pObj;
- delete section;
- #}embed
- RealSection_destructor_cpp(obj)
- return
-
# ----------------------------------------------------------------------
cdef class Mesh:
@@ -99,8 +87,10 @@
try {
ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) pObj;
assert(0 != mesh);
- result =
- (void*) new ALE::Obj<real_section_type>((*mesh)->getRealSection(label));
+ const ALE::Obj<real_section_type>& section =
+ (*mesh)->getRealSection(label);
+ assert(!section.isNull());
+ result = (void*) §ion;
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -112,7 +102,7 @@
#}embed
cdef void* ptr
ptr = Mesh_getRealSection(self.thisptr, label)
- return PyCObject_FromVoidPtr(ptr, RealSection_destructor)
+ return PyCObject_FromVoidPtr(ptr, NULL)
def createRealSection(self, label, fiberDim):
@@ -127,15 +117,13 @@
try {
ALE::Obj<ALE::Mesh>* mesh = (ALE::Obj<ALE::Mesh>*) pObj;
assert(0 != mesh);
- ALE::Obj<real_section_type>* pSection =
- new ALE::Obj<real_section_type>((*mesh)->getRealSection(label));
- assert(0 != *pSection);
- ALE::Obj<real_section_type>& section = *pSection;
+ const ALE::Obj<real_section_type>& section =
+ (*mesh)->getRealSection(label);
assert(!section.isNull());
const ALE::Mesh::topology_type::patch_type patch = 0;
section->setFiberDimensionByDepth(patch, 0, fiberDim);
section->allocate();
- result = (void*) *pSection;
+ result = (void*) §ion;
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -147,7 +135,7 @@
#}embed
cdef void* ptr
ptr = Mesh_createRealSection(self.thisptr, label, fiberDim)
- return PyCObject_FromVoidPtr(ptr, RealSection_destructor)
+ return PyCObject_FromVoidPtr(ptr, NULL)
def _createHandle(self):
@@ -157,4 +145,34 @@
return PyCObject_FromVoidPtr(self.thisptr, MeshPtr_destructor)
+def zeroRealSection(section):
+ """
+ Zero real section.
+ """
+ # create shim for zero section
+ #embed{ void* Section_zero(void* pObj)
+ typedef ALE::Mesh::real_section_type real_section_type;
+
+ try {
+ ALE::Obj<real_section_type>* section =
+ (ALE::Obj<real_section_type>*) pObj;
+ assert(!section->isNull());
+ const ALE::Mesh::topology_type::patch_type patch = 0;
+ (*section)->zero(patch);
+ } catch (const std::exception& err) {
+ PyErr_SetString(PyExc_RuntimeError,
+ const_cast<char*>(err.what()));
+ } catch (...) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Caught unknown C++ exception.");
+ } // try/catch
+ #}embed
+ cdef void* ptr
+ ptr = PyCObject_AsVoidPtr(section)
+ Section_zero(ptr)
+ return
+
+
+
+
# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/MeshIO.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIO.py 2007-03-29 23:59:29 UTC (rev 6469)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIO.py 2007-03-30 01:21:18 UTC (rev 6470)
@@ -73,6 +73,7 @@
mesh = Mesh()
if self.coordsys is None:
raise ValueError, "Coordinate system for mesh is unknown."
+ self.coordsys.initialize()
mesh.initialize(self.coordsys)
self.cppHandle.read(mesh.cppHandle)
return mesh
Modified: short/3D/PyLith/trunk/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Explicit.py 2007-03-29 23:59:29 UTC (rev 6469)
+++ short/3D/PyLith/trunk/pylith/problems/Explicit.py 2007-03-30 01:21:18 UTC (rev 6470)
@@ -123,10 +123,11 @@
Advance to next time step.
"""
self._info.log("Integrating constant term in operator.")
- # Need to zero out sections
- #for integrator in self.integrators:
- # integrator.integrateConstant(self.constant, self.dispT, self.dispTmdt,
- # self.coordinates)
+ import pylith.topology.topology as bindings
+ bindings.zeroRealSection(self.constant)
+ for integrator in self.integrators:
+ integrator.integrateConstant(self.constant, self.dispT, self.dispTmdt,
+ self.coordinates)
self._info.log("Solving equations.")
# solve
More information about the cig-commits
mailing list