[cig-commits] [commit] baagaard/feature-output-station-names, baagaard/feature-progress-monitor, baagaard/fix-custom-faultpc, baagaard/fix-faults-intersect, master: Cleanup by using Field::globalSection(). (1b880b2)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Nov 5 15:47:21 PST 2014
Repository : https://github.com/geodynamics/pylith
On branches: baagaard/feature-output-station-names,baagaard/feature-progress-monitor,baagaard/fix-custom-faultpc,baagaard/fix-faults-intersect,master
Link : https://github.com/geodynamics/pylith/compare/f33c75b19fd60eedb2a3405db76a1fee333bb1d7...5b6d812b1612809fea3bd331c4e5af98c25a536a
>---------------------------------------------------------------
commit 1b880b2d58cfed64bc4b264149b85358d8c79991
Author: Brad Aagaard <baagaard at usgs.gov>
Date: Mon Oct 27 15:38:37 2014 -0700
Cleanup by using Field::globalSection().
>---------------------------------------------------------------
1b880b2d58cfed64bc4b264149b85358d8c79991
libsrc/pylith/bc/PointForce.cc | 6 ++---
libsrc/pylith/faults/FaultCohesiveDyn.cc | 29 +++++++---------------
libsrc/pylith/faults/FaultCohesiveLagrange.cc | 35 ++++++++++-----------------
libsrc/pylith/topology/Field.cc | 15 +++++++-----
4 files changed, 33 insertions(+), 52 deletions(-)
diff --git a/libsrc/pylith/bc/PointForce.cc b/libsrc/pylith/bc/PointForce.cc
index a692380..0db178b 100644
--- a/libsrc/pylith/bc/PointForce.cc
+++ b/libsrc/pylith/bc/PointForce.cc
@@ -109,10 +109,8 @@ pylith::bc::PointForce::integrateResidual(const topology::Field& residual,
PetscScalar* valueArray = valueVisitor.localArray();
// Get global order
- PetscDM dmMesh = residual.dmMesh();assert(dmMesh);
- PetscSection globalSection = NULL;
- PetscErrorCode err;
- err = DMGetDefaultGlobalSection(dmMesh, &globalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection globalSection = residual.globalSection();assert(globalSection);
+ PetscErrorCode err = 0;
const int numPoints = _points.size();
const int numBCDOF = _bcDOF.size();
diff --git a/libsrc/pylith/faults/FaultCohesiveDyn.cc b/libsrc/pylith/faults/FaultCohesiveDyn.cc
index 5dfa27b..22cda36 100644
--- a/libsrc/pylith/faults/FaultCohesiveDyn.cc
+++ b/libsrc/pylith/faults/FaultCohesiveDyn.cc
@@ -209,9 +209,7 @@ pylith::faults::FaultCohesiveDyn::integrateResidual(const topology::Field& resid
const int spaceDim = _quadrature->spaceDim();
// Get sections associated with cohesive cells
- PetscDM residualDM = residual.dmMesh();assert(residualDM);
- PetscSection residualGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(residualDM, &residualGlobalSection);PYLITH_CHECK_ERROR(err);assert(residualGlobalSection);
+ PetscSection residualGlobalSection = residual.globalSection();assert(residualGlobalSection);
topology::VecVisitorMesh residualVisitor(residual);
PetscScalar* residualArray = residualVisitor.localArray();
@@ -251,6 +249,7 @@ pylith::faults::FaultCohesiveDyn::integrateResidual(const topology::Field& resid
#endif
// Loop over fault vertices
+ PetscErrorCode err = 0;
const int numVertices = _cohesiveVertices.size();
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
@@ -548,9 +547,7 @@ pylith::faults::FaultCohesiveDyn::constrainSolnSpace(topology::SolutionFields* c
topology::VecVisitorMesh dispTIncrVisitor(fields->get("dispIncr(t->t+dt)"));
const PetscScalar* dispTIncrArray = dispTIncrVisitor.localArray();
- PetscDM solnDM = fields->get("dispIncr(t->t+dt)").dmMesh();
- PetscSection dispTIncrGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(solnDM, &dispTIncrGlobalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection dispTIncrGlobalSection = fields->get("dispIncr(t->t+dt)").globalSection();assert(dispTIncrGlobalSection);
topology::VecVisitorMesh dispTIncrAdjVisitor(fields->get("dispIncr adjust"));
PetscScalar* dispTIncrAdjArray = dispTIncrAdjVisitor.localArray();
@@ -856,6 +853,7 @@ pylith::faults::FaultCohesiveDyn::constrainSolnSpace(topology::SolutionFields* c
dLagrangeVisitor.initialize(_fields->get("sensitivity dLagrange"));
dLagrangeArray = dLagrangeVisitor.localArray();
+ PetscErrorCode err = 0;
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int v_fault = _cohesiveVertices[iVertex].fault;
const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
@@ -1116,9 +1114,7 @@ pylith::faults::FaultCohesiveDyn::adjustSolnLumped(topology::SolutionFields* con
topology::VecVisitorMesh residualVisitor(fields->get("residual"));
const PetscScalar* residualArray = residualVisitor.localArray();
- PetscDM solnDM = fields->get("dispIncr(t->t+dt)").dmMesh();assert(solnDM);
- PetscSection solnGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(solnDM, &solnGlobalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection solnGlobalSection = fields->get("dispIncr(t->t+dt)").globalSection();assert(solnGlobalSection);
constrainSolnSpace_fn_type constrainSolnSpaceFn;
switch (spaceDim) { // switch
@@ -1145,6 +1141,7 @@ pylith::faults::FaultCohesiveDyn::adjustSolnLumped(topology::SolutionFields* con
_logger->eventBegin(computeEvent);
#endif
+ PetscErrorCode err = 0;
const int numVertices = _cohesiveVertices.size();
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
@@ -1702,13 +1699,10 @@ pylith::faults::FaultCohesiveDyn::_sensitivityUpdateJacobian(const bool negative
// Get solution field
const topology::Field& solutionDomain = fields.solution();
- PetscDM solutionDomainDM = solutionDomain.dmMesh();assert(solutionDomainDM);
PetscSection solutionDomainSection = solutionDomain.localSection();assert(solutionDomainSection);
PetscVec solutionDomainVec = solutionDomain.localVector();assert(solutionDomainVec);
- PetscSection solutionDomainGlobalSection = NULL;
+ PetscSection solutionDomainGlobalSection = solutionDomain.globalSection();assert(solutionDomainGlobalSection);
PetscScalar *solutionDomainArray = NULL;
- assert(solutionDomainSection);assert(solutionDomainVec);
- err = DMGetDefaultGlobalSection(solutionDomainDM, &solutionDomainGlobalSection);PYLITH_CHECK_ERROR(err);
// Get cohesive cells
PetscDM dmMesh = fields.mesh().dmMesh();assert(dmMesh);
@@ -1728,12 +1722,10 @@ pylith::faults::FaultCohesiveDyn::_sensitivityUpdateJacobian(const bool negative
PetscDM faultDMMesh = _faultMesh->dmMesh();assert(faultDMMesh);
// Get sensitivity solution field
- PetscDM solutionFaultDM = _fields->get("sensitivity solution").dmMesh();assert(solutionFaultDM);
PetscSection solutionFaultSection = _fields->get("sensitivity solution").localSection();assert(solutionFaultSection);
PetscVec solutionFaultVec = _fields->get("sensitivity solution").localVector();assert(solutionFaultVec);
- PetscSection solutionFaultGlobalSection = NULL;
+ PetscSection solutionFaultGlobalSection = _fields->get("sensitivity solution").globalSection();assert(solutionFaultGlobalSection);
PetscScalar* solutionFaultArray = NULL;
- err = DMGetDefaultGlobalSection(solutionFaultDM, &solutionFaultGlobalSection);PYLITH_CHECK_ERROR(err);
assert(_jacobian);
const PetscMat jacobianFaultMatrix = _jacobian->matrix();assert(jacobianFaultMatrix);
@@ -2101,10 +2093,7 @@ pylith::faults::FaultCohesiveDyn::_constrainSolnSpaceNorm(const PylithScalar alp
topology::Field& dispTIncr = fields->get("dispIncr(t->t+dt)");
topology::VecVisitorMesh dispTIncrVisitor(dispTIncr);
const PetscScalar* dispTIncrArray = dispTIncrVisitor.localArray();
-
- PetscDM solnDM = dispTIncr.dmMesh();assert(solnDM);
- PetscSection dispTIncrGlobalSection = NULL;
- err = DMGetDefaultGlobalSection(solnDM, &dispTIncrGlobalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection dispTIncrGlobalSection = dispTIncr.globalSection();assert(dispTIncrGlobalSection);
bool isOpening = false;
PylithScalar norm2 = 0.0;
diff --git a/libsrc/pylith/faults/FaultCohesiveLagrange.cc b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
index 9bc70d3..b7e4840 100644
--- a/libsrc/pylith/faults/FaultCohesiveLagrange.cc
+++ b/libsrc/pylith/faults/FaultCohesiveLagrange.cc
@@ -239,10 +239,8 @@ pylith::faults::FaultCohesiveLagrange::integrateResidual(const topology::Field&
const int spaceDim = _quadrature->spaceDim();
// Get sections associated with cohesive cells
- PetscDM residualDM = residual.dmMesh();assert(residualDM);
PetscSection residualSection = residual.localSection();assert(residualSection);
- PetscSection residualGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(residualDM, &residualGlobalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection residualGlobalSection = residual.globalSection();assert(residualGlobalSection);
topology::VecVisitorMesh residualVisitor(residual);
PetscScalar* residualArray = residualVisitor.localArray();
@@ -285,7 +283,7 @@ pylith::faults::FaultCohesiveLagrange::integrateResidual(const topology::Field&
// Compute contribution only if Lagrange constraint is local.
PetscInt goff = 0;
- err = PetscSectionGetOffset(residualGlobalSection, e_lagrange, &goff);PYLITH_CHECK_ERROR(err);
+ PetscErrorCode err = PetscSectionGetOffset(residualGlobalSection, e_lagrange, &goff);PYLITH_CHECK_ERROR(err);
if (goff < 0)
continue;
@@ -390,10 +388,8 @@ pylith::faults::FaultCohesiveLagrange::integrateJacobian(topology::Jacobian* jac
topology::VecVisitorMesh areaVisitor(area);
const PetscScalar* areaArray = areaVisitor.localArray();
- PetscDM solnDM = fields->solution().dmMesh();assert(solnDM);
PetscSection solnSection = fields->solution().localSection();assert(solnSection);
- PetscSection solnGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(solnDM, &solnGlobalSection);PYLITH_CHECK_ERROR(err);assert(solnGlobalSection);
+ PetscSection solnGlobalSection = fields->solution().globalSection();assert(solnGlobalSection);
// Get fault information
PetscDM dmMesh = fields->mesh().dmMesh();assert(dmMesh);
@@ -416,6 +412,7 @@ pylith::faults::FaultCohesiveLagrange::integrateJacobian(topology::Jacobian* jac
_logger->eventBegin(computeEvent);
#endif
+ PetscErrorCode err = 0;
const int numVertices = _cohesiveVertices.size();
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
@@ -545,9 +542,7 @@ pylith::faults::FaultCohesiveLagrange::integrateJacobian(topology::Field* jacobi
const int spaceDim = _quadrature->spaceDim();
- PetscDM jacobianDM = jacobian->dmMesh();assert(jacobianDM);
- PetscSection jacobianGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(jacobianDM, &jacobianGlobalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection jacobianGlobalSection = jacobian->globalSection();assert(jacobianGlobalSection);
topology::VecVisitorMesh jacobianVisitor(*jacobian);
PetscScalar* jacobianArray = jacobianVisitor.localArray();
@@ -557,6 +552,7 @@ pylith::faults::FaultCohesiveLagrange::integrateJacobian(topology::Field* jacobi
_logger->eventBegin(computeEvent);
#endif
+ PetscErrorCode err = 0;
const int numVertices = _cohesiveVertices.size();
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
@@ -656,13 +652,11 @@ pylith::faults::FaultCohesiveLagrange::calcPreconditioner(PetscMat* const precon
topology::VecVisitorMesh areaVisitor(area);
const PetscScalar* areaArray = areaVisitor.localArray();
- PetscDM solnDM = fields->solution().dmMesh();assert(solnDM);
- PetscSection solnGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(solnDM, &solnGlobalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection solnGlobalSection = fields->solution().globalSection();assert(solnGlobalSection);
PetscDM lagrangeDM = fields->solution().subfieldInfo("lagrange_multiplier").dm;assert(lagrangeDM);
- PetscSection lagrangeSection = NULL;
- err = DMGetDefaultGlobalSection(lagrangeDM, &lagrangeSection);PYLITH_CHECK_ERROR(err);
+ PetscSection lagrangeGlobalSection = NULL;
+ PetscErrorCode err = DMGetDefaultGlobalSection(lagrangeDM, &lagrangeGlobalSection);PYLITH_CHECK_ERROR(err);
_logger->eventEnd(setupEvent);
#if !defined(DETAILED_EVENT_LOGGING)
@@ -741,7 +735,7 @@ pylith::faults::FaultCohesiveLagrange::calcPreconditioner(PetscMat* const precon
// Set diagonal entries in preconditioned matrix.
PetscInt poff = 0;
- err = PetscSectionGetOffset(lagrangeSection, e_lagrange, &poff);PYLITH_CHECK_ERROR(err);
+ err = PetscSectionGetOffset(lagrangeGlobalSection, e_lagrange, &poff);PYLITH_CHECK_ERROR(err);
for (int iDim=0; iDim < spaceDim; ++iDim) {
err = MatSetValue(*precondMatrix, poff+iDim, poff+iDim, precondVertexL[iDim], INSERT_VALUES);PYLITH_CHECK_ERROR(err);
@@ -831,9 +825,7 @@ pylith::faults::FaultCohesiveLagrange::adjustSolnLumped(topology::SolutionFields
topology::VecVisitorMesh dispTIncrAdjVisitor(dispTIncrAdj);
PetscScalar* dispTIncrAdjArray = dispTIncrAdjVisitor.localArray();
- PetscDM jacobianDM = jacobian.dmMesh();
- PetscSection jacobianGlobalSection = NULL;
- PetscErrorCode err = DMGetDefaultGlobalSection(jacobianDM, &jacobianGlobalSection);PYLITH_CHECK_ERROR(err);
+ PetscSection jacobianGlobalSection = jacobian.globalSection();assert(jacobianGlobalSection);
_logger->eventEnd(setupEvent);
@@ -841,6 +833,7 @@ pylith::faults::FaultCohesiveLagrange::adjustSolnLumped(topology::SolutionFields
_logger->eventBegin(computeEvent);
#endif
+ PetscErrorCode err = 0;
const int numVertices = _cohesiveVertices.size();
for (int iVertex=0; iVertex < numVertices; ++iVertex) {
const int e_lagrange = _cohesiveVertices[iVertex].lagrange;
@@ -1902,12 +1895,10 @@ pylith::faults::FaultCohesiveLagrange::_getJacobianSubmatrixNP(PetscMat* jacobia
assert(indicesMatToSubmat);
// Get global order
- PetscDM solutionDM = fields.solution().dmMesh();
- PetscSection solutionGlobalSection = NULL;
+ PetscSection solutionGlobalSection = fields.solution().globalSection();assert(solutionGlobalSection);
PetscScalar *solutionArray = NULL;
PetscErrorCode err;
- err = DMGetDefaultGlobalSection(solutionDM, &solutionGlobalSection);PYLITH_CHECK_ERROR(err);
// Get Jacobian matrix
const PetscMat jacobianMatrix = jacobian.matrix();
diff --git a/libsrc/pylith/topology/Field.cc b/libsrc/pylith/topology/Field.cc
index a6cd26e..788dc98 100644
--- a/libsrc/pylith/topology/Field.cc
+++ b/libsrc/pylith/topology/Field.cc
@@ -543,9 +543,11 @@ pylith::topology::Field::cloneSection(const Field& src)
err = PetscObjectSetName((PetscObject) _localVec, _metadata.label.c_str());PYLITH_CHECK_ERROR(err);
// Reuse scatters in clone
+ _scatters.clear();
const scatter_map_type::const_iterator scattersEnd = src._scatters.end();
for (scatter_map_type::const_iterator s_iter=src._scatters.begin(); s_iter != scattersEnd; ++s_iter) {
- ScatterInfo sinfo;
+ ScatterInfo& sinfo = _scatters[s_iter->first];
+ sinfo.dm = 0;
sinfo.vector = 0;
// Copy DM
@@ -563,18 +565,19 @@ pylith::topology::Field::cloneSection(const Field& src)
err = PetscObjectReference((PetscObject) sinfo.vector);PYLITH_CHECK_ERROR(err);
} // if/else
err = PetscObjectSetName((PetscObject)sinfo.vector, _metadata.label.c_str());PYLITH_CHECK_ERROR(err);
-
- _scatters[s_iter->first] = sinfo;
} // for
// Reuse subfields in clone
+ _subfields.clear();
const subfields_type::const_iterator subfieldsEnd = src._subfields.end();
for (subfields_type::const_iterator s_iter=src._subfields.begin(); s_iter != subfieldsEnd; ++s_iter) {
- SubfieldInfo sinfo = s_iter->second;
+ SubfieldInfo& sinfo = _subfields[s_iter->first];
+ sinfo.metadata = s_iter->second.metadata;
+ sinfo.index = s_iter->second.index;
+ sinfo.dm = s_iter->second.dm;
if (sinfo.dm) {
err = PetscObjectReference((PetscObject) sinfo.dm);PYLITH_CHECK_ERROR(err);
} // if
- _subfields[s_iter->first] = sinfo;
} // for
PYLITH_METHOD_END;
@@ -746,7 +749,7 @@ pylith::topology::Field::copy(const Field& field)
PetscErrorCode err = VecCopy(field._localVec, _localVec);PYLITH_CHECK_ERROR(err);
// Update metadata
- _metadata.label = field._metadata.label;
+ label(field._metadata.label.c_str());
_metadata.vectorFieldType = field._metadata.vectorFieldType;
_metadata.scale = field._metadata.scale;
More information about the CIG-COMMITS
mailing list