[cig-commits] r14863 - in short/3D/PyLith/trunk: . applications doc/install doc/uml examples/3d/hex8 examples/bar_shearwave/hex8 examples/bar_shearwave/quad4 examples/bar_shearwave/tet4 examples/bar_shearwave/tri3 examples/twocells/twohex8 examples/twocells/twoquad4 examples/twocells/twotet4 examples/twocells/twotet4-geoproj examples/twocells/twotri3 libsrc libsrc/bc libsrc/faults libsrc/feassemble libsrc/materials libsrc/meshio libsrc/topology libsrc/utils modulesrc modulesrc/bc modulesrc/faults modulesrc/feassemble modulesrc/materials modulesrc/meshio modulesrc/mpi modulesrc/problems modulesrc/topology modulesrc/utils playpen pylith pylith/bc pylith/faults pylith/feassemble pylith/materials pylith/meshio pylith/problems pylith/topology pylith/utils tests tests/1d tests/1d/line2 tests/2d/tri3 unittests/libtests/bc unittests/libtests/faults unittests/libtests/faults/data unittests/libtests/feassemble unittests/libtests/materials unittests/libtests/materials/data unittests/libtests/meshio unittests/libtests/meshio/data unittests/libtests/topology unittests/pytests unittests/pytests/bc unittests/pytests/faults unittests/pytests/feassemble unittests/pytests/materials unittests/pytests/meshio unittests/pytests/problems unittests/pytests/topology unittests/pytests/utils
brad at geodynamics.org
brad at geodynamics.org
Mon May 4 16:10:25 PDT 2009
Author: brad
Date: 2009-05-04 16:09:34 -0700 (Mon, 04 May 2009)
New Revision: 14863
Added:
short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_risetime.spatialdb
short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_risetime.spatialdb
short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_risetime.spatialdb
short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_risetime.spatialdb
short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc
short/3D/PyLith/trunk/libsrc/bc/DirichletBC.hh
short/3D/PyLith/trunk/libsrc/bc/DirichletBC.icc
short/3D/PyLith/trunk/libsrc/bc/bcfwd.hh
short/3D/PyLith/trunk/libsrc/faults/TopologyOps.cc
short/3D/PyLith/trunk/libsrc/faults/TopologyOps.hh
short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.cc
short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.hh
short/3D/PyLith/trunk/libsrc/faults/faultsfwd.hh
short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.cc
short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.hh
short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.icc
short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.cc
short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.hh
short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.icc
short/3D/PyLith/trunk/libsrc/feassemble/feassemblefwd.hh
short/3D/PyLith/trunk/libsrc/materials/Metadata.cc
short/3D/PyLith/trunk/libsrc/materials/Metadata.hh
short/3D/PyLith/trunk/libsrc/materials/Metadata.icc
short/3D/PyLith/trunk/libsrc/materials/materialsfwd.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.hh
short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.cc
short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.hh
short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh
short/3D/PyLith/trunk/libsrc/problems/
short/3D/PyLith/trunk/libsrc/topology/Field.cc
short/3D/PyLith/trunk/libsrc/topology/Field.hh
short/3D/PyLith/trunk/libsrc/topology/Field.icc
short/3D/PyLith/trunk/libsrc/topology/FieldBase.cc
short/3D/PyLith/trunk/libsrc/topology/FieldBase.hh
short/3D/PyLith/trunk/libsrc/topology/Fields.hh
short/3D/PyLith/trunk/libsrc/topology/Fields.icc
short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc
short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh
short/3D/PyLith/trunk/libsrc/topology/SolutionFields.cc
short/3D/PyLith/trunk/libsrc/topology/SolutionFields.hh
short/3D/PyLith/trunk/libsrc/topology/SubMesh.cc
short/3D/PyLith/trunk/libsrc/topology/SubMesh.hh
short/3D/PyLith/trunk/libsrc/topology/SubMesh.icc
short/3D/PyLith/trunk/libsrc/topology/topologyfwd.hh
short/3D/PyLith/trunk/libsrc/utils/TestArray.cc
short/3D/PyLith/trunk/libsrc/utils/TestArray.hh
short/3D/PyLith/trunk/libsrc/utils/petscerror.h
short/3D/PyLith/trunk/libsrc/utils/utilsfwd.hh
short/3D/PyLith/trunk/modulesrc/bc/AbsorbingDampers.i
short/3D/PyLith/trunk/modulesrc/bc/BoundaryCondition.i
short/3D/PyLith/trunk/modulesrc/bc/DirichletBC.i
short/3D/PyLith/trunk/modulesrc/bc/DirichletBoundary.i
short/3D/PyLith/trunk/modulesrc/bc/Neumann.i
short/3D/PyLith/trunk/modulesrc/bc/bc.i
short/3D/PyLith/trunk/modulesrc/faults/BruneSlipFn.i
short/3D/PyLith/trunk/modulesrc/faults/ConstRateSlipFn.i
short/3D/PyLith/trunk/modulesrc/faults/EqKinSrc.i
short/3D/PyLith/trunk/modulesrc/faults/Fault.i
short/3D/PyLith/trunk/modulesrc/faults/FaultCohesive.i
short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveDyn.i
short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveKin.i
short/3D/PyLith/trunk/modulesrc/faults/LiuCosSlipFn.i
short/3D/PyLith/trunk/modulesrc/faults/SlipTimeFn.i
short/3D/PyLith/trunk/modulesrc/faults/StepSlipFn.i
short/3D/PyLith/trunk/modulesrc/faults/faults.i
short/3D/PyLith/trunk/modulesrc/feassemble/CellGeometry.i
short/3D/PyLith/trunk/modulesrc/feassemble/Constraint.i
short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityExplicit.i
short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityImplicit.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryHex3D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine1D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine2D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine3D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint1D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint2D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint3D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad2D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad3D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTet3D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri2D.i
short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri3D.i
short/3D/PyLith/trunk/modulesrc/feassemble/Integrator.i
short/3D/PyLith/trunk/modulesrc/feassemble/IntegratorElasticity.i
short/3D/PyLith/trunk/modulesrc/feassemble/Quadrature.i
short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i
short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i
short/3D/PyLith/trunk/modulesrc/include/
short/3D/PyLith/trunk/modulesrc/materials/ElasticIsotropic3D.i
short/3D/PyLith/trunk/modulesrc/materials/ElasticMaterial.i
short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStrain.i
short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStress.i
short/3D/PyLith/trunk/modulesrc/materials/ElasticStrain1D.i
short/3D/PyLith/trunk/modulesrc/materials/ElasticStress1D.i
short/3D/PyLith/trunk/modulesrc/materials/Material.i
short/3D/PyLith/trunk/modulesrc/materials/MaxwellIsotropic3D.i
short/3D/PyLith/trunk/modulesrc/materials/materials.i
short/3D/PyLith/trunk/modulesrc/meshio/CellFilter.i
short/3D/PyLith/trunk/modulesrc/meshio/CellFilterAvg.i
short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i
short/3D/PyLith/trunk/modulesrc/meshio/DataWriterVTK.i
short/3D/PyLith/trunk/modulesrc/meshio/MeshIOAscii.i
short/3D/PyLith/trunk/modulesrc/meshio/MeshIOCubit.i
short/3D/PyLith/trunk/modulesrc/meshio/MeshIOLagrit.i
short/3D/PyLith/trunk/modulesrc/meshio/MeshIOObj.i
short/3D/PyLith/trunk/modulesrc/meshio/OutputManager.i
short/3D/PyLith/trunk/modulesrc/meshio/OutputSolnSubset.i
short/3D/PyLith/trunk/modulesrc/meshio/VertexFilter.i
short/3D/PyLith/trunk/modulesrc/meshio/VertexFilterVecNorm.i
short/3D/PyLith/trunk/modulesrc/meshio/meshio.i
short/3D/PyLith/trunk/modulesrc/mpi/
short/3D/PyLith/trunk/modulesrc/problems/
short/3D/PyLith/trunk/modulesrc/topology/Distributor.i
short/3D/PyLith/trunk/modulesrc/topology/Field.i
short/3D/PyLith/trunk/modulesrc/topology/FieldBase.i
short/3D/PyLith/trunk/modulesrc/topology/Fields.i
short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i
short/3D/PyLith/trunk/modulesrc/topology/Mesh.i
short/3D/PyLith/trunk/modulesrc/topology/MeshOps.i
short/3D/PyLith/trunk/modulesrc/topology/SolutionFields.i
short/3D/PyLith/trunk/modulesrc/topology/SubMesh.i
short/3D/PyLith/trunk/modulesrc/topology/topology.i
short/3D/PyLith/trunk/modulesrc/utils/EventLogger.i
short/3D/PyLith/trunk/modulesrc/utils/TestArray.i
short/3D/PyLith/trunk/modulesrc/utils/petsc.i
short/3D/PyLith/trunk/modulesrc/utils/petsc_general.i
short/3D/PyLith/trunk/modulesrc/utils/petsc_mat.i
short/3D/PyLith/trunk/modulesrc/utils/utils.i
short/3D/PyLith/trunk/playpen/petscapp/
short/3D/PyLith/trunk/pylith/apps/
short/3D/PyLith/trunk/pylith/bc/DirichletBC.py
short/3D/PyLith/trunk/pylith/feassemble/CellGeometry.py
short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py
short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgMesh.py
short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgSubMesh.py
short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKMesh.py
short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubMesh.py
short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubSubMesh.py
short/3D/PyLith/trunk/pylith/meshio/MeshIOObj.py
short/3D/PyLith/trunk/pylith/meshio/OutputManagerMesh.py
short/3D/PyLith/trunk/pylith/meshio/OutputManagerSubMesh.py
short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormMesh.py
short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormSubMesh.py
short/3D/PyLith/trunk/pylith/mpi/
short/3D/PyLith/trunk/pylith/problems/Solver.py
short/3D/PyLith/trunk/pylith/problems/SolverLinear.py
short/3D/PyLith/trunk/pylith/problems/SolverNonlinear.py
short/3D/PyLith/trunk/pylith/topology/Field.py
short/3D/PyLith/trunk/pylith/topology/Fields.py
short/3D/PyLith/trunk/pylith/topology/Jacobian.py
short/3D/PyLith/trunk/pylith/topology/JacobianViewer.py
short/3D/PyLith/trunk/pylith/topology/SolutionFields.py
short/3D/PyLith/trunk/pylith/topology/SubMesh.py
short/3D/PyLith/trunk/pylith/utils/PetscComponent.py
short/3D/PyLith/trunk/tests/petsc/
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_risetime.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_risetime.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_risetime.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_risetime.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_risetime.spatialdb
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/line3.mesh
short/3D/PyLith/trunk/unittests/libtests/materials/data/matstrain.spatialdb
short/3D/PyLith/trunk/unittests/libtests/materials/data/matstress.spatialdb
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh
short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBC.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestLiuCosSlipFn.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestMeshQuadrature.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestSubMeshQuadrature.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticMaterial.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestDataWriterVTK.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerMesh.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerSubMesh.py
short/3D/PyLith/trunk/unittests/pytests/meshio/testcubit.py
short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py
short/3D/PyLith/trunk/unittests/pytests/mpi/
short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldBase.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestJacobian.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshField.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshFields.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestSolutionFields.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestSubMesh.py
short/3D/PyLith/trunk/unittests/pytests/topology/testtopology.py
Removed:
short/3D/PyLith/trunk/doc/uml/PyLith.vpp
short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_sliprate.spatialdb
short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_sliprate.spatialdb
short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_sliprate.spatialdb
short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_sliprate.spatialdb
short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.cc
short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.hh
short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.icc
short/3D/PyLith/trunk/libsrc/topology/Field.cc
short/3D/PyLith/trunk/libsrc/topology/Field.hh
short/3D/PyLith/trunk/libsrc/topology/Field.icc
short/3D/PyLith/trunk/libsrc/topology/FieldOps.cc
short/3D/PyLith/trunk/libsrc/topology/FieldOps.hh
short/3D/PyLith/trunk/libsrc/topology/FieldUniform.cc
short/3D/PyLith/trunk/libsrc/topology/FieldUniform.hh
short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc
short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh
short/3D/PyLith/trunk/libsrc/utils/vectorfields.hh
short/3D/PyLith/trunk/modulesrc/bc/bc.pyxe.src
short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src
short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src
short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src
short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src
short/3D/PyLith/trunk/pylith/PyLithApp.py
short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py
short/3D/PyLith/trunk/pylith/feassemble/geometry/
short/3D/PyLith/trunk/pylith/feassemble/quadrature/
short/3D/PyLith/trunk/pylith/meshio/CellFilterAvg.py
short/3D/PyLith/trunk/pylith/meshio/MeshIO.py
short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py
short/3D/PyLith/trunk/pylith/solver/
short/3D/PyLith/trunk/pylith/topology/Field.py
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_peakrate.spatialdb
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_cell_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_vertex_t10.vtk
short/3D/PyLith/trunk/unittests/libtests/topology/TestField.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestField.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh
short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletPoints.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestFault.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManager.py
short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py
short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver_cubit.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldsManager.py
short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py
Modified:
short/3D/PyLith/trunk/
short/3D/PyLith/trunk/DEPENDENCIES
short/3D/PyLith/trunk/Makefile.am
short/3D/PyLith/trunk/TODO
short/3D/PyLith/trunk/applications/pylith.in
short/3D/PyLith/trunk/configure.ac
short/3D/PyLith/trunk/doc/install/MacBookPro_Aagaard.txt
short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg
short/3D/PyLith/trunk/examples/3d/hex8/pylithapp.cfg
short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg
short/3D/PyLith/trunk/examples/3d/hex8/shearxy.cfg
short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg
short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg
short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg
short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg
short/3D/PyLith/trunk/examples/twocells/twohex8/axialdisp.cfg
short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twohex8/pylithapp.cfg
short/3D/PyLith/trunk/examples/twocells/twohex8/sheardisp.cfg
short/3D/PyLith/trunk/examples/twocells/twoquad4/axialdisp.cfg
short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg
short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twoquad4/pylithapp.cfg
short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/pylithapp.cfg
short/3D/PyLith/trunk/examples/twocells/twotet4/axialdisp.cfg
short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twotet4/pylithapp.cfg
short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg
short/3D/PyLith/trunk/examples/twocells/twotri3/pylithapp.cfg
short/3D/PyLith/trunk/libsrc/Makefile.am
short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.cc
short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.hh
short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.cc
short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.hh
short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.icc
short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc
short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh
short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc
short/3D/PyLith/trunk/libsrc/bc/Makefile.am
short/3D/PyLith/trunk/libsrc/bc/Neumann.cc
short/3D/PyLith/trunk/libsrc/bc/Neumann.hh
short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc
short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.hh
short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.icc
short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc
short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.hh
short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh
short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc
short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.cc
short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh
short/3D/PyLith/trunk/libsrc/faults/Fault.cc
short/3D/PyLith/trunk/libsrc/faults/Fault.hh
short/3D/PyLith/trunk/libsrc/faults/Fault.icc
short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc
short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh
short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.cc
short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.hh
short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh
short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc
short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.hh
short/3D/PyLith/trunk/libsrc/faults/Makefile.am
short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.cc
short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.hh
short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc
short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh
short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc
short/3D/PyLith/trunk/libsrc/feassemble/CellGeometry.hh
short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc
short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryHex3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine1D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine2D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint1D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint2D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad2D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryTet3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri2D.hh
short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Integrator.cc
short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh
short/3D/PyLith/trunk/libsrc/feassemble/Integrator.icc
short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc
short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.hh
short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.icc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.icc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.icc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.icc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.icc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.icc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.icc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.cc
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.hh
short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.icc
short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.hh
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh
short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc
short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.hh
short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.hh
short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.hh
short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc
short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.hh
short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc
short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.hh
short/3D/PyLith/trunk/libsrc/materials/Makefile.am
short/3D/PyLith/trunk/libsrc/materials/Material.cc
short/3D/PyLith/trunk/libsrc/materials/Material.hh
short/3D/PyLith/trunk/libsrc/materials/Material.icc
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh
short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc
short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.cc
short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.hh
short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.hh
short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc
short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh
short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.cc
short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.hh
short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc
short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc
short/3D/PyLith/trunk/libsrc/meshio/GMVFile.hh
short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc
short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.hh
short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc
short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.hh
short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.hh
short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc
short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh
short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc
short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.cc
short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh
short/3D/PyLith/trunk/libsrc/meshio/PsetFile.hh
short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.hh
short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh
short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.cc
short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.hh
short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc
short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.hh
short/3D/PyLith/trunk/libsrc/topology/Distributor.cc
short/3D/PyLith/trunk/libsrc/topology/Distributor.hh
short/3D/PyLith/trunk/libsrc/topology/Makefile.am
short/3D/PyLith/trunk/libsrc/topology/Mesh.cc
short/3D/PyLith/trunk/libsrc/topology/Mesh.hh
short/3D/PyLith/trunk/libsrc/topology/Mesh.icc
short/3D/PyLith/trunk/libsrc/topology/MeshOps.cc
short/3D/PyLith/trunk/libsrc/topology/MeshOps.hh
short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh
short/3D/PyLith/trunk/libsrc/utils/Makefile.am
short/3D/PyLith/trunk/libsrc/utils/petscfwd.h
short/3D/PyLith/trunk/libsrc/utils/sievefwd.hh
short/3D/PyLith/trunk/libsrc/utils/sievetypes.hh
short/3D/PyLith/trunk/modulesrc/
short/3D/PyLith/trunk/modulesrc/Makefile.am
short/3D/PyLith/trunk/modulesrc/bc/
short/3D/PyLith/trunk/modulesrc/bc/Makefile.am
short/3D/PyLith/trunk/modulesrc/faults/
short/3D/PyLith/trunk/modulesrc/faults/Makefile.am
short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
short/3D/PyLith/trunk/modulesrc/feassemble/
short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am
short/3D/PyLith/trunk/modulesrc/materials/
short/3D/PyLith/trunk/modulesrc/materials/Makefile.am
short/3D/PyLith/trunk/modulesrc/meshio/
short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am
short/3D/PyLith/trunk/modulesrc/topology/
short/3D/PyLith/trunk/modulesrc/topology/Makefile.am
short/3D/PyLith/trunk/modulesrc/utils/
short/3D/PyLith/trunk/modulesrc/utils/Makefile.am
short/3D/PyLith/trunk/pylith/Makefile.am
short/3D/PyLith/trunk/pylith/__init__.py
short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py
short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py
short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py
short/3D/PyLith/trunk/pylith/bc/Neumann.py
short/3D/PyLith/trunk/pylith/bc/__init__.py
short/3D/PyLith/trunk/pylith/faults/BruneSlipFn.py
short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py
short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py
short/3D/PyLith/trunk/pylith/faults/Fault.py
short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py
short/3D/PyLith/trunk/pylith/faults/FaultCohesiveKin.py
short/3D/PyLith/trunk/pylith/faults/LiuCosSlipFn.py
short/3D/PyLith/trunk/pylith/faults/SingleRupture.py
short/3D/PyLith/trunk/pylith/faults/SlipTimeFn.py
short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py
short/3D/PyLith/trunk/pylith/feassemble/Constraint.py
short/3D/PyLith/trunk/pylith/feassemble/ElasticityExplicit.py
short/3D/PyLith/trunk/pylith/feassemble/ElasticityImplicit.py
short/3D/PyLith/trunk/pylith/feassemble/FIATLagrange.py
short/3D/PyLith/trunk/pylith/feassemble/FIATSimplex.py
short/3D/PyLith/trunk/pylith/feassemble/Integrator.py
short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py
short/3D/PyLith/trunk/pylith/feassemble/__init__.py
short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py
short/3D/PyLith/trunk/pylith/materials/ElasticMaterial.py
short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py
short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py
short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py
short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py
short/3D/PyLith/trunk/pylith/materials/Material.py
short/3D/PyLith/trunk/pylith/materials/MaxwellIsotropic3D.py
short/3D/PyLith/trunk/pylith/meshio/CellFilter.py
short/3D/PyLith/trunk/pylith/meshio/DataWriter.py
short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py
short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py
short/3D/PyLith/trunk/pylith/meshio/MeshIOCubit.py
short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py
short/3D/PyLith/trunk/pylith/meshio/OutputDirichlet.py
short/3D/PyLith/trunk/pylith/meshio/OutputFaultKin.py
short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
short/3D/PyLith/trunk/pylith/meshio/OutputMatElastic.py
short/3D/PyLith/trunk/pylith/meshio/OutputNeumann.py
short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py
short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py
short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py
short/3D/PyLith/trunk/pylith/meshio/__init__.py
short/3D/PyLith/trunk/pylith/problems/Explicit.py
short/3D/PyLith/trunk/pylith/problems/Formulation.py
short/3D/PyLith/trunk/pylith/problems/Implicit.py
short/3D/PyLith/trunk/pylith/problems/Problem.py
short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
short/3D/PyLith/trunk/pylith/problems/TimeStep.py
short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py
short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py
short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py
short/3D/PyLith/trunk/pylith/problems/__init__.py
short/3D/PyLith/trunk/pylith/topology/Distributor.py
short/3D/PyLith/trunk/pylith/topology/Mesh.py
short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py
short/3D/PyLith/trunk/pylith/topology/__init__.py
short/3D/PyLith/trunk/pylith/utils/CppData.py
short/3D/PyLith/trunk/pylith/utils/EventLogger.py
short/3D/PyLith/trunk/pylith/utils/PetscManager.py
short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py
short/3D/PyLith/trunk/pylith/utils/__init__.py
short/3D/PyLith/trunk/tests/1d/Makefile.am
short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py
short/3D/PyLith/trunk/tests/1d/line2/axialextension.cfg
short/3D/PyLith/trunk/tests/1d/line2/testpylith.py
short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py
short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation.py
short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation2.py
short/3D/PyLith/trunk/tests/2d/tri3/TestShearPlaneStrain.py
short/3D/PyLith/trunk/tests/2d/tri3/axialplanestrain.cfg
short/3D/PyLith/trunk/tests/2d/tri3/dislocation.cfg
short/3D/PyLith/trunk/tests/2d/tri3/dislocation2.cfg
short/3D/PyLith/trunk/tests/2d/tri3/shearplanestrain.cfg
short/3D/PyLith/trunk/tests/2d/tri3/testpylith.py
short/3D/PyLith/trunk/tests/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersHex8.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersLine2.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTet4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTri3.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryCondition.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryMesh.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryHex8.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTet4.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTri3.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.hh
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannHex8.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannLine2.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTet4.cc
short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTri3.cc
short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcs.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsHex8.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsLine2.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTet4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTri3.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.hh
short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc
short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.cc
short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.hh
short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/feassemble/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestCellGeometry.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.hh
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.cc
short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.hh
short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3D.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialApp.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrain.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStress.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1D.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1D.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc
short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh
short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh
short/3D/PyLith/trunk/unittests/libtests/materials/data/matinitialize.spatialdb
short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputManager.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKData.hh
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshHex8.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshLine2.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshQuad4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTet4.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc
short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3.mesh
short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am
short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldUniform.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.cc
short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.hh
short/3D/PyLith/trunk/unittests/libtests/topology/TestMeshOps.cc
short/3D/PyLith/trunk/unittests/pytests/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/bc/TestAbsorbingDampers.py
short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBoundary.py
short/3D/PyLith/trunk/unittests/pytests/bc/TestNeumann.py
short/3D/PyLith/trunk/unittests/pytests/bc/testbc.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestBruneSlipFn.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesiveKin.py
short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py
short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestCellGeometry.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityExplicit.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityImplicit.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATLagrange.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py
short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py
short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py
short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py
short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOCubit.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOLagrit.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnSubset.py
short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py
short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStep.py
short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepAdapt.py
short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUniform.py
short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUser.py
short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am
short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py
short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
short/3D/PyLith/trunk/unittests/pytests/utils/TestEventLogger.py
short/3D/PyLith/trunk/unittests/pytests/utils/TestPetscManager.py
Log:
Merged SWIG branch into trunk.
Property changes on: short/3D/PyLith/trunk
___________________________________________________________________
Name: svn:ignore
- configure
Makefile.in
aux-config
autom4te.cache
portinfo.in
aclocal.m4
+ Makefile.in
configure
aux-config
portinfo.in
PyLith.egg-info
autom4te.cache
aclocal.m4
Modified: short/3D/PyLith/trunk/DEPENDENCIES
===================================================================
--- short/3D/PyLith/trunk/DEPENDENCIES 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/DEPENDENCIES 2009-05-04 23:09:34 UTC (rev 14863)
@@ -7,9 +7,8 @@
proj
numpy
FIAT
-pyrexembed (from CIG)
-Pyrex
nemesis
+SWIG (if building from repository)
OPTIONAL DEPENDENCIES
Modified: short/3D/PyLith/trunk/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,7 +10,7 @@
# ----------------------------------------------------------------------
#
-ACLOCAL_AMFLAGS = -I./m4
+ACLOCAL_AMFLAGS = -Im4
SUBDIRS = \
libsrc \
Modified: short/3D/PyLith/trunk/TODO
===================================================================
--- short/3D/PyLith/trunk/TODO 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/TODO 2009-05-04 23:09:34 UTC (rev 14863)
@@ -2,13 +2,94 @@
CURRENT ISSUES/PRIORITIES
======================================================================
-0. Add flag to flip which side of fault vertices are replaced when
- creating cohesive cells [Matt]
+-1. Fix Tabrez's bug. [Matt]
- Update unit tests.
+0. SWIG conversion [Brad]
-1. Reduce memory use (new labels) [Matt]
+ (3) Full-scale tests (few 1-D, 2-D, and 3-D)
+ Analytical solutions, time stepping, multiple faults
+
+ (4) SNES
+ Reformulate implicit time stepping to use displacement increment.
+ Solution fields should be disp(t) and dispIncr(t).
+ If solnIncr is true, Dirichlet BC set increment values in dispIncr(t).
+
+ (5) Add missing unit tests
+
+ (6) Tidy up
+
+ Add simple stableTimeStep() for elastic materials.
+
+ Check use of label_sequence. label_sequence - iterators are
+ cached, so use sequence or cache begin/end to maintain access
+
+ Cleanup use of heightStratum() and depthStratum().
+
+ Cleanup logging. Constraints and Integrators should log at the C++
+ level using the C++ EventLogger. Add finer grain logging at C++
+ level as in ElasticityImplicit.
+
+ Update journaling.
+
+ Eliminate use of Inventory class.
+
+ add test_factory() methods to Python unit tests
+
+ Cleanup error checking on PETSc calls.
+ FaultCohesiveKin
+ DataWriterVTK
+
+ pytests
+ test_configure
+
+ Switch Components to PetscComponents.
+ Add _cleanup() to components to deallocate local data structures.
+ Add cleanup() to non-components to deallocate local data structures.
+
+ Create createModuleObj() methods to Python objects as standard way
+ of creating handle to C++ object (not necessary in abstract base
+ classes).
+
+ Add check before calling newSection() when want to enforce at
+ least 1 value.
+
+ Distribution debug (dump VTK) needs Nondimensional
+
+ libsrc/materials
+ Generalized Maxwell materials
+
+ libtests/materials
+ Cleanup testUpdateStateVars for Maxwell models
+
+ libtests/bc/TestDirichletBoundary::testVertexField()
+ libtests/bc/TestDirichletBoundary::testBoundaryMesh()
+
+ pytests/bc/TestDirichletBoundary
+ pytests/bc/TestNeumann (output)
+
+ libtests/feassemble/ElasticityExplict
+ testVerifyConfiguration()
+ testCellField()
+ libtests/feassemble/ElasticityImplict
+ testVerifyConfiguration()
+ testCellField()
+ libtests/materials/Material
+ propertyField()
+ stateVarField()
+
+ DirichletPoints (Python) - rate == None -> dbRate == 0
+ DirichletBoundary (Python) - rate == None -> dbRate == 0
+
+ pytests.meshio.TestOutputSoln
+ pytests.meshio.TestOutputDirichlet
+ pytests.meshio.TestOutputFaultKin
+ pytests.meshio.TestOutputMatElastic
+ pytests.meshio.TestOutputNeumann
+
+1. Memory model [Matt]
+ playpen/memcheck/*
+
2. Nondimensionalize [Brad]
Not working
coordinates in output (nondimensional instead of dimensioned)
@@ -20,42 +101,65 @@
FieldOps::copyValues (obsolete?)
MeshIO::normalizer()
Material::normalizer()
- Material::_nodimProperties()
- Material::_dimProperties()
Constraint::normalizer()
Integrator::normalizer()
DataWriter::normalizer()
-3. Mesh, Field, and FieldUniform objects [Brad]
- Change name of FieldsManager to SolutionFields
- (more accurate description).
+3. 3-D Power-law rheology [Charles]
-4. Clean-up interface for materials [Brad]
+4. 2-D Plane strain Maxwell viscoelastic rheology [Charles]
-5. Power-law nonlinear rheology [Charles]
+5. 2-D Plane strain Generalized Maxwell viscoelastic rheology [Charles]
-6. Savage-Presscott benchmark [Charles]
+6. 2-D Power-law rheology [Charles]
2D viscoelastic models for plane strain
-7. Interface with PETSc nonlinear solvers [Brad and Matt]
+7. Initial stress, strain, state variables for inelastic models [Charles]
-8. Modularize output? [Matt]
+8. Savage-Presscott benchmark [Charles]
HDF5 output
--- Release (v1.4) --
-
-9. Fault friction
-
-Other
-
- 1. Reverse-slip benchmark.
+9. Analytic BC for reverse-slip benchmark [Charles or Brad]
a. Create BC for CUBIT mesh.
b. Create BC for LaGriT mesh.
c. Run benchmarks.
d. Generate analytic solutions.
e. Tabulate results.
+10. PETSc SNES nonlinear solvers [Matt]
+11. Add ability to use symmetric matrix, set block size (default is 1)
+
+12. Update manual for version 1.4 [Brad and Charles]
+
+ * Reduce memory use with ordering elements by material
+
+ * Nondimensionalization
+
+ * Material
+ * initial stress, strain, and state variables
+ * Cleanup notation and discussion of inelastic materials
+
+ * Incompatibilities
+ importer -> reader
+ material
+ db -> properties_db
+ no need to set Quadrature type
+ CellFilterAvg Mesh/SubMesh
+
+-- Release (v1.4) --
+
+Modularize output? [Matt]
+ "field_dimensioned" is prefered to "field"
+
+Fault friction
+
+Uniform refinement (debug, check, all cell types)
+
+Cuthill-McKee ordering of vertices
+
+Cleanup SlipTimeFn tests (refactor test/initialize stuff)
+
======================================================================
KNOWN DEFICIENCIES
======================================================================
@@ -174,8 +278,6 @@
LONG TERM WISH LIST
----------------------------------------------------------------------
- 1. Replace Pyrex/pyrexembed with SWIG
-
4. HDF5 output
HDF5 files
Modified: short/3D/PyLith/trunk/applications/pylith.in
===================================================================
--- short/3D/PyLith/trunk/applications/pylith.in 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/applications/pylith.in 2009-05-04 23:09:34 UTC (rev 14863)
@@ -28,7 +28,7 @@
sys.path.insert(1, directory)
site.addsitedir(directory)
- from pylith.PyLithApp import PyLithApp
+ from pylith.apps.PyLithApp import PyLithApp
from pyre.applications import start
start(applicationClass=PyLithApp)
Modified: short/3D/PyLith/trunk/configure.ac
===================================================================
--- short/3D/PyLith/trunk/configure.ac 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/configure.ac 2009-05-04 23:09:34 UTC (rev 14863)
@@ -107,22 +107,13 @@
# Check for Python modules and packages.
CIT_PYTHON_EGG_SETUP
-# PYREX/PYREXEMBED
-AC_CHECK_PROG([have_pyrex],
- [pyrexc],
- [yes],
- [no])
-if test "$have_pyrex" = "no"; then
- AC_MSG_ERROR([Pyrex not found in current path.])
-fi
-AC_CHECK_PROG([have_pyrexembed],
- [pyrexembed],
- [yes],
- [no])
-if test "$have_pyrexembed" = "no"; then
- AC_MSG_ERROR([Pyrexembed not found in current path.])
-fi
+# NUMPY
+CIT_NUMPY_PYTHON_MODULE
+CIT_NUMPY_INCDIR
+# SWIG
+AC_PROG_SWIG(1.3.33)
+
# CPPUNIT
if test "$enable_testing" = "yes" ; then
AC_LANG(C++)
@@ -211,6 +202,9 @@
fi
fi
+# Check whether compiler sets variable with function names.
+CIT_FUNCTIONSTRING
+
# ENDIANNESS
AC_C_BIGENDIAN
@@ -223,6 +217,7 @@
libsrc/faults/Makefile
libsrc/materials/Makefile
libsrc/meshio/Makefile
+ libsrc/problems/Makefile
libsrc/topology/Makefile
libsrc/utils/Makefile
modulesrc/Makefile
@@ -231,7 +226,8 @@
modulesrc/feassemble/Makefile
modulesrc/materials/Makefile
modulesrc/meshio/Makefile
- modulesrc/solver/Makefile
+ modulesrc/mpi/Makefile
+ modulesrc/problems/Makefile
modulesrc/topology/Makefile
modulesrc/utils/Makefile
applications/Makefile
@@ -261,15 +257,16 @@
unittests/pytests/materials/data/Makefile
unittests/pytests/meshio/Makefile
unittests/pytests/meshio/data/Makefile
+ unittests/pytests/mpi/Makefile
unittests/pytests/problems/Makefile
unittests/pytests/problems/data/Makefile
unittests/pytests/topology/Makefile
unittests/pytests/topology/data/Makefile
unittests/pytests/utils/Makefile
tests/Makefile
+ tests/petsc/Makefile
tests/1d/Makefile
tests/1d/line2/Makefile
- tests/1d/line3/Makefile
tests/2d/Makefile
tests/2d/tri3/Makefile
tests/2d/quad4/Makefile
Modified: short/3D/PyLith/trunk/doc/install/MacBookPro_Aagaard.txt
===================================================================
--- short/3D/PyLith/trunk/doc/install/MacBookPro_Aagaard.txt 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/doc/install/MacBookPro_Aagaard.txt 2009-05-04 23:09:34 UTC (rev 14863)
@@ -96,8 +96,8 @@
To create libmpich.dylib:
cd ${TOOLS_DIR}/mpich2-1.0.5/${TOOLS_FORMAT}/lib
- mkdir lib
- cd lib
+ mkdir tmp
+ cd tmp
ar -x ../libmpich.a
gcc -dynamiclib -single_module -undefined dynamic_lookup -o ${TOOLS_DIR}/mpich2-1.0.5/${TOOLS_FORMAT}/lib/libmpich.dylib *.o
rm *.o
Deleted: short/3D/PyLith/trunk/doc/uml/PyLith.vpp
===================================================================
(Binary files differ)
Modified: short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/3d/hex8/dislocation.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -69,7 +69,6 @@
[pylithapp.timedependent.interfaces.fault]
label = 10
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
mat_db.iohandler.filename = mat_elastic.spatialdb
@@ -97,11 +96,11 @@
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.elastic.output]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = dislocation-statevars-elastic.vtk
[pylithapp.timedependent.materials.viscoelastic.output]
cell_info_fields = [density,mu,lambda,maxwell_time]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = dislocation-statevars-viscoelastic.vtk
Modified: short/3D/PyLith/trunk/examples/3d/hex8/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/pylithapp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/3d/hex8/pylithapp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -27,10 +27,10 @@
[pylithapp.mesh_generator]
#debug = 1 ; uncomment to get very verbose mesh information
-# Change the default mesh importer to the CUBIT importer.
-importer = pylith.meshio.MeshIOCubit
+# Change the default mesh reader to the CUBIT reader.
+reader = pylith.meshio.MeshIOCubit
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
# Set filename of mesh to import.
filename = box_hex8_1000m.exo
@@ -60,16 +60,14 @@
[pylithapp.timedependent.materials.elastic]
label = Elastic material
id = 1
-db.iohandler.filename = mat_elastic.spatialdb
-quadrature = pylith.feassemble.quadrature.Quadrature3D
+properties_db.iohandler.filename = mat_elastic.spatialdb
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 3
[pylithapp.timedependent.materials.viscoelastic]
label = Viscoelastic material
id = 2
-db.iohandler.filename = mat_viscoelastic.spatialdb
-quadrature = pylith.feassemble.quadrature.Quadrature3D
+properties_db.iohandler.filename = mat_viscoelastic.spatialdb
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 3
Modified: short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/3d/hex8/savageprescott.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -88,7 +88,6 @@
[pylithapp.timedependent.interfaces.fault]
label = 10
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
mat_db.iohandler.filename = mat_elastic.spatialdb
@@ -152,7 +151,7 @@
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.elastic.output]
skip = 9
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = savageprescott-statevars-elastic.vtk
writer.time_format = %04.0f
writer.time_constant = 1.0*year
@@ -160,7 +159,7 @@
[pylithapp.timedependent.materials.viscoelastic.output]
cell_info_fields = [density,mu,lambda,maxwell_time]
skip = 9
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = savageprescott-statevars-viscoelastic.vtk
writer.time_format = %04.0f
writer.time_constant = 1.0*year
Modified: short/3D/PyLith/trunk/examples/3d/hex8/shearxy.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/3d/hex8/shearxy.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/3d/hex8/shearxy.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -75,10 +75,10 @@
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.elastic.output]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = shearxy-statevars-elastic.vtk
[pylithapp.timedependent.materials.viscoelastic.output]
cell_info_fields = [density,mu,lambda,maxwell_time]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = shearxy-statevars-viscoelastic.vtk
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -31,9 +31,9 @@
# ----------------------------------------------------------------------
[pylithapp.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOCubit
+reader = pylith.meshio.MeshIOCubit
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename = bar_hex8_200m.exo
# ----------------------------------------------------------------------
@@ -77,11 +77,10 @@
id = 1
# Spatial database with physical properties for elastic material
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
# Set the basis functions and quadrature:
# 3-D Lagrange cell with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 3
quadrature.cell.quad_order = 2
@@ -101,7 +100,6 @@
# Specify the basis functions and quadrature:
# 2-D Lagrange cell in 3-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
quadrature.cell.quad_order = 2
@@ -118,7 +116,6 @@
# Specify the basis functions and quadrature:
# 2-D Lagrange cell in 3-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
quadrature.cell.quad_order = 2
@@ -156,7 +153,6 @@
# Specify the basis functions and quadrature:
# 2-D Lagrange cell in 3-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
quadrature.cell.quad_order = 2
@@ -173,8 +169,8 @@
# Database specifying the final slip.
slip.iohandler.filename = shearwave_slip.spatialdb
-# Database specifying peak slip rate.
-slip_rate.iohandler.filename = shearwave_sliprate.spatialdb
+# Database specifying rise time.
+rise_time.iohandler.filename = shearwave_risetime.spatialdb
# Database specifying time at which slip begins at each point.
slip_time.iohandler.filename = shearwave_sliptime.spatialdb
@@ -222,4 +218,4 @@
writer.time_format = %05.2f
# Averate state variables over cell
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
Copied: short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/examples/bar_shearwave/hex8/shearwave_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,27 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ // number of values for rise time.
+ num-values = 1
+
+ // Name and units for rise time
+ value-names = rise-time
+ value-units = s
+
+ // Number of locations where physical properties are given
+ // 1 location -> data is uniform -> data dimension is 0
+ num-locs = 1
+
+ // Problem is in 3-D
+ data-dim = 0
+
+ // Problem is in 3-D
+ space-dim = 3
+
+ // Coordinate system (3-D with coordinates in meters)
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 3
+ }
+}
+// Columns are x, y, z, rise-time
+0.0 0.0 0.0 2.0
Deleted: short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_sliprate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/hex8/shearwave_sliprate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,27 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- // number of values for peak slip rate
- num-values = 1
-
- // Name and units for peak slip rate
- value-names = slip-rate
- value-units = m/s
-
- // Number of locations where physical properties are given
- // 1 location -> data is uniform -> data dimension is 0
- num-locs = 1
-
- // Problem is in 3-D
- data-dim = 0
-
- // Problem is in 3-D
- space-dim = 3
-
- // Coordinate system (3-D with coordinates in meters)
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 3
- }
-}
-// Columns are x, y, z, slip-rate
-0.0 0.0 0.0 1.0
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -31,9 +31,9 @@
# ----------------------------------------------------------------------
[pylithapp.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOCubit
+reader = pylith.meshio.MeshIOCubit
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename = bar_quad4_200m.exo
coordsys.space_dim = 2
@@ -81,11 +81,10 @@
id = 1
# Spatial database with physical properties for elastic material
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
# Set the basis functions and quadrature:
# 2-D Lagrange cell with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
quadrature.cell.quad_order = 2
@@ -105,7 +104,6 @@
# Specify the basis functions and quadrature:
# 1-D Lagrange cell in 2-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 1
quadrature.cell.quad_order = 2
@@ -122,7 +120,6 @@
# Specify the basis functions and quadrature:
# 1-D Lagrange cell in 2-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 1
quadrature.cell.quad_order = 2
@@ -160,7 +157,6 @@
# Specify the basis functions and quadrature:
# 1-D Lagrange cell in 2-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 1
quadrature.cell.quad_order = 2
@@ -177,8 +173,8 @@
# Database specifying the final slip.
slip.iohandler.filename = shearwave_slip.spatialdb
-# Database specifying peak slip rate.
-slip_rate.iohandler.filename = shearwave_sliprate.spatialdb
+# Database specifying rise_time.
+rise_time.iohandler.filename = shearwave_risetime.spatialdb
# Database specifying time at which slip begins at each point.
slip_time.iohandler.filename = shearwave_sliptime.spatialdb
@@ -226,4 +222,4 @@
writer.time_format = %05.2f
# Averate state variables over cell
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
Copied: short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/examples/bar_shearwave/quad4/shearwave_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,25 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ // number of values for rise time
+ num-values = 1
+
+ // Name and units for rise time
+ value-names = rise-time
+ value-units = s
+
+ // Number of locations where physical properties are given
+ // 1 location -> data is uniform -> data dimension is 0
+ num-locs = 1
+ data-dim = 0
+
+ // Problem is in 2-D
+ space-dim = 2
+
+ // Coordinate system (2-D with coordinates in meters)
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 2
+ }
+}
+// Columns are x, y, rise-time
+0.0 0.0 2.0
Deleted: short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_sliprate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/quad4/shearwave_sliprate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,25 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- // number of values for peak slip rate
- num-values = 1
-
- // Name and units for peak slip rate
- value-names = slip-rate
- value-units = m/s
-
- // Number of locations where physical properties are given
- // 1 location -> data is uniform -> data dimension is 0
- num-locs = 1
- data-dim = 0
-
- // Problem is in 2-D
- space-dim = 2
-
- // Coordinate system (2-D with coordinates in meters)
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 2
- }
-}
-// Columns are x, y, slip-rate
-0.0 0.0 1.0
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -32,9 +32,9 @@
# ----------------------------------------------------------------------
[pylithapp.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOLagrit
+reader = pylith.meshio.MeshIOLagrit
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename_gmv = bar_tet4_200m.gmv
filename_pset = bar_tet4_200m.pset
@@ -79,11 +79,10 @@
id = 1
# Spatial database with physical properties for elastic material
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
# Set the basis functions and quadrature:
# 3-D simplex cell with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature3D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = tetrahedron
quadrature.cell.quad_order = 2
@@ -97,11 +96,10 @@
id = 2
# Spatial database with physical properties for elastic material
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
# Set the basis functions and quadrature:
# 3-D simplex cell with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature3D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = tetrahedron
quadrature.cell.quad_order = 2
@@ -121,7 +119,6 @@
# Specify the basis functions and quadrature:
# 2-D simplex cell in 3-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = triangle
quadrature.cell.quad_order = 2
@@ -138,7 +135,6 @@
# Specify the basis functions and quadrature:
# 2-D simplex cell in 3-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = triangle
quadrature.cell.quad_order = 2
@@ -174,7 +170,6 @@
# Specify the basis functions and quadrature:
# 2-D simplex cell in 3-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = triangle
quadrature.cell.quad_order = 2
@@ -191,8 +186,8 @@
# Database specifying the final slip.
slip.iohandler.filename = shearwave_slip.spatialdb
-# Database specifying peak slip rate.
-slip_rate.iohandler.filename = shearwave_sliprate.spatialdb
+# Database specifying rise time.
+rise_time.iohandler.filename = shearwave_risetime.spatialdb
# Database specifying time at which slip begins at each point.
slip_time.iohandler.filename = shearwave_sliptime.spatialdb
@@ -240,7 +235,7 @@
writer.time_format = %05.2f
# Averate state variables over cell
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.neg.output]
@@ -249,4 +244,4 @@
writer.time_format = %05.2f
# Averate state variables over cell
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
Copied: short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/examples/bar_shearwave/tet4/shearwave_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,27 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ // number of values for rise time.
+ num-values = 1
+
+ // Name and units for rise time
+ value-names = rise-time
+ value-units = s
+
+ // Number of locations where physical properties are given
+ // 1 location -> data is uniform -> data dimension is 0
+ num-locs = 1
+
+ // Problem is in 3-D
+ data-dim = 0
+
+ // Problem is in 3-D
+ space-dim = 3
+
+ // Coordinate system (3-D with coordinates in meters)
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 3
+ }
+}
+// Columns are x, y, z, rise-time
+0.0 0.0 0.0 2.0
Deleted: short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_sliprate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tet4/shearwave_sliprate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,27 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- // number of values for peak slip rate
- num-values = 1
-
- // Name and units for peak slip rate
- value-names = slip-rate
- value-units = m/s
-
- // Number of locations where physical properties are given
- // 1 location -> data is uniform -> data dimension is 0
- num-locs = 1
-
- // Problem is in 3-D
- data-dim = 0
-
- // Problem is in 3-D
- space-dim = 3
-
- // Coordinate system (3-D with coordinates in meters)
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 3
- }
-}
-// Columns are x, y, z, slip-rate
-0.0 0.0 0.0 1.0
Modified: short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -31,9 +31,9 @@
# ----------------------------------------------------------------------
[pylithapp.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOCubit
+reader = pylith.meshio.MeshIOCubit
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename = bar_tri3_200m.exo
coordsys.space_dim = 2
@@ -81,11 +81,10 @@
id = 1
# Spatial database with physical properties for elastic material
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
# Set the basis functions and quadrature:
# 2-D simplex cell with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature2D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = triangle
quadrature.cell.quad_order = 2
@@ -105,7 +104,6 @@
# Specify the basis functions and quadrature:
# 1-D simplex cell in 2-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = line
quadrature.cell.quad_order = 2
@@ -122,7 +120,6 @@
# Specify the basis functions and quadrature:
# 1-D simplex cell in 2-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = line
quadrature.cell.quad_order = 2
@@ -160,7 +157,6 @@
# Specify the basis functions and quadrature:
# 1-D simplex cell in 2-D space with 2nd order quadrature
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = line
quadrature.cell.quad_order = 2
@@ -177,8 +173,8 @@
# Database specifying the final slip.
slip.iohandler.filename = shearwave_slip.spatialdb
-# Database specifying peak slip rate.
-slip_rate.iohandler.filename = shearwave_sliprate.spatialdb
+# Database specifying rise time.
+rise_time.iohandler.filename = shearwave_risetime.spatialdb
# Database specifying time at which slip begins at each point.
slip_time.iohandler.filename = shearwave_sliptime.spatialdb
@@ -226,4 +222,4 @@
writer.time_format = %05.2f
# Averate state variables over cell
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
Copied: short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/examples/bar_shearwave/tri3/shearwave_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,25 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ // number of values for rise time
+ num-values = 1
+
+ // Name and units for rise time
+ value-names = rise-time
+ value-units = s
+
+ // Number of locations where physical properties are given
+ // 1 location -> data is uniform -> data dimension is 0
+ num-locs = 1
+ data-dim = 0
+
+ // Problem is in 2-D
+ space-dim = 2
+
+ // Coordinate system (2-D with coordinates in meters)
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 2
+ }
+}
+// Columns are x, y, rise-time
+0.0 0.0 2.0
Deleted: short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_sliprate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_sliprate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/bar_shearwave/tri3/shearwave_sliprate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,25 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- // number of values for peak slip rate
- num-values = 1
-
- // Name and units for peak slip rate
- value-names = slip-rate
- value-units = m/s
-
- // Number of locations where physical properties are given
- // 1 location -> data is uniform -> data dimension is 0
- num-locs = 1
- data-dim = 0
-
- // Problem is in 2-D
- space-dim = 2
-
- // Coordinate system (2-D with coordinates in meters)
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 2
- }
-}
-// Columns are x, y, slip-rate
-0.0 0.0 1.0
Modified: short/3D/PyLith/trunk/examples/twocells/twohex8/axialdisp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/axialdisp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/axialdisp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -87,7 +87,7 @@
[pylithapp.timedependent.materials.material.output]
cell_data_fields = [total_strain,viscous_strain,stress]
cell_info_fields = [mu,lambda,density,maxwell_time]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = axialdisp-statevars.vtk
writer.time_format = %04.1f ; Time stamp will be xxx.x with the "." removed.
writer.time_constant = 1.0*year ; Normalize time stamp by years
Modified: short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/dislocation.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -98,7 +98,6 @@
mat_db.iohandler.filename = matprops.spatialdb
# The quadrature for a 3D fault is 2D.
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
@@ -130,7 +129,7 @@
[pylithapp.timedependent.materials.material.output]
cell_data_fields = [total_strain,viscous_strain,stress]
cell_info_fields = [mu,lambda,density,maxwell_time]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = dislocation-statevars.vtk
writer.time_format = %04.1f ; Time stamp will be xxx.x with the "." removed.
writer.time_constant = 1.0*year ; Normalize time stamp by years
Modified: short/3D/PyLith/trunk/examples/twocells/twohex8/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/pylithapp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/pylithapp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
# This component specification means we are using PyLith ASCII format,
# and we then specify the filename and number of space dimensions for
# the mesh.
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename = twohex8.mesh
coordsys.space_dim = 3
@@ -78,9 +78,9 @@
# We define uniform material properties for this problem rather than
# using a spatial database file.
-db = spatialdata.spatialdb.UniformDB
-db.values = [vp,vs,density,viscosity]
-db.data = [5773.502691896258, 3333.333333333333, 2700.0, 1.0e18]
+properties_db = spatialdata.spatialdb.UniformDB
+properties_db.values = [vp,vs,density,viscosity]
+properties_db.data = [5773.502691896258, 3333.333333333333, 2700.0, 1.0e18]
# If we instead wanted to used the 'matprops.spatialdb' file to define
# material properties we would comment out the three 'db' lines above
@@ -88,7 +88,6 @@
# db.iohandler.filename = matprops.spatialdb
# We are doing 2D quadrature for a quad.
-quadrature = pylith.feassemble.quadrature.Quadrature3D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 3
Modified: short/3D/PyLith/trunk/examples/twocells/twohex8/sheardisp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twohex8/sheardisp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twohex8/sheardisp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -86,7 +86,7 @@
[pylithapp.timedependent.materials.material.output]
cell_data_fields = [total_strain,viscous_strain,stress]
cell_info_fields = [mu,lambda,density,maxwell_time]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = sheardisp-statevars.vtk
writer.time_format = %04.1f ; Time stamp will be xxx.x with the "." removed.
writer.time_constant = 1.0*year ; Normalize time stamp by years
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/axialdisp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/axialdisp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/axialdisp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -116,5 +116,5 @@
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.material.output]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = axialdisp-statevars.vtk
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/axialtract.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -104,7 +104,6 @@
db.iohandler.filename = axialtract.spatialdb
db.query_type = nearest
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 1
quadrature.cell.quad_order = 2
@@ -148,7 +147,6 @@
mat_db.iohandler.filename = matprops.spatialdb
# The quadrature for a 2D fault is 1D with a linear shape.
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 1
@@ -170,7 +168,7 @@
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.material.output]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = axialtract-statevars.vtk
# Give basename for VTK output of traction BC information.
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/dislocation.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -99,7 +99,6 @@
mat_db.iohandler.filename = matprops.spatialdb
# The quadrature for a 2D fault is 1D with a linear shape.
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 1
@@ -125,5 +124,5 @@
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.material.output]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = dislocation-statevars.vtk
Modified: short/3D/PyLith/trunk/examples/twocells/twoquad4/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twoquad4/pylithapp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twoquad4/pylithapp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,7 +38,7 @@
# This component specification means we are using PyLith ASCII format,
# and we then specify the filename and number of space dimensions for
# the mesh.
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename = twoquad4.mesh
coordsys.space_dim = 2
@@ -78,10 +78,9 @@
# The properties for this material are given in the spatial database file
# 'matprops.spatialdb'.
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
-# We are doing 2D quadrature for a quad.
-quadrature = pylith.feassemble.quadrature.Quadrature2D
+# Set cell type to quadrilateral (2-d Lagrange).
quadrature.cell = pylith.feassemble.FIATLagrange
quadrature.cell.dimension = 2
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4/axialdisp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4/axialdisp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4/axialdisp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -61,5 +61,5 @@
# Give basename for VTK output of state variables.
[pylithapp.timedependent.materials.material.output]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = axialdisp-statevars.vtk
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4/dislocation.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -83,7 +83,6 @@
mat_db.iohandler.filename = matprops.spatialdb
# The quadrature for a 3D fault is 2D.
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell.shape = triangle
# Give the spatial databases specifying the fault slip.
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4/pylithapp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4/pylithapp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
# This component specification means we are using PyLith ASCII format,
# and we then specify the filename and number of space dimensions for
# the mesh.
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename = twotet4.mesh
coordsys.space_dim = 3
@@ -80,10 +80,9 @@
# The properties for this material are given in the spatial database file
# 'matprops.spatialdb'.
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
# We are doing 3D quadrature for a tetrahedron.
-quadrature = pylith.feassemble.quadrature.Quadrature3D
quadrature.cell.shape = tetrahedron
# ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/dislocation.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -91,7 +91,6 @@
# mat_db.iohandler.filename = matprops.spatialdb
# The quadrature for a 3D fault is 2D.
-quadrature = pylith.feassemble.quadrature.Quadrature2Din3D
quadrature.cell.shape = triangle
# Give the spatial databases specifying the fault slip.
Modified: short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/pylithapp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twotet4-geoproj/pylithapp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,19 +38,19 @@
# This component specification means we are using PyLith ASCII format,
# and we then specify the filename and number of space dimensions for
# the mesh.
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
coordsys = spatialdata.geocoords.CSGeoProj
filename = twotet4.mesh
coordsys.space_dim = 3
# Specify the information defining the geographic projected coordinate
# system for the mesh.
-[pylithapp.mesh_generator.importer.coordsys]
+[pylithapp.mesh_generator.reader.coordsys]
datum_horiz = NAD27
datum_vert = mean sea level
ellipsoid = clrk66
-[pylithapp.mesh_generator.importer.coordsys.projector]
+[pylithapp.mesh_generator.reader.coordsys.projector]
projection = utm
proj-options = +zone=11
@@ -84,11 +84,10 @@
id = 1
# The properties for this material are obtained from the SCEC CVM-H.
-db = spatialdata.spatialdb.SCECCVMH
-db.data_dir = /home/brad/data/sceccvm-h/vx53/bin
+properties_db = spatialdata.spatialdb.SCECCVMH
+properties_db.data_dir = /home/brad/data/sceccvm-h/vx53/bin
# We are doing 3D quadrature for a tetrahedron.
-quadrature = pylith.feassemble.quadrature.Quadrature3D
quadrature.cell = pylith.feassemble.FIATSimplex
quadrature.cell.shape = tetrahedron
Modified: short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twotri3/dislocation.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -84,7 +84,6 @@
mat_db.iohandler.filename = matprops.spatialdb
# The quadrature for a 2D fault is 1D with a linear shape.
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell.shape = line
# Give the spatial databases specifying the fault slip.
Modified: short/3D/PyLith/trunk/examples/twocells/twotri3/pylithapp.cfg
===================================================================
--- short/3D/PyLith/trunk/examples/twocells/twotri3/pylithapp.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/examples/twocells/twotri3/pylithapp.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,7 +38,7 @@
# This component specification means we are using PyLith ASCII format,
# and we then specify the filename and number of space dimensions for
# the mesh.
-[pylithapp.mesh_generator.importer]
+[pylithapp.mesh_generator.reader]
filename = twotri3.mesh
coordsys.space_dim = 2
@@ -79,10 +79,9 @@
# The properties for this material are given in the spatial database file
# 'matprops.spatialdb'.
-db.iohandler.filename = matprops.spatialdb
+properties_db.iohandler.filename = matprops.spatialdb
# We are doing 2D quadrature for a triangle.
-quadrature = pylith.feassemble.quadrature.Quadrature2D
quadrature.cell.shape = triangle
# ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/libsrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,34 +14,34 @@
utils \
topology \
meshio \
+ materials \
+ bc \
feassemble \
- bc \
faults \
- materials
+ problems
lib_LTLIBRARIES = libpylith.la
libpylith_la_SOURCES = \
- bc/AbsorbingDampers.cc \
bc/BoundaryCondition.cc \
+ bc/DirichletBC.cc \
bc/DirichletBoundary.cc \
- bc/DirichletPoints.cc \
bc/Neumann.cc \
+ bc/AbsorbingDampers.cc \
+ faults/Fault.cc \
+ faults/SlipTimeFn.cc \
+ faults/StepSlipFn.cc \
+ faults/ConstRateSlipFn.cc \
faults/BruneSlipFn.cc \
- faults/ConstRateSlipFn.cc \
+ faults/LiuCosSlipFn.cc \
+ faults/EqKinSrc.cc \
+ faults/TopologyOps.cc \
faults/CohesiveTopology.cc \
- faults/EqKinSrc.cc \
- faults/Fault.cc \
faults/FaultCohesive.cc \
+ faults/FaultCohesiveDyn.cc \
faults/FaultCohesiveKin.cc \
- faults/FaultCohesiveDyn.cc \
- faults/LiuCosSlipFn.cc \
- faults/SlipTimeFn.cc \
- faults/StepSlipFn.cc \
feassemble/CellGeometry.cc \
feassemble/Constraint.cc \
- feassemble/ElasticityExplicit.cc \
- feassemble/ElasticityImplicit.cc \
feassemble/GeometryPoint1D.cc \
feassemble/GeometryPoint2D.cc \
feassemble/GeometryPoint3D.cc \
@@ -54,9 +54,8 @@
feassemble/GeometryQuad2D.cc \
feassemble/GeometryQuad3D.cc \
feassemble/GeometryHex3D.cc \
- feassemble/Integrator.cc \
- feassemble/IntegratorElasticity.cc \
- feassemble/Quadrature.cc \
+ feassemble/QuadratureRefCell.cc \
+ feassemble/QuadratureEngine.cc \
feassemble/Quadrature0D.cc \
feassemble/Quadrature1D.cc \
feassemble/Quadrature1Din2D.cc \
@@ -64,45 +63,50 @@
feassemble/Quadrature2D.cc \
feassemble/Quadrature2Din3D.cc \
feassemble/Quadrature3D.cc \
+ feassemble/IntegratorElasticity.cc \
+ feassemble/ElasticityImplicit.cc \
+ feassemble/ElasticityExplicit.cc \
+ materials/Metadata.cc \
materials/Material.cc \
+ materials/ElasticMaterial.cc \
+ materials/ElasticStrain1D.cc \
materials/ElasticStress1D.cc \
- materials/ElasticStrain1D.cc \
- materials/ElasticIsotropic3D.cc \
- materials/ElasticMaterial.cc \
materials/ElasticPlaneStrain.cc \
materials/ElasticPlaneStress.cc \
+ materials/ElasticIsotropic3D.cc \
+ materials/ViscoelasticMaxwell.cc \
materials/MaxwellIsotropic3D.cc \
- materials/GenMaxwellIsotropic3D.cc \
- materials/ViscoelasticMaxwell.cc \
meshio/BinaryIO.cc \
- meshio/CellFilter.cc \
- meshio/CellFilterAvg.cc \
- meshio/DataWriter.cc \
- meshio/DataWriterVTK.cc \
meshio/GMVFile.cc \
meshio/GMVFileAscii.cc \
meshio/GMVFileBinary.cc \
+ meshio/MeshBuilder.cc \
meshio/MeshIO.cc \
meshio/MeshIOAscii.cc \
meshio/MeshIOLagrit.cc \
- meshio/OutputManager.cc \
- meshio/OutputSolnSubset.cc \
meshio/PsetFile.cc \
meshio/PsetFileAscii.cc \
meshio/PsetFileBinary.cc \
- meshio/VertexFilter.cc \
- meshio/VertexFilterVecNorm.cc \
- topology/Distributor.cc \
- topology/Field.cc \
- topology/FieldUniform.cc \
- topology/FieldsManager.cc \
- topology/FieldOps.cc \
+ meshio/OutputSolnSubset.cc \
+ meshio/UCDFaultFile.cc \
+ problems/Formulation.cc \
+ problems/Solver.cc \
+ problems/SolverLinear.cc \
+ problems/SolverNonlinear.cc \
+ topology/FieldBase.cc \
+ topology/Jacobian.cc \
topology/Mesh.cc \
topology/MeshOps.cc \
- topology/MeshRefiner.cc \
- topology/RefineUniform.cc \
- utils/EventLogger.cc
+ topology/SubMesh.cc \
+ topology/SolutionFields.cc \
+ topology/Distributor.cc \
+ utils/EventLogger.cc \
+ utils/TestArray.cc
+# materials/GenMaxwellIsotropic3D.cc \
+# topology/MeshRefiner.cc \
+# topology/RefineUniform.cc
+
libpylith_la_LDFLAGS = $(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
libpylith_la_LIBADD = \
-lspatialdata \
Modified: short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,24 +14,32 @@
#include "AbsorbingDampers.hh" // implementation of object methods
-#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
+#include "pylith/topology/Field.hh" // HOLDSA Field
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
#include "pylith/feassemble/CellGeometry.hh" // USES CellGeometry
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-#include <Selection.hh> // USES submesh algorithms
-
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
#include <cstring> // USES memcpy()
#include <cassert> // USES assert()
#include <stdexcept> // USES std::runtime_error
#include <sstream> // USES std::ostringstream
// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
+typedef pylith::topology::SubMesh::RealSection SubRealSection;
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Default constructor.
-pylith::bc::AbsorbingDampers::AbsorbingDampers(void)
+pylith::bc::AbsorbingDampers::AbsorbingDampers(void) :
+ _boundaryMesh(0),
+ _dampingConsts(0)
{ // constructor
} // constructor
@@ -39,71 +47,55 @@
// Destructor.
pylith::bc::AbsorbingDampers::~AbsorbingDampers(void)
{ // destructor
+ delete _boundaryMesh; _boundaryMesh = 0;
+ delete _dampingConsts; _dampingConsts = 0;
} // destructor
// ----------------------------------------------------------------------
// Initialize boundary condition. Determine orienation and compute traction
// vector at integration points.
void
-pylith::bc::AbsorbingDampers::initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir)
+pylith::bc::AbsorbingDampers::initialize(const topology::Mesh& mesh,
+ const double upDir[3])
{ // initialize
assert(0 != _quadrature);
assert(0 != _db);
- assert(!mesh.isNull());
- assert(0 != cs);
- if (3 != upDir.size())
- throw std::runtime_error("Up direction for boundary orientation must be "
- "a vector with 3 components.");
+ delete _boundaryMesh; _boundaryMesh = 0;
+ delete _dampingConsts; _dampingConsts = 0;
- // Extract submesh associated with boundary
- _boundaryMesh = ALE::Selection<Mesh>::submeshV<SubMesh>(mesh, mesh->getIntSection(_label));
- if (_boundaryMesh.isNull()) {
- std::ostringstream msg;
- msg << "Could not construct boundary mesh for absorbing boundary "
- << "condition '" << _label << "'.";
- throw std::runtime_error(msg.str());
- } // if
- _boundaryMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
- // Create the parallel overlap
- Obj<SubMesh::send_overlap_type> sendParallelMeshOverlap = _boundaryMesh->getSendOverlap();
- Obj<SubMesh::recv_overlap_type> recvParallelMeshOverlap = _boundaryMesh->getRecvOverlap();
- Mesh::renumbering_type& renumbering = mesh->getRenumbering();
- // Can I figure this out in a nicer way?
- ALE::SetFromMap<std::map<Mesh::point_type,Mesh::point_type> > globalPoints(renumbering);
+ _boundaryMesh = new topology::SubMesh(mesh, _label.c_str());
+ assert(0 != _boundaryMesh);
- ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering, sendParallelMeshOverlap, recvParallelMeshOverlap);
- _boundaryMesh->setCalculatedOverlap(true);
+ double_array up(upDir, 3);
- //_boundaryMesh->view("ABSORBING BOUNDARY MESH");
-
// check compatibility of quadrature and boundary mesh
- if (_quadrature->cellDim() != _boundaryMesh->getDimension()) {
+ if (_quadrature->cellDim() != _boundaryMesh->dimension()) {
std::ostringstream msg;
msg << "Quadrature is incompatible with cells for absorbing boundary "
<< "condition '" << _label << "'.\n"
- << "Dimension of boundary mesh: " << _boundaryMesh->getDimension()
+ << "Dimension of boundary mesh: " << _boundaryMesh->dimension()
<< ", dimension of quadrature: " << _quadrature->cellDim()
<< ".";
throw std::runtime_error(msg.str());
} // if
const int numCorners = _quadrature->numBasis();
- const ALE::Obj<SubMesh::label_sequence>& cells =
- _boundaryMesh->heightStratum(1);
-
+ // Get 'surface' cells (1 dimension lower than top-level cells)
+ const ALE::Obj<SieveSubMesh>& submesh = _boundaryMesh->sieveMesh();
+ assert(!submesh.isNull());
+ const int boundaryDepth = submesh->depth()-1; // depth of bndry cells
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ submesh->depthStratum(boundaryDepth);
assert(!cells.isNull());
- const SubMesh::label_sequence::iterator cellsBegin = cells->begin();
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
- const int boundaryDepth = _boundaryMesh->depth()-1; // depth of bndry cells
- for (SubMesh::label_sequence::iterator c_iter=cellsBegin;
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
+
+ // Make sure surface cells are compatible with quadrature.
+ for (SieveSubMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- const int cellNumCorners = _boundaryMesh->getNumCellCorners(*c_iter, boundaryDepth);
-
+ const int cellNumCorners =
+ submesh->getNumCellCorners(*c_iter, boundaryDepth);
if (numCorners != cellNumCorners) {
std::ostringstream msg;
msg << "Quadrature is incompatible with cell for absorbing boundary "
@@ -117,26 +109,25 @@
// Get damping constants at each quadrature point and rotate to
// global coordinate frame using orientation information
- const int cellDim = _quadrature->cellDim();
+ const feassemble::CellGeometry& cellGeometry = _quadrature->refGeometry();
+ const int cellDim = _quadrature->cellDim() > 0 ? _quadrature->cellDim() : 1;
const int numBasis = _quadrature->numBasis();
const int numQuadPts = _quadrature->numQuadPts();
- const int spaceDim = cs->spaceDim();
+ const int spaceDim = cellGeometry.spaceDim();
const int fiberDim = numQuadPts * spaceDim;
- _dampingConsts = new real_section_type(_boundaryMesh->comm(),
- _boundaryMesh->debug());
- assert(!_dampingConsts.isNull());
- _dampingConsts->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()), *std::max_element(cells->begin(), cells->end())+1));
- _dampingConsts->setFiberDimension(cells, fiberDim);
- _boundaryMesh->allocate(_dampingConsts);
+ _dampingConsts = new topology::Field<topology::SubMesh>(*_boundaryMesh);
+ assert(0 != _dampingConsts);
+ _dampingConsts->newSection(cells, fiberDim);
+ _dampingConsts->allocate();
+
// Containers for orientation information
- const int orientationSize = spaceDim*spaceDim;
- const feassemble::CellGeometry& cellGeometry = _quadrature->refGeometry();
- const int jacobianSize = (cellDim > 0) ? spaceDim * cellDim : 1;
+ const int orientationSize = spaceDim * spaceDim;
+ const int jacobianSize = spaceDim * cellDim;
double_array jacobian(jacobianSize);
double jacobianDet = 0;
double_array orientation(orientationSize);
- double_array cellVertices(numBasis*spaceDim);
+ double_array cellVertices(numCorners*spaceDim);
// open database with material property information
_db->open();
@@ -160,9 +151,11 @@
double_array dampingConstsLocal(fiberDim);
double_array dampingConstsGlobal(fiberDim);
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates =
+ submesh->getRealSection("coordinates");
assert(!coordinates.isNull());
+ topology::Mesh::RestrictVisitor coordsVisitor(*coordinates,
+ numCorners*spaceDim);
assert(0 != _normalizer);
const double lengthScale = _normalizer->lengthScale();
@@ -170,15 +163,25 @@
const double velocityScale =
_normalizer->lengthScale() / _normalizer->timeScale();
- for(SubMesh::label_sequence::iterator c_iter = cells->begin();
- c_iter != cells->end();
+ const ALE::Obj<SubRealSection>& dampersSection = _dampingConsts->section();
+ assert(!dampersSection.isNull());
+
+ const spatialdata::geocoords::CoordSys* cs = _boundaryMesh->coordsys();
+
+ // Compute quadrature information
+ _quadrature->computeGeometry(*_boundaryMesh, cells);
+
+ for(SieveSubMesh::label_sequence::iterator c_iter = cells->begin();
+ c_iter != cellsEnd;
++c_iter) {
- _quadrature->computeGeometry(_boundaryMesh, coordinates, *c_iter);
+ _quadrature->retrieveGeometry(*c_iter);
const double_array& quadPtsNondim = _quadrature->quadPts();
const double_array& quadPtsRef = _quadrature->quadPtsRef();
quadPtsGlobal = quadPtsNondim;
_normalizer->dimensionalize(&quadPtsGlobal[0], quadPtsGlobal.size(),
lengthScale);
+ coordsVisitor.clear();
+ submesh->restrictClosure(*c_iter, coordsVisitor);
dampingConstsGlobal = 0.0;
for(int iQuad = 0; iQuad < numQuadPts; ++iQuad) {
@@ -212,12 +215,14 @@
dampingConstsLocal[spaceDim-1] = constNormal;
// Compute normal/tangential orientation
- _boundaryMesh->restrictClosure(coordinates, *c_iter,
- &cellVertices[0], cellVertices.size());
- memcpy(&quadPtRef[0], &quadPtsRef[iQuad*cellDim], cellDim*sizeof(double));
+ submesh->restrictClosure(coordinates, *c_iter,
+ &cellVertices[0], cellVertices.size());
+ memcpy(&quadPtRef[0], &quadPtsRef[iQuad*cellDim],
+ cellDim*sizeof(double));
+ memcpy(&cellVertices[0], coordsVisitor.getValues(),
+ cellVertices.size()*sizeof(double));
cellGeometry.jacobian(&jacobian, &jacobianDet, cellVertices, quadPtRef);
- cellGeometry.orientation(&orientation, jacobian, jacobianDet,
- upDir);
+ cellGeometry.orientation(&orientation, jacobian, jacobianDet, up);
orientation /= jacobianDet;
for (int iDim=0; iDim < spaceDim; ++iDim) {
@@ -229,7 +234,7 @@
fabs(dampingConstsGlobal[iQuad*spaceDim+iDim]);
} // for
} // for
- _dampingConsts->updatePoint(*c_iter, &dampingConstsGlobal[0]);
+ dampersSection->updatePoint(*c_iter, &dampingConstsGlobal[0]);
} // for
_db->close();
@@ -239,71 +244,82 @@
// Integrate contributions to residual term (r) for operator.
void
pylith::bc::AbsorbingDampers::integrateResidual(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateResidual
assert(0 != _quadrature);
- assert(!_boundaryMesh.isNull());
- assert(!residual.isNull());
+ assert(0 != _boundaryMesh);
+ assert(0 != _dampingConsts);
assert(0 != fields);
- assert(!mesh.isNull());
- PetscErrorCode err = 0;
+ // Get cell geometry information that doesn't depend on cell
+ const int numQuadPts = _quadrature->numQuadPts();
+ const double_array& quadWts = _quadrature->quadWts();
+ assert(quadWts.size() == numQuadPts);
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
+ // Allocate vectors for cell values.
+ _initCellVector();
+ double_array dampersCell(numQuadPts*spaceDim);
+
// Get cell information
- const ALE::Obj<SubMesh::label_sequence>& cells =
- _boundaryMesh->heightStratum(1);
+ const ALE::Obj<SieveSubMesh>& submesh = _boundaryMesh->sieveMesh();
+ assert(!submesh.isNull());
+ const int boundaryDepth = submesh->depth()-1; // depth of bndry cells
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ submesh->depthStratum(boundaryDepth);
assert(!cells.isNull());
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
// Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const ALE::Obj<real_section_type>& dispTpdt = fields->getFieldByHistory(0);
- const ALE::Obj<real_section_type>& dispTmdt = fields->getFieldByHistory(2);
- assert(!dispTpdt.isNull());
- assert(!dispTmdt.isNull());
+ const ALE::Obj<SubRealSection>& dampersSection = _dampingConsts->section();
+ assert(!dampersSection.isNull());
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ assert(!residualSection.isNull());
+ topology::SubMesh::UpdateAddVisitor residualVisitor(*residualSection,
+ &_cellVector[0]);
+
+ const topology::Field<topology::Mesh>& dispTpdt =
+ fields->get("disp(t+dt)");
+ const ALE::Obj<RealSection>& dispTpdtSection = dispTpdt.section();
+ assert(!dispTpdtSection.isNull());
+ topology::Mesh::RestrictVisitor dispTpdtVisitor(*dispTpdtSection,
+ numBasis*spaceDim);
+ const topology::Field<topology::Mesh>& dispTmdt =
+ fields->get("disp(t-dt)");
+ const ALE::Obj<RealSection>& dispTmdtSection = dispTmdt.section();
+ assert(!dispTmdtSection.isNull());
+ topology::Mesh::RestrictVisitor dispTmdtVisitor(*dispTmdtSection,
+ numBasis*spaceDim);
+
// Get parameters used in integration.
const double dt = _dt;
assert(dt > 0);
- // Get cell geometry information that doesn't depend on cell
- const int numQuadPts = _quadrature->numQuadPts();
- const double_array& quadWts = _quadrature->quadWts();
- assert(quadWts.size() == numQuadPts);
- const int numBasis = _quadrature->numBasis();
- const int spaceDim = _quadrature->spaceDim();
- const int cellDim = _quadrature->cellDim();
-
- // Allocate vectors for cell values.
- _initCellVector();
- const int cellVecSize = numBasis*spaceDim;
- double_array dispTpdtCell(cellVecSize);
- double_array dispTmdtCell(cellVecSize);
-
- for (SubMesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveSubMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- // Compute geometry information for current cell
- _quadrature->computeGeometry(_boundaryMesh, coordinates, *c_iter);
+ // Get geometry information for current cell
+ _quadrature->retrieveGeometry(*c_iter);
// Reset element vector to zero
_resetCellVector();
// Restrict input fields to cell
- _boundaryMesh->restrictClosure(dispTpdt, *c_iter,
- &dispTpdtCell[0], cellVecSize);
- _boundaryMesh->restrictClosure(dispTmdt, *c_iter,
- &dispTmdtCell[0], cellVecSize);
- assert(numQuadPts*spaceDim == _dampingConsts->getFiberDimension(*c_iter));
- const real_section_type::value_type* dampingConstsCell =
- _dampingConsts->restrictPoint(*c_iter);
+ dispTpdtVisitor.clear();
+ submesh->restrictClosure(*c_iter, dispTpdtVisitor);
+ const double* dispTpdtCell = dispTpdtVisitor.getValues();
+ dispTmdtVisitor.clear();
+ submesh->restrictClosure(*c_iter, dispTmdtVisitor);
+ const double* dispTmdtCell = dispTmdtVisitor.getValues();
+
+ dampersSection->restrictPoint(*c_iter,
+ &dampersCell[0], dampersCell.size());
+
// Get cell geometry information that depends on cell
const double_array& basis = _quadrature->basis();
const double_array& jacobianDet = _quadrature->jacobianDet();
@@ -319,7 +335,7 @@
const double valIJ = valI * basis[iQuad*numBasis+jBasis];
for (int iDim=0; iDim < spaceDim; ++iDim)
_cellVector[iBasis*spaceDim+iDim] +=
- dampingConstsCell[iQuad*spaceDim+iDim] *
+ dampersCell[iQuad*spaceDim+iDim] *
valIJ * (dispTmdtCell[jBasis*spaceDim+iDim]);
} // for
} // for
@@ -328,7 +344,8 @@
PetscLogFlops(numQuadPts*(3+numBasis*(1+numBasis*(5*spaceDim))));
// Assemble cell contribution into field
- _boundaryMesh->updateAdd(residual, *c_iter, _cellVector);
+ residualVisitor.clear();
+ submesh->updateAdd(*c_iter, residualVisitor);
} // for
} // integrateResidual
@@ -336,65 +353,65 @@
// Integrate contributions to Jacobian matrix (A) associated with
void
pylith::bc::AbsorbingDampers::integrateJacobian(
- PetscMat* jacobian,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh)
+ topology::Jacobian* jacobian,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateJacobian
assert(0 != _quadrature);
- assert(!_boundaryMesh.isNull());
+ assert(0 != _boundaryMesh);
assert(0 != jacobian);
assert(0 != fields);
- assert(!mesh.isNull());
- typedef ALE::ISieveVisitor::IndicesVisitor<Mesh::real_section_type,Mesh::order_type,PetscInt> visitor_type;
- PetscErrorCode err = 0;
- // Get cell information
- const ALE::Obj<SubMesh::label_sequence>& cells =
- _boundaryMesh->heightStratum(1);
- assert(!cells.isNull());
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
+ typedef ALE::ISieveVisitor::IndicesVisitor<RealSection,SieveMesh::order_type,PetscInt> visitor_type;
- // Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const ALE::Obj<real_section_type>& dispT = fields->getFieldByHistory(1);
- assert(!dispT.isNull());
-
- // Get parameters used in integration.
- const double dt = _dt;
- assert(dt > 0);
-
// Get cell geometry information that doesn't depend on cell
const int numQuadPts = _quadrature->numQuadPts();
const double_array& quadWts = _quadrature->quadWts();
assert(quadWts.size() == numQuadPts);
const int numBasis = _quadrature->numBasis();
const int spaceDim = _quadrature->spaceDim();
- const int cellDim = _quadrature->cellDim();
- // Allocate vectors for cell values.
- _initCellVector();
- const int cellVecSize = numBasis*spaceDim;
+ // Get cell information
+ const ALE::Obj<SieveSubMesh>& submesh = _boundaryMesh->sieveMesh();
+ assert(!submesh.isNull());
+ const int boundaryDepth = submesh->depth()-1; // depth of bndry cells
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ submesh->depthStratum(boundaryDepth);
+ assert(!cells.isNull());
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
- // Allocate vector for cell values (if necessary)
- _initCellMatrix();
+ // Get sections
+ const ALE::Obj<SubRealSection>& dampersSection = _dampingConsts->section();
+ assert(!dampersSection.isNull());
- const ALE::Obj<real_section_type>& solution = fields->getSolution();
- assert(!solution.isNull());
- const ALE::Obj<Mesh::order_type>& globalOrder =
- mesh->getFactory()->getGlobalOrder(mesh, "default", solution);
+ const topology::Field<topology::Mesh>& solution = fields->solution();
+ const ALE::Obj<SieveMesh>& sieveMesh = solution.mesh().sieveMesh();
+ const ALE::Obj<RealSection>& solutionSection = solution.section();
+ assert(!solutionSection.isNull());
+ const ALE::Obj<SieveMesh::order_type>& globalOrder =
+ sieveMesh->getFactory()->getGlobalOrder(sieveMesh, "default",
+ solutionSection);
assert(!globalOrder.isNull());
- visitor_type iV(*solution, *globalOrder,
- (int) pow(mesh->getSieve()->getMaxConeSize(),
- mesh->depth())*spaceDim);
+ visitor_type iV(*solutionSection, *globalOrder,
+ (int) pow(sieveMesh->getSieve()->getMaxConeSize(),
+ sieveMesh->depth())*spaceDim);
- for (SubMesh::label_sequence::iterator c_iter=cells->begin();
+ // Get sparse matrix
+ const PetscMat jacobianMat = jacobian->matrix();
+ assert(0 != jacobianMat);
+
+ // Get parameters used in integration.
+ const double dt = _dt;
+ assert(dt > 0);
+
+ // Allocate matrix for cell values.
+ _initCellMatrix();
+
+ for (SieveSubMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- // Compute geometry information for current cell
- _quadrature->computeGeometry(_boundaryMesh, coordinates, *c_iter);
+ // Get geometry information for current cell
+ _quadrature->retrieveGeometry(*c_iter);
// Reset element vector to zero
_resetCellMatrix();
@@ -403,10 +420,8 @@
const double_array& basis = _quadrature->basis();
const double_array& jacobianDet = _quadrature->jacobianDet();
- // Restrict input fields to cell
- assert(numQuadPts*spaceDim == _dampingConsts->getFiberDimension(*c_iter));
- const real_section_type::value_type* dampingConstsCell =
- _dampingConsts->restrictPoint(*c_iter);
+ assert(numQuadPts*spaceDim == dampersSection->getFiberDimension(*c_iter));
+ const double* dampingConstsCell = dampersSection->restrictPoint(*c_iter);
// Compute Jacobian for absorbing bc terms
for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
@@ -428,10 +443,10 @@
PetscLogFlops(numQuadPts*(3+numBasis*(1+numBasis*(1+2*spaceDim))));
// Assemble cell contribution into PETSc Matrix
- err = updateOperator(*jacobian, *_boundaryMesh->getSieve(),
- iV, *c_iter, _cellMatrix, ADD_VALUES);
- if (err)
- throw std::runtime_error("Update to PETSc Mat failed.");
+ PetscErrorCode err = updateOperator(jacobianMat, *submesh->getSieve(),
+ iV, *c_iter, &_cellMatrix[0],
+ ADD_VALUES);
+ CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
iV.clear();
} // for
@@ -441,7 +456,7 @@
// ----------------------------------------------------------------------
// Verify configuration is acceptable.
void
-pylith::bc::AbsorbingDampers::verifyConfiguration(const ALE::Obj<Mesh>& mesh) const
+pylith::bc::AbsorbingDampers::verifyConfiguration(const topology::Mesh& mesh) const
{ // verifyConfiguration
BoundaryCondition::verifyConfiguration(mesh);
} // verifyConfiguration
Modified: short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/AbsorbingDampers.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -50,32 +50,18 @@
#if !defined(pylith_bc_absorbingdampers_hh)
#define pylith_bc_absorbingdampers_hh
+// Include directives ---------------------------------------------------
#include "BoundaryCondition.hh" // ISA BoundaryCondition
+
+#include "pylith/topology/SubMesh.hh" // ISA Quadrature<SubMesh>
+#include "pylith/feassemble/Quadrature.hh" // ISA Integrator<Quadrature>
#include "pylith/feassemble/Integrator.hh" // ISA Integrator
#include "pylith/utils/array.hh" // USES std::vector, double_array, int_array
-#include "pylith/utils/sievetypes.hh" // USES real_section_type
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class AbsorbingDampers;
- class TestAbsorbingDampers; // unit testing
- } // bc
-} // pylith
-
-/*
-namespace spatialdata {
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-*/
-
-
-/// C++ implementation of AbsorbingDampers boundary conditions.
+// AbsorbingDampers ------------------------------------------------------
class pylith::bc::AbsorbingDampers : public BoundaryCondition,
- public feassemble::Integrator
+ public feassemble::Integrator<feassemble::Quadrature<topology::SubMesh> >
{ // class AbsorbingDampers
friend class TestAbsorbingDampers; // unit testing
@@ -90,47 +76,39 @@
/** Initialize boundary condition.
*
- * @param mesh PETSc mesh
- * @param cs Coordinate system for mesh
+ * @param mesh Finite-element mesh.
* @param upDir Direction perpendicular to horizontal surface tangent
* direction that is not collinear with surface normal.
*/
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir);
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3]);
/** Integrate contributions to residual term (r) for operator.
*
* @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
- * @param cs Mesh coordinate system
*/
- void integrateResidual(const ALE::Obj<real_section_type>& residual,
+ void integrateResidual(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
/** Integrate contributions to Jacobian matrix (A) associated with
* operator.
*
- * @param mat Sparse matrix
+ * @param jacobian Jacobian of system.
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
- void integrateJacobian(PetscMat* mat,
+ void integrateJacobian(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
/** Verify configuration is acceptable.
*
* @param mesh Finite-element mesh
*/
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const;
+ void verifyConfiguration(const topology::Mesh& mesh) const;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
@@ -145,10 +123,10 @@
private :
/// Mesh of absorbing boundary
- ALE::Obj<SubMesh> _boundaryMesh;
+ topology::SubMesh* _boundaryMesh;
/// Damping constants in global coordinates at integration points.
- ALE::Obj<real_section_type> _dampingConsts;
+ topology::Field<topology::SubMesh>* _dampingConsts;
}; // class AbsorbingDampers
Modified: short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,10 @@
#include "BoundaryCondition.hh" // implementation of object methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
+
+#include <stdexcept> // USES std::runtime_error()
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::bc::BoundaryCondition::BoundaryCondition(void) :
@@ -32,11 +36,12 @@
// ----------------------------------------------------------------------
// Verify configuration is acceptable.
void
-pylith::bc::BoundaryCondition::verifyConfiguration(const ALE::Obj<Mesh>& mesh) const
+pylith::bc::BoundaryCondition::verifyConfiguration(const topology::Mesh& mesh) const
{ // verifyConfiguration
- assert(!mesh.isNull());
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
- if (!mesh->hasIntSection(_label)) {
+ if (!sieveMesh->hasIntSection(_label)) {
std::ostringstream msg;
msg << "Mesh missing group of vertices '" << _label
<< " for boundary condition.";
Modified: short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,32 +20,18 @@
#if !defined(pylith_bc_boundarycondition_hh)
#define pylith_bc_boundarycondition_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh, real_section_type
-#include "pylith/utils/petscfwd.h" // USES PETScMat
-#include "pylith/utils/array.hh" // USES double_array
+// Include directives ---------------------------------------------------
+#include "bcfwd.hh" // forward declarations
-#include <string> // HASA std::string
+#include "pylith/topology/topologyfwd.hh" // USES Mesh
+#include "pylith/utils/arrayfwd.hh" // USES double_array
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class BoundaryCondition;
- class TestBoundaryCondition; // unit testing
- } // bc
-} // pylith
+#include "spatialdata/geocoords/geocoordsfwd.hh" // USES CoordSys
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // USES SpatialDB
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace geocoords {
- class CoordSys;
- } // geocoords
+#include <string> // HASA std::string
- namespace spatialdb {
- class SpatialDB;
- } // spatialdb
-} // spatialdata
-
-/// C++ abstract base class for BoundaryCondition object.
+// BoundaryCondition ----------------------------------------------------
class pylith::bc::BoundaryCondition
{ // class BoundaryCondition
friend class TestBoundaryCondition; // unit testing
@@ -70,7 +56,7 @@
*
* @returns Label of surface (from mesh generator).
*/
- const std::string& label(void) const;
+ const char* label(void) const;
/** Set database for boundary condition parameters.
*
@@ -80,20 +66,19 @@
/** Verify configuration.
*
- * @param mesh PETSc mesh
+ * @param mesh Finite-element mesh.
*/
virtual
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const;
+ void verifyConfiguration(const topology::Mesh& mesh) const;
/** Initialize boundary condition.
*
- * @param mesh PETSc mesh
- * @param cs Coordinate system for mesh
+ * @param mesh Finite-element mesh.
+ * @param upDir Vertical direction (somtimes used in 3-D problems).
*/
virtual
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir) = 0;
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3]) = 0;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/BoundaryCondition.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,9 +23,9 @@
// Get label of boundary condition surface.
inline
-const std::string&
+const char*
pylith::bc::BoundaryCondition::label(void) const {
- return _label;
+ return _label.c_str();
}
// Set database for boundary condition parameters.
Copied: short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/bc/DirichletBC.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBC.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,338 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "DirichletBC.hh" // implementation of object methods
+
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+
+#include <cstring> // USES strcpy()
+#include <cassert> // USES assert()
+#include <stdexcept> // USES std::runtime_error
+#include <sstream> // USES std::ostringstream
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::bc::DirichletBC::DirichletBC(void) :
+ _tRef(0.0),
+ _dbRate(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::bc::DirichletBC::~DirichletBC(void)
+{ // destructor
+ _dbRate = 0; // Don't manage memory
+} // destructor
+
+// ----------------------------------------------------------------------
+// Set indices of fixed degrees of freedom.
+void
+pylith::bc::DirichletBC::fixedDOF(const int* flags,
+ const int size)
+{ // fixedDOF
+ if (size > 0)
+ assert(0 != flags);
+
+ _fixedDOF.resize(size);
+ for (int i=0; i < size; ++i)
+ _fixedDOF[i] = flags[i];
+} // fixedDOF
+
+// ----------------------------------------------------------------------
+// Initialize boundary condition.
+void
+pylith::bc::DirichletBC::initialize(const topology::Mesh& mesh,
+ const double upDir[3])
+{ // initialize
+ const int numFixedDOF = _fixedDOF.size();
+ if (0 == numFixedDOF)
+ return;
+
+ _getPoints(mesh);
+ _setupQueryDatabases();
+ _queryDatabases(mesh);
+} // initialize
+
+// ----------------------------------------------------------------------
+// Set number of degrees of freedom that are constrained at points in field.
+void
+pylith::bc::DirichletBC::setConstraintSizes(const topology::Field<topology::Mesh>& field)
+{ // setConstraintSizes
+ const int numFixedDOF = _fixedDOF.size();
+ if (0 == numFixedDOF)
+ return;
+
+ const ALE::Obj<RealSection>& section = field.section();
+ assert(!section.isNull());
+
+ const int numPoints = _points.size();
+ _offsetLocal.resize(numPoints);
+ for (int iPoint=0; iPoint < numPoints; ++iPoint) {
+ const int fiberDim = section->getFiberDimension(_points[iPoint]);
+ const int curNumConstraints =
+ section->getConstraintDimension(_points[iPoint]);
+ if (curNumConstraints + numFixedDOF > fiberDim) {
+ std::ostringstream msg;
+ msg
+ << "Found overly constrained point while setting up constraints for\n"
+ << "DirichletBC boundary condition '" << _label << "'.\n"
+ << "Number of DOF at point " << _points[iPoint] << " is " << fiberDim
+ << "\nand number of attempted constraints is "
+ << curNumConstraints+numFixedDOF << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ _offsetLocal[iPoint] = curNumConstraints;
+ section->addConstraintDimension(_points[iPoint], numFixedDOF);
+ } // for
+} // setConstraintSizes
+
+// ----------------------------------------------------------------------
+// Set which degrees of freedom are constrained at points in field.
+void
+pylith::bc::DirichletBC::setConstraints(const topology::Field<topology::Mesh>& field)
+{ // setConstraints
+ const int numFixedDOF = _fixedDOF.size();
+ if (0 == numFixedDOF)
+ return;
+
+ const ALE::Obj<RealSection>& section = field.section();
+ assert(!section.isNull());
+
+ const int numPoints = _points.size();
+ for (int iPoint=0; iPoint < numPoints; ++iPoint) {
+ const SieveMesh::point_type point = _points[iPoint];
+
+ // Get list of currently constrained DOF
+ const int* curFixedDOF = section->getConstraintDof(point);
+ const int numTotalConstrained = section->getConstraintDimension(point);
+
+ // Create array holding all constrained DOF
+ int_array allFixedDOF(curFixedDOF, numTotalConstrained);
+
+ // Verify other BC has not already constrained DOF
+ const int numPrevious = _offsetLocal[iPoint];
+ for (int iDOF=0; iDOF < numPrevious; ++iDOF)
+ for (int jDOF=0; jDOF < numFixedDOF; ++jDOF)
+ if (allFixedDOF[iDOF] == _fixedDOF[jDOF]) {
+ std::ostringstream msg;
+ msg << "Found multiple constraints on degrees of freedom at\n"
+ << "point while setting up constraints for DirichletBC\n"
+ << "boundary condition '" << _label << "'.\n"
+ << "Degree of freedom " << _fixedDOF[jDOF]
+ << " is already constrained by another Dirichlet BC.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ // Add in the ones for this DirichletBC BC
+ for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
+ assert(_offsetLocal[iPoint]+iDOF < numTotalConstrained);
+ allFixedDOF[_offsetLocal[iPoint]+iDOF] = _fixedDOF[iDOF];
+ } // for
+
+ // Fill in rest of values not yet set (will be set by
+ // another DirichletBC BC)
+ for (int iDOF=_offsetLocal[iPoint]+numFixedDOF;
+ iDOF < numTotalConstrained;
+ ++iDOF) {
+ assert(iDOF < numTotalConstrained);
+ allFixedDOF[iDOF] = 999;
+ } // for
+
+ // Sort list of constrained DOF
+ // I need these sorted for my update algorithms to work properly
+ std::sort(&allFixedDOF[0], &allFixedDOF[numTotalConstrained]);
+
+ // Update list of constrained DOF
+ section->setConstraintDof(point, &allFixedDOF[0]);
+ } // for
+} // setConstraints
+
+// ----------------------------------------------------------------------
+// Set values in field.
+void
+pylith::bc::DirichletBC::setField(const double t,
+ const topology::Field<topology::Mesh>& field)
+{ // setField
+ const int numFixedDOF = _fixedDOF.size();
+ if (0 == numFixedDOF)
+ return;
+
+ const ALE::Obj<RealSection>& section = field.section();
+ assert(!section.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = field.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const int numPoints = _points.size();
+ const int fiberDimension =
+ (numPoints > 0) ? section->getFiberDimension(_points[0]) : 0;
+ double_array allValues(fiberDimension);
+ for (int iPoint=0; iPoint < numPoints; ++iPoint) {
+ const SieveMesh::point_type point = _points[iPoint];
+ assert(fiberDimension == section->getFiberDimension(point));
+ sieveMesh->restrictClosure(section, point, &allValues[0], fiberDimension);
+ for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+ allValues[_fixedDOF[iDOF]] = _valuesInitial[iPoint*numFixedDOF+iDOF];
+ if (t > _tRef && 0 != _dbRate)
+ for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+ allValues[_fixedDOF[iDOF]] +=
+ (t-_tRef) * _valuesRate[iPoint*numFixedDOF+iDOF];
+ section->updatePointAll(_points[iPoint], &allValues[0]);
+ } // for
+} // setField
+
+// ----------------------------------------------------------------------
+// Get mesh labels for points associated with Dirichlet BC.
+void
+pylith::bc::DirichletBC::_getPoints(const topology::Mesh& mesh)
+{ // _getPoints
+ typedef topology::Mesh::IntSection::chart_type chart_type;
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<SieveMesh::int_section_type>& groupField =
+ sieveMesh->getIntSection(_label);
+ if (groupField.isNull()) {
+ std::ostringstream msg;
+ msg << "Could not find group of points '" << _label << "' in mesh.";
+ throw std::runtime_error(msg.str());
+ } // if
+ assert(!groupField.isNull());
+ const chart_type& chart = groupField->getChart();
+ const chart_type::const_iterator& chartEnd = chart.end();
+ const int numPoints = groupField->size();
+ _points.resize(numPoints);
+ int i = 0;
+ for(chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chartEnd;
+ ++c_iter)
+ if (groupField->getFiberDimension(*c_iter))
+ _points[i++] = *c_iter;
+} // _getPoints
+
+// ----------------------------------------------------------------------
+// Setup initial and rate of change databases for querying.
+void
+pylith::bc::DirichletBC::_setupQueryDatabases(void)
+{ // _setupQueryDatabases
+ assert(0 != _db);
+
+ const int numFixedDOF = _fixedDOF.size();
+ char** valueNames = (numFixedDOF > 0) ? new char*[numFixedDOF] : 0;
+ for (int i=0; i < numFixedDOF; ++i) {
+ std::ostringstream name;
+ name << "dof-" << _fixedDOF[i];
+ const int size = 1 + name.str().length();
+ valueNames[i] = new char[size];
+ strcpy(valueNames[i], name.str().c_str());
+ } // for
+
+ // Setup initial database.
+ _db->open();
+ _db->queryVals(const_cast<const char**>(valueNames), numFixedDOF);
+
+ // Setup rate database, if provided.
+ if (0 != _dbRate) {
+ _dbRate->open();
+ _dbRate->queryVals((const char**) valueNames, numFixedDOF);
+ } // if
+ for (int i=0; i < numFixedDOF; ++i) {
+ delete[] valueNames[i]; valueNames[i] = 0;
+ } // for
+ delete[] valueNames; valueNames = 0;
+} // _setupQueryDatabases
+
+// ----------------------------------------------------------------------
+// Query initial and rate of change databases for values.
+void
+pylith::bc::DirichletBC::_queryDatabases(const topology::Mesh& mesh)
+{ // _queryDatabases
+ assert(0 != _db);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
+ assert(!coordinates.isNull());
+
+ const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
+ assert(0 != cs);
+ const int spaceDim = cs->spaceDim();
+
+ assert(0 != _normalizer);
+ const double lengthScale = _normalizer->lengthScale();
+ const double velocityScale =
+ _normalizer->lengthScale() / _normalizer->timeScale();
+
+ const int numPoints = _points.size();
+ const int numFixedDOF = _fixedDOF.size();
+ _valuesInitial.resize(numPoints*numFixedDOF);
+ if (0 != _dbRate)
+ _valuesRate.resize(numPoints*numFixedDOF);
+
+ double_array queryValues(numFixedDOF);
+ double_array vCoordsGlobal(spaceDim);
+ for (int iPoint=0; iPoint < numPoints; ++iPoint) {
+ // Get coordinates of vertex
+ coordinates->restrictPoint(_points[iPoint],
+ &vCoordsGlobal[0], vCoordsGlobal.size());
+ _normalizer->dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
+ lengthScale);
+ int err = _db->query(&queryValues[0], numFixedDOF,
+ &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find initial values at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << vCoordsGlobal[i];
+ msg << ") using spatial database " << _db->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+ _valuesInitial[numFixedDOF*iPoint+iDOF] =
+ _normalizer->nondimensionalize(queryValues[iDOF], lengthScale);
+
+ if (0 != _dbRate) {
+ err = _dbRate->query(&queryValues[0], numFixedDOF,
+ &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find rate values at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << vCoordsGlobal[i];
+ msg << ") using spatial database " << _dbRate->label() << ".";
+ throw std::runtime_error(msg.str());
+ } // if
+ for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+ _valuesRate[numFixedDOF*iPoint+iDOF] =
+ _normalizer->nondimensionalize(queryValues[iDOF], velocityScale);
+ } // if
+ } // for
+ _db->close();
+ if (0 != _dbRate)
+ _dbRate->close();
+} // _queryDatabases
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/bc/DirichletBC.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/bc/DirichletBC.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBC.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBC.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,147 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/bc/DirichletBC.hh
+ *
+ * @brief C++ implementation of Dirichlet (prescribed values at
+ * degrees of freedom) boundary conditions with a set of points.
+ */
+
+#if !defined(pylith_bc_dirichletbc_hh)
+#define pylith_bc_dirichletbc_hh
+
+// Include directives ---------------------------------------------------
+#include "BoundaryCondition.hh" // ISA BoundaryCondition
+#include "pylith/feassemble/Constraint.hh" // ISA Constraint
+
+#include "pylith/utils/array.hh" // HASA std::vector, double_array, int_array
+
+// DirichletBC ------------------------------------------------------
+class pylith::bc::DirichletBC : public BoundaryCondition,
+ public feassemble::Constraint
+{ // class DirichletBC
+ friend class TestDirichletBC; // unit testing
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Default constructor.
+ DirichletBC(void);
+
+ /// Destructor.
+ ~DirichletBC(void);
+
+ /** Set database for rate of change of values.
+ *
+ * @param db Spatial database
+ */
+ void dbRate(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set indices of fixed degrees of freedom.
+ *
+ * Note: all points associated with boundary condition has same
+ * degrees of freedom fixed.
+ *
+ * Example: [0, 1] to fix x and y degrees of freedom in Cartesian system.
+ *
+ * @param flags Array of indices of fixed degrees of freedom.
+ * @param size Size of array
+ */
+ void fixedDOF(const int* flags,
+ const int size);
+
+ /** Set time at which rate of change begins.
+ *
+ * @param t Reference time.
+ */
+ void referenceTime(const double t);
+
+ /** Initialize boundary condition.
+ *
+ * @param mesh PETSc mesh
+ * @param upDir Vertical direction (somtimes used in 3-D problems).
+ */
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3]);
+
+ /** Set number of degrees of freedom that are constrained at points in field.
+ *
+ * @param field Solution field
+ */
+ void setConstraintSizes(const topology::Field<topology::Mesh>& field);
+
+ /** Set which degrees of freedom are constrained at points in field.
+ *
+ * @param field Solution field
+ */
+ void setConstraints(const topology::Field<topology::Mesh>& field);
+
+ /** Set values in field.
+ *
+ * @param t Current time
+ * @param field Solution field
+ */
+ void setField(const double t,
+ const topology::Field<topology::Mesh>& field);
+
+ // PROTECTED METHODS //////////////////////////////////////////////////
+protected :
+
+ /** Get mesh labels for points associated with Dirichlet BC.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ void _getPoints(const topology::Mesh& mesh);
+
+ /// Setup initial and rate of change databases for querying.
+ void _setupQueryDatabases(void);
+
+ /** Query initial and rate of change databases for values.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ void _queryDatabases(const topology::Mesh& mesh);
+
+ // NOT IMPLEMENTED ////////////////////////////////////////////////////
+private :
+
+ /// Not implemented
+ DirichletBC(const DirichletBC& m);
+
+ /// Not implemented
+ const DirichletBC& operator=(const DirichletBC& m);
+
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ double _tRef; /// Time when rate of change for values begins.
+ double_array _valuesInitial; ///< Initial values at points.
+ double_array _valuesRate; ///< Rate of change of values at points.
+
+ int_array _points; ///< Points for BC
+ int_array _fixedDOF; ///< Indices of fixed degrees of freedom
+
+ /// Offset in list of fixed DOF at point to get to fixed DOF
+ /// associated with this DirichletBC boundary condition.
+ int_array _offsetLocal;
+
+ /// Spatial database with parameters for rate of change values.
+ spatialdata::spatialdb::SpatialDB* _dbRate;
+
+}; // class DirichletBC
+
+#include "DirichletBC.icc" // inline methods
+
+#endif // pylith_bc_dirichletbc_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/bc/DirichletBC.icc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/bc/DirichletBC.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBC.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBC.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,32 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#if !defined(pylith_bc_dirichletbc_hh)
+#error "DirichletBC.icc can only be included from DirichletBC.hh"
+#endif
+
+// Set database for boundary condition parameters.
+inline
+void
+pylith::bc::DirichletBC::dbRate(spatialdata::spatialdb::SpatialDB* const db) {
+ _dbRate = db;
+}
+
+// Set time at which rate of change begins.
+inline
+void
+pylith::bc::DirichletBC::referenceTime(const double t) {
+ _tRef = t;
+} // referenceTime
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,13 +14,12 @@
#include "DirichletBoundary.hh" // implementation of object methods
-#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-#include <Selection.hh> // USES submesh algorithms
-
-#include <cstring> // USES strcpy()
#include <strings.h> // USES strcasecmp()
#include <cassert> // USES assert()
#include <stdexcept> // USES std::runtime_error
@@ -29,8 +28,8 @@
// ----------------------------------------------------------------------
// Default constructor.
pylith::bc::DirichletBoundary::DirichletBoundary(void) :
- _tRef(0.0),
- _dbRate(0)
+ _boundaryMesh(0),
+ _tmpField(0)
{ // constructor
} // constructor
@@ -38,349 +37,107 @@
// Destructor.
pylith::bc::DirichletBoundary::~DirichletBoundary(void)
{ // destructor
- _dbRate = 0;
+ delete _boundaryMesh; _boundaryMesh = 0;
+ delete _tmpField; _tmpField = 0;
} // destructor
// ----------------------------------------------------------------------
// Initialize boundary condition.
void
-pylith::bc::DirichletBoundary::initialize(
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir)
+pylith::bc::DirichletBoundary::initialize(const topology::Mesh& mesh,
+ const double upDir[3])
{ // initialize
- assert(0 != _db);
- assert(0 != _dbRate);
- assert(!mesh.isNull());
- assert(0 != cs);
-
const int numFixedDOF = _fixedDOF.size();
if (0 == numFixedDOF)
return;
- // Extract submesh associated with boundary
- _boundaryMesh =
- ALE::Selection<Mesh>::submeshV<SubMesh>(mesh, mesh->getIntSection(_label));
- if (_boundaryMesh.isNull()) {
- std::ostringstream msg;
- msg << "Could not construct boundary mesh for Dirichlet boundary "
- << "condition '" << _label << "'.";
- throw std::runtime_error(msg.str());
- } // if
- _boundaryMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
- // Create the parallel overlap
- Obj<SubMesh::send_overlap_type> sendParallelMeshOverlap = _boundaryMesh->getSendOverlap();
- Obj<SubMesh::recv_overlap_type> recvParallelMeshOverlap = _boundaryMesh->getRecvOverlap();
- Mesh::renumbering_type& renumbering = mesh->getRenumbering();
- // Can I figure this out in a nicer way?
- ALE::SetFromMap<std::map<Mesh::point_type,Mesh::point_type> > globalPoints(renumbering);
+ _boundaryMesh = new topology::SubMesh(mesh, _label.c_str());
+ assert(0 != _boundaryMesh);
- ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering, sendParallelMeshOverlap, recvParallelMeshOverlap);
- _boundaryMesh->setCalculatedOverlap(true);
-
- // Get values for degrees of freedom
- char** valueNames = (numFixedDOF > 0) ? new char*[numFixedDOF] : 0;
- for (int i=0; i < numFixedDOF; ++i) {
- std::ostringstream name;
- name << "dof-" << _fixedDOF[i];
- const int size = 1 + name.str().length();
- valueNames[i] = new char[size];
- strcpy(valueNames[i], name.str().c_str());
- } // for
- _db->open();
- _db->queryVals((const char**) valueNames, numFixedDOF);
- _dbRate->open();
- _dbRate->queryVals((const char**) valueNames, numFixedDOF);
- for (int i=0; i < numFixedDOF; ++i) {
- delete[] valueNames[i]; valueNames[i] = 0;
- } // for
- delete[] valueNames; valueNames = 0;
-
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _boundaryMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
-
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const int spaceDim = cs->spaceDim();
-
- _values = new real_section_type(_boundaryMesh->comm(),
- _boundaryMesh->debug());
- _values->addSpace(); // initial values
- _values->addSpace(); // rate of change of values
- _values->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _values->setFiberDimension(vertices, 2*numFixedDOF);
- _values->setFiberDimension(vertices, numFixedDOF, 0); // initial values
- _values->setFiberDimension(vertices, numFixedDOF, 1); // rate of change
- _boundaryMesh->allocate(_values);
-
- double_array queryValues(2*numFixedDOF);
- double_array vCoordsGlobal(spaceDim);
-
- assert(0 != _normalizer);
- const double lengthScale = _normalizer->lengthScale();
- const double velocityScale =
- _normalizer->lengthScale() / _normalizer->timeScale();
-
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter) {
- // Get coordinates of vertex
- coordinates->restrictPoint(*v_iter,
- &vCoordsGlobal[0], vCoordsGlobal.size());
- _normalizer->dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
- lengthScale);
- int err = _db->query(&queryValues[0], numFixedDOF,
- &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
- if (err) {
- std::ostringstream msg;
- msg << "Could not find values at (";
- for (int i=0; i < spaceDim; ++i)
- msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _db->label() << ".";
- throw std::runtime_error(msg.str());
- } // if
- for (int i=0; i < numFixedDOF; ++i)
- _normalizer->nondimensionalize(queryValues[i], lengthScale);
-
- err = _dbRate->query(&queryValues[numFixedDOF], numFixedDOF,
- &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
- if (err) {
- std::ostringstream msg;
- msg << "Could not find values at (";
- for (int i=0; i < spaceDim; ++i)
- msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _dbRate->label() << ".";
- throw std::runtime_error(msg.str());
- } // if
- for (int i=0; i < numFixedDOF; ++i)
- _normalizer->nondimensionalize(queryValues[numFixedDOF+i], velocityScale);
-
- _values->updatePoint(*v_iter, &queryValues[0]);
- } // for
- _db->close();
- _dbRate->close();
+ _getPoints(mesh);
+ _setupQueryDatabases();
+ _queryDatabases(mesh);
} // initialize
// ----------------------------------------------------------------------
-// Set number of degrees of freedom that are constrained at points in field.
-void
-pylith::bc::DirichletBoundary::setConstraintSizes(
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh)
-{ // setConstraintSizes
- assert(!field.isNull());
- assert(!mesh.isNull());
+// Get vertex field of BC initial or rate of change of values.
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::bc::DirichletBoundary::vertexField(const char* name,
+ const topology::SolutionFields& fields)
+{ // getVertexField
+ typedef topology::SubMesh::SieveMesh SieveMesh;
+ typedef topology::SubMesh::RealSection RealSection;
- const int numFixedDOF = _fixedDOF.size();
- if (0 == numFixedDOF)
- return;
+ assert(0 != name);
+ assert(0 != _boundaryMesh);
+ assert(0 != _normalizer);
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _boundaryMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = _boundaryMesh->sieveMesh();
+ assert(!sieveMesh.isNull());
- _offsetLocal = new int_section_type(_boundaryMesh->comm(),
- _boundaryMesh->debug());
- _offsetLocal->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _offsetLocal->setFiberDimension(vertices, 1);
- _boundaryMesh->allocate(_offsetLocal);
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const int curNumConstraints = field->getConstraintDimension(*v_iter);
- if (curNumConstraints + numFixedDOF > fiberDim) {
- std::ostringstream msg;
- msg << "Found overly constrained point while setting up constraints "
- << "for DirichletBoundary boundary condition '" << _label << "'.\n"
- << "Number of DOF at point " << *v_iter << " is " << fiberDim
- << " and number of attempted constraints is "
- << curNumConstraints+numFixedDOF << ".";
- throw std::runtime_error(msg.str());
- } // if
- _offsetLocal->updatePoint(*v_iter, &curNumConstraints);
- field->addConstraintDimension(*v_iter, numFixedDOF);
- } // for
-} // setConstraintSizes
+ const spatialdata::geocoords::CoordSys* cs = _boundaryMesh->coordsys();
+ assert(0 != cs);
+ const int fiberDim = cs->spaceDim();
+ double_array values(fiberDim);
-// ----------------------------------------------------------------------
-// Set which degrees of freedom are constrained at points in field.
-void
-pylith::bc::DirichletBoundary::setConstraints(
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh)
-{ // setConstraints
- assert(!field.isNull());
- assert(!mesh.isNull());
-
+ const int numPoints = _points.size();
const int numFixedDOF = _fixedDOF.size();
- if (0 == numFixedDOF)
- return;
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _boundaryMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ if (0 == _tmpField) {
+ _tmpField = new topology::Field<topology::SubMesh>(*_boundaryMesh);
+ assert(0 != _tmpField);
+ _tmpField->newSection(vertices, fiberDim);
+ _tmpField->allocate();
+ } // if
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter) {
- // Get list of currently constrained DOF
- const int* curFixedDOF = field->getConstraintDof(*v_iter);
- const int numTotalConstrained = field->getConstraintDimension(*v_iter);
+ // ERROR: NEED TO TRANSLATE LABELS FROM MESH INTO SUBMESH
+ std::cerr << "TODO: Translate labels from mesh into submesh." << std::endl;
+ assert(0);
- // Create array holding all constrained DOF
- int_array allFixedDOF(curFixedDOF, numTotalConstrained);
+ if (0 == strcasecmp(name, "initial")) {
+ _tmpField->label("displacement");
+ _tmpField->vectorFieldType(topology::Field<topology::SubMesh>::VECTOR);
+ _tmpField->scale(_normalizer->lengthScale());
+ _tmpField->addDimensionOkay(true);
+ _tmpField->zero();
+ const ALE::Obj<RealSection>& section = _tmpField->section();
- const int_section_type::value_type* offset =
- _offsetLocal->restrictPoint(*v_iter);
-
- // Verify other BC has not already constrained DOF
- const int numPrevious = offset[0];
- for (int iDOF=0; iDOF < numPrevious; ++iDOF)
- for (int jDOF=0; jDOF < numFixedDOF; ++jDOF)
- if (allFixedDOF[iDOF] == _fixedDOF[jDOF]) {
- std::ostringstream msg;
- msg << "Found multiple constraints on degrees of freedom at\n"
- << "point while setting up constraints for DirichletPoints\n"
- << "boundary condition '" << _label << "'.\n"
- << "Degree of freedom " << _fixedDOF[jDOF]
- << " is already constrained by another Dirichlet BC.";
- throw std::runtime_error(msg.str());
- } // if
-
- // Add in the ones for this DirichletBoundary BC
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
- assert(offset[0]+iDOF < numTotalConstrained);
- allFixedDOF[offset[0]+iDOF] = _fixedDOF[iDOF];
+ for (int iPoint=0; iPoint < numPoints; ++iPoint) {
+ const SieveMesh::point_type point = _points[iPoint];
+ assert(fiberDim == section->getFiberDimension(point));
+ for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
+ values[_fixedDOF[iDOF]] = _valuesInitial[iPoint*numFixedDOF+iDOF];
+ section->updatePointAll(_points[iPoint], &values[0]);
} // for
+ } else if (0 == strcasecmp(name, "rate-of-change")) {
+ _tmpField->label("velocity");
+ _tmpField->vectorFieldType(topology::Field<topology::SubMesh>::VECTOR);
+ _tmpField->scale(_normalizer->lengthScale());
+ _tmpField->addDimensionOkay(true);
+ _tmpField->zero();
+ const ALE::Obj<RealSection>& section = _tmpField->section();
- // Fill in rest of values not yet set
- // (will be set by another DirichletBoundary BC)
- for (int iDOF=offset[0]+numFixedDOF; iDOF < numTotalConstrained; ++iDOF) {
- assert(iDOF < numTotalConstrained);
- allFixedDOF[iDOF] = 999;
- } // for
-
- // Sort list of constrained DOF
- // I need these sorted for my update algorithms to work properly
- std::sort(&allFixedDOF[0], &allFixedDOF[numTotalConstrained]);
-
- // Update list of constrained DOF
- field->setConstraintDof(*v_iter, &allFixedDOF[0]);
- } // for
-} // setConstraints
-
-// ----------------------------------------------------------------------
-// Set values in field.
-void
-pylith::bc::DirichletBoundary::setField(const double t,
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh)
-{ // setField
- assert(!field.isNull());
- assert(!mesh.isNull());
-
- const int numFixedDOF = _fixedDOF.size();
- if (0 == numFixedDOF)
- return;
-
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _boundaryMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
-
- const int fiberDimension =
- (vertices->size() > 0) ? field->getFiberDimension(*vertices->begin()) : 0;
-
- double_array fieldValues(fiberDimension);
-
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter) {
- assert(fiberDimension == field->getFiberDimension(*v_iter));
- mesh->restrictClosure(field, *v_iter, &fieldValues[0], fiberDimension);
-
- const real_section_type::value_type* values =
- _values->restrictPoint(*v_iter);
-
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
- fieldValues[_fixedDOF[iDOF]] = values[iDOF];
- if (t > _tRef)
+ for (int iPoint=0; iPoint < numPoints; ++iPoint) {
+ const SieveMesh::point_type point = _points[iPoint];
+ assert(fiberDim == section->getFiberDimension(point));
for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
- fieldValues[_fixedDOF[iDOF]] += (t-_tRef) * values[numFixedDOF+iDOF];
- field->updatePointAll(*v_iter, &fieldValues[0]);
- } // for
-} // setField
-
-// ----------------------------------------------------------------------
-// Get vertex field of BC initial or rate of change of values.
-const ALE::Obj<pylith::real_section_type>&
-pylith::bc::DirichletBoundary::vertexField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields)
-{ // getVertexField
- assert(0 != fieldType);
- assert(0 != name);
- assert(!_boundaryMesh.isNull());
- assert(!_values.isNull());
- assert(0 != _normalizer);
-
- const ALE::Obj<Mesh::label_sequence>& vertices =
- _boundaryMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
-
- ALE::Obj<real_section_type> field = 0;
- int fiberDim = 0;
- double scale = 0.0;
- if (0 == strcasecmp(name, "initial")) {
- *fieldType = VECTOR_FIELD;
- field = _values->getFibration(0);
- fiberDim =
- (vertices->size() > 0) ? field->getFiberDimension(*vertices->begin()) : 0;
- scale = _normalizer->lengthScale();
- } else if (0 == strcasecmp(name, "rate-of-change")) {
- *fieldType = VECTOR_FIELD;
- field = _values->getFibration(0);
- fiberDim =
- (vertices->size() > 0) ? field->getFiberDimension(*vertices->begin()) : 0;
- scale = _normalizer->lengthScale() / _normalizer->timeScale();
+ values[_fixedDOF[iDOF]] = _valuesRate[iPoint*numFixedDOF+iDOF];
+ section->updatePointAll(_points[iPoint], &values[0]);
+ } // for
} else {
std::ostringstream msg;
- msg << "Unknown field '" << name << "' requested for Dirichlet BC '"
- << _label << "'.";
+ msg
+ << "Unknown field '" << name << "' requested for Dirichlet boundary BC '"
+ << _label << "'.";
throw std::runtime_error(msg.str());
} // else
- // Allocate buffer if necessary
- if (_buffer.isNull()) {
- _buffer = new real_section_type(_boundaryMesh->comm(),
- _boundaryMesh->debug());
- _buffer->setChart(real_section_type::chart_type(
- *std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(),
- vertices->end())+1));
- _buffer->setFiberDimension(vertices, fiberDim);
- _boundaryMesh->allocate(_buffer);
- } // if
-
- // dimensionalize values
- double_array values(fiberDim);
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter) {
- assert(fiberDim == field->getFiberDimension(*v_iter));
- assert(fiberDim == _buffer->getFiberDimension(*v_iter));
- field->restrictPoint(*v_iter, &values[0], values.size());
- _normalizer->dimensionalize(&values[0], values.size(), scale);
- _buffer->updatePointAll(*v_iter, &values[0]);
- } // for
-
- return _buffer;
+ return *_tmpField;
} // getVertexField
Modified: short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,28 +19,11 @@
#if !defined(pylith_bc_dirichletboundary_hh)
#define pylith_bc_dirichletboundary_hh
-#include "BoundaryCondition.hh" // ISA BoundaryCondition
-#include "pylith/feassemble/Constraint.hh" // ISA Constraint
+// Include directives ---------------------------------------------------
+#include "DirichletBC.hh" // ISA DirichletBC
-#include "pylith/utils/array.hh" // USES std::vector, double_array, int_array
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class DirichletBoundary;
- class TestDirichletBoundary; // unit testing
- } // bc
-
- namespace topology {
- class FieldsManager; // forward declaration
- } // topology
-} // pylith
-
-
-/// C++ implementation of DirichletBoundary boundary conditions.
-class pylith::bc::DirichletBoundary : public BoundaryCondition,
- public feassemble::Constraint
+// DirichletBoundary ----------------------------------------------------
+class pylith::bc::DirichletBoundary : public DirichletBC
{ // class DirichletBoundary
friend class TestDirichletBoundary; // unit testing
@@ -53,84 +36,30 @@
/// Destructor.
~DirichletBoundary(void);
- /** Set database for rate of change of values.
- *
- * @param db Spatial database
- */
- void dbRate(spatialdata::spatialdb::SpatialDB* const db);
-
- /** Set indices of fixed degrees of freedom.
- *
- * Note: all points associated with boundary condition has same
- * degrees of freedom fixed.
- *
- * Example: [0, 1] to fix x and y degrees of freedom in Cartesian system.
- *
- * @param flags Indices of fixed degrees of freedom.
- */
- void fixedDOF(const int_array& flags);
-
- /** Set time at which rate of change begins.
- *
- * @param t Reference time.
- */
- void referenceTime(const double t);
-
/** Initialize boundary condition.
*
- * @param mesh PETSc mesh
- * @param cs Coordinate system for mesh
+ * @param mesh Finite-element mesh.
+ * @param upDir Vertical direction (somtimes used in 3-D problems).
*/
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir);
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3]);
- /** Set number of degrees of freedom that are constrained at points in field.
- *
- * @param field Solution field
- * @param mesh PETSc mesh
- */
- void setConstraintSizes(const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh);
-
- /** Set which degrees of freedom are constrained at points in field.
- *
- * @param field Solution field
- * @param mesh PETSc mesh
- */
- void setConstraints(const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh);
-
- /** Set values in field.
- *
- * @param t Current time
- * @param field Solution field
- * @param mesh PETSc mesh
- */
- void setField(const double t,
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh);
-
/** Get boundary mesh.
*
* @return Boundary mesh.
*/
- const ALE::Obj<SubMesh>& boundaryMesh(void) const;
+ const topology::SubMesh& boundaryMesh(void) const;
/** Get vertex field with BC information.
*
- * @param fieldType Type of field.
* @param name Name of field.
- * @param mesh Finite-element mesh.
* @param fields Solution fields.
*
* @returns Field over vertices.
*/
- const ALE::Obj<real_section_type>&
- vertexField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ const topology::Field<topology::SubMesh>&
+ vertexField(const char* name,
+ const topology::SolutionFields& fields);
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
@@ -144,23 +73,9 @@
// PRIVATE MEMBERS ////////////////////////////////////////////////////
private :
- double _tRef; /// Time when rate of change for values begins
+ topology::SubMesh* _boundaryMesh; ///< Boundary mesh.
+ topology::Field<topology::SubMesh>* _tmpField; ///< Temporary field for output.
- /// Initial values and rate of change of values at DOF.
- ALE::Obj<real_section_type> _values;
- ALE::Obj<real_section_type> _buffer; ///< Buffer for output.
-
- ALE::Obj<SubMesh> _boundaryMesh; ///< Boundary mesh.
- int_array _fixedDOF; ///< Indices of fixed degrees of freedom
-
- /// Offset in list of fixed DOF at point to get to fixed DOF
- /// associated with this DirichletBoundary boundary condition.
- ALE::Obj<int_section_type> _offsetLocal;
-
- /// Spatial database with parameters for rate of change values.
- spatialdata::spatialdb::SpatialDB* _dbRate;
-
-
}; // class DirichletBoundary
#include "DirichletBoundary.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletBoundary.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,39 +14,12 @@
#error "DirichletBoundary.icc can only be included from DirichletBoundary.hh"
#endif
-// Set database for boundary condition parameters.
+// Get boundary mesh.
inline
-void
-pylith::bc::DirichletBoundary::dbRate(
- spatialdata::spatialdb::SpatialDB* const db) {
- _dbRate = db;
-}
-
-// Set indices of fixed degrees of freedom.
-inline
-void
-pylith::bc::DirichletBoundary::fixedDOF(const int_array& flags) {
- const size_t size = flags.size();
- _fixedDOF.resize(size);
- _fixedDOF = flags;
-} // fixedDOF
-
-// Set time at which rate of change begins.
-inline
-void
-pylith::bc::DirichletBoundary::referenceTime(const double t) {
- _tRef = t;
-} // referenceTime
-
- /** Get data mesh.
- *
- * @return Boundary mesh.
- */
-inline
-const ALE::Obj<pylith::SubMesh>&
+const pylith::topology::SubMesh&
pylith::bc::DirichletBoundary::boundaryMesh(void) const {
- return _boundaryMesh;
-} // dataMesh
+ return *_boundaryMesh;
+} // boundaryMesh
// End of file
Deleted: short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,276 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "DirichletPoints.hh" // implementation of object methods
-
-#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
-#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
-#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-
-#include <cstring> // USES strcpy()
-#include <cassert> // USES assert()
-#include <stdexcept> // USES std::runtime_error
-#include <sstream> // USES std::ostringstream
-
-// ----------------------------------------------------------------------
-// Default constructor.
-pylith::bc::DirichletPoints::DirichletPoints(void) :
- _tRef(0.0),
- _dbRate(0)
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor.
-pylith::bc::DirichletPoints::~DirichletPoints(void)
-{ // destructor
- _dbRate = 0;
-} // destructor
-
-// ----------------------------------------------------------------------
-// Initialize boundary condition.
-void
-pylith::bc::DirichletPoints::initialize(
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir)
-{ // initialize
- assert(0 != _db);
- assert(0 != _dbRate);
- assert(!mesh.isNull());
- assert(0 != cs);
-
- const int numFixedDOF = _fixedDOF.size();
- if (0 == numFixedDOF)
- return;
-
- // Get points associated with boundary condition
- const ALE::Obj<int_section_type>& groupField = mesh->getIntSection(_label);
- if (groupField.isNull()) {
- std::ostringstream msg;
- msg << "Could not find group of points '" << _label << "' in mesh.";
- throw std::runtime_error(msg.str());
- } // if
- assert(!groupField.isNull());
- const int_section_type::chart_type& chart = groupField->getChart();
- const int numPoints = groupField->size();
- _points.resize(numPoints);
- int i = 0;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin();
- c_iter != chart.end();
- ++c_iter) {
- if (groupField->getFiberDimension(*c_iter)) _points[i++] = *c_iter;
- }
-
- // Get values for degrees of freedom
- char** valueNames = (numFixedDOF > 0) ? new char*[numFixedDOF] : 0;
- for (int i=0; i < numFixedDOF; ++i) {
- std::ostringstream name;
- name << "dof-" << _fixedDOF[i];
- const int size = 1 + name.str().length();
- valueNames[i] = new char[size];
- strcpy(valueNames[i], name.str().c_str());
- } // for
- _db->open();
- _db->queryVals((const char**) valueNames, numFixedDOF);
- _dbRate->open();
- _dbRate->queryVals((const char**) valueNames, numFixedDOF);
- for (int i=0; i < numFixedDOF; ++i) {
- delete[] valueNames[i]; valueNames[i] = 0;
- } // for
- delete[] valueNames; valueNames = 0;
-
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const int spaceDim = cs->spaceDim();
-
- assert(0 != _normalizer);
- const double lengthScale = _normalizer->lengthScale();
- const double velocityScale =
- _normalizer->lengthScale() / _normalizer->timeScale();
-
- _valuesInitial.resize(numPoints*numFixedDOF);
- _valuesRate.resize(numPoints*numFixedDOF);
- double_array queryValues(numFixedDOF);
- double_array vCoordsGlobal(spaceDim);
- for (int iPoint=0; iPoint < numPoints; ++iPoint) {
- // Get coordinates of vertex
- coordinates->restrictPoint(_points[iPoint],
- &vCoordsGlobal[0], vCoordsGlobal.size());
- _normalizer->dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
- lengthScale);
- int err = _db->query(&queryValues[0], numFixedDOF,
- &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
- if (err) {
- std::ostringstream msg;
- msg << "Could not find values at (";
- for (int i=0; i < spaceDim; ++i)
- msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _db->label() << ".";
- throw std::runtime_error(msg.str());
- } // if
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
- _valuesInitial[numFixedDOF*iPoint+iDOF] =
- _normalizer->nondimensionalize(queryValues[iDOF], lengthScale);
-
- err = _dbRate->query(&queryValues[0], numFixedDOF,
- &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
- if (err) {
- std::ostringstream msg;
- msg << "Could not find values at (";
- for (int i=0; i < spaceDim; ++i)
- msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _dbRate->label() << ".";
- throw std::runtime_error(msg.str());
- } // if
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
- _valuesRate[numFixedDOF*iPoint+iDOF] =
- _normalizer->nondimensionalize(queryValues[iDOF], velocityScale);
- } // for
- _db->close();
- _dbRate->close();
-} // initialize
-
-// ----------------------------------------------------------------------
-// Set number of degrees of freedom that are constrained at points in field.
-void
-pylith::bc::DirichletPoints::setConstraintSizes(
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh)
-{ // setConstraintSizes
- assert(!field.isNull());
- assert(!mesh.isNull());
-
- const int numFixedDOF = _fixedDOF.size();
- if (0 == numFixedDOF)
- return;
-
- const int numPoints = _points.size();
- _offsetLocal.resize(numPoints);
- for (int iPoint=0; iPoint < numPoints; ++iPoint) {
- const int fiberDim = field->getFiberDimension(_points[iPoint]);
- const int curNumConstraints = field->getConstraintDimension(_points[iPoint]);
- if (curNumConstraints + numFixedDOF > fiberDim) {
- std::ostringstream msg;
- msg
- << "Found overly constrained point while setting up constraints for\n"
- << "DirichletPoints boundary condition '" << _label << "'.\n"
- << "Number of DOF at point " << _points[iPoint] << " is " << fiberDim
- << "\nand number of attempted constraints is "
- << curNumConstraints+numFixedDOF << ".";
- throw std::runtime_error(msg.str());
- } // if
- _offsetLocal[iPoint] = curNumConstraints;
- field->addConstraintDimension(_points[iPoint], numFixedDOF);
- } // for
-} // setConstraintSizes
-
-// ----------------------------------------------------------------------
-// Set which degrees of freedom are constrained at points in field.
-void
-pylith::bc::DirichletPoints::setConstraints(
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh)
-{ // setConstraints
- assert(!field.isNull());
- assert(!mesh.isNull());
-
- const int numFixedDOF = _fixedDOF.size();
- if (0 == numFixedDOF)
- return;
-
- const int numPoints = _points.size();
- for (int iPoint=0; iPoint < numPoints; ++iPoint) {
- const Mesh::point_type point = _points[iPoint];
-
- // Get list of currently constrained DOF
- const int* curFixedDOF = field->getConstraintDof(point);
- const int numTotalConstrained = field->getConstraintDimension(point);
-
- // Create array holding all constrained DOF
- int_array allFixedDOF(curFixedDOF, numTotalConstrained);
-
- // Verify other BC has not already constrained DOF
- const int numPrevious = _offsetLocal[iPoint];
- for (int iDOF=0; iDOF < numPrevious; ++iDOF)
- for (int jDOF=0; jDOF < numFixedDOF; ++jDOF)
- if (allFixedDOF[iDOF] == _fixedDOF[jDOF]) {
- std::ostringstream msg;
- msg << "Found multiple constraints on degrees of freedom at\n"
- << "point while setting up constraints for DirichletPoints\n"
- << "boundary condition '" << _label << "'.\n"
- << "Degree of freedom " << _fixedDOF[jDOF]
- << " is already constrained by another Dirichlet BC.";
- throw std::runtime_error(msg.str());
- } // if
-
- // Add in the ones for this DirichletPoints BC
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
- assert(_offsetLocal[iPoint]+iDOF < numTotalConstrained);
- allFixedDOF[_offsetLocal[iPoint]+iDOF] = _fixedDOF[iDOF];
- } // for
-
- // Fill in rest of values not yet set (will be set by
- // another DirichletPoints BC)
- for (int iDOF=_offsetLocal[iPoint]+numFixedDOF;
- iDOF < numTotalConstrained;
- ++iDOF) {
- assert(iDOF < numTotalConstrained);
- allFixedDOF[iDOF] = 999;
- } // for
-
- // Sort list of constrained DOF
- // I need these sorted for my update algorithms to work properly
- std::sort(&allFixedDOF[0], &allFixedDOF[numTotalConstrained]);
-
- // Update list of constrained DOF
- field->setConstraintDof(point, &allFixedDOF[0]);
- } // for
-} // setConstraints
-
-// ----------------------------------------------------------------------
-// Set values in field.
-void
-pylith::bc::DirichletPoints::setField(const double t,
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh)
-{ // setField
- assert(!field.isNull());
- assert(!mesh.isNull());
-
- const int numFixedDOF = _fixedDOF.size();
- if (0 == numFixedDOF)
- return;
-
- const int numPoints = _points.size();
- const int fiberDimension =
- (numPoints > 0) ? field->getFiberDimension(_points[0]) : 0;
- double_array allValues(fiberDimension);
- for (int iPoint=0; iPoint < numPoints; ++iPoint) {
- const Mesh::point_type point = _points[iPoint];
- assert(fiberDimension == field->getFiberDimension(point));
- mesh->restrictClosure(field, point, &allValues[0], fiberDimension);
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
- allValues[_fixedDOF[iDOF]] = _valuesInitial[iPoint*numFixedDOF+iDOF];
- if (t > _tRef)
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
- allValues[_fixedDOF[iDOF]] +=
- (t-_tRef) * _valuesRate[iPoint*numFixedDOF+iDOF];
- field->updatePointAll(_points[iPoint], &allValues[0]);
- } // for
-} // setField
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,142 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/** @file libsrc/bc/DirichletPoints.hh
- *
- * @brief C++ implementation of Dirichlet (prescribed values at
- * degrees of freedom) boundary conditions with a set of points.
- */
-
-#if !defined(pylith_bc_dirichletpoints_hh)
-#define pylith_bc_dirichletpoints_hh
-
-#include "BoundaryCondition.hh" // ISA BoundaryCondition
-#include "pylith/feassemble/Constraint.hh" // ISA Constraint
-
-#include "pylith/utils/array.hh" // USES std::vector, double_array, int_array
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class DirichletPoints;
- class TestDirichletPoints; // unit testing
- } // bc
-} // pylith
-
-
-/// C++ implementation of DirichletPoints boundary conditions.
-class pylith::bc::DirichletPoints : public BoundaryCondition,
- public feassemble::Constraint
-{ // class DirichletPoints
- friend class TestDirichletPoints; // unit testing
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Default constructor.
- DirichletPoints(void);
-
- /// Destructor.
- ~DirichletPoints(void);
-
- /** Set database for rate of change of values.
- *
- * @param db Spatial database
- */
- void dbRate(spatialdata::spatialdb::SpatialDB* const db);
-
- /** Set indices of fixed degrees of freedom.
- *
- * Note: all points associated with boundary condition has same
- * degrees of freedom fixed.
- *
- * Example: [0, 1] to fix x and y degrees of freedom in Cartesian system.
- *
- * @param flags Indices of fixed degrees of freedom.
- */
- void fixedDOF(const int_array& flags);
-
- /** Set time at which rate of change begins.
- *
- * @param t Reference time.
- */
- void referenceTime(const double t);
-
- /** Initialize boundary condition.
- *
- * @param mesh PETSc mesh
- * @param cs Coordinate system for mesh
- */
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir);
-
- /** Set number of degrees of freedom that are constrained at points in field.
- *
- * @param field Solution field
- * @param mesh PETSc mesh
- */
- void setConstraintSizes(const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh);
-
- /** Set which degrees of freedom are constrained at points in field.
- *
- * @param field Solution field
- * @param mesh PETSc mesh
- */
- void setConstraints(const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh);
-
- /** Set values in field.
- *
- * @param t Current time
- * @param field Solution field
- * @param mesh PETSc mesh
- */
- void setField(const double t,
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh);
-
- // NOT IMPLEMENTED ////////////////////////////////////////////////////
-private :
-
- /// Not implemented
- DirichletPoints(const DirichletPoints& m);
-
- /// Not implemented
- const DirichletPoints& operator=(const DirichletPoints& m);
-
- // PRIVATE MEMBERS ////////////////////////////////////////////////////
-private :
-
- double _tRef; /// Time when rate of change for values begins
- double_array _valuesInitial; ///< Initial values at degrees of freedom
- double_array _valuesRate; ///< Rate of change of Values at degrees of freedom
-
- std::vector<Mesh::point_type> _points; ///< Locations of boundary condition
- int_array _fixedDOF; ///< Indices of fixed degrees of freedom
-
- /// Offset in list of fixed DOF at point to get to fixed DOF
- /// associated with this DirichletPoints boundary condition.
- int_array _offsetLocal;
-
- /// Spatial database with parameters for rate of change values.
- spatialdata::spatialdb::SpatialDB* _dbRate;
-
-}; // class DirichletPoints
-
-#include "DirichletPoints.icc" // inline methods
-
-#endif // pylith_bc_dirichletpoints_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/DirichletPoints.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,42 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#if !defined(pylith_bc_dirichletpoints_hh)
-#error "DirichletPoints.icc can only be included from DirichletPoints.hh"
-#endif
-
-// Set database for boundary condition parameters.
-inline
-void
-pylith::bc::DirichletPoints::dbRate(
- spatialdata::spatialdb::SpatialDB* const db) {
- _dbRate = db;
-}
-
-// Set indices of fixed degrees of freedom.
-inline
-void
-pylith::bc::DirichletPoints::fixedDOF(const int_array& flags) {
- const size_t size = flags.size();
- _fixedDOF.resize(size);
- _fixedDOF = flags;
-} // fixedDOF
-
-// Set time at which rate of change begins.
-inline
-void
-pylith::bc::DirichletPoints::referenceTime(const double t) {
- _tRef = t;
-} // referenceTime
-
-
-// End of file
Modified: short/3D/PyLith/trunk/libsrc/bc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,11 +17,12 @@
AbsorbingDampers.hh \
BoundaryCondition.hh \
BoundaryCondition.icc \
+ DirichletBC.hh \
+ DirichletBC.icc \
DirichletBoundary.hh \
DirichletBoundary.icc \
- DirichletPoints.hh \
- DirichletPoints.icc \
- Neumann.hh
+ Neumann.hh \
+ bcfwd.hh
noinst_HEADERS =
Modified: short/3D/PyLith/trunk/libsrc/bc/Neumann.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/Neumann.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/Neumann.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,16 +14,13 @@
#include "Neumann.hh" // implementation of object methods
-#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
+#include "pylith/topology/Field.hh" // HOLDSA Field
#include "pylith/feassemble/CellGeometry.hh" // USES CellGeometry
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-#include <Selection.hh> // USES submesh algorithms
-
#include <cstring> // USES memcpy()
#include <strings.h> // USES strcasecmp()
#include <cassert> // USES assert()
@@ -31,8 +28,15 @@
#include <sstream> // USES std::ostringstream
// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
+typedef pylith::topology::SubMesh::RealSection SubRealSection;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Default constructor.
-pylith::bc::Neumann::Neumann(void)
+pylith::bc::Neumann::Neumann(void) :
+ _boundaryMesh(0),
+ _tractions(0)
{ // constructor
} // constructor
@@ -40,54 +44,34 @@
// Destructor.
pylith::bc::Neumann::~Neumann(void)
{ // destructor
+ delete _boundaryMesh; _boundaryMesh = 0;
+ delete _tractions; _tractions = 0;
} // destructor
// ----------------------------------------------------------------------
// Initialize boundary condition. Determine orienation and compute traction
// vector at integration points.
void
-pylith::bc::Neumann::initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir)
+pylith::bc::Neumann::initialize(const topology::Mesh& mesh,
+ const double upDir[3])
{ // initialize
assert(0 != _quadrature);
assert(0 != _db);
- assert(!mesh.isNull());
- assert(0 != cs);
- if (3 != upDir.size())
- throw std::runtime_error("Up direction for surface orientation must be "
- "a vector with 3 components.");
+ delete _boundaryMesh; _boundaryMesh = 0;
+ delete _tractions; _tractions = 0;
- // Extract submesh associated with surface
- _boundaryMesh =
- ALE::Selection<Mesh>::submeshV<SubMesh>(mesh, mesh->getIntSection(_label));
- if (_boundaryMesh.isNull()) {
- std::ostringstream msg;
- msg << "Could not construct boundary mesh for Neumann traction "
- << "boundary condition '" << _label << "'.";
- throw std::runtime_error(msg.str());
- } // if
- _boundaryMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
- // Create the parallel overlap
- Obj<SubMesh::send_overlap_type> sendParallelMeshOverlap = _boundaryMesh->getSendOverlap();
- Obj<SubMesh::recv_overlap_type> recvParallelMeshOverlap = _boundaryMesh->getRecvOverlap();
- Mesh::renumbering_type& renumbering = mesh->getRenumbering();
- // Can I figure this out in a nicer way?
- ALE::SetFromMap<std::map<Mesh::point_type,Mesh::point_type> > globalPoints(renumbering);
+ _boundaryMesh = new topology::SubMesh(mesh, _label.c_str());
+ assert(0 != _boundaryMesh);
- ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering, sendParallelMeshOverlap, recvParallelMeshOverlap);
- _boundaryMesh->setCalculatedOverlap(true);
+ double_array up(upDir, 3);
- //_boundaryMesh->view("TRACTION BOUNDARY MESH");
-
// check compatibility of quadrature and boundary mesh
- if (_quadrature->cellDim() != _boundaryMesh->getDimension()) {
+ if (_quadrature->cellDim() != _boundaryMesh->dimension()) {
std::ostringstream msg;
msg << "Quadrature is incompatible with cells for Neumann traction "
<< "boundary condition '" << _label << "'.\n"
- << "Dimension of boundary mesh: " << _boundaryMesh->getDimension()
+ << "Dimension of boundary mesh: " << _boundaryMesh->dimension()
<< ", dimension of quadrature: " << _quadrature->cellDim()
<< ".";
throw std::runtime_error(msg.str());
@@ -95,19 +79,20 @@
const int numCorners = _quadrature->numBasis();
// Get 'surface' cells (1 dimension lower than top-level cells)
- const ALE::Obj<SubMesh::label_sequence>& cells =
- _boundaryMesh->heightStratum(1);
+ const ALE::Obj<SieveSubMesh>& submesh = _boundaryMesh->sieveMesh();
+ assert(!submesh.isNull());
+ const int boundaryDepth = submesh->depth()-1; // depth of bndry cells
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ submesh->depthStratum(boundaryDepth);
assert(!cells.isNull());
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
- const SubMesh::label_sequence::iterator cellsBegin = cells->begin();
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
- const int boundaryDepth = _boundaryMesh->depth()-1; //depth of boundary cells
-
// Make sure surface cells are compatible with quadrature.
- for (SubMesh::label_sequence::iterator c_iter=cellsBegin;
+ for (SieveSubMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- const int cellNumCorners = _boundaryMesh->getNumCellCorners(*c_iter, boundaryDepth);
+ const int cellNumCorners =
+ submesh->getNumCellCorners(*c_iter, boundaryDepth);
if (numCorners != cellNumCorners) {
std::ostringstream msg;
msg << "Quadrature is incompatible with cell for Neumann traction "
@@ -120,26 +105,25 @@
} // for
// Create section for traction vector in global coordinates
- const int cellDim = _quadrature->cellDim();
+ const feassemble::CellGeometry& cellGeometry = _quadrature->refGeometry();
+ const int cellDim = _quadrature->cellDim() > 0 ? _quadrature->cellDim() : 1;
const int numBasis = _quadrature->numBasis();
const int numQuadPts = _quadrature->numQuadPts();
- const int spaceDim = cs->spaceDim();
+ const int spaceDim = cellGeometry.spaceDim();
const int fiberDim = spaceDim * numQuadPts;
- _tractions = new real_section_type(_boundaryMesh->comm(),
- _boundaryMesh->debug());
- assert(!_tractions.isNull());
- _tractions->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()), *std::max_element(cells->begin(), cells->end())+1));
- _tractions->setFiberDimension(cells, fiberDim);
- _boundaryMesh->allocate(_tractions);
+
+ _tractions = new topology::Field<topology::SubMesh>(*_boundaryMesh);
+ assert(0 != _tractions);
+ _tractions->newSection(cells, fiberDim);
+ _tractions->allocate();
// Containers for orientation information
const int orientationSize = spaceDim * spaceDim;
- const feassemble::CellGeometry& cellGeometry = _quadrature->refGeometry();
- const int jacobianSize = (cellDim > 0) ? spaceDim * cellDim : 1;
+ const int jacobianSize = spaceDim * cellDim;
double_array jacobian(jacobianSize);
double jacobianDet = 0;
double_array orientation(orientationSize);
- double_array cellVertices(numBasis*spaceDim);
+ double_array cellVertices(numCorners*spaceDim);
// Set names based on dimension of problem.
// 1-D problem = {'normal-traction'}
@@ -160,7 +144,8 @@
break;
} // case 2
case 3 : {
- const char* valueNames[] = {"horiz-shear-traction", "vert-shear-traction",
+ const char* valueNames[] = {"horiz-shear-traction",
+ "vert-shear-traction",
"normal-traction"};
_db->queryVals(valueNames, 3);
break;
@@ -179,30 +164,39 @@
// Container for cell tractions rotated to global coordinates.
double_array cellTractionsGlobal(fiberDim);
- // Get mesh coordinates.
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
+ // Get sections.
+ const ALE::Obj<RealSection>& coordinates =
+ submesh->getRealSection("coordinates");
assert(!coordinates.isNull());
+ topology::Mesh::RestrictVisitor coordsVisitor(*coordinates,
+ numCorners*spaceDim);
+ const ALE::Obj<SubRealSection>& tractSection = _tractions->section();
+ assert(!tractSection.isNull());
+
+ const spatialdata::geocoords::CoordSys* cs = _boundaryMesh->coordsys();
+
assert(0 != _normalizer);
const double lengthScale = _normalizer->lengthScale();
const double pressureScale = _normalizer->pressureScale();
+ // Compute quadrature information
+ _quadrature->computeGeometry(*_boundaryMesh, cells);
+
// Loop over cells in boundary mesh, compute orientations, and then
// compute corresponding traction vector in global coordinates
// (store values in _tractionGlobal).
- for(SubMesh::label_sequence::iterator c_iter = cellsBegin;
+ for(SieveSubMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cellsEnd;
++c_iter) {
- // std::cout << "c_iter: " << *c_iter << std::endl;
- _quadrature->computeGeometry(_boundaryMesh, coordinates, *c_iter);
+ _quadrature->retrieveGeometry(*c_iter);
const double_array& quadPtsNondim = _quadrature->quadPts();
quadPtsGlobal = quadPtsNondim;
_normalizer->dimensionalize(&quadPtsGlobal[0], quadPtsGlobal.size(),
lengthScale);
- _boundaryMesh->restrictClosure(coordinates, *c_iter,
- &cellVertices[0], cellVertices.size());
-
+ coordsVisitor.clear();
+ submesh->restrictClosure(*c_iter, coordsVisitor);
+
cellTractionsGlobal = 0.0;
for(int iQuad=0, iRef=0, iSpace=0; iQuad < numQuadPts;
++iQuad, iRef+=cellDim, iSpace+=spaceDim) {
@@ -211,8 +205,7 @@
&quadPtsGlobal[iSpace], spaceDim, cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find traction values at \n"
- << "(";
+ msg << "Could not find traction values at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << quadPtsGlobal[i+iSpace];
msg << ") for traction boundary condition " << _label << "\n"
@@ -225,8 +218,10 @@
// Compute Jacobian and determinant at quadrature point, then get
// orientation.
memcpy(&quadPtRef[0], &quadPtsRef[iRef], cellDim*sizeof(double));
+ memcpy(&cellVertices[0], coordsVisitor.getValues(),
+ cellVertices.size()*sizeof(double));
cellGeometry.jacobian(&jacobian, &jacobianDet, cellVertices, quadPtRef);
- cellGeometry.orientation(&orientation, jacobian, jacobianDet, upDir);
+ cellGeometry.orientation(&orientation, jacobian, jacobianDet, up);
orientation /= jacobianDet;
// Rotate traction vector from local coordinate system to global
@@ -239,9 +234,8 @@
} // for
// Update tractionsGlobal
- _tractions->updatePoint(*c_iter, &cellTractionsGlobal[0]);
+ tractSection->updatePoint(*c_iter, &cellTractionsGlobal[0]);
} // for
- // _tractions->view("Global tractions from Neumann::initialize");
_db->close();
} // initialize
@@ -250,58 +244,54 @@
// Integrate contributions to residual term (r) for operator.
void
pylith::bc::Neumann::integrateResidual(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateResidual
assert(0 != _quadrature);
- assert(!_boundaryMesh.isNull());
- assert(!residual.isNull());
- assert(0 != fields);
- assert(!mesh.isNull());
+ assert(0 != _boundaryMesh);
+ assert(0 != _tractions);
- PetscErrorCode err = 0;
-
- // Get cell information
- const ALE::Obj<SubMesh::label_sequence>& cells =
- _boundaryMesh->heightStratum(1);
- assert(!cells.isNull());
- const SubMesh::label_sequence::iterator cellsBegin = cells->begin();
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
-
- // Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
-
// Get cell geometry information that doesn't depend on cell
const int numQuadPts = _quadrature->numQuadPts();
const double_array& quadWts = _quadrature->quadWts();
assert(quadWts.size() == numQuadPts);
const int numBasis = _quadrature->numBasis();
const int spaceDim = _quadrature->spaceDim();
- const int cellDim = _quadrature->cellDim();
// Allocate vectors for cell values.
_initCellVector();
- const int cellVecSize = numBasis*spaceDim;
double_array tractionsCell(numQuadPts*spaceDim);
+ // Get cell information
+ const ALE::Obj<SieveSubMesh>& submesh = _boundaryMesh->sieveMesh();
+ assert(!submesh.isNull());
+ const int boundaryDepth = submesh->depth()-1; // depth of bndry cells
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ submesh->depthStratum(boundaryDepth);
+ assert(!cells.isNull());
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
+
+ // Get sections
+ const ALE::Obj<SubRealSection>& tractSection = _tractions->section();
+ assert(!tractSection.isNull());
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ topology::SubMesh::UpdateAddVisitor residualVisitor(*residualSection,
+ &_cellVector[0]);
+
// Loop over faces and integrate contribution from each face
- for (SubMesh::label_sequence::iterator c_iter=cellsBegin;
+ for (SieveSubMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- // Compute geometry information for current cell
- _quadrature->computeGeometry(_boundaryMesh, coordinates, *c_iter);
+ // Get geometry information for current cell
+ _quadrature->retrieveGeometry(*c_iter);
// Reset element vector to zero
_resetCellVector();
// Restrict tractions to cell
- _boundaryMesh->restrictClosure(_tractions, *c_iter,
- &tractionsCell[0], tractionsCell.size());
+ tractSection->restrictPoint(*c_iter,
+ &tractionsCell[0], tractionsCell.size());
// Get cell geometry information that depends on cell
const double_array& basis = _quadrature->basis();
@@ -321,7 +311,8 @@
} // for
} // for
// Assemble cell contribution into field
- _boundaryMesh->updateAdd(residual, *c_iter, _cellVector);
+ residualVisitor.clear();
+ submesh->updateAdd(*c_iter, residualVisitor);
PetscLogFlops(numQuadPts*(1+numBasis*(1+numBasis*(1+2*spaceDim))));
} // for
@@ -330,58 +321,42 @@
// ----------------------------------------------------------------------
// Integrate contributions to Jacobian matrix (A) associated with
void
-pylith::bc::Neumann::integrateJacobian(PetscMat* mat,
+pylith::bc::Neumann::integrateJacobian(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh)
+ topology::SolutionFields* const fields)
{ // integrateJacobian
+ _needNewJacobian = false;
} // integrateJacobian
// ----------------------------------------------------------------------
// Verify configuration is acceptable.
void
-pylith::bc::Neumann::verifyConfiguration(const ALE::Obj<Mesh>& mesh) const
+pylith::bc::Neumann::verifyConfiguration(const topology::Mesh& mesh) const
{ // verifyConfiguration
BoundaryCondition::verifyConfiguration(mesh);
} // verifyConfiguration
// ----------------------------------------------------------------------
// Get boundary mesh.
-const ALE::Obj<pylith::SubMesh>&
+const pylith::topology::SubMesh&
pylith::bc::Neumann::boundaryMesh(void) const
{ // dataMesh
- return _boundaryMesh;
+ assert(0 != _boundaryMesh);
+
+ return *_boundaryMesh;
} // dataMesh
// ----------------------------------------------------------------------
// Get cell field for tractions.
-const ALE::Obj<pylith::real_section_type>&
-pylith::bc::Neumann::cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields)
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::bc::Neumann::cellField(const char* name,
+ topology::SolutionFields* const fields)
{ // cellField
- assert(0 != fieldType);
+ assert(0 != _tractions);
assert(0 != name);
- assert(!_boundaryMesh.isNull());
- assert(!_tractions.isNull());
- assert(0 != _normalizer);
- const ALE::Obj<Mesh::label_sequence>& cells = _boundaryMesh->heightStratum(1);
- assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
-
- const int numQuadPts = _quadrature->numQuadPts();
- const int spaceDim = _quadrature->spaceDim();
-
- ALE::Obj<real_section_type> field = 0;
- int fiberDim = 0;
- double scale = 0.0;
if (0 == strcasecmp(name, "tractions")) {
- *fieldType = OTHER_FIELD;
- field = _tractions;
- fiberDim = spaceDim * numQuadPts;
- scale = _normalizer->pressureScale();
+ return *_tractions;
} else {
std::ostringstream msg;
msg << "Unknown field '" << name << "' requested for Neumann BC '"
@@ -389,30 +364,7 @@
throw std::runtime_error(msg.str());
} // else
- // Allocate buffer if necessary
- if (_buffer.isNull()) {
- _buffer = new real_section_type(_boundaryMesh->comm(), _boundaryMesh->debug());
- assert(!_buffer.isNull());
- _buffer->setChart(real_section_type::chart_type(
- *std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- _buffer->setFiberDimension(cells, fiberDim);
- _boundaryMesh->allocate(_buffer);
- } // if
-
- // dimensionalize values
- double_array values(fiberDim);
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
- c_iter != cellsEnd;
- ++c_iter) {
- assert(fiberDim == field->getFiberDimension(*c_iter));
- assert(fiberDim == _buffer->getFiberDimension(*c_iter));
- field->restrictPoint(*c_iter, &values[0], values.size());
- _normalizer->dimensionalize(&values[0], values.size(), scale);
- _buffer->updatePointAll(*c_iter, &values[0]);
- } // for
-
- return _buffer;
+ return *_tractions;
} // cellField
Modified: short/3D/PyLith/trunk/libsrc/bc/Neumann.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/Neumann.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/bc/Neumann.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,33 +19,18 @@
#if !defined(pylith_bc_neumann_hh)
#define pylith_bc_neumann_hh
+// Include directives ---------------------------------------------------
#include "BoundaryCondition.hh" // ISA BoundaryCondition
+
+#include "pylith/topology/SubMesh.hh" // ISA Quadrature<SubMesh>
+#include "pylith/feassemble/Quadrature.hh" // ISA Integrator<Quadrature>
#include "pylith/feassemble/Integrator.hh" // ISA Integrator
#include "pylith/utils/array.hh" // USES std::vector, double_array, int_array
-#include "pylith/utils/sievetypes.hh" // USES real_section_type
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class Neumann;
- class TestNeumann; // unit testing
- } // bc
-} // pylith
-
-/*
-namespace spatialdata {
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-*/
-
-
-/// C++ implementation of Neumann boundary conditions.
+// Neumann --------------------------------------------------------------
class pylith::bc::Neumann : public BoundaryCondition,
- public feassemble::Integrator
+ public feassemble::Integrator<feassemble::Quadrature<topology::SubMesh> >
{ // class Neumann
friend class TestNeumann; // unit testing
@@ -60,53 +45,45 @@
/** Initialize boundary condition.
*
- * @param mesh PETSc mesh
- * @param cs Coordinate system for mesh
+ * @param mesh Finite-element mesh.
* @param upDir Direction perpendicular to horizontal surface tangent
* direction that is not collinear with surface normal.
*/
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir);
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3]);
/** Integrate contributions to residual term (r) for operator.
*
- * @param residual Field containing values for residual
- * @param t Current time
- * @param fields Solution fields
- * @param mesh Finite-element mesh
- * @param cs Mesh coordinate system
+ * @param residual Field containing values for residual.
+ * @param t Current time.
+ * @param fields Solution fields.
*/
- void integrateResidual(const ALE::Obj<real_section_type>& residual,
+ void integrateResidual(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
/** Integrate contributions to Jacobian matrix (A) associated with
* operator.
*
- * @param mat Sparse matrix
+ * @param jacobian Sparse matrix for Jacobian of system.
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
- void integrateJacobian(PetscMat* mat,
+ void integrateJacobian(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
/** Verify configuration is acceptable.
*
* @param mesh Finite-element mesh
*/
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const;
+ void verifyConfiguration(const topology::Mesh& mesh) const;
/** Get boundary mesh.
*
* @returns Boundary mesh.
*/
- const ALE::Obj<SubMesh>& boundaryMesh(void) const;
+ const topology::SubMesh& boundaryMesh(void) const;
/** Get cell field with BC information.
*
@@ -117,11 +94,9 @@
*
* @returns Traction vector at integration points.
*/
- const ALE::Obj<real_section_type>&
- cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ const topology::Field<topology::SubMesh>&
+ cellField(const char* name,
+ topology::SolutionFields* const fields);
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
@@ -136,17 +111,13 @@
private :
/// Mesh over which tractions are applied
- ALE::Obj<SubMesh> _boundaryMesh;
+ topology::SubMesh* _boundaryMesh;
/// Traction vector in global coordinates at integration points.
- ALE::Obj<real_section_type> _tractions;
+ topology::Field<topology::SubMesh>* _tractions;
- ALE::Obj<real_section_type> _buffer; ///< Buffer for output.
-
}; // class Neumann
-// #include "Neumann.icc" // inline methods
-
#endif // pylith_bc_neumann_hh
Copied: short/3D/PyLith/trunk/libsrc/bc/bcfwd.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/bc/bcfwd.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/bc/bcfwd.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/bc/bcfwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/bc/bcfwd.hh
+ *
+ * @brief Forward declarations for PyLith boundary condition objects.
+ *
+ * Including this header file eliminates the need to use separate
+ * forward declarations.
+ */
+
+#if !defined(pylith_bc_bcfwd_hh)
+#define pylith_bc_bcfwd_hh
+
+namespace pylith {
+ namespace bc {
+
+ class BoundaryCondition;
+ class DirichletBC;
+ class DirichletBoundary;
+ class Neumann;
+ class AbsorbingDampers;
+
+ } // bc
+} // pylith
+
+
+#endif // pylith_bc_bcfwd_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,9 @@
#include "BruneSlipFn.hh" // implementation of object methods
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#include "pylith/utils/array.hh" // USES double_array
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/topology/Field.hh" // USES Field
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
@@ -25,22 +26,20 @@
#include <sstream> // USES std::ostringstream
#include <stdexcept> // USES std::runtime_error
-namespace pylith {
- namespace faults {
- namespace _BruneSlipFn {
- const int offsetPeakRate = 0;
- const int offsetSlipTime = 1;
- } // _BruneSlipFn
- } // faults
-} // pylith
+// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::SieveMesh::label_sequence label_sequence;
+typedef pylith::topology::SubMesh::RealSection RealSection;
// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::BruneSlipFn::BruneSlipFn(void) :
+ _slipTimeVertex(0),
+ _riseTimeVertex(0),
+ _parameters(0),
_dbFinalSlip(0),
_dbSlipTime(0),
- _dbPeakRate(0),
- _spaceDim(0)
+ _dbRiseTime(0)
{ // constructor
} // constructor
@@ -48,50 +47,68 @@
// Destructor.
pylith::faults::BruneSlipFn::~BruneSlipFn(void)
{ // destructor
- _dbFinalSlip = 0;
- _dbSlipTime = 0;
- _dbPeakRate = 0;
+ delete _parameters; _parameters = 0;
+ _dbFinalSlip = 0; // :TODO: Use shared pointer.
+ _dbSlipTime = 0; // :TODO: Use shared pointer.
+ _dbRiseTime = 0; // :TODO: Use shared pointer.
} // destructor
// ----------------------------------------------------------------------
// Initialize slip time function.
void
pylith::faults::BruneSlipFn::initialize(
- const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
- const spatialdata::units::Nondimensional& normalizer,
- const double originTime)
+ const topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime)
{ // initialize
- assert(!faultMesh.isNull());
- assert(0 != cs);
assert(0 != _dbFinalSlip);
assert(0 != _dbSlipTime);
- assert(0 != _dbPeakRate);
+ assert(0 != _dbRiseTime);
- _spaceDim = cs->spaceDim();
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexPeakRate = spaceDim + _BruneSlipFn::offsetPeakRate;
- const int indexSlipTime = spaceDim + _BruneSlipFn::offsetSlipTime;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ assert(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const double lengthScale = normalizer.lengthScale();
+ const double timeScale = normalizer.timeScale();
+
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = faultMesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- const int fiberDim = spaceDim + 2;
- _parameters = new real_section_type(faultMesh->comm(), faultMesh->debug());
- _parameters->addSpace(); // final slip
- _parameters->addSpace(); // peak slip rate
- _parameters->addSpace(); // slip time
- assert(3 == _parameters->getNumSpaces());
- _parameters->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _parameters->setFiberDimension(vertices, fiberDim);
- _parameters->setFiberDimension(vertices, spaceDim, 0); // final slip
- _parameters->setFiberDimension(vertices, 1, 1); // peak slip rate
- _parameters->setFiberDimension(vertices, 1, 2); // slip time
- faultMesh->allocate(_parameters);
- assert(!_parameters.isNull());
+ delete _parameters; _parameters = new topology::Fields<topology::Field<topology::SubMesh> >(faultMesh);
+ assert(0 != _parameters);
+ _parameters->add("final slip", "final_slip");
+ topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ finalSlip.newSection(vertices, spaceDim);
+ finalSlip.allocate();
+ finalSlip.scale(lengthScale);
+ finalSlip.vectorFieldType(topology::FieldBase::VECTOR);
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ _parameters->add("slip time", "slip_time");
+ topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
+ slipTime.newSection(finalSlipSection->getChart(), 1);
+ slipTime.allocate();
+ slipTime.scale(timeScale);
+ slipTime.vectorFieldType(topology::FieldBase::SCALAR);
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+
+ _parameters->add("rise time", "rise_time");
+ topology::Field<topology::SubMesh>& riseTime = _parameters->get("rise time");
+ riseTime.newSection(slipTime);
+ riseTime.allocate();
+ riseTime.scale(timeScale);
+ riseTime.vectorFieldType(topology::FieldBase::SCALAR);
+ const ALE::Obj<RealSection>& riseTimeSection = riseTime.section();
+ assert(!riseTimeSection.isNull());
+
// Open databases and set query values
_dbFinalSlip->open();
switch (spaceDim)
@@ -120,199 +137,211 @@
const char* slipTimeValues[] = {"slip-time"};
_dbSlipTime->queryVals(slipTimeValues, 1);
- _dbPeakRate->open();
- const char* peakRateValues[] = {"slip-rate"};
- _dbPeakRate->queryVals(peakRateValues, 1);
+ _dbRiseTime->open();
+ const char* riseTimeValues[] = {"rise-time"};
+ _dbRiseTime->queryVals(riseTimeValues, 1);
// Get coordinates of vertices
- const ALE::Obj<real_section_type>& coordinates =
- faultMesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
assert(!coordinates.isNull());
- const double lengthScale = normalizer.lengthScale();
- const double timeScale = normalizer.timeScale();
- const double velocityScale =
- normalizer.lengthScale() / normalizer.timeScale();
-
- double_array paramsVertex(fiberDim);
+ _slipVertex.resize(spaceDim);
double_array vCoordsGlobal(spaceDim);
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
coordinates->restrictPoint(*v_iter,
&vCoordsGlobal[0], vCoordsGlobal.size());
normalizer.dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
lengthScale);
-
- int err = _dbFinalSlip->query(¶msVertex[indexFinalSlip], spaceDim,
- &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
+
+ int err = _dbFinalSlip->query(&_slipVertex[0], _slipVertex.size(),
+ &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find final slip at (";
+ msg << "Could not find slip rate at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << vCoordsGlobal[i];
msg << ") using spatial database " << _dbFinalSlip->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexFinalSlip], spaceDim,
+ normalizer.nondimensionalize(&_slipVertex[0], _slipVertex.size(),
lengthScale);
- err = _dbPeakRate->query(¶msVertex[indexPeakRate], 1,
+
+ err = _dbSlipTime->query(&_slipTimeVertex, 1,
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find peak slip rate at (";
+ msg << "Could not find slip initiation time at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _dbPeakRate->label() << ".";
+ msg << ") using spatial database " << _dbSlipTime->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexPeakRate], 1,
- velocityScale);
+ normalizer.nondimensionalize(&_slipTimeVertex, 1, timeScale);
+ // add origin time to rupture time
+ _slipTimeVertex += originTime;
- err = _dbSlipTime->query(¶msVertex[indexSlipTime], 1,
+ err = _dbRiseTime->query(&_riseTimeVertex, 1,
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find slip initiation time at (";
+ msg << "Could not find rise time at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _dbSlipTime->label() << ".";
+ msg << ") using spatial database " << _dbRiseTime->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexSlipTime], 1,
- timeScale);
+ normalizer.nondimensionalize(&_riseTimeVertex, 1, timeScale);
- // add origin time to rupture time
- paramsVertex[indexSlipTime] += originTime;
-
- _parameters->updatePoint(*v_iter, ¶msVertex[0]);
+ finalSlipSection->updatePoint(*v_iter, &_slipVertex[0]);
+ slipTimeSection->updatePoint(*v_iter, &_slipTimeVertex);
+ riseTimeSection->updatePoint(*v_iter, &_riseTimeVertex);
} // for
// Close databases
_dbFinalSlip->close();
_dbSlipTime->close();
- _dbPeakRate->close();
+ _dbRiseTime->close();
} // initialize
// ----------------------------------------------------------------------
// Get slip on fault surface at time t.
void
-pylith::faults::BruneSlipFn::slip(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::BruneSlipFn::slip(topology::Field<topology::SubMesh>* slip,
+ const double t)
{ // slip
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexPeakRate = spaceDim + _BruneSlipFn::offsetPeakRate;
- const int indexSlipTime = spaceDim + _BruneSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const topology::Field<topology::SubMesh>& riseTime =
+ _parameters->get("rise time");
+ const ALE::Obj<RealSection>& riseTimeSection = riseTime.section();
+ assert(!riseTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ const int spaceDim = _slipVertex.size();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ finalSlipSection->restrictPoint(*v_iter, &_slipVertex[0],
+ _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
+ riseTimeSection->restrictPoint(*v_iter, &_riseTimeVertex, 1);
- const double* finalSlip = ¶msVertex[indexFinalSlip];
- const double peakRate = paramsVertex[indexPeakRate];
- const double slipTime = paramsVertex[indexSlipTime];
-
double finalSlipMag = 0.0;
for (int i=0; i < spaceDim; ++i)
- finalSlipMag += finalSlip[i]*finalSlip[i];
+ finalSlipMag += _slipVertex[i]*_slipVertex[i];
finalSlipMag = sqrt(finalSlipMag);
- const double slip = _slipFn(t-slipTime, finalSlipMag, peakRate);
+ const double slip = _slipFn(t-_slipTimeVertex, finalSlipMag,
+ _riseTimeVertex);
const double scale = finalSlipMag > 0.0 ? slip / finalSlipMag : 0.0;
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = scale * finalSlip[i];
-
+ _slipVertex *= scale;
+
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
} // for
- PetscLogFlops(numVertices * (2+8 + 3*spaceDim));
+ PetscLogFlops(vertices->size() * (2+8 + 3*_slipVertex.size()));
} // slip
// ----------------------------------------------------------------------
// Get increment of slip on fault surface between time t0 and t1.
void
-pylith::faults::BruneSlipFn::slipIncr(const ALE::Obj<pylith::real_section_type>& slipField,
+pylith::faults::BruneSlipFn::slipIncr(
+ topology::Field<topology::SubMesh>* slip,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh)
+ const double t1)
{ // slipIncr
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexPeakRate = spaceDim + _BruneSlipFn::offsetPeakRate;
- const int indexSlipTime = spaceDim + _BruneSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const topology::Field<topology::SubMesh>& riseTime =
+ _parameters->get("rise time");
+ const ALE::Obj<RealSection>& riseTimeSection = riseTime.section();
+ assert(!riseTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ const int spaceDim = _slipVertex.size();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ finalSlipSection->restrictPoint(*v_iter, &_slipVertex[0],
+ _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
+ riseTimeSection->restrictPoint(*v_iter, &_riseTimeVertex, 1);
- const double* finalSlip = ¶msVertex[indexFinalSlip];
- const double peakRate = paramsVertex[indexPeakRate];
- const double slipTime = paramsVertex[indexSlipTime];
-
double finalSlipMag = 0.0;
for (int i=0; i < spaceDim; ++i)
- finalSlipMag += finalSlip[i]*finalSlip[i];
+ finalSlipMag += _slipVertex[i]*_slipVertex[i];
finalSlipMag = sqrt(finalSlipMag);
- const double slip0 = _slipFn(t0-slipTime, finalSlipMag, peakRate);
- const double slip1 = _slipFn(t1-slipTime, finalSlipMag, peakRate);
+ const double slip0 = _slipFn(t0-_slipTimeVertex, finalSlipMag,
+ _riseTimeVertex);
+ const double slip1 = _slipFn(t1-_slipTimeVertex, finalSlipMag,
+ _riseTimeVertex);
const double scale = finalSlipMag > 0.0 ?
(slip1 - slip0) / finalSlipMag : 0.0;
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = scale * finalSlip[i];
+ _slipVertex *= scale;
+
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
} // for
- PetscLogFlops(numVertices * (3+2*8 + 3*spaceDim));
+ PetscLogFlops(vertices->size() * (3+2*8 + 3*_slipVertex.size()));
} // slipIncr
// ----------------------------------------------------------------------
// Get final slip.
-ALE::Obj<pylith::real_section_type>
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::BruneSlipFn::finalSlip(void)
{ // finalSlip
- return _parameters->getFibration(0);
+ return _parameters->get("final slip");
} // finalSlip
// ----------------------------------------------------------------------
// Get time when slip begins at each point.
-ALE::Obj<pylith::real_section_type>
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::BruneSlipFn::slipTime(void)
{ // slipTime
- return _parameters->getFibration(2);
+ return _parameters->get("slip time");
} // slipTime
Modified: short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,7 +14,7 @@
*
* @brief C++ implementation of Brune slip time function.
*
- * Slip time function follows the integral of Brune's (1907) far-field
+ * Slip time function follows the integral of Brune's (1970) far-field
* time function.
*
* Normalize slip = 1 - exp(-t/tau)(1 + t/tau),
@@ -24,27 +24,14 @@
#if !defined(pylith_faults_bruneslipfn_hh)
#define pylith_faults_bruneslipfn_hh
+// Include directives ---------------------------------------------------
#include "SlipTimeFn.hh"
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class BruneSlipFn;
- class TestBruneSlipFn; // unit testing
- } // faults
-} // pylith
+#include "pylith/topology/topologyfwd.hh" // USES Fields<Field<SubMesh> >
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB;
- } // spatialdb
- namespace units {
- class Nondimensional;
- } // units
-} // spatialdata
+#include "pylith/utils/array.hh" // HASA double_array
-/// C++ implementation of Brune slip time function.
+// BruneSlipFn ----------------------------------------------------------
class pylith::faults::BruneSlipFn : public SlipTimeFn
{ // class BruneSlipFn
friend class TestBruneSlipFn; // unit testing
@@ -56,7 +43,6 @@
BruneSlipFn(void);
/// Destructor.
- virtual
~BruneSlipFn(void);
/** Set spatial database for final slip.
@@ -71,21 +57,20 @@
*/
void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
- /** Set spatial database for peak slip rate.
+ /** Set spatial database for rise time (0 -> 0.95 final slip).
*
* @param db Spatial database
*/
- void dbPeakRate(spatialdata::spatialdb::SpatialDB* const db);
+ void dbRiseTime(spatialdata::spatialdb::SpatialDB* const db);
/** Initialize slip time function.
*
* @param faultMesh Finite-element mesh of fault.
- * @param cs Coordinate system for mesh.
+ * @param cs Coordinate system for mesh
* @param normalizer Nondimensionalization of scales.
* @param originTime Origin time for earthquake source.
*/
- void initialize(const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
+ void initialize(const topology::SubMesh& faultMesh,
const spatialdata::units::Nondimensional& normalizer,
const double originTime =0.0);
@@ -93,84 +78,78 @@
*
* @param slipField Slip field over fault surface.
* @param t Time t.
- * @param faultMesh Mesh over fault surface.
*
* @returns Slip vector as left-lateral/reverse/normal.
*/
- void slip(const ALE::Obj<real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh);
+ void slip(topology::Field<topology::SubMesh>* const slipField,
+ const double t);
/** Get slip increment on fault surface between time t0 and t1.
*
* @param slipField Slip field over fault surface.
* @param t0 Time t.
* @param t1 Time t+dt.
- * @param faultMesh Mesh over fault surface.
*
* @returns Increment in slip vector as left-lateral/reverse/normal.
*/
- void slipIncr(const ALE::Obj<real_section_type>& slipField,
+ void slipIncr(topology::Field<topology::SubMesh>* slipField,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh);
+ const double t1);
-
/** Get final slip.
*
* @returns Final slip.
*/
- ALE::Obj<real_section_type> finalSlip(void);
+ const topology::Field<topology::SubMesh>& finalSlip(void);
/** Get time when slip begins at each point.
*
* @returns Time when slip begins.
*/
- ALE::Obj<real_section_type> slipTime(void);
+ const topology::Field<topology::SubMesh>& slipTime(void);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
- /// Not implemented
- BruneSlipFn(const BruneSlipFn& m);
+ BruneSlipFn(const BruneSlipFn&); ///< Not implemented
+ const BruneSlipFn& operator=(const BruneSlipFn&); ///< Not implemented
- /// Not implemented
- const BruneSlipFn& operator=(const BruneSlipFn& f);
-
// PRIVATE METHODS //////////////////////////////////////////////////////
private :
/** Compute slip using slip time function.
*
- * @param t Time relative to slip starting time at point
- * @param finalSlip Final slip at point
- * @param peakRate Peak slip rate at point
+ * @param t Time relative to slip starting time at point.
+ * @param finalSlip Final slip at point.
+ * @param riseTime Rise time at point.
*
* @returns Slip at point at time t
*/
static
double _slipFn(const double t,
const double finalSlip,
- const double peakRate);
+ const double riseTime);
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- /// Parameters for Brune slip time function.
- /// Final slip (vector), peak slip rate (scalar), slip time (scalar).
- ALE::Obj<real_section_type> _parameters;
+ double _slipTimeVertex; ///< Slip time at a vertex.
+ double _riseTimeVertex; ///< Rise time at a vertex.
+ double_array _slipVertex; ///< Slip at a vertex.
- /// Spatial database for final slip
+ /// Parameters for Brune slip time function, final slip (vector),
+ /// rise time (scalar), slip time (scalar).
+ topology::Fields<topology::Field<topology::SubMesh> >* _parameters;
+
+ /// Spatial database for final slip.
spatialdata::spatialdb::SpatialDB* _dbFinalSlip;
- /// Spatial database for slip time
+ /// Spatial database for slip time.
spatialdata::spatialdb::SpatialDB* _dbSlipTime;
- /// Spatial database for peak slip rate
- spatialdata::spatialdb::SpatialDB* _dbPeakRate;
+ /// Spatial database for rise time (0 -> 0.95 final slip).
+ spatialdata::spatialdb::SpatialDB* _dbRiseTime;
- int _spaceDim; ///< Spatial dimension for slip field.
-
}; // class BruneSlipFn
#include "BruneSlipFn.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/BruneSlipFn.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -31,11 +31,11 @@
_dbSlipTime = db;
} // dbSlipTime
-// Set spatial database for peak slip rate.
+// Set spatial database for rise time.
inline
void
-pylith::faults::BruneSlipFn::dbPeakRate(spatialdata::spatialdb::SpatialDB* const db) {
- _dbPeakRate = db;
+pylith::faults::BruneSlipFn::dbRiseTime(spatialdata::spatialdb::SpatialDB* const db) {
+ _dbRiseTime = db;
} // dbPeakRate
// Compute slip using slip time function.
@@ -43,10 +43,11 @@
double
pylith::faults::BruneSlipFn::_slipFn(const double t,
const double finalSlip,
- const double peakRate) {
+ const double riseTime) {
double slip = 0.0;
if (t > 0.0) {
- assert(peakRate > 0.0);
+ assert(riseTime > 0.0);
+ const double peakRate = finalSlip / riseTime * 1.745;
const double tau =
// prevent 0 == tau when 0 == finalSlip
(finalSlip > 0.0) ? finalSlip / (exp(1.0) * peakRate) : 0.1;
Modified: short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,626 +13,324 @@
#include <portinfo>
#include "CohesiveTopology.hh" // implementation of object methods
-#include <Selection.hh> // Algorithms for submeshes
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "TopologyOps.hh" // USES TopologyOps
+#include "TopologyVisitors.hh" // USES TopologyVisitors
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include <Selection.hh> // Algorithms for submeshes
+
#include <cassert> // USES assert()
// ----------------------------------------------------------------------
-void
-pylith::faults::CohesiveTopology::createFaultSieveFromVertices(const int dim,
- const int firstCell,
- const PointSet& faultVertices,
- const Obj<Mesh>& mesh,
- const Obj<ALE::Mesh::arrow_section_type>& orientation,
- const Obj<ALE::Mesh::sieve_type>& faultSieve,
- const bool flipFault)
-{
- typedef ALE::Selection<ALE::Mesh> selection;
- const Obj<sieve_type>& sieve = mesh->getSieve();
- const PointSet::const_iterator fvBegin = faultVertices.begin();
- const PointSet::const_iterator fvEnd = faultVertices.end();
- int curCell = firstCell;
- int curVertex = 0;
- int newElement = curCell + dim*faultVertices.size();
- int o = 1;
- ALE::Mesh::point_type f = firstCell;
- const int debug = mesh->debug();
- Obj<PointSet> face = new PointSet();
- int numCorners = 0; // The number of vertices in a mesh cell
- int faceSize = 0; // The number of vertices in a mesh face
- int *indices = NULL; // The indices of a face vertex set in a cell
- std::map<int,int*> curElement;
- std::map<int,PointArray> bdVertices;
- std::map<int,PointArray> faultFaces;
- std::map<int,oPointArray> oFaultFaces;
- PointSet faultCells;
- PointArray origVertices;
- PointArray faceVertices;
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::IntSection IntSection;
- if (!faultSieve->commRank()) {
- numCorners = mesh->getNumCellCorners();
- faceSize = selection::numFaceVertices(mesh);
- indices = new int[faceSize];
- }
-
- curElement[0] = &curVertex;
- curElement[dim] = &curCell;
- for(int d = 1; d < dim; d++) {
- curElement[d] = &newElement;
- }
-
- // This only works for uninterpolated meshes
- assert((mesh->depth() == 1) || (mesh->depth() == -1));
- ALE::ISieveVisitor::PointRetriever<sieve_type> sV(std::max(1, sieve->getMaxSupportSize()));
- ALE::ISieveVisitor::PointRetriever<sieve_type> cV(std::max(1, sieve->getMaxConeSize()));
- for(PointSet::const_iterator fv_iter = fvBegin; fv_iter != fvEnd; ++fv_iter) {
- sieve->support(*fv_iter, sV);
- const Mesh::point_type *support = sV.getPoints();
-
- if (debug) std::cout << "Checking fault vertex " << *fv_iter << std::endl;
- const int sVsize = sV.getSize();
- for (int i=0; i < sVsize; ++i) {
- const int s = (!flipFault) ? i : sVsize - i - 1;
- sieve->cone(support[s], cV);
- const Mesh::point_type *cone = cV.getPoints();
-
- if (debug) std::cout << " Checking cell " << support[s] << std::endl;
- if (faultCells.find(support[s]) != faultCells.end()) {
- cV.clear();
- continue;
- }
- face->clear();
- for(int c = 0; c < cV.getSize(); ++c) {
- if (faultVertices.find(cone[c]) != fvEnd) {
- if (debug) std::cout << " contains fault vertex " << cone[c] << std::endl;
- face->insert(face->end(), cone[c]);
- } // if
- } // for
- if (face->size() > faceSize)
- throw ALE::Exception("Invalid fault mesh: Too many vertices of an "
- "element on the fault");
- if (face->size() == faceSize) {
- if (debug) std::cout << " Contains a face on the fault" << std::endl;
- ALE::Obj<sieve_type::supportSet> preFace;
- if (dim < 2) {
- preFace = faultSieve->nJoin1(face);
- } else {
- preFace = faultSieve->nJoin(face, dim);
- }
-
- if (preFace->size() > 1) {
- throw ALE::Exception("Invalid fault sieve: Multiple faces from vertex set");
- } else if (preFace->size() == 1) {
- // Add the other cell neighbor for this face
- if (dim == 0) {
- faultSieve->addArrow(*faceVertices.begin(), support[s]);
- } else {
- faultSieve->addArrow(*preFace->begin(), support[s]);
- }
- } else if (preFace->size() == 0) {
- if (debug) std::cout << " Orienting face " << f << std::endl;
- selection::getOrientedFace(mesh, support[s], face, numCorners, indices, &origVertices, &faceVertices);
- bdVertices[dim].clear();
- for(PointArray::const_iterator v_iter = faceVertices.begin(); v_iter != faceVertices.end(); ++v_iter) {
- bdVertices[dim].push_back(*v_iter);
- if (debug) std::cout << " Boundary vertex " << *v_iter << std::endl;
- }
- if (dim == 0) {
- f = *faceVertices.begin();
- }
- if (faceSize != dim+1) {
- if (debug) std::cout << " Adding hex face " << f << std::endl;
- ALE::SieveBuilder<ALE::Mesh>::buildHexFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
- } else {
- if (debug) std::cout << " Adding simplicial face " << f << std::endl;
- ALE::SieveBuilder<ALE::Mesh>::buildFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
- }
- faultSieve->addArrow(f, support[s]);
- //faultSieve->view("");
- f++;
- } // if/else
- faultCells.insert(support[s]);
- } // if
- cV.clear();
- } // for
- sV.clear();
- } // for
- if (!faultSieve->commRank()) delete [] indices;
-}
-
// ----------------------------------------------------------------------
void
-pylith::faults::CohesiveTopology::createFaultSieveFromFaces(const int dim,
- const int firstCell,
- const int numFaces,
- const int faultVertices[],
- const int faultCells[],
- const Obj<Mesh>& mesh,
- const Obj<ALE::Mesh::arrow_section_type>& orientation,
- const Obj<ALE::Mesh::sieve_type>& faultSieve)
-{
- typedef ALE::Selection<ALE::Mesh> selection;
- int faceSize = 0; // The number of vertices in a mesh face
- int curCell = firstCell;
- int curVertex = 0;
- int newElement = curCell + dim*numFaces;
- int o = 1;
- int f = firstCell;
- const int debug = mesh->debug();
- std::map<int,int*> curElement;
- std::map<int,PointArray> bdVertices;
- std::map<int,oPointArray> oFaultFaces;
+pylith::faults::CohesiveTopology::createFault(topology::SubMesh* faultMesh,
+ ALE::Obj<ALE::Mesh>& faultBoundary,
+ const topology::Mesh& mesh,
+ const ALE::Obj<topology::Mesh::IntSection>& groupField,
+ const bool flipFault)
+{ // createFault
+ assert(0 != faultMesh);
+ assert(!groupField.isNull());
- if (!faultSieve->commRank()) {
- faceSize = selection::numFaceVertices(mesh);
- }
+ faultMesh->coordsys(mesh);
- curElement[0] = &curVertex;
- curElement[dim] = &curCell;
- for(int d = 1; d < dim; d++) {
- curElement[d] = &newElement;
- }
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ faultSieveMesh =
+ new SieveSubMesh(mesh.comm(), mesh.dimension()-1, mesh.debug());
- // Loop over fault faces
- for(int face = 0; face < numFaces; ++face) {
- // Push oriented vertices of face
- bdVertices[dim].clear();
- for(int i = 0; i < faceSize; ++i) {
- bdVertices[dim].push_back(faultVertices[face*faceSize+i]);
- if (debug) std::cout << " Boundary vertex " << faultVertices[face*faceSize+i] << std::endl;
- }
- // Create face
- if (faceSize != dim+1) {
- if (debug) std::cout << " Adding hex face " << f << std::endl;
- ALE::SieveBuilder<ALE::Mesh>::buildHexFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
- } else {
- if (debug) std::cout << " Adding simplicial face " << f << std::endl;
- ALE::SieveBuilder<ALE::Mesh>::buildFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
- }
- // Add arrow to cells
- faultSieve->addArrow(face, faultCells[face*2+0]);
- faultSieve->addArrow(face, faultCells[face*2+1]);
- }
-}
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = sieveMesh->getSieve();
+ assert(!sieve.isNull());
+ const ALE::Obj<SieveSubMesh::sieve_type> ifaultSieve =
+ new SieveMesh::sieve_type(sieve->comm(), sieve->debug());
+ assert(!ifaultSieve.isNull());
+ ALE::Obj<ALE::Mesh> fault =
+ new ALE::Mesh(mesh.comm(), mesh.dimension()-1, mesh.debug());
+ assert(!fault.isNull());
+ ALE::Obj<ALE::Mesh::sieve_type> faultSieve =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+ assert(!faultSieve.isNull());
+ const int debug = mesh.debug();
-// ----------------------------------------------------------------------
-void
-pylith::faults::CohesiveTopology::orientFaultSieve(const int dim,
- const Obj<Mesh>& mesh,
- const Obj<ALE::Mesh::arrow_section_type>& orientation,
- const Obj<ALE::Mesh>& fault)
-{
- // Must check the orientation here
- typedef ALE::Selection<ALE::Mesh> selection;
- const Obj<ALE::Mesh::sieve_type>& faultSieve = fault->getSieve();
- const Mesh::point_type firstFaultCell = *fault->heightStratum(1)->begin();
- const Obj<ALE::Mesh::label_sequence>& fFaces = fault->heightStratum(2);
- const int numFaultFaces = fFaces->size();
- const int faultDepth = fault->depth()-1; // Depth of fault cells
- int numFaultCorners = 0; // The number of vertices in a fault cell
- int faultFaceSize = 0; // The number of vertices in a face between fault cells
- int faceSize = 0; // The number of vertices in a mesh face
- const int debug = fault->debug();
- Obj<PointSet> newCells = new PointSet();
- Obj<PointSet> loopCells = new PointSet();
- PointSet flippedCells; // Incorrectly oriented fault cells
- PointSet facesSeen; // Fault faces already considered
- PointSet cellsSeen; // Fault cells already matched
- PointArray faceVertices;
-
- if (!fault->commRank()) {
- faceSize = selection::numFaceVertices(mesh);
- numFaultCorners = faultSieve->nCone(firstFaultCell, faultDepth)->size();
- if (debug) std::cout << " Fault corners " << numFaultCorners << std::endl;
- if (dim == 0) {
- assert(numFaultCorners == faceSize-1);
- } else {
- assert(numFaultCorners == faceSize);
- }
- if (faultDepth == 1) {
- faultFaceSize = 1;
- } else {
- faultFaceSize = faultSieve->nCone(*fFaces->begin(), faultDepth-1)->size();
- }
- }
- if (debug) std::cout << " Fault face size " << faultFaceSize << std::endl;
-
- newCells->insert(firstFaultCell);
- while(facesSeen.size() != numFaultFaces) {
- Obj<PointSet> tmp = newCells; newCells = loopCells; loopCells = tmp;
-
- newCells->clear();
- if (!loopCells->size()) {throw ALE::Exception("Fault surface not a single connected component.");}
- // Loop over new cells
- for(PointSet::iterator c_iter = loopCells->begin(); c_iter != loopCells->end(); ++c_iter) {
- // Loop over edges of this cell
- const Obj<ALE::Mesh::sieve_type::traits::coneSequence>& cone = faultSieve->cone(*c_iter);
- const ALE::Mesh::sieve_type::traits::coneSequence::iterator eBegin = cone->begin();
- const ALE::Mesh::sieve_type::traits::coneSequence::iterator eEnd = cone->end();
-
- for(ALE::Mesh::sieve_type::traits::coneSequence::iterator e_iter = eBegin; e_iter != eEnd; ++e_iter) {
- if (facesSeen.find(*e_iter) != facesSeen.end()) continue;
- facesSeen.insert(*e_iter);
- if (debug) std::cout << " Checking orientation of fault face " << *e_iter << std::endl;
- const Obj<ALE::Mesh::sieve_type::traits::supportSequence>& support = faultSieve->support(*e_iter);
- ALE::Mesh::sieve_type::traits::supportSequence::iterator s_iter = support->begin();
-
- // Throw out boundary fault faces
- if (support->size() < 2) continue;
- ALE::Mesh::point_type cellA = *s_iter; ++s_iter;
- ALE::Mesh::point_type cellB = *s_iter;
- bool flippedA = (flippedCells.find(cellA) != flippedCells.end());
- bool flippedB = (flippedCells.find(cellB) != flippedCells.end());
- bool seenA = (cellsSeen.find(cellA) != cellsSeen.end());
- bool seenB = (cellsSeen.find(cellB) != cellsSeen.end());
-
- if (!seenA) newCells->insert(cellA);
- if (!seenB) newCells->insert(cellB);
- if (debug) std::cout << " neighboring cells " << cellA << " and " << cellB << std::endl;
- // In 1D, just check that vertices match
- if (dim == 1) {
- const Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneA = faultSieve->cone(cellA);
- ALE::Mesh::sieve_type::traits::coneSequence::iterator iterA = coneA->begin();
- const Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneB = faultSieve->cone(cellB);
- ALE::Mesh::sieve_type::traits::coneSequence::iterator iterB = coneB->begin();
- int posA, posB;
-
- for(posA = 0; posA < 2; ++posA, ++iterA) if (*iterA == *e_iter) break;
- for(posB = 0; posB < 2; ++posB, ++iterB) if (*iterB == *e_iter) break;
- if (debug) std::cout << " with face positions " << posA << " and " << posB << std::endl;
- if ((posA == 2) || (posB == 2)) {throw ALE::Exception("Could not find fault face in cone");}
- if ((posA == posB) ^ (flippedA || flippedB)) {
- if (debug) {
- std::cout << "Invalid orientation in fault mesh" << std::endl;
- std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
- }
- if (flippedA && flippedB) {throw ALE::Exception("Attempt to flip already flipped cell: Fault mesh is non-orientable");}
- if (seenA && seenB) {throw ALE::Exception("Previous cells do not match: Fault mesh is non-orientable");}
- if (!seenA && !flippedA) {
- flippedCells.insert(cellA);
- } else if (!seenB && !flippedB) {
- flippedCells.insert(cellB);
- } else {
- throw ALE::Exception("Inconsistent mesh orientation: Fault mesh is non-orientable");
- }
- }
- } else if (dim == 2) {
- // Check orientation
- ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowA(*e_iter, cellA);
- const int oA = orientation->restrictPoint(arrowA)[0];
- ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowB(*e_iter, cellB);
- const int oB = orientation->restrictPoint(arrowB)[0];
- const bool mismatch = (oA == oB);
-
- // Truth Table
- // mismatch flips action mismatch flipA ^ flipB action
- // F 0 flips no F F F
- // F 1 flip yes F T T
- // F 2 flips no T F T
- // T 0 flips yes T T F
- // T 1 flip no
- // T 2 flips yes
- if (mismatch ^ (flippedA ^ flippedB)) {
- if (debug) {
- std::cout << "Invalid orientation in fault mesh" << std::endl;
- std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
- }
- if (flippedA && flippedB) {throw ALE::Exception("Attempt to flip already flipped cell: Fault mesh is non-orientable");}
- if (seenA && seenB) {throw ALE::Exception("Previous cells do not match: Fault mesh is non-orientable");}
- if (!seenA && !flippedA) {
- flippedCells.insert(cellA);
- if (debug) {std::cout << " Scheduling cell " << cellA << " for flipping" << std::endl;}
- } else if (!seenB && !flippedB) {
- flippedCells.insert(cellB);
- if (debug) {std::cout << " Scheduling cell " << cellB << " for flipping" << std::endl;}
- } else {
- throw ALE::Exception("Inconsistent mesh orientation: Fault mesh is non-orientable");
- }
- }
- }
- cellsSeen.insert(cellA);
- cellsSeen.insert(cellB);
- }
- }
- }
- for(PointSet::const_iterator f_iter = flippedCells.begin(); f_iter != flippedCells.end(); ++f_iter) {
- if (debug) std::cout << " Reversing fault face " << *f_iter << std::endl;
- faceVertices.clear();
- const ALE::Obj<ALE::Mesh::sieve_type::traits::coneSequence>& cone = faultSieve->cone(*f_iter);
- for(ALE::Mesh::sieve_type::traits::coneSequence::iterator v_iter = cone->begin(); v_iter != cone->end(); ++v_iter) {
- faceVertices.insert(faceVertices.begin(), *v_iter);
- }
- faultSieve->clearCone(*f_iter);
- int color = 0;
- for(PointArray::const_iterator v_iter = faceVertices.begin(); v_iter != faceVertices.end(); ++v_iter) {
- faultSieve->addArrow(*v_iter, *f_iter, color++);
- }
-
- if (dim > 1) {
- // Here, they are edges, not vertices
- for(PointArray::const_iterator e_iter = faceVertices.begin(); e_iter != faceVertices.end(); ++e_iter) {
- ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrow(*e_iter, *f_iter);
- int o = orientation->restrictPoint(arrow)[0];
-
- if (debug) std::cout << " Reversing orientation of " << *e_iter <<"-->"<<*f_iter << " from " << o << " to " << -(o+1) << std::endl;
- o = -(o+1);
- orientation->updatePoint(arrow, &o);
- }
- }
- }
- flippedCells.clear();
- for(ALE::Mesh::label_sequence::iterator e_iter = fFaces->begin(); e_iter != fFaces->end(); ++e_iter) {
- if (debug) std::cout << " Checking orientation of fault face " << *e_iter << std::endl;
- // for each face get the support (2 fault cells)
- const Obj<ALE::Mesh::sieve_type::traits::supportSequence>& support = faultSieve->support(*e_iter);
- ALE::Mesh::sieve_type::traits::supportSequence::iterator s_iter = support->begin();
-
- // Throw out boundary fault faces
- if (support->size() > 1) {
- ALE::Mesh::point_type cellA = *s_iter; ++s_iter;
- ALE::Mesh::point_type cellB = *s_iter;
-
- if (debug) std::cout << " neighboring cells " << cellA << " and " << cellB << std::endl;
- // In 1D, just check that vertices match
- if (dim == 1) {
- const Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneA = faultSieve->cone(cellA);
- ALE::Mesh::sieve_type::traits::coneSequence::iterator iterA = coneA->begin();
- const Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneB = faultSieve->cone(cellB);
- ALE::Mesh::sieve_type::traits::coneSequence::iterator iterB = coneB->begin();
- int posA, posB;
-
- for(posA = 0; posA < 2; ++posA, ++iterA) if (*iterA == *e_iter) break;
- for(posB = 0; posB < 2; ++posB, ++iterB) if (*iterB == *e_iter) break;
- if (debug) std::cout << " with face positions " << posA << " and " << posB << std::endl;
- if ((posA == 2) || (posB == 2)) {throw ALE::Exception("Could not find fault face in cone");}
- if (posA == posB) {
- std::cout << "Invalid orientation in fault mesh" << std::endl;
- std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
- throw ALE::Exception("Invalid orientation in fault mesh");
- }
- } else {
- // Check orientation
- ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowA(*e_iter, cellA);
- const int oA = orientation->restrictPoint(arrowA)[0];
- ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowB(*e_iter, cellB);
- const int oB = orientation->restrictPoint(arrowB)[0];
-
- if (oA == oB) {
- std::cout << "Invalid orientation in fault mesh" << std::endl;
- std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
- throw ALE::Exception("Invalid orientation in fault mesh");
- }
- }
- }
- }
- if (debug) fault->view("Oriented Fault mesh");
-}
-
-// ----------------------------------------------------------------------
-void
-pylith::faults::CohesiveTopology::createFault(Obj<SubMesh>& ifault,
- Obj<ALE::Mesh>& faultBd,
- const Obj<Mesh>& mesh,
- const Obj<Mesh::int_section_type>& groupField,
- const bool flipFault)
-{
- const Obj<sieve_type>& sieve = mesh->getSieve();
- const Obj<SubMesh::sieve_type> ifaultSieve = new Mesh::sieve_type(sieve->comm(), sieve->debug());
- Obj<ALE::Mesh> fault = new ALE::Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- Obj<ALE::Mesh::sieve_type> faultSieve = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
- const int debug = mesh->debug();
-
// Create set with vertices on fault
- const int_section_type::chart_type& chart = groupField->getChart();
- PointSet faultVertices; // Vertices on fault
+ const IntSection::chart_type& chart = groupField->getChart();
+ TopologyOps::PointSet faultVertices; // Vertices on fault
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
- assert(!mesh->depth(*c_iter));
- if (groupField->getFiberDimension(*c_iter)) {faultVertices.insert(*c_iter);}
+ const IntSection::chart_type::const_iterator chartEnd = chart.end();
+ for(IntSection::chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chartEnd;
+ ++c_iter) {
+ assert(!sieveMesh->depth(*c_iter));
+ if (groupField->getFiberDimension(*c_iter))
+ faultVertices.insert(*c_iter);
} // for
// Create a sieve which captures the fault
- const bool vertexFault = true;
- const int firstFaultCell = sieve->getBaseSize() + sieve->getCapSize();
+ const bool vertexFault = true;
+ const int firstFaultCell = sieve->getBaseSize() + sieve->getCapSize();
- createFaultSieveFromVertices(fault->getDimension(), firstFaultCell,
- faultVertices, mesh,
- fault->getArrowSection("orientation"),
- faultSieve, flipFault);
+ TopologyOps::createFaultSieveFromVertices(fault->getDimension(), firstFaultCell,
+ faultVertices, sieveMesh,
+ fault->getArrowSection("orientation"),
+ faultSieve, flipFault);
fault->setSieve(faultSieve);
fault->stratify();
- if (debug) fault->view("Fault mesh");
+ if (debug)
+ fault->view("Fault mesh");
- faultBd = ALE::Selection<ALE::Mesh>::boundary(fault);
- if (debug) faultBd->view("Fault boundary mesh");
+ faultBoundary = ALE::Selection<ALE::Mesh>::boundary(fault);
+ if (debug)
+ faultBoundary->view("Fault boundary mesh");
// Orient the fault sieve
- orientFaultSieve(fault->getDimension(), mesh, fault->getArrowSection("orientation"), fault);
+ TopologyOps::orientFaultSieve(fault->getDimension(), sieveMesh,
+ fault->getArrowSection("orientation"), fault);
// Convert fault to an IMesh
- SubMesh::renumbering_type& renumbering = ifault->getRenumbering();
- ifault->setSieve(ifaultSieve);
- ALE::ISieveConverter::convertMesh(*fault, *ifault, renumbering, false);
+ SieveSubMesh::renumbering_type& renumbering = faultSieveMesh->getRenumbering();
+ faultSieveMesh->setSieve(ifaultSieve);
+ ALE::ISieveConverter::convertMesh(*fault, *faultSieveMesh, renumbering, false);
renumbering.clear();
-};
+} // createFault
// ----------------------------------------------------------------------
void
-pylith::faults::CohesiveTopology::create(Obj<SubMesh>& ifault,
- const Obj<ALE::Mesh>& faultBd,
- const Obj<Mesh>& mesh,
- const Obj<Mesh::int_section_type>& groupField,
+pylith::faults::CohesiveTopology::create(topology::Mesh* mesh,
+ const topology::SubMesh& faultMesh,
+ const ALE::Obj<ALE::Mesh>& faultBoundary,
+ const ALE::Obj<topology::Mesh::IntSection>& groupField,
const int materialId,
const bool constraintCell)
{ // create
- typedef ALE::SieveAlg<ALE::Mesh> sieveAlg;
+ assert(0 != mesh);
+ assert(!faultBoundary.isNull());
+ assert(!groupField.isNull());
+
+ typedef ALE::SieveAlg<ALE::Mesh> sieveAlg;
typedef ALE::Selection<ALE::Mesh> selection;
- const Obj<sieve_type>& sieve = mesh->getSieve();
- const Obj<SubMesh::sieve_type> ifaultSieve = ifault->getSieve();
- const int depth = mesh->depth();
- const int numCells = mesh->heightStratum(0)->size();
- int numCorners = 0; // The number of vertices in a mesh cell
- int faceSize = 0; // The number of vertices in a mesh face
- int numFaultCorners = 0; // The number of vertices in a fault cell
- int *indices = NULL; // The indices of a face vertex set in a cell
- const int debug = mesh->debug();
- int oppositeVertex; // For simplices, the vertex opposite a given face
- PointArray origVertices;
- PointArray faceVertices;
- PointArray neighborVertices;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ assert(!faultSieveMesh.isNull());
- if (!ifault->commRank()) {
- const SubMesh::point_type p = *ifault->heightStratum(1)->begin();
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = sieveMesh->getSieve();
+ assert(!sieve.isNull());
+ const ALE::Obj<SieveSubMesh::sieve_type> ifaultSieve =
+ faultSieveMesh->getSieve();
+ assert(!ifaultSieve.isNull());
- numCorners = mesh->getNumCellCorners();
- faceSize = selection::numFaceVertices(mesh);
- indices = new int[faceSize];
- numFaultCorners = ifault->getNumCellCorners(p, ifault->depth(p));
+ const int depth = sieveMesh->depth();
+ assert(!sieveMesh->heightStratum(0).isNull());
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ int numCorners = 0; // The number of vertices in a mesh cell
+ int faceSize = 0; // The number of vertices in a mesh face
+ int numFaultCorners = 0; // The number of vertices in a fault cell
+ int* indices = 0; // The indices of a face vertex set in a cell
+ const int debug = mesh->debug();
+ int oppositeVertex = 0; // For simplices, the vertex opposite a given face
+ TopologyOps::PointArray origVertices;
+ TopologyOps::PointArray faceVertices;
+ TopologyOps::PointArray neighborVertices;
+
+ if (!faultSieveMesh->commRank()) {
+ assert(!faultSieveMesh->heightStratum(1).isNull());
+ const SieveSubMesh::point_type p = *faultSieveMesh->heightStratum(1)->begin();
+
+ numCorners = sieveMesh->getNumCellCorners();
+ faceSize = selection::numFaceVertices(sieveMesh);
+ indices = new int[faceSize];
+ numFaultCorners = faultSieveMesh->getNumCellCorners(p, faultSieveMesh->depth(p));
}
- //ifault->view("Serial fault mesh");
+ //faultSieveMesh->view("Serial fault mesh");
// Add new shadow vertices and possibly Lagrange multipler vertices
- const Obj<SubMesh::label_sequence>& fVertices = ifault->depthStratum(0);
- const Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const Obj<std::set<std::string> >& groupNames = mesh->getIntSections();
- Mesh::point_type newPoint = sieve->getBaseSize() + sieve->getCapSize();
- const int numFaultVertices = fVertices->size();
- std::map<Mesh::point_type,Mesh::point_type> vertexRenumber;
- std::map<Mesh::point_type,Mesh::point_type> cellRenumber;
+ const ALE::Obj<SieveSubMesh::label_sequence>& fVertices = faultSieveMesh->depthStratum(0);
+ assert(!fVertices.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const ALE::Obj<std::set<std::string> >& groupNames =
+ sieveMesh->getIntSections();
+ assert(!groupNames.isNull());
+ point_type newPoint = sieve->getBaseSize() + sieve->getCapSize();
+ const int numFaultVertices = fVertices->size();
+ std::map<point_type,point_type> vertexRenumber;
+ std::map<point_type,point_type> cellRenumber;
- for(SubMesh::label_sequence::iterator v_iter = fVertices->begin(); v_iter != fVertices->end(); ++v_iter, ++newPoint) {
+ const SieveSubMesh::label_sequence::const_iterator fVerticesEnd =
+ fVertices->end();
+ for(SieveSubMesh::label_sequence::iterator v_iter = fVertices->begin();
+ v_iter != fVerticesEnd;
+ ++v_iter, ++newPoint) {
vertexRenumber[*v_iter] = newPoint;
- if (debug) std::cout << "Duplicating " << *v_iter << " to " << vertexRenumber[*v_iter] << std::endl;
+ if (debug)
+ std::cout << "Duplicating " << *v_iter << " to "
+ << vertexRenumber[*v_iter] << std::endl;
// Add shadow and constraint vertices (if they exist) to group
// associated with fault
groupField->addPoint(newPoint, 1);
- if (constraintCell) {
+ if (constraintCell)
groupField->addPoint(newPoint+numFaultVertices, 1);
- }
// Add shadow vertices to other groups, don't add constraint
// vertices (if they exist) because we don't want BC, etc to act
// on constraint vertices
+ const std::set<std::string>::const_iterator namesEnd = groupNames->end();
for(std::set<std::string>::const_iterator name = groupNames->begin();
- name != groupNames->end(); ++name) {
- const ALE::Obj<int_section_type>& group = mesh->getIntSection(*name);
+ name != namesEnd;
+ ++name) {
+ const ALE::Obj<IntSection>& group = sieveMesh->getIntSection(*name);
+ assert(!group.isNull());
if (group->getFiberDimension(*v_iter))
group->addPoint(newPoint, 1);
} // for
} // for
+ const std::set<std::string>::const_iterator namesEnd = groupNames->end();
for(std::set<std::string>::const_iterator name = groupNames->begin();
- name != groupNames->end(); ++name) {
- mesh->reallocate(mesh->getIntSection(*name));
+ name != namesEnd;
+ ++name) {
+ sieveMesh->reallocate(sieveMesh->getIntSection(*name));
} // for
-#if 0
- for(SubMesh::label_sequence::iterator v_iter = fVertices->begin(); v_iter != fVertices->end(); ++v_iter, ++newPoint) {
+#if 0 // TEST OF OPTIMIZATION?? [MATT: WHY IS THIS COMMENTED OUT?]
+ for(SieveSubMesh::label_sequence::iterator v_iter = fVertices->begin();
+ v_iter != fVerticesEnd;
+ ++v_iter, ++newPoint) {
vertexRenumber[*v_iter] = newPoint;
// OPTIMIZATION
- mesh->setHeight(newPoint, 1);
- mesh->setDepth(newPoint, 0);
+ sieveMesh->setHeight(newPoint, 1);
+ sieveMesh->setDepth(newPoint, 0);
if (constraintCell) {
// OPTIMIZATION
- mesh->setHeight(newPoint+numFaultVertices, 1);
- mesh->setDepth(newPoint+numFaultVertices, 0);
+ sieveMesh->setHeight(newPoint+numFaultVertices, 1);
+ sieveMesh->setDepth(newPoint+numFaultVertices, 0);
}
}
#endif
- if (constraintCell) newPoint += numFaultVertices;
+ if (constraintCell)
+ newPoint += numFaultVertices;
// Split the mesh along the fault sieve and create cohesive elements
- const ALE::Obj<SubMesh::label_sequence>& faces = ifault->heightStratum(1);
- const ALE::Obj<Mesh::label_type>& material = mesh->getLabel("material-id");
+ const ALE::Obj<SieveSubMesh::label_sequence>& faces =
+ faultSieveMesh->heightStratum(1);
+ assert(!faces.isNull());
+ const ALE::Obj<Mesh::label_type>& material =
+ sieveMesh->getLabel("material-id");
+ assert(!material.isNull());
const int firstCohesiveCell = newPoint;
- PointSet replaceCells;
- PointSet noReplaceCells;
- PointSet replaceVertices;
- ALE::ISieveVisitor::PointRetriever<sieve_type> sV2(std::max(1, ifaultSieve->getMaxSupportSize()));
- ALE::ISieveVisitor::NConeRetriever<sieve_type> cV2(*ifaultSieve, (size_t) pow(std::max(1, ifaultSieve->getMaxConeSize()), ifault->depth()));
+ TopologyOps::PointSet replaceCells;
+ TopologyOps::PointSet noReplaceCells;
+ TopologyOps::PointSet replaceVertices;
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> sV2(std::max(1, ifaultSieve->getMaxSupportSize()));
+ ALE::ISieveVisitor::NConeRetriever<SieveMesh::sieve_type> cV2(*ifaultSieve, (size_t) pow(std::max(1, ifaultSieve->getMaxConeSize()), faultSieveMesh->depth()));
std::set<Mesh::point_type> faceSet;
- for(SubMesh::label_sequence::iterator f_iter = faces->begin(); f_iter != faces->end(); ++f_iter, ++newPoint) {
- const Mesh::point_type face = *f_iter;
- if (debug) std::cout << "Considering fault face " << face << std::endl;
+ const SieveSubMesh::label_sequence::const_iterator facesEnd = faces->end();
+ for(SieveSubMesh::label_sequence::iterator f_iter = faces->begin();
+ f_iter != facesEnd;
+ ++f_iter, ++newPoint) {
+ const point_type face = *f_iter;
+ if (debug)
+ std::cout << "Considering fault face " << face << std::endl;
ifaultSieve->support(face, sV2);
- const Mesh::point_type *cells = sV2.getPoints();
- Mesh::point_type cell = cells[0];
- Mesh::point_type otherCell = cells[1];
+ const point_type *cells = sV2.getPoints();
+ point_type cell = cells[0];
+ point_type otherCell = cells[1];
- if (debug) std::cout << " Checking orientation against cell " << cell << std::endl;
- ALE::ISieveTraversal<sieve_type>::orientedClosure(*ifaultSieve, face, cV2);
- const int coneSize = cV2.getSize();
- const Mesh::point_type *faceCone = cV2.getPoints();
+ if (debug)
+ std::cout << " Checking orientation against cell " << cell << std::endl;
+ ALE::ISieveTraversal<SieveMesh::sieve_type>::orientedClosure(*ifaultSieve,
+ face, cV2);
+ const int coneSize = cV2.getSize();
+ const point_type *faceCone = cV2.getPoints();
//ifaultSieve->cone(face, cV2);
- //const int coneSize = cV2.getSize() ? cV2.getSize() : 1;
- //const Mesh::point_type *faceCone = cV2.getSize() ? cV2.getPoints() : &face;
- bool found = true;
+ //const int coneSize = cV2.getSize() ? cV2.getSize() : 1;
+ //const point_type *faceCone = cV2.getSize() ? cV2.getPoints() : &face;
+ bool found = true;
- for(int i = 0; i < coneSize; ++i) faceSet.insert(faceCone[i]);
- selection::getOrientedFace(mesh, cell, &faceSet, numCorners, indices, &origVertices, &faceVertices);
+ for(int i = 0; i < coneSize; ++i)
+ faceSet.insert(faceCone[i]);
+ selection::getOrientedFace(sieveMesh, cell, &faceSet, numCorners, indices,
+ &origVertices, &faceVertices);
if (faceVertices.size() != coneSize) {
- std::cout << "Invalid size for faceVertices " << faceVertices.size() << " of face " << face << "should be " << coneSize << std::endl;
- std::cout << " firstCohesiveCell " << firstCohesiveCell << " newPoint " << newPoint << " numFaces " << faces->size() << std::endl;
+ std::cout << "Invalid size for faceVertices " << faceVertices.size()
+ << " of face " << face << "should be " << coneSize << std::endl;
+ std::cout << " firstCohesiveCell " << firstCohesiveCell << " newPoint "
+ << newPoint << " numFaces " << faces->size() << std::endl;
std::cout << " faceSet:" << std::endl;
- for(std::set<Mesh::point_type>::const_iterator p_iter = faceSet.begin(); p_iter != faceSet.end(); ++p_iter) {
+ for(std::set<Mesh::point_type>::const_iterator p_iter = faceSet.begin();
+ p_iter != faceSet.end();
+ ++p_iter) {
std::cout << " " << *p_iter << std::endl;
- }
+ } // if
std::cout << " cell cone:" << std::endl;
- ALE::ISieveVisitor::PointRetriever<sieve_type> cV(std::max(1, sieve->getMaxConeSize()));
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> cV(std::max(1, sieve->getMaxConeSize()));
sieve->cone(cell, cV);
- const int coneSize2 = cV.getSize();
- const Mesh::point_type *cellCone = cV.getPoints();
+ const int coneSize2 = cV.getSize();
+ const point_type *cellCone = cV.getPoints();
- for(int c = 0; c < coneSize2; ++c) {
+ for(int c = 0; c < coneSize2; ++c)
std::cout << " " << cellCone[c] << std::endl;
- }
std::cout << " fault cell support:" << std::endl;
- ALE::ISieveVisitor::PointRetriever<sieve_type> sV(std::max(1, ifaultSieve->getMaxSupportSize()));
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> sV(std::max(1, ifaultSieve->getMaxSupportSize()));
ifaultSieve->support(face, sV);
- const int supportSize2 = sV.getSize();
- const Mesh::point_type *cellSupport = sV.getPoints();
- for(int s = 0; s < supportSize2; ++s) {
+ const int supportSize2 = sV.getSize();
+ const point_type *cellSupport = sV.getPoints();
+ for(int s = 0; s < supportSize2; ++s)
std::cout << " " << cellSupport[s] << std::endl;
- }
- }
+ } // if
assert(faceVertices.size() == coneSize);
faceSet.clear();
- ///selection::getOrientedFace(mesh, cell, &vertexRenumber, numCorners, indices, &origVertices, &faceVertices);
+ //selection::getOrientedFace(sieveMesh, cell, &vertexRenumber, numCorners,
+ // indices, &origVertices, &faceVertices);
if (numFaultCorners == 0) {
found = false;
} else if (numFaultCorners == 2) {
- if (faceVertices[0] != faceCone[0]) found = false;
+ if (faceVertices[0] != faceCone[0])
+ found = false;
} else {
int v = 0;
// Locate first vertex
- while((v < numFaultCorners) && (faceVertices[v] != faceCone[0])) ++v;
+ while((v < numFaultCorners) && (faceVertices[v] != faceCone[0]))
+ ++v;
for(int c = 0; c < coneSize; ++c, ++v) {
- if (debug) std::cout << " Checking " << faceCone[c] << " against " << faceVertices[v%numFaultCorners] << std::endl;
+ if (debug) std::cout << " Checking " << faceCone[c] << " against "
+ << faceVertices[v%numFaultCorners] << std::endl;
if (faceVertices[v%numFaultCorners] != faceCone[c]) {
found = false;
break;
- }
- }
- }
+ } // if
+ } // for
+ } // if/else
if (found) {
- if (debug) std::cout << " Choosing other cell" << std::endl;
- Mesh::point_type tmpCell = otherCell;
+ if (debug)
+ std::cout << " Choosing other cell" << std::endl;
+ point_type tmpCell = otherCell;
otherCell = cell;
- cell = tmpCell;
+ cell = tmpCell;
} else {
- if (debug) std::cout << " Verifing reverse orientation" << std::endl;
+ if (debug)
+ std::cout << " Verifing reverse orientation" << std::endl;
found = true;
int v = 0;
if (numFaultCorners > 0) {
// Locate first vertex
- while((v < numFaultCorners) && (faceVertices[v] != faceCone[coneSize-1])) ++v;
+ while((v < numFaultCorners) && (faceVertices[v] != faceCone[coneSize-1]))
+ ++v;
for(int c = coneSize-1; c >= 0; --c, ++v) {
- if (debug) std::cout << " Checking " << faceCone[c] << " against " << faceVertices[v%numFaultCorners] << std::endl;
+ if (debug)
+ std::cout << " Checking " << faceCone[c] << " against "
+ << faceVertices[v%numFaultCorners] << std::endl;
if (faceVertices[v%numFaultCorners] != faceCone[c]) {
found = false;
break;
@@ -653,270 +351,353 @@
replaceVertices.insert(faceCone, &faceCone[coneSize]);
cellRenumber[cell] = newPoint;
// Adding cohesive cell (not interpolated)
- if (debug) std::cout << " Creating cohesive cell " << newPoint << std::endl;
- for(int c = 0; c < coneSize; ++c) {
- if (debug) std::cout << " vertex " << faceCone[c] << std::endl;
+ if (debug)
+ std::cout << " Creating cohesive cell " << newPoint << std::endl;
+ for (int c = 0; c < coneSize; ++c) {
+ if (debug)
+ std::cout << " vertex " << faceCone[c] << std::endl;
sieve->addArrow(faceCone[c], newPoint);
- }
- for(int c = 0; c < coneSize; ++c) {
- if (debug) std::cout << " shadow vertex " << vertexRenumber[faceCone[c]] << std::endl;
+ } // for
+ for (int c = 0; c < coneSize; ++c) {
+ if (debug)
+ std::cout << " shadow vertex " << vertexRenumber[faceCone[c]] << std::endl;
sieve->addArrow(vertexRenumber[faceCone[c]], newPoint);
- }
+ } // for
if (constraintCell) {
- for(int c = 0; c < coneSize; ++c) {
- if (debug) std::cout << " Lagrange vertex " << vertexRenumber[faceCone[c]]+numFaultVertices << std::endl;
+ for (int c = 0; c < coneSize; ++c) {
+ if (debug)
+ std::cout << " Lagrange vertex " << vertexRenumber[faceCone[c]]+numFaultVertices << std::endl;
sieve->addArrow(vertexRenumber[faceCone[c]]+numFaultVertices, newPoint);
- }
- }
+ } // for
+ } // if
// TODO: Need to reform the material label when sieve is reallocated
- mesh->setValue(material, newPoint, materialId);
-#if 0
+ sieveMesh->setValue(material, newPoint, materialId);
+#if 0 // TEST OF OPTIMIZATION?? [MATT: WHY IS THIS COMMENTED OUT?]
// OPTIMIZATION
- mesh->setHeight(newPoint, 0);
- mesh->setDepth(newPoint, 1);
+ sieveMesh->setHeight(newPoint, 0);
+ sieveMesh->setDepth(newPoint, 1);
#endif
sV2.clear();
cV2.clear();
} // for
// This completes the set of cells scheduled to be replaced
- PointSet replaceCellsBase(replaceCells);
+ TopologyOps::PointSet replaceCellsBase(replaceCells);
- const ALE::Obj<ALE::Mesh::label_sequence>& faultBdVerts = faultBd->depthStratum(0);
- PointSet faultBdVertices;
+ const ALE::Obj<ALE::Mesh::label_sequence>& faultBdVerts =
+ faultBoundary->depthStratum(0);
+ assert(!faultBdVerts.isNull());
+ TopologyOps::PointSet faultBdVertices;
faultBdVertices.insert(faultBdVerts->begin(), faultBdVerts->end());
- for(PointSet::const_iterator v_iter = replaceVertices.begin(); v_iter != replaceVertices.end(); ++v_iter) {
- if (faultBdVertices.find(*v_iter) != faultBdVertices.end()) continue;
- classifyCells(sieve, *v_iter, depth, faceSize, firstCohesiveCell, replaceCells, noReplaceCells, debug);
- }
- for(PointSet::const_iterator v_iter = faultBdVertices.begin(); v_iter != faultBdVertices.end(); ++v_iter) {
- classifyCells(sieve, *v_iter, depth, faceSize, firstCohesiveCell, replaceCells, noReplaceCells, debug);
- }
+ TopologyOps::PointSet::const_iterator rVerticesEnd = replaceVertices.end();
+ for (TopologyOps::PointSet::const_iterator v_iter = replaceVertices.begin();
+ v_iter != rVerticesEnd; ++v_iter) {
+ if (faultBdVertices.find(*v_iter) != faultBdVertices.end())
+ continue;
+ TopologyOps::classifyCells(sieve, *v_iter, depth, faceSize,
+ firstCohesiveCell, replaceCells, noReplaceCells,
+ debug);
+ } // for
+ const TopologyOps::PointSet::const_iterator fbdVerticesEnd =
+ faultBdVertices.end();
+ for (TopologyOps::PointSet::const_iterator v_iter=faultBdVertices.begin();
+ v_iter != fbdVerticesEnd;
+ ++v_iter) {
+ TopologyOps::classifyCells(sieve, *v_iter, depth, faceSize,
+ firstCohesiveCell, replaceCells, noReplaceCells,
+ debug);
+ } // for
// Add new arrows for support of replaced vertices
- ALE::ISieveVisitor::PointRetriever<sieve_type> sV(std::max(1, sieve->getMaxSupportSize()));
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> sV(std::max(1, sieve->getMaxSupportSize()));
- for(PointSet::const_iterator v_iter = replaceVertices.begin(); v_iter != replaceVertices.end(); ++v_iter) {
+ rVerticesEnd = replaceVertices.end();
+ for (TopologyOps::PointSet::const_iterator v_iter = replaceVertices.begin();
+ v_iter != rVerticesEnd;
+ ++v_iter) {
sieve->support(*v_iter, sV);
- const Mesh::point_type *support = sV.getPoints();
+ const point_type *support = sV.getPoints();
- if (debug) std::cout << " Checking support of " << *v_iter << std::endl;
- for(int s = 0; s < sV.getSize(); ++s) {
+ if (debug)
+ std::cout << " Checking support of " << *v_iter << std::endl;
+ const int sVSize = sV.getSize();
+ for (int s = 0; s < sVSize; ++s) {
if (replaceCells.find(support[s]) != replaceCells.end()) {
- if (debug) std::cout << " Adding new support " << vertexRenumber[*v_iter] << " --> " << support[s] << std::endl;
+ if (debug)
+ std::cout << " Adding new support " << vertexRenumber[*v_iter]
+ << " --> " << support[s] << std::endl;
sieve->addArrow(vertexRenumber[*v_iter], support[s]);
} else {
- if (debug) std::cout << " Keeping same support " << *v_iter<<","<<vertexRenumber[*v_iter] << " --> " << support[s] << std::endl;
- }
- }
+ if (debug)
+ std::cout << " Keeping same support " << *v_iter<<","
+ << vertexRenumber[*v_iter] << " --> " << support[s]
+ << std::endl;
+ } // if/else
+ } // for
sV.clear();
}
sieve->reallocate();
// More checking
- const bool firstFault = !mesh->hasRealSection("replaced_cells");
- const ALE::Obj<real_section_type>& replacedCells = mesh->getRealSection("replaced_cells");
- PointSet cellNeighbors;
-
+ const bool firstFault = !sieveMesh->hasRealSection("replaced_cells");
+ const ALE::Obj<topology::Mesh::RealSection>& replacedCells =
+ sieveMesh->getRealSection("replaced_cells");
+ assert(!replacedCells.isNull());
+ TopologyOps::PointSet cellNeighbors;
+
if (firstFault) {
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
+ assert(!cells.isNull());
- replacedCells->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()), *std::max_element(cells->begin(), cells->end())+1));
+ replacedCells->setChart(topology::Mesh::RealSection::chart_type(*std::min_element(cells->begin(), cells->end()), *std::max_element(cells->begin(), cells->end())+1));
replacedCells->setFiberDimension(cells, 1);
replacedCells->allocatePoint();
- }
- for(PointSet::const_iterator c_iter = noReplaceCells.begin(); c_iter != noReplaceCells.end(); ++c_iter) {
+ } // if
+
+ const TopologyOps::PointSet::const_iterator noRCellsEnd = noReplaceCells.end();
+ for (TopologyOps::PointSet::const_iterator c_iter = noReplaceCells.begin();
+ c_iter != noRCellsEnd;
+ ++c_iter) {
const double minusOne = -1.0;
-
if (replacedCells->restrictPoint(*c_iter)[0] == 0.0) {
replacedCells->updatePoint(*c_iter, &minusOne);
} else {
const double minusTwo = -2.0;
-
replacedCells->updatePoint(*c_iter, &minusTwo);
- }
- }
- for(PointSet::const_iterator c_iter = replaceCells.begin(); c_iter != replaceCells.end(); ++c_iter) {
+ } // if/else
+ } // for
+
+ TopologyOps::PointSet::const_iterator rCellsEnd = replaceCells.end();
+ for (TopologyOps::PointSet::const_iterator c_iter = replaceCells.begin();
+ c_iter != rCellsEnd;
+ ++c_iter) {
if (replaceCellsBase.find(*c_iter) != replaceCellsBase.end()) {
const double one = 1.0;
-
if (replacedCells->restrictPoint(*c_iter)[0] == 0.0) {
replacedCells->updatePoint(*c_iter, &one);
} else {
const double two = 2.0;
-
replacedCells->updatePoint(*c_iter, &two);
- }
+ } // if/else
continue;
- }
+ } // if
const double ten = 10.0;
-
if (replacedCells->restrictPoint(*c_iter)[0] == 0.0) {
replacedCells->updatePoint(*c_iter, &ten);
} else {
- const double twenty = 20.0;
-
- replacedCells->updatePoint(*c_iter, &twenty);
- }
+ const double twenty = 20.0;
+ replacedCells->updatePoint(*c_iter, &twenty);
+ } // if/else
// There should be a way to check for boundary elements
- if (mesh->getDimension() == 1) {
+ if (mesh->dimension() == 1) {
if (cellNeighbors.size() > 2) {
- std::cout << "Cell " << *c_iter << " has an invalid number of neighbors " << cellNeighbors.size() << std::endl;
+ std::cout << "Cell " << *c_iter
+ << " has an invalid number of neighbors "
+ << cellNeighbors.size() << std::endl;
throw ALE::Exception("Invalid number of neighbors");
- }
- } else if (mesh->getDimension() == 2) {
+ } // if
+ } else if (mesh->dimension() == 2) {
if (numCorners == 3) {
if (cellNeighbors.size() > 3) {
- std::cout << "Cell " << *c_iter << " has an invalid number of neighbors " << cellNeighbors.size() << std::endl;
+ std::cout << "Cell " << *c_iter
+ << " has an invalid number of neighbors "
+ << cellNeighbors.size() << std::endl;
throw ALE::Exception("Invalid number of neighbors");
- }
+ } // if
} else if (numCorners == 4) {
if (cellNeighbors.size() > 4) {
- std::cout << "Cell " << *c_iter << " has an invalid number of neighbors " << cellNeighbors.size() << std::endl;
+ std::cout << "Cell " << *c_iter
+ << " has an invalid number of neighbors "
+ << cellNeighbors.size() << std::endl;
throw ALE::Exception("Invalid number of neighbors");
- }
- }
- } else if (mesh->getDimension() == 3) {
+ } // if
+ } // if/else
+ } else if (mesh->dimension() == 3) {
if (numCorners == 4) {
if (cellNeighbors.size() > 4) {
- std::cout << "Cell " << *c_iter << " has an invalid number of neighbors " << cellNeighbors.size() << std::endl;
+ std::cout << "Cell " << *c_iter
+ << " has an invalid number of neighbors "
+ << cellNeighbors.size() << std::endl;
throw ALE::Exception("Invalid number of neighbors");
- }
+ } // if
} else if (numCorners == 8) {
if (cellNeighbors.size() > 6) {
- std::cout << "Cell " << *c_iter << " has an invalid number of neighbors " << cellNeighbors.size() << std::endl;
+ std::cout << "Cell " << *c_iter
+ << " has an invalid number of neighbors "
+ << cellNeighbors.size() << std::endl;
throw ALE::Exception("Invalid number of neighbors");
- }
- }
- }
- }
- ReplaceVisitor<sieve_type,std::map<Mesh::point_type,Mesh::point_type> > rVc(vertexRenumber, std::max(1, sieve->getMaxConeSize()), debug);
-
- for(PointSet::const_iterator c_iter = replaceCells.begin(); c_iter != replaceCells.end(); ++c_iter) {
+ } // if
+ } // if/else
+ } // if/else
+ } // for
+ ReplaceVisitor<SieveMesh::sieve_type,std::map<Mesh::point_type,Mesh::point_type> > rVc(vertexRenumber, std::max(1, sieve->getMaxConeSize()), debug);
+
+ rCellsEnd = replaceCells.end();
+ for (TopologyOps::PointSet::const_iterator c_iter = replaceCells.begin();
+ c_iter != rCellsEnd;
+ ++c_iter) {
sieve->cone(*c_iter, rVc);
if (rVc.mappedPoint()) {
- if (debug) std::cout << " Replacing cell " << *c_iter << std::endl;
+ if (debug)
+ std::cout << " Replacing cell " << *c_iter << std::endl;
sieve->setCone(rVc.getPoints(), *c_iter);
- }
+ } // if
rVc.clear();
- }
- ReplaceVisitor<sieve_type,std::map<Mesh::point_type,Mesh::point_type> > rVs(cellRenumber, std::max(1, sieve->getMaxSupportSize()), debug);
+ } // for
+ ReplaceVisitor<SieveMesh::sieve_type,std::map<Mesh::point_type,Mesh::point_type> > rVs(cellRenumber, std::max(1, sieve->getMaxSupportSize()), debug);
- for(PointSet::const_iterator v_iter = replaceVertices.begin(); v_iter != replaceVertices.end(); ++v_iter) {
+ rVerticesEnd = replaceVertices.end();
+ for (TopologyOps::PointSet::const_iterator v_iter = replaceVertices.begin();
+ v_iter != rVerticesEnd;
+ ++v_iter) {
sieve->support(*v_iter, rVs);
if (rVs.mappedPoint()) {
- if (debug) std::cout << " Replacing support for " << *v_iter << std::endl;
+ if (debug)
+ std::cout << " Replacing support for " << *v_iter << std::endl;
sieve->setSupport(*v_iter, rVs.getPoints());
} else {
- if (debug) std::cout << " Not replacing support for " << *v_iter << std::endl;
- }
+ if (debug)
+ std::cout << " Not replacing support for " << *v_iter << std::endl;
+ } // if/else
rVs.clear();
- }
- if (!ifault->commRank()) delete [] indices;
+ } // for
+ if (!faultSieveMesh->commRank())
+ delete [] indices;
#if 1
- mesh->stratify();
+ sieveMesh->stratify();
#endif
const std::string labelName("censored depth");
- if (!mesh->hasLabel(labelName)) {
- const ALE::Obj<Mesh::label_type>& label = mesh->createLabel(labelName);
+ if (!sieveMesh->hasLabel(labelName)) {
+ const ALE::Obj<Mesh::label_type>& label = sieveMesh->createLabel(labelName);
+ assert(!label.isNull());
- _computeCensoredDepth(label, mesh->getSieve(), firstCohesiveCell-(constraintCell?numFaultVertices:0));
+ TopologyOps::computeCensoredDepth(label, sieveMesh->getSieve(),
+ firstCohesiveCell-(constraintCell?numFaultVertices:0));
} else {
// Insert new shadow vertices into existing label
- const ALE::Obj<Mesh::label_type>& label = mesh->getLabel(labelName);
+ const ALE::Obj<Mesh::label_type>& label = sieveMesh->getLabel(labelName);
+ assert(!label.isNull());
- for(std::map<int,int>::const_iterator v_iter = vertexRenumber.begin(); v_iter != vertexRenumber.end(); ++v_iter) {
- mesh->setValue(label, v_iter->second, 0);
- }
- }
- if (debug) mesh->view("Mesh with Cohesive Elements");
+ const std::map<int,int>::const_iterator vRenumberEnd = vertexRenumber.end();
+ for (std::map<int,int>::const_iterator v_iter = vertexRenumber.begin();
+ v_iter != vRenumberEnd;
+ ++v_iter)
+ sieveMesh->setValue(label, v_iter->second, 0);
+ } // if/else
+ if (debug)
+ mesh->view("Mesh with Cohesive Elements");
// Fix coordinates
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- const ALE::Obj<SubMesh::label_sequence>& fVertices2 = ifault->depthStratum(0);
+ const ALE::Obj<topology::Mesh::RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
+ assert(!coordinates.isNull());
+ const ALE::Obj<SieveSubMesh::label_sequence>& fVertices2 =
+ faultSieveMesh->depthStratum(0);
+ assert(!fVertices2.isNull());
- if (debug) coordinates->view("Coordinates without shadow vertices");
- for(SubMesh::label_sequence::iterator v_iter = fVertices2->begin();
- v_iter != fVertices2->end();
+ if (debug)
+ coordinates->view("Coordinates without shadow vertices");
+ SieveSubMesh::label_sequence::const_iterator fVertices2End =
+ fVertices2->end();
+ for (SieveSubMesh::label_sequence::iterator v_iter = fVertices2->begin();
+ v_iter != fVertices2End;
++v_iter) {
coordinates->addPoint(vertexRenumber[*v_iter],
coordinates->getFiberDimension(*v_iter));
- if (constraintCell) {
+ if (constraintCell)
coordinates->addPoint(vertexRenumber[*v_iter]+numFaultVertices,
- coordinates->getFiberDimension(*v_iter));
- }
+ coordinates->getFiberDimension(*v_iter));
} // for
- mesh->reallocate(coordinates);
- for(SubMesh::label_sequence::iterator v_iter = fVertices2->begin();
- v_iter != fVertices2->end();
+ sieveMesh->reallocate(coordinates);
+ fVertices2End = fVertices2->end();
+ for (SieveSubMesh::label_sequence::iterator v_iter = fVertices2->begin();
+ v_iter != fVertices2End;
++v_iter) {
coordinates->updatePoint(vertexRenumber[*v_iter],
coordinates->restrictPoint(*v_iter));
- if (constraintCell) {
+ if (constraintCell)
coordinates->updatePoint(vertexRenumber[*v_iter]+numFaultVertices,
coordinates->restrictPoint(*v_iter));
- }
- }
- if (debug) coordinates->view("Coordinates with shadow vertices");
+ } // for
+ if (debug)
+ coordinates->view("Coordinates with shadow vertices");
} // createCohesiveCells
// ----------------------------------------------------------------------
// Form a parallel fault mesh using the cohesive cell information
void
-pylith::faults::CohesiveTopology::createParallel(
- ALE::Obj<SubMesh>* ifault,
- std::map<Mesh::point_type, Mesh::point_type>* cohesiveToFault,
- const ALE::Obj<Mesh>& mesh,
- const int materialId,
- const bool constraintCell)
-{
- assert(0 != ifault);
+pylith::faults::CohesiveTopology::createFaultParallel(
+ topology::SubMesh* faultMesh,
+ std::map<point_type, point_type>* cohesiveToFault,
+ const topology::Mesh& mesh,
+ const int materialId,
+ const bool constraintCell)
+{ // createFaultParallel
+ assert(0 != faultMesh);
assert(0 != cohesiveToFault);
- const ALE::Obj<sieve_type>& sieve = mesh->getSieve();
- *ifault = new SubMesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- const ALE::Obj<sieve_type> ifaultSieve = new sieve_type(sieve->comm(), sieve->debug());
- ALE::Obj<ALE::Mesh> fault = new ALE::Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh::sieve_type> faultSieve = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+ faultMesh->coordsys(mesh);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = sieveMesh->getSieve();
+ assert(!sieve.isNull());
+ faultSieveMesh =
+ new SieveSubMesh(mesh.comm(), mesh.dimension()-1, mesh.debug());
+ const ALE::Obj<SieveMesh::sieve_type> ifaultSieve =
+ new SieveMesh::sieve_type(sieve->comm(), sieve->debug());
+ assert(!ifaultSieve.isNull());
+ ALE::Obj<ALE::Mesh> fault =
+ new ALE::Mesh(mesh.comm(), mesh.dimension()-1, mesh.debug());
+ assert(!fault.isNull());
+ ALE::Obj<ALE::Mesh::sieve_type> faultSieve =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+ assert(!faultSieve.isNull());
cohesiveToFault->clear();
- const ALE::Obj<Mesh::label_sequence>& cohesiveCells = mesh->getLabelStratum("material-id", materialId);
- const Mesh::label_sequence::iterator cBegin = cohesiveCells->begin();
- const Mesh::label_sequence::iterator cEnd = cohesiveCells->end();
+ const ALE::Obj<SieveMesh::label_sequence>& cohesiveCells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ assert(!cohesiveCells.isNull());
+ const SieveMesh::label_sequence::iterator cBegin = cohesiveCells->begin();
+ const SieveMesh::label_sequence::iterator cEnd = cohesiveCells->end();
const int sieveEnd = sieve->getBaseSize() + sieve->getCapSize();
const int numFaces = cohesiveCells->size();
int globalSieveEnd = 0;
int globalFaceOffset = 0;
- MPI_Allreduce((void *) &sieveEnd, (void *) &globalSieveEnd, 1, MPI_INT, MPI_SUM, sieve->comm());
- MPI_Scan((void *) &numFaces, (void *) &globalFaceOffset, 1, MPI_INT, MPI_SUM, sieve->comm());
+ MPI_Allreduce((void *) &sieveEnd, (void *) &globalSieveEnd, 1,
+ MPI_INT, MPI_SUM, sieve->comm());
+ MPI_Scan((void *) &numFaces, (void *) &globalFaceOffset, 1,
+ MPI_INT, MPI_SUM, sieve->comm());
int face = globalSieveEnd + globalFaceOffset - numFaces;
- ALE::ISieveVisitor::PointRetriever<sieve_type> cV(std::max(sieve->getMaxConeSize(), 1));
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> cV(std::max(sieve->getMaxConeSize(), 1));
- for(Mesh::label_sequence::iterator c_iter = cBegin; c_iter != cEnd; ++c_iter) {
+ for(SieveMesh::label_sequence::iterator c_iter = cBegin;
+ c_iter != cEnd;
+ ++c_iter) {
sieve->cone(*c_iter, cV);
- const int coneSize = cV.getSize();
- const Mesh::point_type *cone = cV.getPoints();
- int color = 0;
+ const int coneSize = cV.getSize();
+ const Mesh::point_type *cone = cV.getPoints();
+ int color = 0;
if (!constraintCell) {
const int faceSize = coneSize / 2;
assert(0 == coneSize % faceSize);
// Use first vertices (negative side of the fault) for fault mesh
- for(int i = 0; i < faceSize; ++i) {
+ for (int i = 0; i < faceSize; ++i)
faultSieve->addArrow(cone[i], face, color++);
- }
} else {
const int faceSize = coneSize / 3;
assert(0 == coneSize % faceSize);
// Use last vertices (contraints) for fault mesh
- for(int i = 2*faceSize; i < 3*faceSize; ++i) {
+ for (int i = 2*faceSize; i < 3*faceSize; ++i)
faultSieve->addArrow(cone[i], face, color++);
- }
} // if/else
(*cohesiveToFault)[*c_iter] = face;
++face;
@@ -926,167 +707,96 @@
fault->stratify();
// Convert fault to an IMesh
- SubMesh::renumbering_type& fRenumbering = (*ifault)->getRenumbering();
- (*ifault)->setSieve(ifaultSieve);
- //ALE::ISieveConverter::convertMesh(*fault, *(*ifault), fRenumbering, true);
+ SieveSubMesh::renumbering_type& fRenumbering =
+ faultSieveMesh->getRenumbering();
+ const SieveSubMesh::renumbering_type::const_iterator fRenumberingEnd =
+ fRenumbering.end();
+ faultSieveMesh->setSieve(ifaultSieve);
+ //ALE::ISieveConverter::convertMesh(*fault, *faultSieveMesh, fRenumbering, true);
{
- ALE::ISieveConverter::convertSieve(*fault->getSieve(), *(*ifault)->getSieve(), fRenumbering, true);
- (*ifault)->stratify();
- ALE::ISieveConverter::convertOrientation(*fault->getSieve(), *(*ifault)->getSieve(), fRenumbering, fault->getArrowSection("orientation").ptr());
+ ALE::ISieveConverter::convertSieve(*fault->getSieve(),
+ *faultSieveMesh->getSieve(),
+ fRenumbering, true);
+ faultSieveMesh->stratify();
+ ALE::ISieveConverter::convertOrientation(*fault->getSieve(),
+ *faultSieveMesh->getSieve(),
+ fRenumbering,
+ fault->getArrowSection("orientation").ptr());
}
fault = NULL;
faultSieve = NULL;
- const ALE::Obj<SubMesh::label_sequence>& faultCells = (*ifault)->heightStratum(0);
+ const ALE::Obj<SieveSubMesh::label_sequence>& faultCells =
+ faultSieveMesh->heightStratum(0);
assert(!faultCells.isNull());
- SubMesh::label_sequence::iterator f_iter = faultCells->begin();
+ SieveSubMesh::label_sequence::iterator f_iter = faultCells->begin();
- for(Mesh::label_sequence::iterator c_iter = cBegin; c_iter != cEnd; ++c_iter, ++f_iter) {
+ for(SieveMesh::label_sequence::iterator c_iter = cBegin;
+ c_iter != cEnd;
+ ++c_iter, ++f_iter)
(*cohesiveToFault)[*c_iter] = *f_iter;
- }
-#if 0
- (*ifault)->setRealSection("coordinates", mesh->getRealSection("coordinates"));
-#else
- const ALE::Obj<Mesh::real_section_type>& coordinates = mesh->getRealSection("coordinates");
- const ALE::Obj<Mesh::real_section_type>& fCoordinates = (*ifault)->getRealSection("coordinates");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const Mesh::label_sequence::iterator vBegin = vertices->begin();
- const Mesh::label_sequence::iterator vEnd = vertices->end();
+ const ALE::Obj<topology::Mesh::RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
+ assert(!coordinates.isNull());
+ const ALE::Obj<topology::Mesh::RealSection>& fCoordinates =
+ faultSieveMesh->getRealSection("coordinates");
+ assert(!fCoordinates.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator vBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator vEnd = vertices->end();
- fCoordinates->setChart(Mesh::real_section_type::chart_type((*ifault)->heightStratum(0)->size(),
- (*ifault)->getSieve()->getChart().max()));
- for(Mesh::label_sequence::iterator v_iter = vBegin;
+ fCoordinates->setChart(topology::Mesh::RealSection::chart_type(faultSieveMesh->heightStratum(0)->size(),
+ faultSieveMesh->getSieve()->getChart().max()));
+ for (SieveMesh::label_sequence::iterator v_iter = vBegin;
v_iter != vEnd;
++v_iter) {
- if (fRenumbering.find(*v_iter) == fRenumbering.end()) continue;
- fCoordinates->setFiberDimension(fRenumbering[*v_iter], coordinates->getFiberDimension(*v_iter));
- }
+ if (fRenumbering.find(*v_iter) == fRenumberingEnd)
+ continue;
+ fCoordinates->setFiberDimension(fRenumbering[*v_iter],
+ coordinates->getFiberDimension(*v_iter));
+ } // for
fCoordinates->allocatePoint();
- for(Mesh::label_sequence::iterator v_iter = vBegin;
+ for(SieveMesh::label_sequence::iterator v_iter = vBegin;
v_iter != vEnd;
++v_iter) {
- if (fRenumbering.find(*v_iter) == fRenumbering.end()) continue;
- fCoordinates->updatePoint(fRenumbering[*v_iter], coordinates->restrictPoint(*v_iter));
+ if (fRenumbering.find(*v_iter) == fRenumberingEnd)
+ continue;
+ fCoordinates->updatePoint(fRenumbering[*v_iter],
+ coordinates->restrictPoint(*v_iter));
}
-#endif
- //(*ifault)->view("Parallel fault mesh");
+ //faultSieveMesh->view("Parallel fault mesh");
// Create the parallel overlap
// Can I figure this out in a nicer way?
- Obj<SubMesh::send_overlap_type> sendParallelMeshOverlap = (*ifault)->getSendOverlap();
- Obj<SubMesh::recv_overlap_type> recvParallelMeshOverlap = (*ifault)->getRecvOverlap();
+ ALE::Obj<SieveSubMesh::send_overlap_type> sendParallelMeshOverlap =
+ faultSieveMesh->getSendOverlap();
+ assert(!sendParallelMeshOverlap.isNull());
+ ALE::Obj<SieveSubMesh::recv_overlap_type> recvParallelMeshOverlap =
+ faultSieveMesh->getRecvOverlap();
+ assert(!recvParallelMeshOverlap.isNull());
// Must process the renumbering local --> fault to global --> fault
- Mesh::renumbering_type& renumbering = mesh->getRenumbering();
- Mesh::renumbering_type gRenumbering;
+ SieveMesh::renumbering_type& renumbering = sieveMesh->getRenumbering();
+ SieveMesh::renumbering_type gRenumbering;
- for(Mesh::renumbering_type::const_iterator r_iter = renumbering.begin(); r_iter != renumbering.end(); ++r_iter) {
- if (fRenumbering.find(r_iter->second) != fRenumbering.end()) {
+ const SieveMesh::renumbering_type::const_iterator renumberingEnd =
+ renumbering.end();
+ for (SieveMesh::renumbering_type::const_iterator r_iter = renumbering.begin();
+ r_iter != renumberingEnd;
+ ++r_iter)
+ if (fRenumbering.find(r_iter->second) != fRenumbering.end())
gRenumbering[r_iter->first] = fRenumbering[r_iter->second];
- }
- }
- ALE::SetFromMap<Mesh::renumbering_type> globalPoints(gRenumbering);
- ALE::OverlapBuilder<>::constructOverlap(globalPoints, gRenumbering, sendParallelMeshOverlap, recvParallelMeshOverlap);
- (*ifault)->setCalculatedOverlap(true);
+ ALE::SetFromMap<SieveMesh::renumbering_type> globalPoints(gRenumbering);
+ ALE::OverlapBuilder<>::constructOverlap(globalPoints, gRenumbering,
+ sendParallelMeshOverlap,
+ recvParallelMeshOverlap);
+ faultSieveMesh->setCalculatedOverlap(true);
//sendParallelMeshOverlap->view("Send parallel fault overlap");
//recvParallelMeshOverlap->view("Recv parallel fault overlap");
-}
+} // createFaultParallel
-// ----------------------------------------------------------------------
-void
-pylith::faults::CohesiveTopology::classifyCells(const ALE::Obj<Mesh::sieve_type>& sieve,
- const Mesh::point_type& vertex,
- const int depth,
- const int faceSize,
- const Mesh::point_type& firstCohesiveCell,
- PointSet& replaceCells,
- PointSet& noReplaceCells,
- const int debug)
-{
- // Replace all cells on a given side of the fault with a vertex on the fault
- ClassifyVisitor<Mesh::sieve_type> cV(*sieve, replaceCells, noReplaceCells, firstCohesiveCell, faceSize, debug);
- const PointSet& vReplaceCells = cV.getReplaceCells();
- const PointSet& vNoReplaceCells = cV.getNoReplaceCells();
- if (debug) {std::cout << "Checking fault vertex " << vertex << std::endl;}
- sieve->support(vertex, cV);
- cV.setMode(false);
- const int classifyTotal = cV.getSize();
- int classifySize = vReplaceCells.size() + vNoReplaceCells.size();
-
- while(cV.getModified() && (classifySize < classifyTotal)) {
- cV.reset();
- sieve->support(vertex, cV);
- if (debug) {
- std::cout << "classifySize: " << classifySize << std::endl;
- std::cout << "classifyTotal: " << classifyTotal << std::endl;
- std::cout << "vReplaceCells.size: " << vReplaceCells.size() << std::endl;
- std::cout << "vNoReplaceCells.size: " << vNoReplaceCells.size() << std::endl;
- }
- assert(classifySize < vReplaceCells.size() + vNoReplaceCells.size());
- classifySize = vReplaceCells.size() + vNoReplaceCells.size();
- assert(classifySize <= classifyTotal);
- }
- replaceCells.insert(vReplaceCells.begin(), vReplaceCells.end());
- // More checking
- noReplaceCells.insert(vNoReplaceCells.begin(), vNoReplaceCells.end());
-}
-
-// ----------------------------------------------------------------------
-template<class InputPoints>
-bool
-pylith::faults::CohesiveTopology::_compatibleOrientation(const ALE::Obj<Mesh>& mesh,
- const Mesh::point_type& p,
- const Mesh::point_type& q,
- const int numFaultCorners,
- const int faultFaceSize,
- const int faultDepth,
- const Obj<InputPoints>& points,
- int indices[],
- PointArray *origVertices,
- PointArray *faceVertices,
- PointArray *neighborVertices)
-{
- typedef ALE::Selection<Mesh> selection;
- const int debug = mesh->debug();
- bool compatible;
-
- bool eOrient = selection::getOrientedFace(mesh, p, points, numFaultCorners, indices, origVertices, faceVertices);
- bool nOrient = selection::getOrientedFace(mesh, q, points, numFaultCorners, indices, origVertices, neighborVertices);
-
- if (faultFaceSize > 1) {
- if (debug) {
- for(PointArray::iterator v_iter = faceVertices->begin(); v_iter != faceVertices->end(); ++v_iter) {
- std::cout << " face vertex " << *v_iter << std::endl;
- }
- for(PointArray::iterator v_iter = neighborVertices->begin(); v_iter != neighborVertices->end(); ++v_iter) {
- std::cout << " neighbor vertex " << *v_iter << std::endl;
- }
- }
- compatible = !(*faceVertices->begin() == *neighborVertices->begin());
- } else {
- compatible = !(nOrient == eOrient);
- }
- return compatible;
-}
-
-// ----------------------------------------------------------------------
-void
-pylith::faults::CohesiveTopology::_computeCensoredDepth(const ALE::Obj<Mesh::label_type>& depth,
- const ALE::Obj<Mesh::sieve_type>& sieve,
- const Mesh::point_type& firstCohesiveCell)
-{
- Mesh::DepthVisitor d(*sieve, firstCohesiveCell, *depth);
-
- sieve->roots(d);
- while(d.isModified()) {
- // FIX: Avoid the copy here somehow by fixing the traversal
- std::vector<Mesh::point_type> modifiedPoints(d.getModifiedPoints().begin(), d.getModifiedPoints().end());
-
- d.clear();
- sieve->support(modifiedPoints, d);
- }
-};
// End of file
Modified: short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/CohesiveTopology.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,160 +18,35 @@
#if !defined(pylith_faults_cohesivetopology_hh)
#define pylith_faults_cohesivetopology_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+// Include directives ---------------------------------------------------
+#include "faultsfwd.hh" // forward declarations
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class CohesiveTopology;
- } // faults
-} // pylith
+#include "pylith/topology/Mesh.hh" // USES Mesh::IntSection
+#include "pylith/utils/sievetypes.hh" // USE ALE::Obj
-/// C++ object to manage creation of cohesive cells.
+// CohesiveTopology -----------------------------------------------------
class pylith::faults::CohesiveTopology
{ // class CohesiveTopology
-public :
- typedef std::set<Mesh::point_type> PointSet;
- typedef std::vector<sieve_type::point_type> PointArray;
- typedef std::pair<sieve_type::point_type, int> oPoint_type;
- typedef std::vector<oPoint_type> oPointArray;
-protected:
- template<typename Sieve, typename Renumbering>
- class ReplaceVisitor {
- public:
- typedef typename Sieve::point_type point_type;
- protected:
- Renumbering& renumbering;
- const int size;
- int i;
- const int debug;
- point_type *points;
- bool mapped;
- public:
- ReplaceVisitor(Renumbering& r, const int size, const int debug = 0) : renumbering(r), size(size), i(0), debug(debug) {
- this->points = new point_type[this->size];
- this->mapped = false;
- };
- ~ReplaceVisitor() {delete [] this->points;};
- void visitPoint(const point_type& point) {
- if (i >= this->size) {throw ALE::Exception("Too many points for ReplaceVisitor");}
- if (this->renumbering.find(point) != this->renumbering.end()) {
- if (debug) std::cout << " point " << this->renumbering[point] << std::endl;
- points[i] = this->renumbering[point];
- this->mapped = true;
- } else {
- if (debug) std::cout << " point " << point << std::endl;
- points[i] = point;
- }
- ++i;
- };
- void visitArrow(const typename Sieve::arrow_type&) {};
- public:
- const point_type *getPoints() {return this->points;};
- bool mappedPoint() {return this->mapped;};
- void clear() {this->i = 0; this->mapped = false;};
- };
- template<typename Sieve>
- class ClassifyVisitor {
- public:
- typedef typename Sieve::point_type point_type;
- protected:
- const Sieve& sieve;
- const PointSet& replaceCells;
- const PointSet& noReplaceCells;
- const point_type firstCohesiveCell;
- const int faceSize;
- const int debug;
- PointSet vReplaceCells;
- PointSet vNoReplaceCells;
- bool modified;
- bool setupMode;
- int size;
- ALE::ISieveVisitor::PointRetriever<Sieve> pR;
- public:
- ClassifyVisitor(const Sieve& s, const PointSet& rC, const PointSet& nrC, const point_type& fC, const int fS, const int debug = 0) : sieve(s), replaceCells(rC), noReplaceCells(nrC), firstCohesiveCell(fC), faceSize(fS), debug(debug), modified(false), setupMode(true), size(0) {
- pR.setSize(s.getMaxConeSize());
- };
- ~ClassifyVisitor() {};
- void visitPoint(const point_type& point) {
- if (this->setupMode) {
- if (replaceCells.find(point) != replaceCells.end()) vReplaceCells.insert(point);
- if (noReplaceCells.find(point) != noReplaceCells.end()) vNoReplaceCells.insert(point);
- if (point >= firstCohesiveCell) return;
- this->modified = true;
- this->size++;
- return;
- }
- bool classified = false;
+private :
+ typedef pylith::topology::Mesh::SieveMesh::point_type point_type;
- if (debug) {std::cout << "Checking neighbor " << point << std::endl;}
- if (vReplaceCells.find(point) != vReplaceCells.end()) {
- if (debug) {std::cout << " already in replaceCells" << std::endl;}
- return;
- }
- if (vNoReplaceCells.find(point) != vNoReplaceCells.end()) {
- if (debug) {std::cout << " already in noReplaceCells" << std::endl;}
- return;
- }
- if (point >= firstCohesiveCell) {
- if (debug) {std::cout << " already a cohesive cell" << std::endl;}
- return;
- }
- // If neighbor shares a face with anyone in replaceCells, then add
- for(PointSet::const_iterator c_iter = vReplaceCells.begin(); c_iter != vReplaceCells.end(); ++c_iter) {
- sieve.meet(*c_iter, point, pR);
-
- if (pR.getSize() == faceSize) {
- if (debug) {std::cout << " Scheduling " << point << " for replacement" << std::endl;}
- vReplaceCells.insert(point);
- modified = true;
- classified = true;
- pR.clear();
- break;
- }
- pR.clear();
- }
- if (classified) return;
- // It is unclear whether taking out the noReplace cells will speed this up
- for(PointSet::const_iterator c_iter = vNoReplaceCells.begin(); c_iter != vNoReplaceCells.end(); ++c_iter) {
- sieve.meet(*c_iter, point, pR);
-
- if (pR.getSize() == faceSize) {
- if (debug) {std::cout << " Scheduling " << point << " for no replacement" << std::endl;}
- vNoReplaceCells.insert(point);
- modified = true;
- classified = true;
- pR.clear();
- break;
- }
- pR.clear();
- }
- };
- void visitArrow(const typename Sieve::arrow_type&) {};
- public:
- const PointSet& getReplaceCells() const {return this->vReplaceCells;};
- const PointSet& getNoReplaceCells() const {return this->vNoReplaceCells;};
- const bool getModified() const {return this->modified;};
- const int getSize() const {return this->size;};
- void setMode(const bool isSetup) {this->setupMode = isSetup;};
- void reset() {this->modified = false;};
- };
-
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+
/** Create the fault mesh.
*
- * @param fault Finite-element mesh of fault (output)
- * @param mesh Finite-element mesh
+ * @param faultMesh Finite-element mesh of fault (output).
+ * @param faultBoundary Finite-element mesh of fault boundary (output).
+ * @param mesh Finite-element mesh of domain.
* @param faultVertices Vertices assocated with faces of cells defining
* fault surface
*/
static
- void createFault(Obj<SubMesh>& ifault,
- Obj<ALE::Mesh>& faultBd,
- const Obj<Mesh>& mesh,
- const Obj<Mesh::int_section_type>& groupField,
+ void createFault(topology::SubMesh* faultMesh,
+ ALE::Obj<ALE::Mesh>& faultBoundary,
+ const topology::Mesh& mesh,
+ const ALE::Obj<topology::Mesh::IntSection>& groupField,
const bool flipFault =false);
/** Create cohesive cells.
@@ -183,124 +58,30 @@
* Lagrange multipliers that require extra vertices, false otherwise
*/
static
- void create(Obj<SubMesh>& ifault,
- const Obj<ALE::Mesh>& faultBd,
- const Obj<Mesh>& mesh,
- const Obj<Mesh::int_section_type>& groupField,
+ void create(topology::Mesh* mesh,
+ const topology::SubMesh& faultMesh,
+ const ALE::Obj<ALE::Mesh>& faultBoundary,
+ const ALE::Obj<topology::Mesh::IntSection>& groupField,
const int materialId,
const bool constraintCell =false);
/** Create (distributed) fault mesh from cohesive cells.
*
- * @param fault Finite-element mesh of fault (output).
- * @param cohesiveToFault Mapping of cohesive cell to fault mesh cell.
+ * @param faultMesh Finite-element mesh of fault (output).
+ * @param cohesiveToFault Mapping of cohesive cell to fault mesh
+ * cell (output).
* @param mesh Finite-element mesh.
* @param materialId Material id for cohesive elements.
* @param constraintCell True if creating cells constrained with
* Lagrange multipliers that require extra vertices, false otherwise.
*/
static
- void createParallel(ALE::Obj<SubMesh>* ifault,
- std::map<Mesh::point_type, Mesh::point_type>* cohesiveToFault,
- const ALE::Obj<Mesh>& mesh,
- const int materialId,
- const bool constraintCell =false);
+ void createFaultParallel(topology::SubMesh* faultMesh,
+ std::map<point_type, point_type>* cohesiveToFault,
+ const topology::Mesh& mesh,
+ const int materialId,
+ const bool constraintCell =false);
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
- /** Get number of vertices on face.
- *
- * @param cell Finite-element cell
- * @param mesh Finite-element mesh
- *
- * @returns Number of vertices on cell face
- */
- static
- unsigned int _numFaceVertices(const Mesh::point_type& cell,
- const ALE::Obj<Mesh>& mesh,
- const int depth =-1);
-
- /** Determine a face orientation
- * We should really have an interpolated mesh, instead of
- * calculating this on the fly.
- *
- * @param cell Finite-element cell
- * @param mesh Finite-element mesh
- *
- * @returns True for positive orientation, otherwise false
- */
- static
- bool _faceOrientation(const Mesh::point_type& cell,
- const ALE::Obj<Mesh>& mesh,
- const int numCorners,
- const int indices[],
- const int oppositeVertex,
- PointArray *origVertices,
- PointArray *faceVertices);
-
- template<typename FaceType>
- static
- bool _getOrientedFace(const ALE::Obj<Mesh>& mesh,
- const Mesh::point_type& cell,
- FaceType face,
- const int numCorners,
- int indices[],
- PointArray *origVertices,
- PointArray *faceVertices);
-
- template<class InputPoints>
- static
- bool _compatibleOrientation(const ALE::Obj<Mesh>& mesh,
- const Mesh::point_type& p,
- const Mesh::point_type& q,
- const int numFaultCorners,
- const int faultFaceSize,
- const int faultDepth,
- const Obj<InputPoints>& points,
- int indices[],
- PointArray *origVertices,
- PointArray *faceVertices,
- PointArray *neighborVertices);
-
- static
- void _computeCensoredDepth(const ALE::Obj<Mesh::label_type>& depth,
- const ALE::Obj<Mesh::sieve_type>& sieve,
- const Mesh::point_type& firstCohesiveCell);
-
- static
- void classifyCells(const ALE::Obj<Mesh::sieve_type>& sieve,
- const Mesh::point_type& vertex,
- const int depth,
- const int faceSize,
- const Mesh::point_type& firstCohesiveCell,
- PointSet& replaceCells,
- PointSet& noReplaceCells,
- const int debug);
-
- static
- void createFaultSieveFromVertices(const int dim,
- const int firstCell,
- const PointSet& faultVertices,
- const Obj<Mesh>& mesh,
- const Obj<ALE::Mesh::arrow_section_type>& orientation,
- const Obj<ALE::Mesh::sieve_type>& faultSieve,
- const bool flipFault);
-
- static
- void createFaultSieveFromFaces(const int dim,
- const int firstCell,
- const int numFaces,
- const int faultVertices[],
- const int faultCells[],
- const Obj<Mesh>& mesh,
- const Obj<ALE::Mesh::arrow_section_type>& orientation,
- const Obj<ALE::Mesh::sieve_type>& faultSieve);
-
- static
- void orientFaultSieve(const int dim,
- const Obj<Mesh>& mesh,
- const Obj<ALE::Mesh::arrow_section_type>& orientation,
- const Obj<ALE::Mesh>& fault);
}; // class CohesiveTopology
#endif // pylith_faults_cohesivetopology_hh
Modified: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,9 @@
#include "ConstRateSlipFn.hh" // implementation of object methods
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#include "pylith/utils/array.hh" // USES double_array
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/topology/Field.hh" // USES Field
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
@@ -25,20 +26,18 @@
#include <sstream> // USES std::ostringstream
#include <stdexcept> // USES std::runtime_error
-namespace pylith {
- namespace faults {
- namespace _ConstRateSlipFn {
- const int offsetSlipTime = 0;
- } // _ConstRateSlipFn
- } // faults
-} // pylith
+// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::SieveMesh::label_sequence label_sequence;
+typedef pylith::topology::SubMesh::RealSection RealSection;
// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::ConstRateSlipFn::ConstRateSlipFn(void) :
+ _slipTimeVertex(0),
+ _parameters(0),
_dbSlipRate(0),
- _dbSlipTime(0),
- _spaceDim(0)
+ _dbSlipTime(0)
{ // constructor
} // constructor
@@ -46,45 +45,58 @@
// Destructor.
pylith::faults::ConstRateSlipFn::~ConstRateSlipFn(void)
{ // destructor
- _dbSlipRate = 0;
- _dbSlipTime = 0;
+ delete _parameters; _parameters = 0;
+ _dbSlipRate = 0; // :TODO: Use shared pointer.
+ _dbSlipTime = 0; // :TODO: Use shared pointer.
} // destructor
// ----------------------------------------------------------------------
// Initialize slip time function.
void
pylith::faults::ConstRateSlipFn::initialize(
- const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
- const spatialdata::units::Nondimensional& normalizer,
- const double originTime)
+ const topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime)
{ // initialize
- assert(!faultMesh.isNull());
- assert(0 != cs);
assert(0 != _dbSlipRate);
assert(0 != _dbSlipTime);
- _spaceDim = cs->spaceDim();
- const int spaceDim = _spaceDim;
- const int indexSlipRate = 0;
- const int indexSlipTime = spaceDim + _ConstRateSlipFn::offsetSlipTime;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ assert(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const double lengthScale = normalizer.lengthScale();
+ const double timeScale = normalizer.timeScale();
+ const double velocityScale =
+ normalizer.lengthScale() / normalizer.timeScale();
+
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = faultMesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- const int fiberDim = spaceDim + 1;
- _parameters = new real_section_type(faultMesh->comm(), faultMesh->debug());
- _parameters->addSpace(); // slip rate
- _parameters->addSpace(); // slip time
- assert(2 == _parameters->getNumSpaces());
- _parameters->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _parameters->setFiberDimension(vertices, fiberDim);
- _parameters->setFiberDimension(vertices, spaceDim, 0); // slip rate
- _parameters->setFiberDimension(vertices, 1, 1); // slip time
- faultMesh->allocate(_parameters);
- assert(!_parameters.isNull());
+ delete _parameters; _parameters = new topology::Fields<topology::Field<topology::SubMesh> >(faultMesh);
+ assert(0 != _parameters);
+ _parameters->add("slip rate", "slip_rate");
+ topology::Field<topology::SubMesh>& slipRate = _parameters->get("slip rate");
+ slipRate.newSection(vertices, spaceDim);
+ slipRate.allocate();
+ slipRate.scale(velocityScale);
+ slipRate.vectorFieldType(topology::FieldBase::VECTOR);
+ const ALE::Obj<RealSection>& slipRateSection = slipRate.section();
+ assert(!slipRateSection.isNull());
+ _parameters->add("slip time", "slip_time");
+ topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
+ slipTime.newSection(slipRateSection->getChart(), 1);
+ slipTime.allocate();
+ slipTime.scale(timeScale);
+ slipTime.vectorFieldType(topology::FieldBase::SCALAR);
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+
// Open databases and set query values
_dbSlipRate->open();
switch (spaceDim)
@@ -114,18 +126,13 @@
_dbSlipTime->queryVals(slipTimeValues, 1);
// Get coordinates of vertices
- const ALE::Obj<real_section_type>& coordinates =
- faultMesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
assert(!coordinates.isNull());
- const double lengthScale = normalizer.lengthScale();
- const double timeScale = normalizer.timeScale();
- const double velocityScale =
- normalizer.lengthScale() / normalizer.timeScale();
-
- double_array paramsVertex(fiberDim);
+ _slipRateVertex.resize(spaceDim);
double_array vCoordsGlobal(spaceDim);
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
coordinates->restrictPoint(*v_iter,
@@ -133,7 +140,7 @@
normalizer.dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
lengthScale);
- int err = _dbSlipRate->query(¶msVertex[indexSlipRate], spaceDim,
+ int err = _dbSlipRate->query(&_slipRateVertex[0], _slipRateVertex.size(),
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
@@ -143,10 +150,10 @@
msg << ") using spatial database " << _dbSlipRate->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexSlipRate], spaceDim,
+ normalizer.nondimensionalize(&_slipRateVertex[0], _slipRateVertex.size(),
velocityScale);
- err = _dbSlipTime->query(¶msVertex[indexSlipTime], 1,
+ err = _dbSlipTime->query(&_slipTimeVertex, 1,
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
@@ -156,12 +163,12 @@
msg << ") using spatial database " << _dbSlipTime->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexSlipTime], 1,
- timeScale);
+ normalizer.nondimensionalize(&_slipTimeVertex, 1, timeScale);
// add origin time to rupture time
- paramsVertex[indexSlipTime] += originTime;
+ _slipTimeVertex += originTime;
- _parameters->updatePoint(*v_iter, ¶msVertex[0]);
+ slipRateSection->updatePoint(*v_iter, &_slipRateVertex[0]);
+ slipTimeSection->updatePoint(*v_iter, &_slipTimeVertex);
} // for
// Close databases
@@ -172,114 +179,117 @@
// ----------------------------------------------------------------------
// Get slip on fault surface at time t.
void
-pylith::faults::ConstRateSlipFn::slip(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::ConstRateSlipFn::slip(topology::Field<topology::SubMesh>* slip,
+ const double t)
{ // slip
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexSlipRate = 0;
- const int indexSlipTime = spaceDim + _ConstRateSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& slipRate =
+ _parameters->get("slip rate");
+ const ALE::Obj<RealSection>& slipRateSection = slipRate.section();
+ assert(!slipRateSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ slipRateSection->restrictPoint(*v_iter, &_slipRateVertex[0],
+ _slipRateVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
- const double* slipRate = ¶msVertex[indexSlipRate];
- const double slipTime = paramsVertex[indexSlipTime];
- slipValues = 0.0;
+ const double relTime = t - _slipTimeVertex;
+ const double elapsedTime = (relTime > 0) ? relTime : 0.0;
+ _slipRateVertex *= elapsedTime; // Convert slip rate to slip
- const double relTime = t - slipTime;
- if (relTime > 0)
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = slipRate[i] * relTime;
-
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipRateVertex[0]);
} // for
- PetscLogFlops(numVertices * (1+1 + 4*spaceDim));
+ PetscLogFlops(vertices->size() * (1 + _slipRateVertex.size()));
} // slip
// ----------------------------------------------------------------------
// Get increment of slip on fault surface between time t0 and t1.
void
-pylith::faults::ConstRateSlipFn::slipIncr(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::ConstRateSlipFn::slipIncr(
+ topology::Field<topology::SubMesh>* slip,
+ const double t0,
+ const double t1)
{ // slipIncr
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexSlipRate = 0;
- const int indexSlipTime = spaceDim + _ConstRateSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& slipRate =
+ _parameters->get("slip rate");
+ const ALE::Obj<RealSection>& slipRateSection = slipRate.section();
+ assert(!slipRateSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ slipRateSection->restrictPoint(*v_iter, &_slipRateVertex[0],
+ _slipRateVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
- const double* slipRate = ¶msVertex[indexSlipRate];
- const double slipTime = paramsVertex[indexSlipTime];
- slipValues = 0.0;
-
- const double relTime0 = t0 - slipTime;
- const double relTime1 = t1 - slipTime;
+ const double relTime0 = t0 - _slipTimeVertex;
+ const double relTime1 = t1 - _slipTimeVertex;
double elapsedTime = 0.0;
if (relTime0 > 0)
elapsedTime = t1 - t0;
else if (relTime1 > 0)
- elapsedTime = t1 - slipTime;
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = slipRate[i] * elapsedTime;
+ elapsedTime = t1 - _slipTimeVertex;
+ _slipRateVertex *= elapsedTime; // Convert slip rate to slip
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipRateVertex[0]);
} // for
- PetscLogFlops(numVertices * (2 + spaceDim));
+ PetscLogFlops(vertices->size() * (4 + _slipRateVertex.size()));
} // slipIncr
// ----------------------------------------------------------------------
-// Get final slip (slip rate in this case).
-ALE::Obj<pylith::real_section_type>
+// Get final slip.
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::ConstRateSlipFn::finalSlip(void)
{ // finalSlip
- // This is actually slip rate.
- return _parameters->getFibration(0);
+ // Slip rate is parameter instead of final slip.
+ return _parameters->get("slip rate");
} // finalSlip
// ----------------------------------------------------------------------
// Get time when slip begins at each point.
-ALE::Obj<pylith::real_section_type>
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::ConstRateSlipFn::slipTime(void)
{ // slipTime
- return _parameters->getFibration(1);
+ return _parameters->get("slip time");
} // slipTime
Modified: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,27 +23,14 @@
#if !defined(pylith_faults_constrateslipfn_hh)
#define pylith_faults_constrateslipfn_hh
+// Include directives ---------------------------------------------------
#include "SlipTimeFn.hh"
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class ConstRateSlipFn;
- class TestConstRateSlipFn; // unit testing
- } // faults
-} // pylith
+#include "pylith/topology/topologyfwd.hh" // USES Fields<Field<SubMesh> >
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB;
- } // spatialdb
- namespace units {
- class Nondimensional;
- } // units
-} // spatialdata
+#include "pylith/utils/array.hh" // HASA double_array
-/// C++ implementation of ConstRate slip time function.
+// ConstRateTimeFn ------------------------------------------------------
class pylith::faults::ConstRateSlipFn : public SlipTimeFn
{ // class ConstRateSlipFn
friend class TestConstRateSlipFn; // unit testing
@@ -55,7 +42,6 @@
ConstRateSlipFn(void);
/// Destructor.
- virtual
~ConstRateSlipFn(void);
/** Set spatial database for slip rate.
@@ -73,12 +59,11 @@
/** Initialize slip time function.
*
* @param faultMesh Finite-element mesh of fault.
- * @param cs Coordinate system for mesh.
+ * @param cs Coordinate system for mesh
* @param normalizer Nondimensionalization of scales.
* @param originTime Origin time for earthquake source.
*/
- void initialize(const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
+ void initialize(const topology::SubMesh& faultMesh,
const spatialdata::units::Nondimensional& normalizer,
const double originTime =0.0);
@@ -86,64 +71,58 @@
*
* @param slipField Slip field over fault surface.
* @param t Time t.
- * @param faultMesh Mesh over fault surface.
*
* @returns Slip vector as left-lateral/reverse/normal.
*/
- void slip(const ALE::Obj<real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh);
+ void slip(topology::Field<topology::SubMesh>* const slipField,
+ const double t);
/** Get slip increment on fault surface between time t0 and t1.
*
* @param slipField Slip field over fault surface.
* @param t0 Time t.
* @param t1 Time t+dt.
- * @param faultMesh Mesh over fault surface.
*
* @returns Increment in slip vector as left-lateral/reverse/normal.
*/
- void slipIncr(const ALE::Obj<real_section_type>& slipField,
+ void slipIncr(topology::Field<topology::SubMesh>* slipField,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh);
+ const double t1);
/** Get final slip.
*
* @returns Final slip.
*/
- ALE::Obj<real_section_type> finalSlip(void);
+ const topology::Field<topology::SubMesh>& finalSlip(void);
/** Get time when slip begins at each point.
*
* @returns Time when slip begins.
*/
- ALE::Obj<real_section_type> slipTime(void);
+ const topology::Field<topology::SubMesh>& slipTime(void);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
- /// Not implemented
- ConstRateSlipFn(const ConstRateSlipFn& m);
+ ConstRateSlipFn(const ConstRateSlipFn&); ///< Not implemented
+ const ConstRateSlipFn& operator=(const ConstRateSlipFn&); ///< Not implemented
- /// Not implemented
- const ConstRateSlipFn& operator=(const ConstRateSlipFn& f);
-
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- /// Parameters for ConstRate slip time function.
- /// Slip rate (vector), slip time (scalar).
- ALE::Obj<real_section_type> _parameters;
+ double _slipTimeVertex; ///< Slip time at a vertex.
+ double_array _slipRateVertex; ///< Slip rate at a vertex.
+ /// Parameters for constant slip rate slip time function, slip rate
+ /// (vector) and slip time (scalar).
+ topology::Fields<topology::Field<topology::SubMesh> >* _parameters;
+
/// Spatial database for slip rate.
spatialdata::spatialdb::SpatialDB* _dbSlipRate;
/// Spatial database for slip time.
spatialdata::spatialdb::SpatialDB* _dbSlipTime;
- int _spaceDim; ///< Spatial dimension for slip field.
-
}; // class ConstRateSlipFn
#include "ConstRateSlipFn.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/ConstRateSlipFn.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,9 +14,6 @@
#error "ConstRateSlipFn.icc can only be included from ConstRateSlipFn.hh"
#endif
-#include <math.h> // USES exp()
-#include <assert.h> // USES assert()
-
// Set spatial database for slip rate.
inline
void
Modified: short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -32,7 +32,7 @@
// Destructor.
pylith::faults::EqKinSrc::~EqKinSrc(void)
{ // destructor
- _slipfn = 0; // Don't manage memory for slip fn
+ _slipfn = 0; // :TODO: Use shared pointer.
} // destructor
// ----------------------------------------------------------------------
@@ -56,49 +56,49 @@
void
pylith::faults::EqKinSrc::slipfn(SlipTimeFn* slipfn)
{ // slipfn
- _slipfn = slipfn; // Don't manage memory for slip fn
+ _slipfn = slipfn; // :TODO: Use shared pointer.
} // slipfn
// ----------------------------------------------------------------------
// Initialize slip time function.
void
pylith::faults::EqKinSrc::initialize(
- const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
- const spatialdata::units::Nondimensional& normalizer)
+ const topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer)
{ // initialize
+ // :TODO: Normalize slip time in Python?
normalizer.nondimensionalize(&_originTime, 1, normalizer.timeScale());
assert(0 != _slipfn);
- _slipfn->initialize(faultMesh, cs, normalizer, _originTime);
+ _slipfn->initialize(faultMesh, normalizer, _originTime);
} // initialize
// ----------------------------------------------------------------------
// Get slip on fault surface at time t.
void
-pylith::faults::EqKinSrc::slip(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::EqKinSrc::slip(
+ topology::Field<topology::SubMesh>* const slipField,
+ const double t)
{ // slip
assert(0 != _slipfn);
- _slipfn->slip(slipField, t, faultMesh);
+ _slipfn->slip(slipField, t);
} // slip
// ----------------------------------------------------------------------
// Get slip increment on fault surface from time t0 to 1.
void
-pylith::faults::EqKinSrc::slipIncr(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::EqKinSrc::slipIncr(
+ topology::Field<topology::SubMesh>* const slipField,
+ const double t0,
+ const double t1)
{ // slip
assert(0 != _slipfn);
- _slipfn->slipIncr(slipField, t0, t1, faultMesh);
+ _slipfn->slipIncr(slipField, t0, t1);
} // slip
// ----------------------------------------------------------------------
// Get final slip.
-ALE::Obj<pylith::real_section_type>
-pylith::faults::EqKinSrc::finalSlip(void)
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::faults::EqKinSrc::finalSlip(void) const
{ // finalSlip
assert(0 != _slipfn);
return _slipfn->finalSlip();
@@ -106,8 +106,8 @@
// ----------------------------------------------------------------------
// Get time when slip begins at each point.
-ALE::Obj<pylith::real_section_type>
-pylith::faults::EqKinSrc::slipTime(void)
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::faults::EqKinSrc::slipTime(void) const
{ // slipTime
assert(0 != _slipfn);
return _slipfn->slipTime();
Modified: short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/EqKinSrc.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,32 +22,14 @@
#if !defined(pylith_faults_eqkinsrc_hh)
#define pylith_faults_eqkinsrc_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+// Include directives ---------------------------------------------------
+#include "faultsfwd.hh" // forward declarations
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class EqKinSrc;
- class TestEqKinSrc; // unit testing
+#include "pylith/topology/topologyfwd.hh" // USES Field<SubMesh>
- class SlipTimeFn; // HOLDSA SlipTimeFn
- } // faults
-} // pylith
+#include "spatialdata/units/unitsfwd.hh" // USES Nondimensional
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB;
- } // spatialdb
- namespace geocoords {
- class CoordSys;
- } // geocoord
- namespace units {
- class Nondimensional;
- } // units
-} // spatialdata
-
-/// C++ oject for managing parameters for a kinematic earthquake source.
+// EqKinSrc -------------------------------------------------------------
class pylith::faults::EqKinSrc
{ // class EqKinSrc
friend class TestEqKinSrc; // unit testing
@@ -82,55 +64,47 @@
/** Initialize slip time function.
*
* @param faultMesh Finite-element mesh of fault.
- * @param cs Coordinate system for mesh
* @param normalizer Nondimensionalization of scales.
*/
- void initialize(const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
+ void initialize(const topology::SubMesh& faultMesh,
const spatialdata::units::Nondimensional& normalizer);
/** Get slip on fault surface at time t.
*
* @param slipField Slip field over fault mesh.
* @param t Time t.
- * @param faultMesh Finite-element mesh of fault.
*/
- void slip(const ALE::Obj<real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh);
+ void slip(topology::Field<topology::SubMesh>* const slipField,
+ const double t);
/** Get increment of slip on fault surface between time t0 and t1.
*
- * @param slipField Slip field over fault mesh.
- * @param t Time t.
- * @param faultMesh Finite-element mesh of fault.
+ * @param slipField Slip increment field over fault mesh.
+ * @param t0 Time for start of slip increment.
+ * @param t1 Time for end of slip increment.
*/
- void slipIncr(const ALE::Obj<real_section_type>& slipField,
+ void slipIncr(topology::Field<topology::SubMesh>* const slipField,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh);
+ const double t1);
/** Get final slip.
*
* @returns Final slip.
*/
- ALE::Obj<real_section_type> finalSlip(void);
+ const topology::Field<topology::SubMesh>& finalSlip(void) const;
/** Get time when slip begins at each point.
*
* @returns Time when slip begins.
*/
- ALE::Obj<real_section_type> slipTime(void);
+ const topology::Field<topology::SubMesh>& slipTime(void) const;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
- /// Not implemented
- EqKinSrc(const EqKinSrc& s);
+ EqKinSrc(const EqKinSrc&); ///< Not implemented
+ const EqKinSrc& operator=(const EqKinSrc&); ///< Not implemented
- /// Not implemented
- const EqKinSrc& operator=(const EqKinSrc& s);
-
// PRIVATE MEMBERS ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/faults/Fault.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/Fault.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/Fault.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,8 @@
#include "Fault.hh" // implementation of object methods
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::Fault::Fault(void) :
@@ -27,14 +29,15 @@
// Destructor.
pylith::faults::Fault::~Fault(void)
{ // destructor
+ delete _faultMesh; _faultMesh = 0;
} // destructor
// ----------------------------------------------------------------------
// Get mesh associated with fault fields.
-const ALE::Obj<pylith::SubMesh>&
+const pylith::topology::SubMesh&
pylith::faults::Fault:: faultMesh(void) const
{ // faultMesh
- return _faultMesh;
+ return *_faultMesh;
} // faultMesh
Modified: short/3D/PyLith/trunk/libsrc/faults/Fault.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/Fault.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/Fault.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,36 +24,17 @@
#if !defined(pylith_faults_fault_hh)
#define pylith_faults_fault_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh, real_section_type
+// Include directives ---------------------------------------------------
+#include "faultsfwd.hh" // forward declarations
+
+#include "pylith/topology/topologyfwd.hh" // USES Field<SubMesh>, SubMesh
#include "pylith/utils/arrayfwd.hh" // USES double_array
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // USES SpatialDB
+
#include <string> // HASA std::string
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class Fault;
- class TestFault; // unit testing
- } // faults
-
- namespace topology {
- class FieldsManager;
- } // topology
-} // pylith
-
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace geocoords {
- class CoordSys;
- } // geocoords
-
- namespace spatialdb {
- class SpatialDB; // USES SpatialDB
- } // spatialdb
-} // spatialdata
-
-/// C++ abstract base class for Fault object.
+// Fault ----------------------------------------------------------------
class pylith::faults::Fault
{ // class Fault
friend class TestFault; // unit testing
@@ -90,14 +71,15 @@
*
* @returns Label of fault
*/
- const std::string& label(void) const;
+ const char* label(void) const;
/** Adjust mesh topology for fault implementation.
*
* @param mesh PETSc mesh
*/
virtual
- void adjustTopology(const ALE::Obj<Mesh>& mesh, const bool flipFault = false) = 0;
+ void adjustTopology(topology::Mesh* const mesh,
+ const bool flipFault =false) = 0;
/** Initialize fault. Determine orientation and setup boundary
* condition parameters.
@@ -114,61 +96,49 @@
* (used to improve conditioning of Jacobian matrix)
*/
virtual
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir,
- const double_array& normalDir,
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
spatialdata::spatialdb::SpatialDB* matDB) = 0;
/** Get mesh associated with fault fields.
*
* @returns PETSc mesh object
*/
- const ALE::Obj<SubMesh>& faultMesh(void) const;
+ const topology::SubMesh& faultMesh(void) const;
/** Get vertex field associated with integrator.
*
- * @param fieldType Type of field.
* @param name Name of vertex field.
- * @param mesh PETSc mesh for problem.
- * @param fields Fields manager.
+ * @param fields Solution fields.
* @returns Vertex field.
*/
virtual
- const ALE::Obj<real_section_type>&
- vertexField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields) = 0;
+ const topology::Field<topology::SubMesh>&
+ vertexField(const char* name,
+ const topology::SolutionFields* fields =0) = 0;
/** Get cell field associated with integrator.
*
- * @param fieldType Type of field.
* @param name Name of cell field.
- * @param mesh PETSc mesh for problem.
- * @param fields Fields manager.
+ * @param fields Solution fields.
* @returns Cell field.
*/
virtual
- const ALE::Obj<real_section_type>&
- cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields) = 0;
+ const topology::Field<topology::SubMesh>&
+ cellField(const char* name,
+ const topology::SolutionFields* fields =0) = 0;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
- /// Not implemented
- Fault(const Fault& m);
+ Fault(const Fault&); ///< Not implemented
+ const Fault& operator=(const Fault&); ///< Not implemented
- /// Not implemented
- const Fault& operator=(const Fault& m);
-
// PROTECTED MEMBERS ////////////////////////////////////////////////////
protected :
- ALE::Obj<SubMesh> _faultMesh; ///< Mesh over fault surface
+ topology::SubMesh* _faultMesh; ///< Mesh over fault surface
// PRIVATE MEMBERS ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/faults/Fault.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/Fault.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/Fault.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -37,9 +37,9 @@
// Get label of fault.
inline
-const std::string&
+const char*
pylith::faults::Fault::label(void) const {
- return _label;
+ return _label.c_str();
}
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,13 +14,10 @@
#include "FaultCohesive.hh" // implementation of object methods
-#include "CohesiveTopology.hh" // USES CohesiveTopology::create()
+#include "CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/meshio/UCDFaultFile.hh" // USES UCDFaultFile
-#include "pylith/meshio/MeshIOLagrit.hh" // USES MeshIOLagrit::readFault()
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-#include "pylith/utils/array.hh" // USES double_array
-
#include <cassert> // USES assert()
#include <sstream> // USES std::ostringstream
#include <stdexcept> // USES std::runtime_error
@@ -59,49 +56,50 @@
// ----------------------------------------------------------------------
// Adjust mesh topology for fault implementation.
void
-pylith::faults::FaultCohesive::adjustTopology(const ALE::Obj<Mesh>& mesh,
+pylith::faults::FaultCohesive::adjustTopology(topology::Mesh* const mesh,
const bool flipFault)
{ // adjustTopology
+ assert(0 != mesh);
assert(std::string("") != label());
- Obj<SubMesh> faultMesh = NULL;
- Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
+ ALE::Obj<ALE::Mesh> faultBoundary;
+
+ // Get group of vertices associated with fault
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<topology::Mesh::IntSection>& groupField =
+ sieveMesh->getIntSection(label());
+ assert(!groupField.isNull());
+
if (_useFaultMesh) {
const int faultDim = 2;
+ assert(3 == mesh->dimension());
- //MPI_Bcast(&faultDim, 1, MPI_INT, 0, comm);
- faultMesh = new SubMesh(mesh->comm(), faultDim, mesh->debug());
- pylith::meshio::MeshIOLagrit::readFault(_faultMeshFilename, mesh,
- faultMesh, faultBd);
+ meshio::UCDFaultFile::read(_faultMeshFilename.c_str(),
+ &faultMesh, faultBoundary, *mesh);
- // Get group of vertices associated with fault
- const ALE::Obj<int_section_type>& groupField =
- mesh->getIntSection(label());
- faultMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ // Set coordinates in fault mesh
+ const ALE::Obj<topology::SubMesh::SieveMesh>& faultSieveMesh =
+ faultMesh.sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
- CohesiveTopology::create(faultMesh, faultBd, mesh, groupField, id(),
+ CohesiveTopology::create(mesh, faultMesh, faultBoundary, groupField, id(),
_useLagrangeConstraints());
} else {
- if (!mesh->hasIntSection(label())) {
+ if (!sieveMesh->hasIntSection(label())) {
std::ostringstream msg;
msg << "Mesh missing group of vertices '" << label()
<< " for fault interface condition.";
throw std::runtime_error(msg.str());
} // if
- // Get group of vertices associated with fault
- const ALE::Obj<int_section_type>& groupField =
- mesh->getIntSection(label());
- assert(!groupField.isNull());
-
- faultMesh =
- new SubMesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
-
- CohesiveTopology::createFault(faultMesh, faultBd, mesh, groupField,
+ CohesiveTopology::createFault(&faultMesh, faultBoundary, *mesh, groupField,
flipFault);
- CohesiveTopology::create(faultMesh, faultBd, mesh, groupField, id(),
+ CohesiveTopology::create(mesh, faultMesh, faultBoundary, groupField, id(),
_useLagrangeConstraints());
} // if/else
} // adjustTopology
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesive.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,21 +19,10 @@
#if !defined(pylith_faults_faultcohesive_hh)
#define pylith_faults_faultcohesive_hh
+// Include directives ---------------------------------------------------
#include "Fault.hh" // ISA Fault
-#include "pylith/utils/sievefwd.hh" // HOLDSA PETSc Mesh
-#include "pylith/utils/petscfwd.h" // USES PetscMat
-
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class FaultCohesive;
- class TestFaultCohesive; // unit testing
- } // faults
-} // pylith
-
-/// C++ abstract base class for a fault surface implemented with
-/// cohesive elements.
+// FaultCohesive --------------------------------------------------------
class pylith::faults::FaultCohesive : public Fault
{ // class FaultCohesive
friend class TestFaultCohesive; // unit testing
@@ -64,9 +53,11 @@
/** Adjust mesh topology for fault implementation.
*
- * @param mesh PETSc mesh
+ * @param mesh PETSc mesh.
+ * @param flipFault Flip fault orientation.
*/
- void adjustTopology(const ALE::Obj<Mesh>& mesh, const bool flipFault = false);
+ void adjustTopology(topology::Mesh* const mesh,
+ const bool flipFault =false);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,17 +14,14 @@
#include "FaultCohesiveDyn.hh" // implementation of object methods
-#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#include "pylith/utils/array.hh" // USES double_array
-
-#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
-
#include <cassert> // USES assert()
#include <sstream> // USES std::ostringstream
#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::FaultCohesiveDyn::FaultCohesiveDyn(void)
{ // constructor
@@ -39,10 +36,9 @@
// ----------------------------------------------------------------------
// Initialize fault. Determine orientation and setup boundary
void
-pylith::faults::FaultCohesiveDyn::initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir,
- const double_array& normalDir,
+pylith::faults::FaultCohesiveDyn::initialize(const topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
spatialdata::spatialdb::SpatialDB* matDB)
{ // initialize
throw std::logic_error("FaultCohesiveDyn::initialize() not implemented.");
@@ -52,11 +48,9 @@
// Integrate contribution of cohesive cells to residual term.
void
pylith::faults::FaultCohesiveDyn::integrateResidual(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateResidual
throw std::logic_error("FaultCohesiveDyn::integrateResidual() not implemented.");
} // integrateResidual
@@ -65,24 +59,25 @@
// Compute Jacobian matrix (A) associated with operator.
void
pylith::faults::FaultCohesiveDyn::integrateJacobian(
- PetscMat* mat,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh)
+ topology::Jacobian* jacobian,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateJacobian
throw std::logic_error("FaultCohesiveDyn::integrateJacobian() not implemented.");
} // integrateJacobian
-
// ----------------------------------------------------------------------
// Verify configuration is acceptable.
void
pylith::faults::FaultCohesiveDyn::verifyConfiguration(
- const ALE::Obj<Mesh>& mesh) const
+ const topology::Mesh& mesh) const
{ // verifyConfiguration
assert(0 != _quadrature);
- if (!mesh->hasIntSection(label())) {
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ if (!sieveMesh->hasIntSection(label())) {
std::ostringstream msg;
msg << "Mesh missing group of vertices '" << label()
<< " for boundary condition.";
@@ -90,7 +85,7 @@
} // if
// check compatibility of mesh and quadrature scheme
- const int dimension = mesh->getDimension()-1;
+ const int dimension = mesh.dimension()-1;
if (_quadrature->cellDim() != dimension) {
std::ostringstream msg;
msg << "Dimension of reference cell in quadrature scheme ("
@@ -101,15 +96,15 @@
throw std::runtime_error(msg.str());
} // if
const int numCorners = _quadrature->numBasis();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", id());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", id());
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsBegin = cells->begin();
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
- for (Mesh::label_sequence::iterator c_iter=cellsBegin;
+ const SieveMesh::label_sequence::iterator cellsBegin = cells->begin();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ for (SieveMesh::label_sequence::iterator c_iter=cellsBegin;
c_iter != cellsEnd;
++c_iter) {
- const int cellNumCorners = mesh->getNumCellCorners(*c_iter);
+ const int cellNumCorners = sieveMesh->getNumCellCorners(*c_iter);
if (3*numCorners != cellNumCorners) {
std::ostringstream msg;
msg << "Number of vertices in reference cell (" << numCorners
@@ -123,38 +118,22 @@
// ----------------------------------------------------------------------
// Get vertex field associated with integrator.
-const ALE::Obj<pylith::real_section_type>&
-pylith::faults::FaultCohesiveDyn::vertexField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* fields)
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::faults::FaultCohesiveDyn::vertexField(
+ const char* name,
+ const topology::SolutionFields* fields)
{ // vertexField
- // Should not reach this point if requested field was found
- std::ostringstream msg;
- msg << "Request for unknown vertex field '" << name
- << "' for fault '" << label() << ".";
- throw std::runtime_error(msg.str());
-
- // Return generic section to satisfy member function definition.
- //return _outputVertxScalar;
+ throw std::logic_error("FaultCohesiveDyn::vertexField() not implemented.");
} // vertexField
// ----------------------------------------------------------------------
// Get cell field associated with integrator.
-const ALE::Obj<pylith::real_section_type>&
-pylith::faults::FaultCohesiveDyn::cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* fields)
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::faults::FaultCohesiveDyn::cellField(
+ const char* name,
+ const topology::SolutionFields* fields)
{ // cellField
- // Should not reach this point if requested field was found
- std::ostringstream msg;
- msg << "Request for unknown cell field '" << name
- << "' for fault '" << label() << ".";
- throw std::runtime_error(msg.str());
-
- // Return generic section to satisfy member function definition.
- //return _outputCellVector;
+ throw std::logic_error("FaultCohesiveDyn::vertexField() not implemented.");
} // cellField
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveDyn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,30 +23,16 @@
#if !defined(pylith_faults_faultcohesivedyn_hh)
#define pylith_faults_faultcohesivedyn_hh
+// Include directives ---------------------------------------------------
#include "FaultCohesive.hh" // ISA FaultCohesive
-#include "pylith/feassemble/Integrator.hh" // ISA Constraint
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class FaultCohesiveDyn;
- class TestFaultCohesiveDyn; // unit testing
- } // faults
-} // pylith
+#include "pylith/topology/SubMesh.hh" // ISA Integrator<Quadrature<SubMesh> >
+#include "pylith/feassemble/Quadrature.hh" // ISA Integrator<Quadrature>
+#include "pylith/feassemble/Integrator.hh" // ISA Integrator
-/*
-namespace spatialdata {
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-*/
-
-
-/// @brief C++ implementation for a fault surface with spontaneous
-/// (dynamic) slip implemented with cohesive elements.
+// FaultCohesiveDyn -----------------------------------------------------
class pylith::faults::FaultCohesiveDyn : public FaultCohesive,
- public feassemble::Integrator
+ public feassemble::Integrator<feassemble::Quadrature<topology::SubMesh> >
{ // class FaultCohesiveDyn
friend class TestFaultCohesiveDyn; // unit testing
@@ -63,8 +49,7 @@
/** Initialize fault. Determine orientation and setup boundary
* condition parameters.
*
- * @param mesh PETSc mesh
- * @param cs Coordinate system for mesh
+ * @param mesh Finite-element mesh.
* @param upDir Direction perpendicular to along-strike direction that is
* not collinear with fault normal (usually "up" direction but could
* be up-dip direction; only applies to fault surfaces in a 3-D domain).
@@ -74,73 +59,59 @@
* @param matDB Database of bulk elastic properties for fault region
* (used to improve conditioning of Jacobian matrix)
*/
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir,
- const double_array& normalDir,
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
spatialdata::spatialdb::SpatialDB* matDB);
/** Integrate contribution of cohesive cells to residual term.
*
- * @param residual Residual field (output)
+ * @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
- * @param cs Mesh coordinate system
*/
- void integrateResidual(const ALE::Obj<real_section_type>& residual,
+ void integrateResidual(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
- /** Compute Jacobian matrix (A) associated with operator.
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
*
- * @param mat Sparse matrix
+ * @param jacobian Sparse matrix for Jacobian of system.
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
- void integrateJacobian(PetscMat* mat,
+ void integrateJacobian(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
/** Verify configuration is acceptable.
*
* @param mesh Finite-element mesh
*/
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const;
+ void verifyConfiguration(const topology::Mesh& mesh) const;
/** Get vertex field associated with integrator.
*
- * @param fieldType Type of field.
* @param name Name of vertex field.
- * @param mesh PETSc mesh for problem.
- * @param fields Fields manager.
+ * @param fields Solution fields.
*
* @returns Vertex field.
*/
- const ALE::Obj<real_section_type>&
- vertexField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ const topology::Field<topology::SubMesh>&
+ vertexField(const char* name,
+ const topology::SolutionFields* fields =0);
/** Get cell field associated with integrator.
*
- * @param fieldType Type of field.
- * @param name Name of vertex field.
- * @param mesh PETSc mesh for problem.
- * @param fields Fields manager.
+ * @param name Name of cell field.
+ * @param fields Solution fields.
*
* @returns Cell field.
*/
- const ALE::Obj<real_section_type>&
- cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ const topology::Field<topology::SubMesh>&
+ cellField(const char* name,
+ const topology::SolutionFields* fields =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -156,17 +127,17 @@
private :
/// Not implemented
- FaultCohesiveDyn(const FaultCohesiveDyn& m);
+ FaultCohesiveDyn(const FaultCohesiveDyn&);
/// Not implemented
- const FaultCohesiveDyn& operator=(const FaultCohesiveDyn& m);
+ const FaultCohesiveDyn& operator=(const FaultCohesiveDyn&);
// PRIVATE MEMBERS ////////////////////////////////////////////////////
private :
/// Orientation of fault surface at vertices (fiber dimension is
/// nonzero only at constraint vertices)
- ALE::Obj<real_section_type> _orientation;
+ topology::Field<topology::SubMesh>* _orientation;
}; // class FaultCohesiveDyn
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,18 +19,18 @@
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/CellGeometry.hh" // USES CellGeometry
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#include "pylith/topology/FieldOps.hh" // USES FieldOps
-#include "pylith/utils/array.hh" // USES double_array
-#include <petscmat.h> // USES PETSc Mat
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
-#include "spatialdata/spatialdb/SpatialDB.hh" // USES CoordSys
+#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-#include <Completion.hh> // USES completeSection
-#include <Selection.hh> // Algorithms for submeshes
-
#include <cmath> // USES pow(), sqrt()
#include <strings.h> // USES strcasecmp()
#include <cstring> // USES strlen()
@@ -40,8 +40,16 @@
#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
+
+// ----------------------------------------------------------------------
// Default constructor.
-pylith::faults::FaultCohesiveKin::FaultCohesiveKin(void)
+pylith::faults::FaultCohesiveKin::FaultCohesiveKin(void) :
+ _fields(0),
+ _bufferVectorField(0),
+ _bufferScalarField(0)
{ // constructor
} // constructor
@@ -49,85 +57,98 @@
// Destructor.
pylith::faults::FaultCohesiveKin::~FaultCohesiveKin(void)
{ // destructor
- // Don't manage memory for eq source pointers
+ delete _fields; _fields = 0;
+ delete _bufferVectorField; _bufferVectorField = 0;
+ delete _bufferScalarField; _bufferScalarField = 0;
+ // :TODO: Use shared pointers for earthquake sources
} // destructor
// ----------------------------------------------------------------------
// Set kinematic earthquake source.
void
-pylith::faults::FaultCohesiveKin::eqsrcs(const char** names,
+pylith::faults::FaultCohesiveKin::eqsrcs(const char* const* names,
+ const int numNames,
EqKinSrc** sources,
const int numSources)
{ // eqsrcs
+ assert(numNames == numSources);
+
+ // :TODO: Use shared pointers for earthquake sources
_eqSrcs.clear();
for (int i=0; i < numSources; ++i) {
if (0 == sources[i])
throw std::runtime_error("Null earthquake source.");
- _eqSrcs[std::string(names[i])] = sources[i]; // Don't manage memory for eq source
+ _eqSrcs[std::string(names[i])] = sources[i];
} // for
} // eqsrcs
// ----------------------------------------------------------------------
// Initialize fault. Determine orientation and setup boundary
void
-pylith::faults::FaultCohesiveKin::initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir,
- const double_array& normalDir,
+pylith::faults::FaultCohesiveKin::initialize(const topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
spatialdata::spatialdb::SpatialDB* matDB)
{ // initialize
+ assert(0 != upDir);
+ assert(0 != normalDir);
assert(0 != _quadrature);
+
+ const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
+ assert(0 != cs);
- if (3 != upDir.size())
- throw std::runtime_error("Up direction for fault orientation must be "
- "a vector with 3 components.");
- if (3 != normalDir.size())
- throw std::runtime_error("Normal direction for fault orientation must be "
- "a vector with 3 components.");
+ delete _faultMesh; _faultMesh = new topology::SubMesh();
+ CohesiveTopology::createFaultParallel(_faultMesh, &_cohesiveToFault,
+ mesh, id(), _useLagrangeConstraints());
- CohesiveTopology::createParallel(&_faultMesh, &_cohesiveToFault, mesh, id(),
- _useLagrangeConstraints());
- //_faultMesh->getLabel("height")->view("Fault mesh height");
- //_faultMesh->view("FAULT MESH");
+ delete _fields;
+ _fields = new topology::Fields<topology::Field<topology::SubMesh> >(*_faultMesh);
- // Setup pseudo-stiffness of cohesive cells to improve conditioning
- // of Jacobian matrix
- _calcConditioning(cs, matDB);
-
- // Compute orientation at vertices in fault mesh.
- _calcOrientation(upDir, normalDir);
-
- // Compute tributary area for each vertex in fault mesh.
- _calcArea();
-
const srcs_type::const_iterator srcsEnd = _eqSrcs.end();
for (srcs_type::iterator s_iter=_eqSrcs.begin();
s_iter != srcsEnd;
++s_iter) {
EqKinSrc* src = s_iter->second;
assert(0 != src);
- src->initialize(_faultMesh, cs, *_normalizer);
+ src->initialize(*_faultMesh, *_normalizer);
} // for
// Allocate slip field
- const ALE::Obj<SubMesh::label_sequence>& vertices = _faultMesh->depthStratum(0);
- _slip = new real_section_type(_faultMesh->comm(), _faultMesh->debug());
- _slip->setChart(real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- _slip->setFiberDimension(vertices, cs->spaceDim());
- _faultMesh->allocate(_slip);
- assert(!_slip.isNull());
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ _fields->add("slip", "slip");
+ topology::Field<topology::SubMesh>& slip = _fields->get("slip");
+ slip.newSection(vertices, cs->spaceDim());
+ slip.allocate();
// Allocate cumulative slip field
- _cumSlip = new real_section_type(_faultMesh->comm(), _faultMesh->debug());
- _cumSlip->setChart(real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- _cumSlip->setFiberDimension(vertices, cs->spaceDim());
- _faultMesh->allocate(_cumSlip);
- assert(!_cumSlip.isNull());
+ _fields->add("cumulative slip", "cumulative_slip");
+ topology::Field<topology::SubMesh>& cumSlip = _fields->get("cumulative slip");
+ cumSlip.newSection(slip);
+ cumSlip.allocate();
+ // Setup pseudo-stiffness of cohesive cells to improve conditioning
+ // of Jacobian matrix
+ _calcConditioning(cs, matDB);
+
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ faultSieveMesh->heightStratum(0);
+ assert(!cells.isNull());
+ const SieveSubMesh::label_sequence::iterator cellsBegin = cells->begin();
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
+ _quadrature->computeGeometry(*_faultMesh, cells);
+
+ // Compute orientation at vertices in fault mesh.
+ _calcOrientation(upDir, normalDir);
+
+ // Compute tributary area for each vertex in fault mesh.
+ _calcArea();
+
+ // Create empty tractions field for change in fault tractions.
+ _fields->add("tractions", "tractions_change");
} // initialize
// ----------------------------------------------------------------------
@@ -135,15 +156,13 @@
// require assembly across processors.
void
pylith::faults::FaultCohesiveKin::integrateResidual(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateResidual
- assert(!residual.isNull());
assert(0 != fields);
- assert(!mesh.isNull());
+ assert(0 != _quadrature);
+ assert(0 != _fields);
// Cohesive cells with normal vertices i and j, and constraint
// vertex k make 2 contributions to the residual:
@@ -167,57 +186,94 @@
const double_array& basis = _quadrature->basis();
const double_array& jacobianDet = _quadrature->jacobianDet();
- double_array cellOrientation(numConstraintVert*orientationSize);
- double_array cellSoln(numCorners*spaceDim);
- double_array cellStiffness(numConstraintVert);
- double_array cellResidual(numCorners*spaceDim);
- double_array cellArea(numConstraintVert);
- double_array cellAreaAssembled(numConstraintVert);
+ // Allocate vectors for cell values
+ double_array orientationCell(numConstraintVert*orientationSize);
+ double_array stiffnessCell(numConstraintVert);
+ double_array solutionCell(numCorners*spaceDim);
+ double_array residualCell(numCorners*spaceDim);
+ double_array areaCell(numConstraintVert);
+ double_array areaAssembledCell(numConstraintVert);
// Get cohesive cells
- const ALE::Obj<Mesh::label_sequence>& cellsCohesive =
- mesh->getLabelStratum("material-id", id());
+ const ALE::Obj<SieveMesh>& sieveMesh = residual.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cellsCohesive =
+ sieveMesh->getLabelStratum("material-id", id());
assert(!cellsCohesive.isNull());
- const Mesh::label_sequence::iterator cellsCohesiveBegin =
+ const SieveMesh::label_sequence::iterator cellsCohesiveBegin =
cellsCohesive->begin();
- const Mesh::label_sequence::iterator cellsCohesiveEnd =
+ const SieveMesh::label_sequence::iterator cellsCohesiveEnd =
cellsCohesive->end();
const int cellsCohesiveSize = cellsCohesive->size();
+ // Get fault Sieve mesh
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+
// Get section information
- const ALE::Obj<real_section_type>& solution = fields->getSolution();
- assert(!solution.isNull());
+ const ALE::Obj<RealSection>& orientationSection =
+ _fields->get("orientation").section();
+ assert(!orientationSection.isNull());
+ topology::Mesh::RestrictVisitor orientationVisitor(*orientationSection,
+ orientationCell.size(),
+ &orientationCell[0]);
- for (Mesh::label_sequence::iterator c_iter=cellsCohesiveBegin;
+ const ALE::Obj<RealSection>& stiffnessSection =
+ _fields->get("pseudostiffness").section();
+ assert(!stiffnessSection.isNull());
+ topology::Mesh::RestrictVisitor stiffnessVisitor(*stiffnessSection,
+ stiffnessCell.size(),
+ &stiffnessCell[0]);
+
+ const ALE::Obj<RealSection>& areaSection =
+ _fields->get("area").section();
+ assert(!areaSection.isNull());
+ topology::Mesh::RestrictVisitor areaVisitor(*areaSection,
+ areaAssembledCell.size(),
+ &areaAssembledCell[0]);
+
+ topology::Field<topology::Mesh>& solution = fields->solution();
+ const ALE::Obj<RealSection>& solutionSection = solution.section();
+ assert(!solutionSection.isNull());
+ topology::Mesh::RestrictVisitor solutionVisitor(*solutionSection,
+ solutionCell.size(),
+ &solutionCell[0]);
+
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ topology::Mesh::UpdateAddVisitor residualVisitor(*residualSection,
+ &residualCell[0]);
+
+ for (SieveMesh::label_sequence::iterator c_iter=cellsCohesiveBegin;
c_iter != cellsCohesiveEnd;
++c_iter) {
- const Mesh::point_type c_fault = _cohesiveToFault[*c_iter];
- cellArea = 0.0;
- cellResidual = 0.0;
+ const SieveMesh::point_type c_fault = _cohesiveToFault[*c_iter];
+ areaCell = 0.0;
+ residualCell = 0.0;
// Compute contributory area for cell (to weight contributions)
for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
const double wt = quadWts[iQuad] * jacobianDet[iQuad];
for (int iBasis=0; iBasis < numBasis; ++iBasis) {
const double dArea = wt*basis[iQuad*numBasis+iBasis];
- cellArea[iBasis] += dArea;
+ areaCell[iBasis] += dArea;
} // for
} // for
// Get orientations at fault cell's vertices.
- _faultMesh->restrictClosure(_orientation, c_fault, &cellOrientation[0],
- cellOrientation.size());
+ orientationVisitor.clear();
+ faultSieveMesh->restrictClosure(c_fault, orientationVisitor);
// Get pseudo stiffness at fault cell's vertices.
- _faultMesh->restrictClosure(_pseudoStiffness, c_fault, &cellStiffness[0],
- cellStiffness.size());
+ stiffnessVisitor.clear();
+ faultSieveMesh->restrictClosure(c_fault, stiffnessVisitor);
- // Get pseudo stiffness at fault cell's vertices.
- _faultMesh->restrictClosure(_area, c_fault, &cellAreaAssembled[0],
- cellAreaAssembled.size());
+ // Get area at fault cell's vertices.
+ areaVisitor.clear();
+ faultSieveMesh->restrictClosure(c_fault, areaVisitor);
// Get solution at cohesive cell's vertices.
- mesh->restrictClosure(solution, *c_iter, &cellSoln[0], cellSoln.size());
+ solutionVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, solutionVisitor);
for (int iConstraint=0; iConstraint < numConstraintVert; ++iConstraint) {
// Blocks in cell matrix associated with normal cohesive
@@ -226,49 +282,51 @@
const int indexJ = iConstraint + numConstraintVert;
const int indexK = iConstraint + 2*numConstraintVert;
- const double pseudoStiffness = cellStiffness[iConstraint];
+ const double pseudoStiffness = stiffnessCell[iConstraint];
+ //assert(areaAssembledCell[iConstraint] > 0);
const double wt = pseudoStiffness *
- cellArea[iConstraint] / cellAreaAssembled[iConstraint];
+ areaCell[iConstraint] / areaAssembledCell[iConstraint];
// Get orientation at constraint vertex
- const real_section_type::value_type* constraintOrient =
- &cellOrientation[iConstraint*orientationSize];
- assert(0 != constraintOrient);
+ const double* orientationVertex =
+ &orientationCell[iConstraint*orientationSize];
+ assert(0 != orientationVertex);
// Entries associated with constraint forces applied at node i
for (int iDim=0; iDim < spaceDim; ++iDim) {
for (int kDim=0; kDim < spaceDim; ++kDim)
- cellResidual[indexI*spaceDim+iDim] -=
- cellSoln[indexK*spaceDim+kDim] *
- -constraintOrient[kDim*spaceDim+iDim] * wt;
+ residualCell[indexI*spaceDim+iDim] -=
+ solutionCell[indexK*spaceDim+kDim] *
+ -orientationVertex[kDim*spaceDim+iDim] * wt;
} // for
// Entries associated with constraint forces applied at node j
for (int jDim=0; jDim < spaceDim; ++jDim) {
for (int kDim=0; kDim < spaceDim; ++kDim)
- cellResidual[indexJ*spaceDim+jDim] -=
- cellSoln[indexK*spaceDim+kDim] *
- constraintOrient[kDim*spaceDim+jDim] * wt;
+ residualCell[indexJ*spaceDim+jDim] -=
+ solutionCell[indexK*spaceDim+kDim] *
+ orientationVertex[kDim*spaceDim+jDim] * wt;
} // for
} // for
#if 0 // DEBUGGING
std::cout << "Updating fault residual for cell " << *c_iter << std::endl;
for(int i = 0; i < numConstraintVert; ++i) {
- std::cout << " stif["<<i<<"]: " << cellStiffness[i] << std::endl;
+ std::cout << " stif["<<i<<"]: " << stiffnessCell[i] << std::endl;
}
for(int i = 0; i < numConstraintVert*spaceDim; ++i) {
std::cout << " slip["<<i<<"]: " << cellSlip[i] << std::endl;
}
for(int i = 0; i < numCorners*spaceDim; ++i) {
- std::cout << " soln["<<i<<"]: " << cellSoln[i] << std::endl;
+ std::cout << " soln["<<i<<"]: " << solutionCell[i] << std::endl;
}
for(int i = 0; i < numCorners*spaceDim; ++i) {
- std::cout << " v["<<i<<"]: " << cellResidual[i] << std::endl;
+ std::cout << " v["<<i<<"]: " << residualCell[i] << std::endl;
}
#endif
- mesh->updateAdd(residual, *c_iter, &cellResidual[0]);
+ residualVisitor.clear();
+ sieveMesh->updateAdd(*c_iter, residualVisitor);
} // for
// FIX THIS
@@ -280,15 +338,12 @@
// not require assembly across cells, vertices, or processors.
void
pylith::faults::FaultCohesiveKin::integrateResidualAssembled(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateResidualAssembled
- assert(!residual.isNull());
assert(0 != fields);
- assert(!mesh.isNull());
+ assert(0 != _fields);
// Cohesive cells with normal vertices i and j, and constraint
// vertex k make 2 contributions to the residual:
@@ -297,8 +352,8 @@
// slip
// * DOF k: slip values
- assert(!_slip.isNull());
- _slip->zero();
+ topology::Field<topology::SubMesh>& slip = _fields->get("slip");
+ slip.zero();
if (!_useSolnIncr) {
// Compute slip field at current time step
const srcs_type::const_iterator srcsEnd = _eqSrcs.end();
@@ -308,7 +363,7 @@
EqKinSrc* src = s_iter->second;
assert(0 != src);
if (t >= src->originTime())
- src->slip(_slip, t, _faultMesh);
+ src->slip(&slip, t);
} // for
} else {
// Compute increment of slip field at current time step
@@ -319,27 +374,43 @@
EqKinSrc* src = s_iter->second;
assert(0 != src);
if (t >= src->originTime())
- src->slipIncr(_slip, t-_dt, t, _faultMesh);
+ src->slipIncr(&slip, t-_dt, t);
} // for
} // else
const int spaceDim = _quadrature->spaceDim();
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+
+ // Get sections
+ const ALE::Obj<SieveMesh>& sieveMesh = residual.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ assert(!slipSection.isNull());
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ assert(!residualSection.isNull());
+
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
assert(!vertices.isNull());
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- Mesh::renumbering_type& renumbering = _faultMesh->getRenumbering();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesBegin =
+ vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ SieveSubMesh::renumbering_type& renumbering =
+ faultSieveMesh->getRenumbering();
+ const SieveSubMesh::renumbering_type::const_iterator renumberingEnd =
+ renumbering.end();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter)
- if (renumbering.find(*v_iter) != renumbering.end()) {
+ if (renumbering.find(*v_iter) != renumberingEnd) {
const int vertexFault = renumbering[*v_iter];
const int vertexMesh = *v_iter;
- const real_section_type::value_type* slip =
- _slip->restrictPoint(vertexFault);
- assert(spaceDim == _slip->getFiberDimension(vertexFault));
- assert(spaceDim == residual->getFiberDimension(vertexMesh));
- assert(0 != slip);
- residual->updatePoint(vertexMesh, slip);
+ const double* slipVertex = slipSection->restrictPoint(vertexFault);
+ assert(spaceDim == slipSection->getFiberDimension(vertexFault));
+ assert(spaceDim == residualSection->getFiberDimension(vertexMesh));
+ assert(0 != slipVertex);
+ residualSection->updatePoint(vertexMesh, slipVertex);
} // if
} // integrateResidualAssembled
@@ -348,16 +419,16 @@
// require assembly across cells, vertices, or processors.
void
pylith::faults::FaultCohesiveKin::integrateJacobianAssembled(
- PetscMat* mat,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh)
+ topology::Jacobian* jacobian,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateJacobianAssembled
- assert(0 != mat);
+ assert(0 != jacobian);
assert(0 != fields);
- assert(!mesh.isNull());
- typedef ALE::ISieveVisitor::IndicesVisitor<Mesh::real_section_type,Mesh::order_type,PetscInt> visitor_type;
+ assert(0 != _fields);
+ typedef ALE::ISieveVisitor::IndicesVisitor<RealSection,SieveMesh::order_type,PetscInt> visitor_type;
+
// Add constraint information to Jacobian matrix; these are the
// direction cosines. Entries are associated with vertices ik, jk,
// ki, and kj.
@@ -365,29 +436,46 @@
PetscErrorCode err = 0;
// Get cohesive cells
- const ALE::Obj<Mesh::label_sequence>& cellsCohesive =
- mesh->getLabelStratum("material-id", id());
+ const ALE::Obj<SieveMesh>& sieveMesh = fields->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cellsCohesive =
+ sieveMesh->getLabelStratum("material-id", id());
assert(!cellsCohesive.isNull());
- const Mesh::label_sequence::iterator cellsCohesiveBegin =
+ const SieveMesh::label_sequence::iterator cellsCohesiveBegin =
cellsCohesive->begin();
- const Mesh::label_sequence::iterator cellsCohesiveEnd =
+ const SieveMesh::label_sequence::iterator cellsCohesiveEnd =
cellsCohesive->end();
const int cellsCohesiveSize = cellsCohesive->size();
- // Get section information
- const ALE::Obj<real_section_type>& solution = fields->getSolution();
- assert(!solution.isNull());
-
const int spaceDim = _quadrature->spaceDim();
const int orientationSize = spaceDim*spaceDim;
const int numConstraintVert = _quadrature->numBasis();
const int numCorners = 3*numConstraintVert; // cohesive cell
- double_array cellMatrix(numCorners*spaceDim * numCorners*spaceDim);
- double_array cellOrientation(numConstraintVert*orientationSize);
- double_array cellStiffness(numConstraintVert);
+ double_array matrixCell(numCorners*spaceDim * numCorners*spaceDim);
+ double_array orientationCell(numConstraintVert*orientationSize);
+ double_array stiffnessCell(numConstraintVert);
-#if 0
+ // Get section information
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ const ALE::Obj<RealSection>& solutionSection = fields->solution().section();
+ assert(!solutionSection.isNull());
+ const ALE::Obj<RealSection>& orientationSection =
+ _fields->get("orientation").section();
+ assert(!orientationSection.isNull());
+ topology::Mesh::RestrictVisitor orientationVisitor(*orientationSection,
+ orientationCell.size(),
+ &orientationCell[0]);
+
+ const ALE::Obj<RealSection>& stiffnessSection =
+ _fields->get("pseudostiffness").section();
+ assert(!stiffnessSection.isNull());
+ topology::Mesh::RestrictVisitor stiffnessVisitor(*stiffnessSection,
+ stiffnessCell.size(),
+ &stiffnessCell[0]);
+
+#if 0 // DEBUGGING
// Check that fault cells match cohesive cells
ALE::ISieveVisitor::PointRetriever<sieve_type> cV(std::max(1, mesh->getSieve()->getMaxConeSize()));
ALE::ISieveVisitor::PointRetriever<sieve_type> cV2(std::max(1, _faultMesh->getSieve()->getMaxConeSize()));
@@ -415,23 +503,30 @@
}
#endif
- const ALE::Obj<Mesh::order_type>& globalOrder = mesh->getFactory()->getGlobalOrder(mesh, "default", solution);
+ const PetscMat jacobianMatrix = jacobian->matrix();
+ assert(0 != jacobianMatrix);
+ const ALE::Obj<SieveMesh::order_type>& globalOrder =
+ sieveMesh->getFactory()->getGlobalOrder(sieveMesh, "default", solutionSection);
assert(!globalOrder.isNull());
- visitor_type iV(*solution, *globalOrder, (int) pow(mesh->getSieve()->getMaxConeSize(), mesh->depth())*spaceDim);
+ // We would need to request unique points here if we had an interpolated mesh
+ topology::Mesh::IndicesVisitor jacobianVisitor(*solutionSection,
+ *globalOrder,
+ (int) pow(sieveMesh->getSieve()->getMaxConeSize(),
+ sieveMesh->depth())*spaceDim);
- for (Mesh::label_sequence::iterator c_iter=cellsCohesiveBegin;
+ for (SieveMesh::label_sequence::iterator c_iter=cellsCohesiveBegin;
c_iter != cellsCohesiveEnd;
++c_iter) {
- const Mesh::point_type c_fault = _cohesiveToFault[*c_iter];
+ const SieveMesh::point_type c_fault = _cohesiveToFault[*c_iter];
- cellMatrix = 0.0;
+ matrixCell = 0.0;
// Get orientations at fault cell's vertices.
- _faultMesh->restrictClosure(_orientation, c_fault, &cellOrientation[0],
- cellOrientation.size());
+ orientationVisitor.clear();
+ faultSieveMesh->restrictClosure(c_fault, orientationVisitor);
// Get pseudo stiffness at fault cell's vertices.
- _faultMesh->restrictClosure(_pseudoStiffness, c_fault, &cellStiffness[0],
- cellStiffness.size());
+ stiffnessVisitor.clear();
+ faultSieveMesh->restrictClosure(c_fault, stiffnessVisitor);
for (int iConstraint=0; iConstraint < numConstraintVert; ++iConstraint) {
// Blocks in cell matrix associated with normal cohesive
@@ -441,11 +536,11 @@
const int indexK = iConstraint + 2*numConstraintVert;
// Get orientation at constraint vertex
- const real_section_type::value_type* constraintOrient =
- &cellOrientation[iConstraint*orientationSize];
- assert(0 != constraintOrient);
+ const double* orientationVertex =
+ &orientationCell[iConstraint*orientationSize];
+ assert(0 != orientationVertex);
- const double pseudoStiffness = cellStiffness[iConstraint];
+ const double stiffnessVertex = stiffnessCell[iConstraint];
// Scale orientation information by pseudo-stiffness to bring
// constraint forces in solution vector to the same order of
@@ -456,10 +551,10 @@
for (int kDim=0; kDim < spaceDim; ++kDim) {
const int row = indexI*spaceDim+iDim;
const int col = indexK*spaceDim+kDim;
- cellMatrix[row*numCorners*spaceDim+col] =
- -constraintOrient[kDim*spaceDim+iDim]*pseudoStiffness;
- cellMatrix[col*numCorners*spaceDim+row] =
- -constraintOrient[kDim*spaceDim+iDim];
+ matrixCell[row*numCorners*spaceDim+col] =
+ -orientationVertex[kDim*spaceDim+iDim]*stiffnessVertex;
+ matrixCell[col*numCorners*spaceDim+row] =
+ -orientationVertex[kDim*spaceDim+iDim];
} // for
// Entries associated with constraint forces applied at node j
@@ -467,18 +562,18 @@
for (int kDim=0; kDim < spaceDim; ++kDim) {
const int row = indexJ*spaceDim+jDim;
const int col = indexK*spaceDim+kDim;
- cellMatrix[row*numCorners*spaceDim+col] =
- constraintOrient[kDim*spaceDim+jDim]*pseudoStiffness;
- cellMatrix[col*numCorners*spaceDim+row] =
- constraintOrient[kDim*spaceDim+jDim];
+ matrixCell[row*numCorners*spaceDim+col] =
+ orientationVertex[kDim*spaceDim+jDim]*stiffnessVertex;
+ matrixCell[col*numCorners*spaceDim+row] =
+ orientationVertex[kDim*spaceDim+jDim];
} // for
} // for
// Insert cell contribution into PETSc Matrix
- err = updateOperator(*mat, *mesh->getSieve(), iV, *c_iter, &cellMatrix[0], INSERT_VALUES);
- if (err)
- throw std::runtime_error("Update to PETSc Mat failed.");
- iV.clear();
+ jacobianVisitor.clear();
+ err = updateOperator(jacobianMatrix, *sieveMesh->getSieve(),
+ jacobianVisitor, *c_iter, &matrixCell[0], INSERT_VALUES);
+ CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
} // for
PetscLogFlops(cellsCohesiveSize*numConstraintVert*spaceDim*spaceDim*4);
_needNewJacobian = false;
@@ -487,30 +582,32 @@
// ----------------------------------------------------------------------
// Update state variables as needed.
void
-pylith::faults::FaultCohesiveKin::updateState(const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh)
-{ // updateState
+pylith::faults::FaultCohesiveKin::updateStateVars(const double t,
+ topology::SolutionFields* const fields)
+{ // updateStateVars
assert(0 != fields);
- assert(!mesh.isNull());
- assert(!_faultMesh.isNull());
+ assert(0 != _fields);
// Update cumulative slip
- assert(!_cumSlip.isNull());
+ topology::Field<topology::SubMesh>& cumSlip = _fields->get("cumulative slip");
+ topology::Field<topology::SubMesh>& slip = _fields->get("slip");
if (!_useSolnIncr)
- _cumSlip->zero();
- _cumSlip->add(_cumSlip, _slip);
-} // updateState
+ cumSlip.zero();
+ cumSlip += slip;
+} // updateStateVars
// ----------------------------------------------------------------------
// Verify configuration is acceptable.
void
-pylith::faults::FaultCohesiveKin::verifyConfiguration(const ALE::Obj<Mesh>& mesh) const
+pylith::faults::FaultCohesiveKin::verifyConfiguration(
+ const topology::Mesh& mesh) const
{ // verifyConfiguration
- assert(!mesh.isNull());
assert(0 != _quadrature);
- if (!mesh->hasIntSection(label())) {
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ if (!sieveMesh->hasIntSection(label())) {
std::ostringstream msg;
msg << "Mesh missing group of vertices '" << label()
<< " for boundary condition.";
@@ -518,7 +615,7 @@
} // if
// check compatibility of mesh and quadrature scheme
- const int dimension = mesh->getDimension()-1;
+ const int dimension = mesh.dimension()-1;
if (_quadrature->cellDim() != dimension) {
std::ostringstream msg;
msg << "Dimension of reference cell in quadrature scheme ("
@@ -530,15 +627,14 @@
} // if
const int numCorners = _quadrature->refGeometry().numCorners();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", id());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", id());
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsBegin = cells->begin();
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
- for (Mesh::label_sequence::iterator c_iter=cellsBegin;
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- const int cellNumCorners = mesh->getNumCellCorners(*c_iter);
+ const int cellNumCorners = sieveMesh->getNumCellCorners(*c_iter);
if (3*numCorners != cellNumCorners) {
std::ostringstream msg;
msg << "Number of vertices in reference cell (" << numCorners
@@ -552,18 +648,17 @@
// ----------------------------------------------------------------------
// Get vertex field associated with integrator.
-const ALE::Obj<pylith::real_section_type>&
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::FaultCohesiveKin::vertexField(
- VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* fields)
+ const char* name,
+ const topology::SolutionFields* fields)
{ // vertexField
- assert(!_faultMesh.isNull());
- assert(!_orientation.isNull());
+ assert(0 != _faultMesh);
+ assert(0 != _quadrature);
assert(0 != _normalizer);
+ assert(0 != _fields);
- const int cohesiveDim = _faultMesh->getDimension();
+ const int cohesiveDim = _faultMesh->dimension();
const int spaceDim = _quadrature->spaceDim();
const int slipStrLen = strlen("final_slip");
@@ -572,67 +667,71 @@
double scale = 0.0;
int fiberDim = 0;
if (0 == strcasecmp("slip", name)) {
- *fieldType = VECTOR_FIELD;
- assert(!_cumSlip.isNull());
- _allocateBufferVertexVector();
- topology::FieldOps::copyValues(_bufferVertexVector, _cumSlip);
- _bufferTmp = _bufferVertexVector;
- scale = _normalizer->lengthScale();
- fiberDim = spaceDim;
+ const topology::Field<topology::SubMesh>& cumSlip =
+ _fields->get("cumulative slip");
+ return cumSlip;
} else if (cohesiveDim > 0 && 0 == strcasecmp("strike_dir", name)) {
- *fieldType = VECTOR_FIELD;
- _bufferTmp = _orientation->getFibration(0);
- scale = 0.0;
- fiberDim = spaceDim;
+ const ALE::Obj<RealSection>& orientationSection =
+ _fields->get("orientation").section();
+ assert(!orientationSection.isNull());
+ const ALE::Obj<RealSection>& dirSection =
+ orientationSection->getFibration(0);
+ assert(!dirSection.isNull());
+ _allocateBufferVectorField();
+ assert(0 != _bufferVectorField);
+ _bufferVectorField->copy(dirSection);
+ _bufferVectorField->label("strike_dir");
+ return *_bufferVectorField;
} else if (2 == cohesiveDim && 0 == strcasecmp("dip_dir", name)) {
- *fieldType = VECTOR_FIELD;
- _bufferTmp = _orientation->getFibration(1);
- scale = 0.0;
- fiberDim = spaceDim;
+ const ALE::Obj<RealSection>& orientationSection =
+ _fields->get("orientation").section();
+ assert(!orientationSection.isNull());
+ const ALE::Obj<RealSection>& dirSection =
+ orientationSection->getFibration(1);
+ _allocateBufferVectorField();
+ assert(0 != _bufferVectorField);
+ _bufferVectorField->copy(dirSection);
+ _bufferVectorField->label("dip_dir");
+ return *_bufferVectorField;
} else if (0 == strcasecmp("normal_dir", name)) {
- *fieldType = VECTOR_FIELD;
+ const ALE::Obj<RealSection>& orientationSection =
+ _fields->get("orientation").section();
+ assert(!orientationSection.isNull());
const int space =
(0 == cohesiveDim) ? 0 : (1 == cohesiveDim) ? 1 : 2;
- _bufferTmp = _orientation->getFibration(space);
- scale = 0.0;
- fiberDim = spaceDim;
+ const ALE::Obj<RealSection>& dirSection =
+ orientationSection->getFibration(space);
+ assert(!dirSection.isNull());
+ _allocateBufferVectorField();
+ assert(0 != _bufferVectorField);
+ _bufferVectorField->copy(dirSection);
+ _bufferVectorField->label("normal_dir");
+ return *_bufferVectorField;
} else if (0 == strncasecmp("final_slip_X", name, slipStrLen)) {
const std::string value = std::string(name).substr(slipStrLen+1);
- *fieldType = VECTOR_FIELD;
const srcs_type::const_iterator s_iter = _eqSrcs.find(value);
assert(s_iter != _eqSrcs.end());
- _allocateBufferVertexVector();
- topology::FieldOps::copyValues(_bufferVertexVector,
- s_iter->second->finalSlip());
- _bufferTmp = _bufferVertexVector;
- scale = _normalizer->lengthScale();
- fiberDim = spaceDim;
+ return s_iter->second->finalSlip();
} else if (0 == strncasecmp("slip_time_X", name, timeStrLen)) {
- *fieldType = SCALAR_FIELD;
const std::string value = std::string(name).substr(timeStrLen+1);
const srcs_type::const_iterator s_iter = _eqSrcs.find(value);
assert(s_iter != _eqSrcs.end());
- _allocateBufferVertexScalar();
- topology::FieldOps::copyValues(_bufferVertexScalar,
- s_iter->second->slipTime());
- _bufferTmp = _bufferVertexScalar;
- scale = _normalizer->timeScale();
- fiberDim = 1;
+ return s_iter->second->slipTime();
} else if (0 == strcasecmp("traction_change", name)) {
- *fieldType = VECTOR_FIELD;
- const ALE::Obj<real_section_type>& solution = fields->getSolution();
- _calcTractionsChange(&_bufferVertexVector, mesh, solution);
- _bufferTmp = _bufferVertexVector;
- scale = _normalizer->pressureScale();
- fiberDim = spaceDim;
-
+ assert(0 != fields);
+ const topology::Field<topology::Mesh>& solution = fields->solution();
+ _allocateBufferVectorField();
+ _calcTractionsChange(_bufferVectorField, solution);
+ _bufferVectorField->label("traction_change");
+ return *_bufferVectorField;
+
} else {
std::ostringstream msg;
msg << "Request for unknown vertex field '" << name
@@ -640,32 +739,16 @@
throw std::runtime_error(msg.str());
} // else
- if (0 != scale) {
- // dimensionalize values
- double_array values(fiberDim);
- const ALE::Obj<Mesh::label_sequence>& vertices = _faultMesh->depthStratum(0);
- assert(!vertices.isNull());
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter) {
- assert(fiberDim == _bufferTmp->getFiberDimension(*v_iter));
- _bufferTmp->restrictPoint(*v_iter, &values[0], values.size());
- _normalizer->dimensionalize(&values[0], values.size(), scale);
- _bufferTmp->updatePointAll(*v_iter, &values[0]);
- } // for
- } // if
-
- return _bufferTmp;
+ assert(0 != _bufferScalarField);
+ return *_bufferScalarField;
} // vertexField
// ----------------------------------------------------------------------
// Get cell field associated with integrator.
-const ALE::Obj<pylith::real_section_type>&
-pylith::faults::FaultCohesiveKin::cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* fields)
+const pylith::topology::Field<pylith::topology::SubMesh>&
+pylith::faults::FaultCohesiveKin::cellField(
+ const char* name,
+ const topology::SolutionFields* fields)
{ // cellField
// Should not reach this point if requested field was found
std::ostringstream msg;
@@ -674,44 +757,76 @@
throw std::runtime_error(msg.str());
// Return generic section to satisfy member function definition.
- //return _outputCellVector;
+ assert(0 != _bufferScalarField);
+ return *_bufferScalarField;
} // cellField
// ----------------------------------------------------------------------
// Calculate orientation at fault vertices.
void
-pylith::faults::FaultCohesiveKin::_calcOrientation(const double_array& upDir,
- const double_array& normalDir)
+pylith::faults::FaultCohesiveKin::_calcOrientation(const double upDir[3],
+ const double normalDir[3])
{ // _calcOrientation
- assert(!_faultMesh.isNull());
+ assert(0 != upDir);
+ assert(0 != normalDir);
+ assert(0 != _faultMesh);
+ assert(0 != _fields);
- // Get vertices in fault mesh
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _faultMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ double_array upDirArray(upDir, 3);
- // Create orientation section for fault (constraint) vertices
- const int cohesiveDim = _faultMesh->getDimension();
- const int spaceDim = cohesiveDim + 1;
+ // Get vertices in fault mesh.
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
+
+ // Containers for orientation information.
+ const int cohesiveDim = _faultMesh->dimension();
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
const int orientationSize = spaceDim*spaceDim;
- _orientation = new real_section_type(_faultMesh->comm(),
- _faultMesh->debug());
- assert(!_orientation.isNull());
+ const feassemble::CellGeometry& cellGeometry = _quadrature->refGeometry();
+ const double_array& verticesRef = cellGeometry.vertices();
+ const int jacobianSize = (cohesiveDim > 0) ? spaceDim * cohesiveDim : 1;
+ const double_array& quadWts = _quadrature->quadWts();
+ double_array jacobian(jacobianSize);
+ double jacobianDet = 0;
+ double_array orientationVertex(orientationSize);
+ double_array coordinatesCell(numBasis*spaceDim);
+ double_array refCoordsVertex(cohesiveDim);
+
+ // Allocate orientation field.
+ _fields->add("orientation", "orientation");
+ topology::Field<topology::SubMesh>& orientation = _fields->get("orientation");
+ orientation.newSection(topology::FieldBase::VERTICES_FIELD, orientationSize);
+ const ALE::Obj<RealSection>& orientationSection = orientation.section();
+ assert(!orientationSection.isNull());
+ // Create subspaces for along-strike, up-dip, and normal directions
for (int iDim=0; iDim <= cohesiveDim; ++iDim)
- _orientation->addSpace();
- assert(cohesiveDim+1 == _orientation->getNumSpaces());
- _orientation->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _orientation->setFiberDimension(vertices, orientationSize);
+ orientationSection->addSpace();
for (int iDim=0; iDim <= cohesiveDim; ++iDim)
- _orientation->setFiberDimension(vertices, spaceDim, iDim);
- _faultMesh->allocate(_orientation);
+ orientationSection->setFiberDimension(vertices, spaceDim, iDim);
+ orientation.allocate();
+ orientation.zero();
+ // Get fault cells (1 dimension lower than top-level cells)
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ faultSieveMesh->heightStratum(0);
+ assert(!cells.isNull());
+ const SieveSubMesh::label_sequence::iterator cellsBegin = cells->begin();
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
+
// Compute orientation of fault at constraint vertices
// Get section containing coordinates of vertices
- const ALE::Obj<real_section_type>& coordinates =
- _faultMesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
+ const ALE::Obj<RealSection>& coordinatesSection =
+ faultSieveMesh->getRealSection("coordinates");
+ assert(!coordinatesSection.isNull());
+ topology::Mesh::RestrictVisitor coordinatesVisitor(*coordinatesSection,
+ coordinatesCell.size(),
+ &coordinatesCell[0]);
// Set orientation function
assert(cohesiveDim == _quadrature->cellDim());
@@ -719,126 +834,105 @@
// Loop over cohesive cells, computing orientation weighted by
// jacobian at constraint vertices
- const int numBasis = _quadrature->numBasis();
- const feassemble::CellGeometry& cellGeometry = _quadrature->refGeometry();
- const double_array& verticesRef = cellGeometry.vertices();
- const int jacobianSize = (cohesiveDim > 0) ? spaceDim * cohesiveDim : 1;
- double_array jacobian(jacobianSize);
- double jacobianDet = 0;
- double_array vertexOrientation(orientationSize);
- double_array faceVertices(numBasis*spaceDim);
- // Get fault cells (1 dimension lower than top-level cells)
- const ALE::Obj<SubMesh::label_sequence>& cells =
- _faultMesh->heightStratum(0);
- assert(!cells.isNull());
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
-
- const ALE::Obj<sieve_type>& sieve = _faultMesh->getSieve();
+ const ALE::Obj<SieveSubMesh::sieve_type>& sieve = faultSieveMesh->getSieve();
assert(!sieve.isNull());
- const int faultDepth = _faultMesh->depth(); // depth of fault cells
- typedef ALE::SieveAlg<Mesh> SieveAlg;
+ typedef ALE::SieveAlg<SieveSubMesh> SieveAlg;
- ALE::ISieveVisitor::NConeRetriever<sieve_type> ncV(*sieve, (size_t) pow(sieve->getMaxConeSize(), std::max(0, _faultMesh->depth())));
+ ALE::ISieveVisitor::NConeRetriever<SieveMesh::sieve_type> ncV(*sieve, (size_t) pow(sieve->getMaxConeSize(), std::max(0, faultSieveMesh->depth())));
- for (SubMesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveSubMesh::label_sequence::iterator c_iter=cellsBegin;
c_iter != cellsEnd;
++c_iter) {
- _faultMesh->restrictClosure(coordinates, *c_iter,
- &faceVertices[0], faceVertices.size());
+ // Get orientations at fault cell's vertices.
+ coordinatesVisitor.clear();
+ faultSieveMesh->restrictClosure(*c_iter, coordinatesVisitor);
- ALE::ISieveTraversal<sieve_type>::orientedClosure(*sieve, *c_iter, ncV);
+ ncV.clear();
+ ALE::ISieveTraversal<SieveSubMesh::sieve_type>::orientedClosure(*sieve, *c_iter, ncV);
const int coneSize = ncV.getSize();
const Mesh::point_type *cone = ncV.getPoints();
- for(int v = 0; v < coneSize; ++v) {
+ for (int v=0; v < coneSize; ++v) {
// Compute Jacobian and determinant of Jacobian at vertex
- double_array vertex(&verticesRef[v*cohesiveDim], cohesiveDim);
- cellGeometry.jacobian(&jacobian, &jacobianDet, faceVertices, vertex);
+ memcpy(&refCoordsVertex[0], &verticesRef[v*cohesiveDim],
+ cohesiveDim*sizeof(double));
+ cellGeometry.jacobian(&jacobian, &jacobianDet, coordinatesCell,
+ refCoordsVertex);
// Compute orientation
- cellGeometry.orientation(&vertexOrientation, jacobian, jacobianDet,
- upDir);
+ cellGeometry.orientation(&orientationVertex, jacobian, jacobianDet,
+ upDirArray);
// Update orientation
- _orientation->updateAddPoint(cone[v], &vertexOrientation[0]);
+ orientationSection->updateAddPoint(cone[v], &orientationVertex[0]);
} // for
- ncV.clear();
} // for
+ //orientation.view("ORIENTATION BEFORE COMPLETE");
+
// Assemble orientation information
- ALE::Completion::completeSectionAdd(_faultMesh->getSendOverlap(),
- _faultMesh->getRecvOverlap(),
- _orientation, _orientation);
+ orientation.complete();
// Loop over vertices, make orientation information unit magnitude
double_array vertexDir(orientationSize);
int count = 0;
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++count) {
- const real_section_type::value_type* vertexOrient =
- _orientation->restrictPoint(*v_iter);
- assert(0 != vertexOrient);
-
- assert(spaceDim*spaceDim == orientationSize);
+ orientationVertex = 0.0;
+ orientationSection->restrictPoint(*v_iter, &orientationVertex[0],
+ orientationVertex.size());
for (int iDim=0; iDim < spaceDim; ++iDim) {
double mag = 0;
for (int jDim=0, index=iDim*spaceDim; jDim < spaceDim; ++jDim)
- mag += pow(vertexOrient[index+jDim],2);
+ mag += pow(orientationVertex[index+jDim],2);
mag = sqrt(mag);
assert(mag > 0.0);
for (int jDim=0, index=iDim*spaceDim; jDim < spaceDim; ++jDim)
- vertexDir[index+jDim] =
- vertexOrient[index+jDim] / mag;
+ orientationVertex[index+jDim] /= mag;
} // for
- _orientation->updatePoint(*v_iter, &vertexDir[0]);
+ orientationSection->updatePoint(*v_iter, &orientationVertex[0]);
} // for
PetscLogFlops(count * orientationSize * 4);
- if (2 == cohesiveDim) {
+ if (2 == cohesiveDim && vertices->size() > 0) {
// Check orientation of first vertex, if dot product of fault
// normal with preferred normal is negative, flip up/down dip direction.
// If the user gives the correct normal direction, we should end
// up with left-lateral-slip, reverse-slip, and fault-opening for
// positive slip values.
-
- const real_section_type::value_type* vertexOrient =
- _orientation->restrictPoint(*vertices->begin());
- assert(0 != vertexOrient);
-
- double_array vertNormalDir(&vertexOrient[6], 3);
+
+ assert(vertices->size() > 0);
+ orientationSection->restrictPoint(*vertices->begin(), &orientationVertex[0],
+ orientationVertex.size());
+
+ assert(3 == spaceDim);
+ double_array normalDirVertex(&orientationVertex[6], 3);
const double dot =
- normalDir[0]*vertNormalDir[0] +
- normalDir[1]*vertNormalDir[1] +
- normalDir[2]*vertNormalDir[2];
+ normalDir[0]*normalDirVertex[0] +
+ normalDir[1]*normalDirVertex[1] +
+ normalDir[2]*normalDirVertex[2];
if (dot < 0.0)
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* vertexOrient =
- _orientation->restrictPoint(*v_iter);
- assert(0 != vertexOrient);
- assert(9 == _orientation->getFiberDimension(*v_iter));
- // Keep along-strike direction
- for (int iDim=0; iDim < 3; ++iDim)
- vertexDir[iDim] = vertexOrient[iDim];
+ orientationSection->restrictPoint(*v_iter, &orientationVertex[0],
+ orientationVertex.size());
+ assert(9 == orientationSection->getFiberDimension(*v_iter));
// Flip up-dip direction
for (int iDim=3; iDim < 6; ++iDim)
- vertexDir[iDim] = -vertexOrient[iDim];
- // Keep normal direction
- for (int iDim=6; iDim < 9; ++iDim)
- vertexDir[iDim] = vertexOrient[iDim];
+ orientationVertex[iDim] = -orientationVertex[iDim];
// Update direction
- _orientation->updatePoint(*v_iter, &vertexDir[0]);
+ orientationSection->updatePoint(*v_iter, &orientationVertex[0]);
} // for
PetscLogFlops(5 + count * 3);
} // if
- //_orientation->view("ORIENTATION");
+ //orientation.view("ORIENTATION");
} // _calcOrientation
// ----------------------------------------------------------------------
@@ -849,55 +943,61 @@
{ // _calcConditioning
assert(0 != cs);
assert(0 != matDB);
- assert(!_faultMesh.isNull());
+ assert(0 != _faultMesh);
+ assert(0 != _fields);
const int spaceDim = cs->spaceDim();
- // Get vertices in fault mesh
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _faultMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ // Get vertices in fault mesh.
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
- _pseudoStiffness = new real_section_type(_faultMesh->comm(),
- _faultMesh->debug());
- assert(!_pseudoStiffness.isNull());
- _pseudoStiffness->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(),
- vertices->end())+1));
- _pseudoStiffness->setFiberDimension(vertices, 1);
- _faultMesh->allocate(_pseudoStiffness);
-
+ // Allocate stiffness field.
+ _fields->add("pseudostiffness", "pseudostiffness");
+ topology::Field<topology::SubMesh>& stiffness = _fields->get("pseudostiffness");
+ stiffness.newSection(topology::FieldBase::VERTICES_FIELD, 1);
+ stiffness.allocate();
+ stiffness.zero();
+ const ALE::Obj<RealSection>& stiffnessSection = stiffness.section();
+ assert(!stiffnessSection.isNull());
+
+ // Setup queries of physical properties.
matDB->open();
const char* stiffnessVals[] = { "density", "vs" };
const int numStiffnessVals = 2;
matDB->queryVals(stiffnessVals, numStiffnessVals);
// Get section containing coordinates of vertices
- const ALE::Obj<real_section_type>& coordinates =
- _faultMesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates =
+ faultSieveMesh->getRealSection("coordinates");
assert(!coordinates.isNull());
+ // Get dimensional scales.
assert(0 != _normalizer);
const double pressureScale = _normalizer->pressureScale();
const double lengthScale = _normalizer->lengthScale();
double_array matprops(numStiffnessVals);
- double_array vCoords(spaceDim);
+ double_array coordsVertex(spaceDim);
int count = 0;
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
+ // Set values in orientation section.
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++count) {
- coordinates->restrictPoint(*v_iter, &vCoords[0], vCoords.size());
- _normalizer->dimensionalize(&vCoords[0], vCoords.size(), lengthScale);
- int err = matDB->query(&matprops[0], numStiffnessVals, &vCoords[0],
- vCoords.size(), cs);
+ coordinates->restrictPoint(*v_iter, &coordsVertex[0], coordsVertex.size());
+ _normalizer->dimensionalize(&coordsVertex[0], coordsVertex.size(), lengthScale);
+ int err = matDB->query(&matprops[0], numStiffnessVals, &coordsVertex[0],
+ coordsVertex.size(), cs);
if (err) {
std::ostringstream msg;
msg << "Could not find material properties at (";
for (int i=0; i < spaceDim; ++i)
- msg << " " << vCoords[i];
+ msg << " " << coordsVertex[i];
msg << ") using spatial database " << matDB->label() << ".";
throw std::runtime_error(msg.str());
} // if
@@ -906,7 +1006,7 @@
const double vs = matprops[1];
const double mu = density * vs*vs;
const double muN = _normalizer->nondimensionalize(mu, pressureScale);
- _pseudoStiffness->updatePoint(*v_iter, &muN);
+ stiffnessSection->updatePoint(*v_iter, &muN);
} // for
PetscLogFlops(count * 2);
@@ -917,35 +1017,9 @@
void
pylith::faults::FaultCohesiveKin::_calcArea(void)
{ // _calcArea
- assert(!_faultMesh.isNull());
+ assert(0 != _faultMesh);
+ assert(0 != _fields);
- // Get vertices in fault mesh
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _faultMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
-
- _area = new real_section_type(_faultMesh->comm(),
- _faultMesh->debug());
- assert(!_area.isNull());
- _area->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(),
- vertices->end())+1));
- _area->setFiberDimension(vertices, 1);
- _faultMesh->allocate(_area);
-
- // Get fault cells (1 dimension lower than top-level cells)
- const ALE::Obj<SubMesh::label_sequence>& cells =
- _faultMesh->heightStratum(0);
- assert(!cells.isNull());
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
-
- // Get section containing coordinates of vertices
- const ALE::Obj<real_section_type>& coordinates =
- _faultMesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
-
// Containers for area information
const int cellDim = _quadrature->cellDim();
const int numBasis = _quadrature->numBasis();
@@ -955,15 +1029,39 @@
const double_array& quadWts = _quadrature->quadWts();
assert(quadWts.size() == numQuadPts);
double jacobianDet = 0;
- double_array cellArea(numBasis);
- double_array cellVertices(numBasis*spaceDim);
+ double_array areaCell(numBasis);
+ double_array verticesCell(numBasis*spaceDim);
+ // Get vertices in fault mesh.
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
+
+ // Allocate area field.
+ _fields->add("area", "area");
+ topology::Field<topology::SubMesh>& area = _fields->get("area");
+ area.newSection(topology::FieldBase::VERTICES_FIELD, 1);
+ area.allocate();
+ area.zero();
+ const ALE::Obj<RealSection>& areaSection = area.section();
+ assert(!areaSection.isNull());
+ topology::Mesh::UpdateAddVisitor areaVisitor(*areaSection, &areaCell[0]);
+
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ faultSieveMesh->heightStratum(0);
+ assert(!cells.isNull());
+ const SieveSubMesh::label_sequence::iterator cellsBegin = cells->begin();
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
+
// Loop over cells in fault mesh, compute area
- for(SubMesh::label_sequence::iterator c_iter = cells->begin();
+ for(SieveSubMesh::label_sequence::iterator c_iter = cellsBegin;
c_iter != cellsEnd;
++c_iter) {
- _quadrature->computeGeometry(_faultMesh, coordinates, *c_iter);
- cellArea = 0.0;
+ _quadrature->retrieveGeometry(*c_iter);
+ areaCell = 0.0;
// Get cell geometry information that depends on cell
const double_array& basis = _quadrature->basis();
@@ -974,21 +1072,22 @@
const double wt = quadWts[iQuad] * jacobianDet[iQuad];
for (int iBasis=0; iBasis < numBasis; ++iBasis) {
const double dArea = wt*basis[iQuad*numBasis+iBasis];
- cellArea[iBasis] += dArea;
+ areaCell[iBasis] += dArea;
} // for
} // for
- _faultMesh->updateAdd(_area, *c_iter, &cellArea[0]);
+ areaVisitor.clear();
+ faultSieveMesh->updateAdd(*c_iter, areaVisitor);
PetscLogFlops( numQuadPts*(1+numBasis*2) );
} // for
// Assemble area information
- ALE::Completion::completeSectionAdd(_faultMesh->getSendOverlap(), _faultMesh->getRecvOverlap(), _area, _area);
+ area.complete();
#if 0 // DEBUGGING
- _area->view("AREA");
- _faultMesh->getSendOverlap()->view("Send fault overlap");
- _faultMesh->getRecvOverlap()->view("Receive fault overlap");
+ area.view("AREA");
+ //_faultMesh->getSendOverlap()->view("Send fault overlap");
+ //_faultMesh->getRecvOverlap()->view("Receive fault overlap");
#endif
} // _calcArea
@@ -997,34 +1096,52 @@
// NOTE: We must convert vertex labels to fault vertex labels
void
pylith::faults::FaultCohesiveKin::_calcTractionsChange(
- ALE::Obj<real_section_type>* tractions,
- const ALE::Obj<Mesh>& mesh,
- const ALE::Obj<real_section_type>& solution)
+ topology::Field<topology::SubMesh>* tractions,
+ const topology::Field<topology::Mesh>& solution)
{ // _calcTractionsChange
assert(0 != tractions);
- assert(!mesh.isNull());
- assert(!solution.isNull());
- assert(!_faultMesh.isNull());
- assert(!_pseudoStiffness.isNull());
- assert(!_area.isNull());
+ assert(0 != _faultMesh);
+ assert(0 != _fields);
- const ALE::Obj<Mesh::label_sequence>& vertices =
- mesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ // Get vertices from mesh of domain.
+ const ALE::Obj<SieveMesh>& sieveMesh = solution.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& fvertices =
- _faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator fverticesEnd = fvertices->end();
+ // Get fault vertices
+ const ALE::Obj<SieveMesh>& faultSieveMesh = _faultMesh->sieveMesh();
+ assert(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh::label_sequence>& fvertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator fverticesBegin = fvertices->begin();
+ const SieveSubMesh::label_sequence::iterator fverticesEnd = fvertices->end();
+
+ // Get sections.
+ const ALE::Obj<RealSection>& stiffnessSection =
+ _fields->get("pseudostiffness").section();
+ assert(!stiffnessSection.isNull());
+ const ALE::Obj<RealSection>& areaSection =
+ _fields->get("area").section();
+ assert(!areaSection.isNull());
+ const ALE::Obj<RealSection>& solutionSection = solution.section();
+ assert(!solutionSection.isNull());
+
const int numFaultVertices = fvertices->size();
- Mesh::renumbering_type& renumbering = _faultMesh->getRenumbering();
+ Mesh::renumbering_type& renumbering = faultSieveMesh->getRenumbering();
+ const SieveSubMesh::renumbering_type::const_iterator renumberingEnd =
+ renumbering.end();
-#if 0 // MOVE TO SEPARATE CHECK METHOD
+#if 0 // DEBUGGING, MOVE TO SEPARATE CHECK METHOD
// Check fault mesh and volume mesh coordinates
- const ALE::Obj<real_section_type>& coordinates = mesh->getRealSection("coordinates");
- const ALE::Obj<real_section_type>& fCoordinates = _faultMesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates = mesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& fCoordinates = _faultMesh->getRealSection("coordinates");
for (Mesh::label_sequence::iterator v_iter = vertices->begin(); v_iter != verticesEnd; ++v_iter) {
- if (renumbering.find(*v_iter) != renumbering.end()) {
+ if (renumbering.find(*v_iter) != renumberingEnd) {
const int v = *v_iter;
const int dim = coordinates->getFiberDimension(*v_iter);
const double *a = coordinates->restrictPoint(*v_iter);
@@ -1042,46 +1159,40 @@
// Fiber dimension of tractions matches spatial dimension.
const int fiberDim = _quadrature->spaceDim();
- double_array tractionValues(fiberDim);
+ double_array tractionsVertex(fiberDim);
// Allocate buffer for tractions field (if nec.).
- if (tractions->isNull() ||
- fiberDim != (*tractions)->getFiberDimension(*fvertices->begin())) {
- *tractions = new real_section_type(_faultMesh->comm(), _faultMesh->debug());
- (*tractions)->setChart(real_section_type::chart_type(
- *std::min_element(fvertices->begin(), fvertices->end()),
- *std::max_element(fvertices->begin(), fvertices->end())+1));
- (*tractions)->setFiberDimension(fvertices, fiberDim);
- _faultMesh->allocate(*tractions);
- assert(!tractions->isNull());
+ const ALE::Obj<RealSection>& tractionsSection = tractions->section();
+ if (tractionsSection.isNull()) {
+ tractions->newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ tractions->allocate();
} // if
+ assert(!tractionsSection.isNull());
+ tractions->zero();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter = verticesBegin;
v_iter != verticesEnd;
++v_iter)
- if (renumbering.find(*v_iter) != renumbering.end()) {
+ if (renumbering.find(*v_iter) != renumberingEnd) {
const int vertexMesh = *v_iter;
const int vertexFault = renumbering[*v_iter];
- assert(fiberDim == solution->getFiberDimension(vertexMesh));
- assert(fiberDim == (*tractions)->getFiberDimension(vertexFault));
- assert(1 == _pseudoStiffness->getFiberDimension(vertexFault));
- assert(1 == _area->getFiberDimension(vertexFault));
+ assert(fiberDim == solutionSection->getFiberDimension(vertexMesh));
+ assert(fiberDim == tractionsSection->getFiberDimension(vertexFault));
+ assert(1 == stiffnessSection->getFiberDimension(vertexFault));
+ assert(1 == areaSection->getFiberDimension(vertexFault));
- const real_section_type::value_type* solutionValues =
- solution->restrictPoint(vertexMesh);
- assert(0 != solutionValues);
- const real_section_type::value_type* pseudoStiffValue =
- _pseudoStiffness->restrictPoint(vertexFault);
- assert(0 != _pseudoStiffness);
- const real_section_type::value_type* areaValue =
- _area->restrictPoint(vertexFault);
- assert(0 != _area);
+ const double* solutionVertex = solutionSection->restrictPoint(vertexMesh);
+ assert(0 != solutionVertex);
+ const double* stiffnessVertex = stiffnessSection->restrictPoint(vertexFault);
+ assert(0 != stiffnessVertex);
+ const double* areaVertex = areaSection->restrictPoint(vertexFault);
+ assert(0 != areaVertex);
- const double scale = pseudoStiffValue[0] / areaValue[0];
+ const double scale = stiffnessVertex[0] / areaVertex[0];
for (int i=0; i < fiberDim; ++i)
- tractionValues[i] = solutionValues[i] * scale;
+ tractionsVertex[i] = solutionVertex[i] * scale;
- (*tractions)->updatePoint(vertexFault, &tractionValues[0]);
+ tractionsSection->updatePoint(vertexFault, &tractionsVertex[0]);
} // if
PetscLogFlops(numFaultVertices * (1 + fiberDim) );
@@ -1095,43 +1206,41 @@
} // _calcTractionsChange
// ----------------------------------------------------------------------
-// Allocate scalar field for output of vertex information.
+// Allocate buffer for vector field.
void
-pylith::faults::FaultCohesiveKin::_allocateBufferVertexScalar(void)
-{ // _allocateBufferVertexScalar
- const int fiberDim = 1;
- if (_bufferVertexScalar.isNull()) {
- _bufferVertexScalar = new real_section_type(_faultMesh->comm(),
- _faultMesh->debug());
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _faultMesh->depthStratum(0);
- _bufferVertexScalar->setChart(real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- _bufferVertexScalar->setFiberDimension(vertices, fiberDim);
- _faultMesh->allocate(_bufferVertexScalar);
- } // if
-} // _allocateBufferVertexScalar
+pylith::faults::FaultCohesiveKin::_allocateBufferVectorField(void)
+{ // _allocateBufferVectorField
+ if (0 != _bufferVectorField)
+ return;
+ // Create vector field; use same shape/chart as cumulative slip field.
+ assert(0 != _faultMesh);
+ assert(0 != _fields);
+ _bufferVectorField = new topology::Field<topology::SubMesh>(*_faultMesh);
+ const topology::Field<topology::SubMesh>& slip =
+ _fields->get("cumulative slip");
+ _bufferVectorField->newSection(slip);
+ _bufferVectorField->allocate();
+ _bufferVectorField->zero();
+} // _allocateBufferVectorField
+
// ----------------------------------------------------------------------
-// Allocate vector field for output of vertex information.
+// Allocate buffer for scalar field.
void
-pylith::faults::FaultCohesiveKin::_allocateBufferVertexVector(void)
-{ // _allocateBufferVertexVector
- assert(0 != _quadrature);
- const int fiberDim = _quadrature->spaceDim();
- if (_bufferVertexVector.isNull()) {
- _bufferVertexVector = new real_section_type(_faultMesh->comm(),
- _faultMesh->debug());
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- _faultMesh->depthStratum(0);
- _bufferVertexVector->setChart(real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- _bufferVertexVector->setFiberDimension(vertices, fiberDim);
- _faultMesh->allocate(_bufferVertexVector);
- } // if
-} // _allocateBufferVertexVector
+pylith::faults::FaultCohesiveKin::_allocateBufferScalarField(void)
+{ // _allocateBufferScalarField
+ if (0 != _bufferScalarField)
+ return;
+ // Create vector field; use same shape/chart as area field.
+ assert(0 != _faultMesh);
+ assert(0 != _fields);
+ _bufferScalarField = new topology::Field<topology::SubMesh>(*_faultMesh);
+ const topology::Field<topology::SubMesh>& area = _fields->get("area");
+ _bufferScalarField->newSection(area);
+ _bufferScalarField->allocate();
+ _bufferScalarField->zero();
+} // _allocateBufferScalarField
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/FaultCohesiveKin.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -37,35 +37,19 @@
#if !defined(pylith_faults_faultcohesivekin_hh)
#define pylith_faults_faultcohesivekin_hh
+// Include directives ---------------------------------------------------
#include "FaultCohesive.hh" // ISA FaultCohesive
+
+#include "pylith/topology/SubMesh.hh" // ISA Integrator<Quadrature<SubMesh> >
+#include "pylith/feassemble/Quadrature.hh" // ISA Integrator<Quadrature>
#include "pylith/feassemble/Integrator.hh" // ISA Integrator
#include <map> // HASA std::map
#include <string> // HASA std::string
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class FaultCohesiveKin;
- class TestFaultCohesiveKin; // unit testing
-
- class EqKinSrc; // HOLDSA EqKinSrc
- } // faults
-} // pylith
-
-/*
-namespace spatialdata {
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-*/
-
-
-/// C++ implementation for a fault surface with kinematic (prescribed)
-/// slip implemented with cohesive elements.
+// FaultCohesiveKin -----------------------------------------------------
class pylith::faults::FaultCohesiveKin : public FaultCohesive,
- public feassemble::Integrator
+ public feassemble::Integrator<feassemble::Quadrature<topology::SubMesh> >
{ // class FaultCohesiveKin
friend class TestFaultCohesiveKin; // unit testing
@@ -82,18 +66,19 @@
/** Set kinematic earthquake sources.
*
* @param names Array of kinematic earthquake source names.
+ * @param numNames Number of earthquake sources.
* @param sources Array of kinematic earthquake sources.
- * @param numSources Number of earthquake sources
+ * @param numSources Number of earthquake sources.
*/
- void eqsrcs(const char** names,
+ void eqsrcs(const char* const* names,
+ const int numNames,
EqKinSrc** sources,
const int numSources);
/** Initialize fault. Determine orientation and setup boundary
* condition parameters.
*
- * @param mesh PETSc mesh
- * @param cs Coordinate system for mesh
+ * @param mesh Finite-element mesh.
* @param upDir Direction perpendicular to along-strike direction that is
* not collinear with fault normal (usually "up" direction but could
* be up-dip direction; only applies to fault surfaces in a 3-D domain).
@@ -103,10 +88,9 @@
* @param matDB Database of bulk elastic properties for fault region
* (used to improve conditioning of Jacobian matrix)
*/
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- const double_array& upDir,
- const double_array& normalDir,
+ void initialize(const topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
spatialdata::spatialdb::SpatialDB* matDB);
/** Integrate contributions to residual term (r) for operator that
@@ -115,13 +99,10 @@
* @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
- void integrateResidual(const ALE::Obj<real_section_type>& residual,
+ void integrateResidual(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
/** Integrate contributions to residual term (r) for operator that
* do not require assembly across cells, vertices, or processors.
@@ -129,13 +110,10 @@
* @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
- void integrateResidualAssembled(const ALE::Obj<real_section_type>& residual,
+ void integrateResidualAssembled(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
/** Integrate contributions to Jacobian matrix (A) associated with
* operator that do not require assembly across cells, vertices, or
@@ -146,10 +124,9 @@
* @param fields Solution fields
* @param mesh Finite-element mesh
*/
- void integrateJacobianAssembled(PetscMat* mat,
+ void integrateJacobianAssembled(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
/** Update state variables as needed.
*
@@ -157,43 +134,34 @@
* @param fields Solution fields
* @param mesh Finite-element mesh
*/
- void updateState(const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ void updateStateVars(const double t,
+ topology::SolutionFields* const fields);
/** Verify configuration is acceptable.
*
* @param mesh Finite-element mesh
*/
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const;
+ void verifyConfiguration(const topology::Mesh& mesh) const;
/** Get vertex field associated with integrator.
*
- * @param fieldType Type of field.
- * @param name Name of vertex field.
- * @param mesh PETSc mesh for problem.
- * @param fields Fields manager.
+ * @param name Name of cell field.
+ * @param fields Solution fields.
* @returns Vertex field.
*/
- const ALE::Obj<real_section_type>&
- vertexField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ const topology::Field<topology::SubMesh>&
+ vertexField(const char* name,
+ const topology::SolutionFields* fields =0);
/** Get cell field associated with integrator.
*
- * @param fieldType Type of field.
- * @param name Name of vertex field.
- * @param mesh PETSc mesh for problem.
- * @param fields Fields manager.
+ * @param name Name of cell field.
+ * @param fields Solution fields.
* @returns Cell field.
*/
- const ALE::Obj<real_section_type>&
- cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ const topology::Field<topology::SubMesh>&
+ cellField(const char* name,
+ const topology::SolutionFields* fields =0);
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -217,8 +185,8 @@
* (used to pick which of two possible normal directions for
* interface; only applies to fault surfaces in a 3-D domain).
*/
- void _calcOrientation(const double_array& upDir,
- const double_array& normalDir);
+ void _calcOrientation(const double upDir[3],
+ const double normalDir[3]);
/** Calculate conditioning field.
*
@@ -238,24 +206,23 @@
* @param mesh Finite-element mesh for domain
* @param solution Solution over domain
*/
- void _calcTractionsChange(ALE::Obj<real_section_type>* tractions,
- const ALE::Obj<Mesh>& mesh,
- const ALE::Obj<real_section_type>& solution);
+ void _calcTractionsChange(topology::Field<topology::SubMesh>* tractions,
+ const topology::Field<topology::Mesh>& solution);
- /// Allocate scalar field for output of vertex information.
- void _allocateBufferVertexScalar(void);
+ /// Allocate buffer for vector field.
+ void _allocateBufferVectorField(void);
- /// Allocate vector field for output of vertex information.
- void _allocateBufferVertexVector(void);
+ /// Allocate buffer for scalar field.
+ void _allocateBufferScalarField(void);
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
/// Not implemented
- FaultCohesiveKin(const FaultCohesiveKin& m);
+ FaultCohesiveKin(const FaultCohesiveKin&);
/// Not implemented
- const FaultCohesiveKin& operator=(const FaultCohesiveKin& m);
+ const FaultCohesiveKin& operator=(const FaultCohesiveKin&);
// PRIVATE TYPEDEFS ///////////////////////////////////////////////////
private :
@@ -266,38 +233,20 @@
private :
srcs_type _eqSrcs; ///< Array of kinematic earthquake sources.
-
- /// Field over fault mesh vertices of pseudo-stiffness values for
- /// scaling constraint information to improve conditioning of
- /// Jacobian matrix.
- ALE::Obj<real_section_type> _pseudoStiffness;
- /// Field over fault mesh vertices of area associated with each vertex.
- ALE::Obj<real_section_type> _area;
+ /// Fields for fault information.
+ topology::Fields<topology::Field<topology::SubMesh> >* _fields;
- /// Field over the fault mesh vertices of orientation of fault
- /// surface.
- ALE::Obj<real_section_type> _orientation;
-
- /// Field over the fault mesh vertices of vector field of current
- /// slip or slip increment.
- ALE::Obj<real_section_type> _slip;
-
- /// Field over the fault mesh vertices of vector field of cumulative slip.
- ALE::Obj<real_section_type> _cumSlip;
-
+ /// Buffer for vector field over fault vertices.
+ topology::Field<topology::SubMesh>* _bufferVectorField;
+
+ /// Buffer for scalar field over fault vertices.
+ topology::Field<topology::SubMesh>* _bufferScalarField;
+
/// Map label of cohesive cell to label of cells in fault mesh.
- std::map<Mesh::point_type, Mesh::point_type> _cohesiveToFault;
+ std::map<topology::Mesh::SieveMesh::point_type,
+ topology::SubMesh::SieveMesh::point_type> _cohesiveToFault;
- /// Scalar field for vertex information over fault mesh.
- ALE::Obj<real_section_type> _bufferVertexScalar;
-
- /// Vector field for vertex information over fault mesh.
- ALE::Obj<real_section_type> _bufferVertexVector;
-
- /// Handle to field managed elsewhere for data over fault mesh.
- ALE::Obj<real_section_type> _bufferTmp;
-
}; // class FaultCohesiveKin
#include "FaultCohesiveKin.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,9 @@
#include "LiuCosSlipFn.hh" // implementation of object methods
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#include "pylith/utils/array.hh" // USES double_array
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/topology/Field.hh" // USES Field
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
@@ -25,22 +26,20 @@
#include <sstream> // USES std::ostringstream
#include <stdexcept> // USES std::runtime_error
-namespace pylith {
- namespace faults {
- namespace _LiuCosSlipFn {
- const int offsetRiseTime = 0;
- const int offsetSlipTime = 1;
- } // _LiuCosSlipFn
- } // faults
-} // pylith
+// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::SieveMesh::label_sequence label_sequence;
+typedef pylith::topology::SubMesh::RealSection RealSection;
// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::LiuCosSlipFn::LiuCosSlipFn(void) :
+ _slipTimeVertex(0),
+ _riseTimeVertex(0),
+ _parameters(0),
_dbFinalSlip(0),
_dbSlipTime(0),
- _dbRiseTime(0),
- _spaceDim(0)
+ _dbRiseTime(0)
{ // constructor
} // constructor
@@ -48,50 +47,68 @@
// Destructor.
pylith::faults::LiuCosSlipFn::~LiuCosSlipFn(void)
{ // destructor
- _dbFinalSlip = 0;
- _dbSlipTime = 0;
- _dbRiseTime = 0;
+ delete _parameters; _parameters = 0;
+ _dbFinalSlip = 0; // :TODO: Use shared pointer.
+ _dbSlipTime = 0; // :TODO: Use shared pointer.
+ _dbRiseTime = 0; // :TODO: Use shared pointer.
} // destructor
// ----------------------------------------------------------------------
// Initialize slip time function.
void
pylith::faults::LiuCosSlipFn::initialize(
- const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
- const spatialdata::units::Nondimensional& normalizer,
- const double originTime)
+ const topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime)
{ // initialize
- assert(!faultMesh.isNull());
- assert(0 != cs);
assert(0 != _dbFinalSlip);
assert(0 != _dbSlipTime);
assert(0 != _dbRiseTime);
- _spaceDim = cs->spaceDim();
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexRiseTime = spaceDim + _LiuCosSlipFn::offsetRiseTime;
- const int indexSlipTime = spaceDim + _LiuCosSlipFn::offsetSlipTime;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ assert(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const double lengthScale = normalizer.lengthScale();
+ const double timeScale = normalizer.timeScale();
+
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = faultMesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- const int fiberDim = spaceDim + 2;
- _parameters = new real_section_type(faultMesh->comm(), faultMesh->debug());
- _parameters->addSpace(); // final slip
- _parameters->addSpace(); // rise time
- _parameters->addSpace(); // slip time
- assert(3 == _parameters->getNumSpaces());
- _parameters->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _parameters->setFiberDimension(vertices, fiberDim);
- _parameters->setFiberDimension(vertices, spaceDim, 0); // final slip
- _parameters->setFiberDimension(vertices, 1, 1); // rise time
- _parameters->setFiberDimension(vertices, 1, 2); // slip time
- faultMesh->allocate(_parameters);
- assert(!_parameters.isNull());
+ delete _parameters; _parameters = new topology::Fields<topology::Field<topology::SubMesh> >(faultMesh);
+ assert(0 != _parameters);
+ _parameters->add("final slip", "final_slip");
+ topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ finalSlip.newSection(vertices, spaceDim);
+ finalSlip.allocate();
+ finalSlip.scale(lengthScale);
+ finalSlip.vectorFieldType(topology::FieldBase::VECTOR);
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ _parameters->add("slip time", "slip_time");
+ topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
+ slipTime.newSection(finalSlipSection->getChart(), 1);
+ slipTime.allocate();
+ slipTime.scale(timeScale);
+ slipTime.vectorFieldType(topology::FieldBase::SCALAR);
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+
+ _parameters->add("rise time", "rise_time");
+ topology::Field<topology::SubMesh>& riseTime = _parameters->get("rise time");
+ riseTime.newSection(slipTime);
+ riseTime.allocate();
+ riseTime.scale(timeScale);
+ riseTime.vectorFieldType(topology::FieldBase::SCALAR);
+ const ALE::Obj<RealSection>& riseTimeSection = riseTime.section();
+ assert(!riseTimeSection.isNull());
+
// Open databases and set query values
_dbFinalSlip->open();
switch (spaceDim)
@@ -121,69 +138,66 @@
_dbSlipTime->queryVals(slipTimeValues, 1);
_dbRiseTime->open();
- const char* peakRateValues[] = {"rise-time"};
- _dbRiseTime->queryVals(peakRateValues, 1);
+ const char* riseTimeValues[] = {"rise-time"};
+ _dbRiseTime->queryVals(riseTimeValues, 1);
// Get coordinates of vertices
- const ALE::Obj<real_section_type>& coordinates =
- faultMesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
assert(!coordinates.isNull());
- const double lengthScale = normalizer.lengthScale();
- const double timeScale = normalizer.timeScale();
-
- double_array paramsVertex(fiberDim);
+ _slipVertex.resize(spaceDim);
double_array vCoordsGlobal(spaceDim);
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
coordinates->restrictPoint(*v_iter,
&vCoordsGlobal[0], vCoordsGlobal.size());
normalizer.dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
lengthScale);
-
- int err = _dbFinalSlip->query(¶msVertex[indexFinalSlip], spaceDim,
- &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
+
+ int err = _dbFinalSlip->query(&_slipVertex[0], _slipVertex.size(),
+ &vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find final slip at (";
+ msg << "Could not find slip rate at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << vCoordsGlobal[i];
msg << ") using spatial database " << _dbFinalSlip->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexFinalSlip], spaceDim,
+ normalizer.nondimensionalize(&_slipVertex[0], _slipVertex.size(),
lengthScale);
- err = _dbRiseTime->query(¶msVertex[indexRiseTime], 1,
+ err = _dbSlipTime->query(&_slipTimeVertex, 1,
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find rise time at (";
+ msg << "Could not find slip initiation time at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _dbRiseTime->label() << ".";
+ msg << ") using spatial database " << _dbSlipTime->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexRiseTime], spaceDim,
- timeScale);
+ normalizer.nondimensionalize(&_slipTimeVertex, 1, timeScale);
+ // add origin time to rupture time
+ _slipTimeVertex += originTime;
- err = _dbSlipTime->query(¶msVertex[indexSlipTime], 1,
+ err = _dbRiseTime->query(&_riseTimeVertex, 1,
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find slip initiation time at (";
+ msg << "Could not find rise time at (";
for (int i=0; i < spaceDim; ++i)
msg << " " << vCoordsGlobal[i];
- msg << ") using spatial database " << _dbSlipTime->label() << ".";
+ msg << ") using spatial database " << _dbRiseTime->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexSlipTime], 1,
- timeScale);
- // add origin time to rupture time
- paramsVertex[indexSlipTime] += originTime;
+ normalizer.nondimensionalize(&_riseTimeVertex, 1, timeScale);
- _parameters->updatePoint(*v_iter, ¶msVertex[0]);
+ finalSlipSection->updatePoint(*v_iter, &_slipVertex[0]);
+ slipTimeSection->updatePoint(*v_iter, &_slipTimeVertex);
+ riseTimeSection->updatePoint(*v_iter, &_riseTimeVertex);
} // for
// Close databases
@@ -195,122 +209,138 @@
// ----------------------------------------------------------------------
// Get slip on fault surface at time t.
void
-pylith::faults::LiuCosSlipFn::slip(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::LiuCosSlipFn::slip(topology::Field<topology::SubMesh>* slip,
+ const double t)
{ // slip
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexRiseTime = spaceDim + _LiuCosSlipFn::offsetRiseTime;
- const int indexSlipTime = spaceDim + _LiuCosSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const topology::Field<topology::SubMesh>& riseTime =
+ _parameters->get("rise time");
+ const ALE::Obj<RealSection>& riseTimeSection = riseTime.section();
+ assert(!riseTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ const int spaceDim = _slipVertex.size();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ finalSlipSection->restrictPoint(*v_iter, &_slipVertex[0],
+ _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
+ riseTimeSection->restrictPoint(*v_iter, &_riseTimeVertex, 1);
- const double* finalSlip = ¶msVertex[indexFinalSlip];
- const double riseTime = paramsVertex[indexRiseTime];
- const double slipTime = paramsVertex[indexSlipTime];
-
double finalSlipMag = 0.0;
for (int i=0; i < spaceDim; ++i)
- finalSlipMag += finalSlip[i]*finalSlip[i];
+ finalSlipMag += _slipVertex[i]*_slipVertex[i];
finalSlipMag = sqrt(finalSlipMag);
- const double slip = _slipFn(t-slipTime, finalSlipMag, riseTime);
+ const double slip = _slipFn(t-_slipTimeVertex, finalSlipMag,
+ _riseTimeVertex);
const double scale = finalSlipMag > 0.0 ? slip / finalSlipMag : 0.0;
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = scale * finalSlip[i];
-
+ _slipVertex *= scale;
+
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
} // for
- PetscLogFlops(numVertices * (2+8 + 3*spaceDim));
+ PetscLogFlops(vertices->size() * (2+28 + 3*_slipVertex.size()));
} // slip
// ----------------------------------------------------------------------
// Get increment of slip on fault surface between time t0 and t1.
void
-pylith::faults::LiuCosSlipFn::slipIncr(const ALE::Obj<pylith::real_section_type>& slipField,
+pylith::faults::LiuCosSlipFn::slipIncr( topology::Field<topology::SubMesh>* slip,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh)
+ const double t1)
{ // slipIncr
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexRiseTime = spaceDim + _LiuCosSlipFn::offsetRiseTime;
- const int indexSlipTime = spaceDim + _LiuCosSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const topology::Field<topology::SubMesh>& riseTime =
+ _parameters->get("rise time");
+ const ALE::Obj<RealSection>& riseTimeSection = riseTime.section();
+ assert(!riseTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ const int spaceDim = _slipVertex.size();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ finalSlipSection->restrictPoint(*v_iter, &_slipVertex[0],
+ _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
+ riseTimeSection->restrictPoint(*v_iter, &_riseTimeVertex, 1);
- const double* finalSlip = ¶msVertex[indexFinalSlip];
- const double riseTime = paramsVertex[indexRiseTime];
- const double slipTime = paramsVertex[indexSlipTime];
-
double finalSlipMag = 0.0;
for (int i=0; i < spaceDim; ++i)
- finalSlipMag += finalSlip[i]*finalSlip[i];
+ finalSlipMag += _slipVertex[i]*_slipVertex[i];
finalSlipMag = sqrt(finalSlipMag);
- const double slip0 = _slipFn(t0-slipTime, finalSlipMag, riseTime);
- const double slip1 = _slipFn(t1-slipTime, finalSlipMag, riseTime);
+ const double slip0 = _slipFn(t0-_slipTimeVertex, finalSlipMag,
+ _riseTimeVertex);
+ const double slip1 = _slipFn(t1-_slipTimeVertex, finalSlipMag,
+ _riseTimeVertex);
const double scale = finalSlipMag > 0.0 ?
(slip1 - slip0) / finalSlipMag : 0.0;
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = scale * finalSlip[i];
+ _slipVertex *= scale;
+
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
} // for
- PetscLogFlops(numVertices * (3+2*8 + 3*spaceDim));
+ PetscLogFlops(vertices->size() * (3+2*28 + 3*_slipVertex.size()));
} // slipIncr
// ----------------------------------------------------------------------
// Get final slip.
-ALE::Obj<pylith::real_section_type>
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::LiuCosSlipFn::finalSlip(void)
{ // finalSlip
- return _parameters->getFibration(0);
+ return _parameters->get("final slip");
} // finalSlip
// ----------------------------------------------------------------------
// Get time when slip begins at each point.
-ALE::Obj<pylith::real_section_type>
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::LiuCosSlipFn::slipTime(void)
{ // slipTime
- return _parameters->getFibration(2);
+ return _parameters->get("slip time");
} // slipTime
Modified: short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/LiuCosSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,27 +22,14 @@
#if !defined(pylith_faults_liucosslipfn_hh)
#define pylith_faults_liucosslipfn_hh
+// Include directives ---------------------------------------------------
#include "SlipTimeFn.hh"
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class LiuCosSlipFn;
- class TestLiuCosSlipFn; // unit testing
- } // faults
-} // pylith
+#include "pylith/topology/topologyfwd.hh" // USES Fields<Field<SubMesh> >
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB;
- } // spatialdb
- namespace units {
- class Nondimensional;
- } // units
-} // spatialdata
+#include "pylith/utils/array.hh" // HASA double_array
-/// C++ implementation of LiuCos slip time function.
+// LiuCosSlipFn ---------------------------------------------------------
class pylith::faults::LiuCosSlipFn : public SlipTimeFn
{ // class LiuCosSlipFn
friend class TestLiuCosSlipFn; // unit testing
@@ -54,7 +41,6 @@
LiuCosSlipFn(void);
/// Destructor.
- virtual
~LiuCosSlipFn(void);
/** Set spatial database for final slip.
@@ -80,12 +66,11 @@
/** Initialize slip time function.
*
* @param faultMesh Finite-element mesh of fault.
- * @param cs Coordinate system for mesh.
- * @param originTime Origin time for earthquake source.
+ * @param cs Coordinate system for mesh
* @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
*/
- void initialize(const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
+ void initialize(const topology::SubMesh& faultMesh,
const spatialdata::units::Nondimensional& normalizer,
const double originTime =0.0);
@@ -93,50 +78,42 @@
*
* @param slipField Slip field over fault surface.
* @param t Time t.
- * @param faultMesh Mesh over fault surface.
*
* @returns Slip vector as left-lateral/reverse/normal.
*/
- void slip(const ALE::Obj<real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh);
+ void slip(topology::Field<topology::SubMesh>* const slipField,
+ const double t);
/** Get slip increment on fault surface between time t0 and t1.
*
* @param slipField Slip field over fault surface.
* @param t0 Time t.
* @param t1 Time t+dt.
- * @param faultMesh Mesh over fault surface.
*
* @returns Increment in slip vector as left-lateral/reverse/normal.
*/
- void slipIncr(const ALE::Obj<real_section_type>& slipField,
+ void slipIncr(topology::Field<topology::SubMesh>* slipField,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh);
+ const double t1);
-
/** Get final slip.
*
* @returns Final slip.
*/
- ALE::Obj<real_section_type> finalSlip(void);
+ const topology::Field<topology::SubMesh>& finalSlip(void);
/** Get time when slip begins at each point.
*
* @returns Time when slip begins.
*/
- ALE::Obj<real_section_type> slipTime(void);
+ const topology::Field<topology::SubMesh>& slipTime(void);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
- /// Not implemented
- LiuCosSlipFn(const LiuCosSlipFn& m);
+ LiuCosSlipFn(const LiuCosSlipFn&); ///< Not implemented
+ const LiuCosSlipFn& operator=(const LiuCosSlipFn&); ///< Not implemented
- /// Not implemented
- const LiuCosSlipFn& operator=(const LiuCosSlipFn& f);
-
// PRIVATE METHODS //////////////////////////////////////////////////////
private :
@@ -156,10 +133,14 @@
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- /// Parameters for LiuCos slip time function.
- /// Final slip (vector), peak slip rate (scalar), slip time (scalar).
- ALE::Obj<real_section_type> _parameters;
+ double _slipTimeVertex; ///< Slip time at a vertex.
+ double _riseTimeVertex; ///< Rise time at a vertex.
+ double_array _slipVertex; ///< Slip at a vertex.
+ /// Parameters for Liu cosine/sine slip time function, final slip
+ /// (vector), slip time (scalar), rise time (scalar).
+ topology::Fields<topology::Field<topology::SubMesh> >* _parameters;
+
/// Spatial database for final slip.
spatialdata::spatialdb::SpatialDB* _dbFinalSlip;
@@ -169,8 +150,6 @@
/// Spatial database for rise time.
spatialdata::spatialdb::SpatialDB* _dbRiseTime;
- int _spaceDim; ///< Spatial dimension for slip field.
-
}; // class LiuCosSlipFn
#include "LiuCosSlipFn.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -31,9 +31,13 @@
LiuCosSlipFn.icc \
SlipTimeFn.hh \
StepSlipFn.hh \
- StepSlipFn.icc
+ StepSlipFn.icc \
+ faultsfwd.hh
-noinst_HEADERS =
+noinst_HEADERS = \
+ TopologyOps.hh \
+ TopologyVisitors.hh \
+ TopologyVisitors.cc
# export
clean-local: clean-subpkgincludeHEADERS
Modified: short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,6 @@
#include "SlipTimeFn.hh" // implementation of object methods
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-
// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::SlipTimeFn::SlipTimeFn(void)
Modified: short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/SlipTimeFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,27 +20,15 @@
#if !defined(pylith_faults_sliptimefn_hh)
#define pylith_faults_sliptimefn_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+// Include directives ---------------------------------------------------
+#include "faultsfwd.hh" // forward declarations
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class SlipTimeFn;
- class TestSlipTimeFn; // unit testing
- } // faults
-} // pylith
+#include "pylith/topology/topologyfwd.hh" // USES Field<SubMesh>
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace geocoords {
- class CoordSys;
- } // geocoords
- namespace units {
- class Nondimensional;
- } // units
-} // spatialdata
+#include "spatialdata/units/unitsfwd.hh" // USES Nondimensional
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // USES SpatialDB
-/// C++ abstract base class for Fault object.
+// SlipTimeFn -----------------------------------------------------------
class pylith::faults::SlipTimeFn
{ // class SlipTimeFn
friend class TestSlipTimeFn; // unit testing
@@ -63,8 +51,7 @@
* @param originTime Origin time for earthquake source.
*/
virtual
- void initialize(const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
+ void initialize(const topology::SubMesh& faultMesh,
const spatialdata::units::Nondimensional& normalizer,
const double originTime =0.0) = 0;
@@ -72,53 +59,46 @@
*
* @param slipField Slip field over fault surface.
* @param t Time t.
- * @param faultMesh Mesh over fault surface.
*
* @returns Slip vector as left-lateral/reverse/normal.
*/
virtual
- void slip(const ALE::Obj<real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh) = 0;
+ void slip(topology::Field<topology::SubMesh>* const slipField,
+ const double t) = 0;
/** Get slip increment on fault surface between time t0 and t1.
*
* @param slipField Slip field over fault surface.
* @param t0 Time t.
* @param t1 Time t+dt.
- * @param faultMesh Mesh over fault surface.
*
* @returns Increment in slip vector as left-lateral/reverse/normal.
*/
virtual
- void slipIncr(const ALE::Obj<real_section_type>& slipField,
+ void slipIncr(topology::Field<topology::SubMesh>* slipField,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh) = 0;
+ const double t1) = 0;
/** Get final slip.
*
* @returns Final slip.
*/
virtual
- ALE::Obj<real_section_type> finalSlip(void) = 0;
+ const topology::Field<topology::SubMesh>& finalSlip(void) = 0;
/** Get time when slip begins at each point.
*
* @returns Time when slip begins.
*/
virtual
- ALE::Obj<real_section_type> slipTime(void) = 0;
+ const topology::Field<topology::SubMesh>& slipTime(void) = 0;
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
- /// Not implemented.
- SlipTimeFn(const SlipTimeFn& f);
+ SlipTimeFn(const SlipTimeFn&); ///< Not implemented
+ const SlipTimeFn& operator=(const SlipTimeFn&); ///< Not implemented
- /// Not implemented
- const SlipTimeFn& operator=(const SlipTimeFn& f);
-
}; // class SlipTimeFn
#endif // pylith_faults_sliptimefn_hh
Modified: short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,9 @@
#include "StepSlipFn.hh" // implementation of object methods
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#include "pylith/utils/array.hh" // USES double_array
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/topology/Field.hh" // USES Field
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
@@ -25,20 +26,18 @@
#include <sstream> // USES std::ostringstream
#include <stdexcept> // USES std::runtime_error
-namespace pylith {
- namespace faults {
- namespace _StepSlipFn {
- const int offsetSlipTime = 0;
- } // _StepSlipFn
- } // faults
-} // pylith
+// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::SieveMesh::label_sequence label_sequence;
+typedef pylith::topology::SubMesh::RealSection RealSection;
// ----------------------------------------------------------------------
// Default constructor.
pylith::faults::StepSlipFn::StepSlipFn(void) :
+ _slipTimeVertex(0),
+ _parameters(0),
_dbFinalSlip(0),
- _dbSlipTime(0),
- _spaceDim(0)
+ _dbSlipTime(0)
{ // constructor
} // constructor
@@ -46,45 +45,56 @@
// Destructor.
pylith::faults::StepSlipFn::~StepSlipFn(void)
{ // destructor
- _dbFinalSlip = 0;
- _dbSlipTime = 0;
+ delete _parameters; _parameters = 0;
+ _dbFinalSlip = 0; // :TODO: Use shared pointer
+ _dbSlipTime = 0; // :TODO: Use shared pointer
} // destructor
// ----------------------------------------------------------------------
// Initialize slip time function.
void
pylith::faults::StepSlipFn::initialize(
- const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
- const spatialdata::units::Nondimensional& normalizer,
- const double originTime)
+ const topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime)
{ // initialize
- assert(!faultMesh.isNull());
- assert(0 != cs);
assert(0 != _dbFinalSlip);
assert(0 != _dbSlipTime);
- _spaceDim = cs->spaceDim();
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexSlipTime = spaceDim + _StepSlipFn::offsetSlipTime;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ assert(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const double lengthScale = normalizer.lengthScale();
+ const double timeScale = normalizer.timeScale();
+
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = faultMesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- const int fiberDim = spaceDim + 1;
- _parameters = new real_section_type(faultMesh->comm(), faultMesh->debug());
- _parameters->addSpace(); // final slip
- _parameters->addSpace(); // slip time
- assert(2 == _parameters->getNumSpaces());
- _parameters->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _parameters->setFiberDimension(vertices, fiberDim);
- _parameters->setFiberDimension(vertices, spaceDim, 0); // final slip
- _parameters->setFiberDimension(vertices, 1, 1); // slip time
- faultMesh->allocate(_parameters);
- assert(!_parameters.isNull());
+ delete _parameters; _parameters = new topology::Fields<topology::Field<topology::SubMesh> >(faultMesh);
+ assert(0 != _parameters);
+ _parameters->add("final slip", "final_slip");
+ topology::Field<topology::SubMesh>& finalSlip = _parameters->get("final slip");
+ finalSlip.newSection(vertices, spaceDim);
+ finalSlip.allocate();
+ finalSlip.scale(lengthScale);
+ finalSlip.vectorFieldType(topology::FieldBase::VECTOR);
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ _parameters->add("slip time", "slip_time");
+ topology::Field<topology::SubMesh>& slipTime = _parameters->get("slip time");
+ slipTime.newSection(finalSlipSection->getChart(), 1);
+ slipTime.allocate();
+ slipTime.scale(timeScale);
+ slipTime.vectorFieldType(topology::FieldBase::SCALAR);
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+
// Open databases and set query values
_dbFinalSlip->open();
switch (spaceDim)
@@ -114,16 +124,13 @@
_dbSlipTime->queryVals(slipTimeValues, 1);
// Get coordinates of vertices
- const ALE::Obj<real_section_type>& coordinates =
- faultMesh->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
assert(!coordinates.isNull());
- const double lengthScale = normalizer.lengthScale();
- const double timeScale = normalizer.timeScale();
-
- double_array paramsVertex(fiberDim);
+ _slipVertex.resize(spaceDim);
double_array vCoordsGlobal(spaceDim);
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
coordinates->restrictPoint(*v_iter,
@@ -131,7 +138,7 @@
normalizer.dimensionalize(&vCoordsGlobal[0], vCoordsGlobal.size(),
lengthScale);
- int err = _dbFinalSlip->query(¶msVertex[indexFinalSlip], spaceDim,
+ int err = _dbFinalSlip->query(&_slipVertex[0], _slipVertex.size(),
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
@@ -141,10 +148,10 @@
msg << ") using spatial database " << _dbFinalSlip->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexFinalSlip], spaceDim,
+ normalizer.nondimensionalize(&_slipVertex[0], _slipVertex.size(),
lengthScale);
- err = _dbSlipTime->query(¶msVertex[indexSlipTime], 1,
+ err = _dbSlipTime->query(&_slipTimeVertex, 1,
&vCoordsGlobal[0], vCoordsGlobal.size(), cs);
if (err) {
std::ostringstream msg;
@@ -154,12 +161,12 @@
msg << ") using spatial database " << _dbSlipTime->label() << ".";
throw std::runtime_error(msg.str());
} // if
- normalizer.nondimensionalize(¶msVertex[indexSlipTime], 1,
- timeScale);
+ normalizer.nondimensionalize(&_slipTimeVertex, 1, timeScale);
// add origin time to rupture time
- paramsVertex[indexSlipTime] += originTime;
+ _slipTimeVertex += originTime;
- _parameters->updatePoint(*v_iter, ¶msVertex[0]);
+ finalSlipSection->updatePoint(*v_iter, &_slipVertex[0]);
+ slipTimeSection->updatePoint(*v_iter, &_slipTimeVertex);
} // for
// Close databases
@@ -170,109 +177,109 @@
// ----------------------------------------------------------------------
// Get slip on fault surface at time t.
void
-pylith::faults::StepSlipFn::slip(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::StepSlipFn::slip(topology::Field<topology::SubMesh>* slip,
+ const double t)
{ // slip
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexSlipTime = spaceDim + _StepSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ finalSlipSection->restrictPoint(*v_iter, &_slipVertex[0], _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
- const double* finalSlip = ¶msVertex[indexFinalSlip];
- const double slipTime = paramsVertex[indexSlipTime];
- slipValues = 0.0;
-
- const double relTime = t - slipTime;
- if (relTime >= 0.0)
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = finalSlip[i];
+ const double relTime = t - _slipTimeVertex;
+ if (relTime < 0.0)
+ _slipVertex = 0.0;
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
} // for
- PetscLogFlops(numVertices * 1);
+ PetscLogFlops(vertices->size() * 1);
} // slip
// ----------------------------------------------------------------------
// Get increment of slip on fault surface between time t0 and t1.
void
-pylith::faults::StepSlipFn::slipIncr(const ALE::Obj<pylith::real_section_type>& slipField,
- const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh)
+pylith::faults::StepSlipFn::slipIncr(topology::Field<topology::SubMesh>* slip,
+ const double t0,
+ const double t1)
{ // slipIncr
- assert(!_parameters.isNull());
- assert(!slipField.isNull());
- assert(!faultMesh.isNull());
+ assert(0 != slip);
+ assert(0 != _parameters);
- const int spaceDim = _spaceDim;
- const int indexFinalSlip = 0;
- const int indexSlipTime = spaceDim + _StepSlipFn::offsetSlipTime;
-
- double_array slipValues(spaceDim);
-
// Get vertices in fault mesh
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- const int numVertices = vertices->size();
+ const ALE::Obj<SieveMesh>& sieveMesh = slip->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
+ assert(!vertices.isNull());
+ const label_sequence::iterator verticesEnd = vertices->end();
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ // Get sections
+ const topology::Field<topology::SubMesh>& finalSlip =
+ _parameters->get("final slip");
+ const ALE::Obj<RealSection>& finalSlipSection = finalSlip.section();
+ assert(!finalSlipSection.isNull());
+ const topology::Field<topology::SubMesh>& slipTime =
+ _parameters->get("slip time");
+ const ALE::Obj<RealSection>& slipTimeSection = slipTime.section();
+ assert(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& slipSection = slip->section();
+ assert(!slipSection.isNull());
+
+ for (label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* paramsVertex =
- _parameters->restrictPoint(*v_iter);
- assert(0 != paramsVertex);
+ finalSlipSection->restrictPoint(*v_iter, &_slipVertex[0], _slipVertex.size());
+ slipTimeSection->restrictPoint(*v_iter, &_slipTimeVertex, 1);
- const double* finalSlip = ¶msVertex[indexFinalSlip];
- const double slipTime = paramsVertex[indexSlipTime];
- slipValues = 0.0;
-
- const double relTime0 = t0 - slipTime;
- const double relTime1 = t1 - slipTime;
- if (relTime1 >= 0.0 && relTime0 < 0.0)
- for (int i=0; i < spaceDim; ++i)
- slipValues[i] = finalSlip[i];
+ const double relTime0 = t0 - _slipTimeVertex;
+ const double relTime1 = t1 - _slipTimeVertex;
+ if (relTime1 < 0.0 || relTime0 >= 0.0)
+ _slipVertex = 0.0;
// Update field
- slipField->updateAddPoint(*v_iter, &slipValues[0]);
+ slipSection->updateAddPoint(*v_iter, &_slipVertex[0]);
} // for
- PetscLogFlops(numVertices * 3);
+ PetscLogFlops(vertices->size() * 2);
} // slipIncr
// ----------------------------------------------------------------------
// Get final slip.
-ALE::Obj<pylith::real_section_type>
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::StepSlipFn::finalSlip(void)
{ // finalSlip
- return _parameters->getFibration(0);
+ return _parameters->get("final slip");
} // finalSlip
// ----------------------------------------------------------------------
// Get time when slip begins at each point.
-ALE::Obj<pylith::real_section_type>
+const pylith::topology::Field<pylith::topology::SubMesh>&
pylith::faults::StepSlipFn::slipTime(void)
{ // slipTime
- return _parameters->getFibration(1);
+ return _parameters->get("slip time");
} // slipTime
Modified: short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,27 +22,14 @@
#if !defined(pylith_faults_stepslipfn_hh)
#define pylith_faults_stepslipfn_hh
+// Include directives ---------------------------------------------------
#include "SlipTimeFn.hh"
-/// Namespace for pylith package
-namespace pylith {
- namespace faults {
- class StepSlipFn;
- class TestStepSlipFn; // unit testing
- } // faults
-} // pylith
+#include "pylith/topology/topologyfwd.hh" // USES Fields<Field<SubMesh> >
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB;
- } // spatialdb
- namespace units {
- class Nondimensional;
- } // units
-} // spatialdata
+#include "pylith/utils/array.hh" // HASA double_array
-/// C++ implementation of Step slip time function.
+// StepSlipFn -----------------------------------------------------------
class pylith::faults::StepSlipFn : public SlipTimeFn
{ // class StepSlipFn
friend class TestStepSlipFn; // unit testing
@@ -71,12 +58,11 @@
/** Initialize slip time function.
*
* @param faultMesh Finite-element mesh of fault.
- * @param cs Coordinate system for mesh.
+ * @param cs Coordinate system for mesh
* @param normalizer Nondimensionalization of scales.
* @param originTime Origin time for earthquake source.
*/
- void initialize(const ALE::Obj<Mesh>& faultMesh,
- const spatialdata::geocoords::CoordSys* cs,
+ void initialize(const topology::SubMesh& faultMesh,
const spatialdata::units::Nondimensional& normalizer,
const double originTime =0.0);
@@ -84,64 +70,58 @@
*
* @param slipField Slip field over fault surface.
* @param t Time t.
- * @param faultMesh Mesh over fault surface.
*
* @returns Slip vector as left-lateral/reverse/normal.
*/
- void slip(const ALE::Obj<real_section_type>& slipField,
- const double t,
- const ALE::Obj<Mesh>& faultMesh);
+ void slip(topology::Field<topology::SubMesh>* const slipField,
+ const double t);
/** Get slip increment on fault surface between time t0 and t1.
*
* @param slipField Slip field over fault surface.
* @param t0 Time t.
* @param t1 Time t+dt.
- * @param faultMesh Mesh over fault surface.
*
* @returns Increment in slip vector as left-lateral/reverse/normal.
*/
- void slipIncr(const ALE::Obj<real_section_type>& slipField,
+ void slipIncr(topology::Field<topology::SubMesh>* slipField,
const double t0,
- const double t1,
- const ALE::Obj<Mesh>& faultMesh);
+ const double t1);
/** Get final slip.
*
* @returns Final slip.
*/
- ALE::Obj<real_section_type> finalSlip(void);
+ const topology::Field<topology::SubMesh>& finalSlip(void);
/** Get time when slip begins at each point.
*
* @returns Time when slip begins.
*/
- ALE::Obj<real_section_type> slipTime(void);
+ const topology::Field<topology::SubMesh>& slipTime(void);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
- /// Not implemented
- StepSlipFn(const StepSlipFn& m);
+ StepSlipFn(const StepSlipFn&); ///< Not implemented.
+ const StepSlipFn& operator=(const StepSlipFn&); ///< Not implemented
- /// Not implemented
- const StepSlipFn& operator=(const StepSlipFn& f);
-
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- /// Parameters for Step slip time function.
- /// Final slip (vector), slip time (scalar).
- ALE::Obj<real_section_type> _parameters;
+ double _slipTimeVertex; ///< Slip time at a vertex.
+ double_array _slipVertex; ///< Final slip at a vertex.
+ /// Parameters for step slip time function, final slip (vector) and
+ /// slip time (scalar).
+ topology::Fields<topology::Field<topology::SubMesh> >* _parameters;
+
/// Spatial database for final slip
spatialdata::spatialdb::SpatialDB* _dbFinalSlip;
/// Spatial database for slip time
spatialdata::spatialdb::SpatialDB* _dbSlipTime;
- int _spaceDim; ///< Spatial dimension for slip field.
-
}; // class StepSlipFn
#include "StepSlipFn.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/faults/StepSlipFn.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,9 +14,6 @@
#error "StepSlipFn.icc can only be included from StepSlipFn.hh"
#endif
-#include <math.h> // USES exp()
-#include <assert.h> // USES assert()
-
// Set spatial database for final slip.
inline
void
Copied: short/3D/PyLith/trunk/libsrc/faults/TopologyOps.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/faults/TopologyOps.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/TopologyOps.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/TopologyOps.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,512 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TopologyOps.hh" // implementation of object methods
+
+#include "TopologyVisitors.hh" // USES ClassifyVisitor
+
+#include <Selection.hh> // Algorithms for submeshes
+
+#include <cassert> // USES assert()
+
+// ----------------------------------------------------------------------
+template<class InputPoints>
+bool
+pylith::faults::TopologyOps::compatibleOrientation(const ALE::Obj<SieveMesh>& mesh,
+ const SieveMesh::point_type& p,
+ const SieveMesh::point_type& q,
+ const int numFaultCorners,
+ const int faultFaceSize,
+ const int faultDepth,
+ const ALE::Obj<InputPoints>& points,
+ int indices[],
+ PointArray *origVertices,
+ PointArray *faceVertices,
+ PointArray *neighborVertices)
+{
+ typedef ALE::Selection<SieveMesh> selection;
+ const int debug = mesh->debug();
+ bool compatible;
+
+ bool eOrient = selection::getOrientedFace(mesh, p, points, numFaultCorners, indices, origVertices, faceVertices);
+ bool nOrient = selection::getOrientedFace(mesh, q, points, numFaultCorners, indices, origVertices, neighborVertices);
+
+ if (faultFaceSize > 1) {
+ if (debug) {
+ for(PointArray::iterator v_iter = faceVertices->begin(); v_iter != faceVertices->end(); ++v_iter) {
+ std::cout << " face vertex " << *v_iter << std::endl;
+ }
+ for(PointArray::iterator v_iter = neighborVertices->begin(); v_iter != neighborVertices->end(); ++v_iter) {
+ std::cout << " neighbor vertex " << *v_iter << std::endl;
+ }
+ }
+ compatible = !(*faceVertices->begin() == *neighborVertices->begin());
+ } else {
+ compatible = !(nOrient == eOrient);
+ }
+ return compatible;
+}
+
+// ----------------------------------------------------------------------
+void
+pylith::faults::TopologyOps::computeCensoredDepth(const ALE::Obj<SieveMesh::label_type>& depth,
+ const ALE::Obj<SieveMesh::sieve_type>& sieve,
+ const SieveMesh::point_type& firstCohesiveCell)
+{
+ SieveMesh::DepthVisitor d(*sieve, firstCohesiveCell, *depth);
+
+ sieve->roots(d);
+ while(d.isModified()) {
+ // FIX: Avoid the copy here somehow by fixing the traversal
+ std::vector<SieveMesh::point_type> modifiedPoints(d.getModifiedPoints().begin(), d.getModifiedPoints().end());
+
+ d.clear();
+ sieve->support(modifiedPoints, d);
+ }
+}
+
+// ----------------------------------------------------------------------
+void
+pylith::faults::TopologyOps::classifyCells(const ALE::Obj<SieveMesh::sieve_type>& sieve,
+ const SieveMesh::point_type& vertex,
+ const int depth,
+ const int faceSize,
+ const SieveMesh::point_type& firstCohesiveCell,
+ PointSet& replaceCells,
+ PointSet& noReplaceCells,
+ const int debug)
+{
+ // Replace all cells on a given side of the fault with a vertex on the fault
+ ClassifyVisitor<SieveMesh::sieve_type> cV(*sieve, replaceCells, noReplaceCells,
+ firstCohesiveCell, faceSize, debug);
+ const PointSet& vReplaceCells = cV.getReplaceCells();
+ const PointSet& vNoReplaceCells = cV.getNoReplaceCells();
+
+ if (debug) {std::cout << "Checking fault vertex " << vertex << std::endl;}
+ sieve->support(vertex, cV);
+ cV.setMode(false);
+ const int classifyTotal = cV.getSize();
+ int classifySize = vReplaceCells.size() + vNoReplaceCells.size();
+
+ while(cV.getModified() && (classifySize < classifyTotal)) {
+ cV.reset();
+ sieve->support(vertex, cV);
+ if (debug) {
+ std::cout << "classifySize: " << classifySize << std::endl;
+ std::cout << "classifyTotal: " << classifyTotal << std::endl;
+ std::cout << "vReplaceCells.size: " << vReplaceCells.size() << std::endl;
+ std::cout << "vNoReplaceCells.size: " << vNoReplaceCells.size() << std::endl;
+ }
+ assert(classifySize < vReplaceCells.size() + vNoReplaceCells.size());
+ classifySize = vReplaceCells.size() + vNoReplaceCells.size();
+ assert(classifySize <= classifyTotal);
+ }
+ replaceCells.insert(vReplaceCells.begin(), vReplaceCells.end());
+ // More checking
+ noReplaceCells.insert(vNoReplaceCells.begin(), vNoReplaceCells.end());
+}
+
+// ----------------------------------------------------------------------
+void
+pylith::faults::TopologyOps::createFaultSieveFromVertices(const int dim,
+ const int firstCell,
+ const PointSet& faultVertices,
+ const ALE::Obj<SieveMesh>& mesh,
+ const ALE::Obj<ALE::Mesh::arrow_section_type>& orientation,
+ const ALE::Obj<ALE::Mesh::sieve_type>& faultSieve,
+ const bool flipFault)
+{
+ typedef ALE::Selection<ALE::Mesh> selection;
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = mesh->getSieve();
+ const PointSet::const_iterator fvBegin = faultVertices.begin();
+ const PointSet::const_iterator fvEnd = faultVertices.end();
+ int curCell = firstCell;
+ int curVertex = 0;
+ int newElement = curCell + dim*faultVertices.size();
+ int o = 1;
+ ALE::Mesh::point_type f = firstCell;
+ const int debug = mesh->debug();
+ ALE::Obj<PointSet> face = new PointSet();
+ int numCorners = 0; // The number of vertices in a mesh cell
+ int faceSize = 0; // The number of vertices in a mesh face
+ int *indices = NULL; // The indices of a face vertex set in a cell
+ std::map<int,int*> curElement;
+ std::map<int,PointArray> bdVertices;
+ std::map<int,PointArray> faultFaces;
+ std::map<int,oPointArray> oFaultFaces;
+ PointSet faultCells;
+ PointArray origVertices;
+ PointArray faceVertices;
+
+ if (!faultSieve->commRank()) {
+ numCorners = mesh->getNumCellCorners();
+ faceSize = selection::numFaceVertices(mesh);
+ indices = new int[faceSize];
+ }
+
+ curElement[0] = &curVertex;
+ curElement[dim] = &curCell;
+ for(int d = 1; d < dim; d++) {
+ curElement[d] = &newElement;
+ }
+
+ // This only works for uninterpolated meshes
+ assert((mesh->depth() == 1) || (mesh->depth() == -1));
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> sV(std::max(1, sieve->getMaxSupportSize()));
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> cV(std::max(1, sieve->getMaxConeSize()));
+ for(PointSet::const_iterator fv_iter = fvBegin; fv_iter != fvEnd; ++fv_iter) {
+ sieve->support(*fv_iter, sV);
+ const SieveMesh::point_type *support = sV.getPoints();
+
+ if (debug) std::cout << "Checking fault vertex " << *fv_iter << std::endl;
+ const int sVsize = sV.getSize();
+ for (int i=0; i < sVsize; ++i) {
+ const int s = (!flipFault) ? i : sVsize - i - 1;
+ sieve->cone(support[s], cV);
+ const SieveMesh::point_type *cone = cV.getPoints();
+
+ if (debug) std::cout << " Checking cell " << support[s] << std::endl;
+ if (faultCells.find(support[s]) != faultCells.end()) {
+ cV.clear();
+ continue;
+ }
+ face->clear();
+ for(int c = 0; c < cV.getSize(); ++c) {
+ if (faultVertices.find(cone[c]) != fvEnd) {
+ if (debug) std::cout << " contains fault vertex " << cone[c] << std::endl;
+ face->insert(face->end(), cone[c]);
+ } // if
+ } // for
+ if (face->size() > faceSize)
+ throw ALE::Exception("Invalid fault mesh: Too many vertices of an "
+ "element on the fault");
+ if (face->size() == faceSize) {
+ if (debug) std::cout << " Contains a face on the fault" << std::endl;
+ ALE::Obj<SieveMesh::sieve_type::supportSet> preFace;
+ if (dim < 2) {
+ preFace = faultSieve->nJoin1(face);
+ } else {
+ preFace = faultSieve->nJoin(face, dim);
+ }
+
+ if (preFace->size() > 1) {
+ throw ALE::Exception("Invalid fault sieve: Multiple faces from vertex set");
+ } else if (preFace->size() == 1) {
+ // Add the other cell neighbor for this face
+ if (dim == 0) {
+ faultSieve->addArrow(*faceVertices.begin(), support[s]);
+ } else {
+ faultSieve->addArrow(*preFace->begin(), support[s]);
+ }
+ } else if (preFace->size() == 0) {
+ if (debug) std::cout << " Orienting face " << f << std::endl;
+ selection::getOrientedFace(mesh, support[s], face, numCorners, indices, &origVertices, &faceVertices);
+ bdVertices[dim].clear();
+ for(PointArray::const_iterator v_iter = faceVertices.begin(); v_iter != faceVertices.end(); ++v_iter) {
+ bdVertices[dim].push_back(*v_iter);
+ if (debug) std::cout << " Boundary vertex " << *v_iter << std::endl;
+ }
+ if (dim == 0) {
+ f = *faceVertices.begin();
+ }
+ if (faceSize != dim+1) {
+ if (debug) std::cout << " Adding hex face " << f << std::endl;
+ ALE::SieveBuilder<ALE::Mesh>::buildHexFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
+ } else {
+ if (debug) std::cout << " Adding simplicial face " << f << std::endl;
+ ALE::SieveBuilder<ALE::Mesh>::buildFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
+ }
+ faultSieve->addArrow(f, support[s]);
+ //faultSieve->view("");
+ f++;
+ } // if/else
+ faultCells.insert(support[s]);
+ } // if
+ cV.clear();
+ } // for
+ sV.clear();
+ } // for
+ if (!faultSieve->commRank()) delete [] indices;
+}
+
+// ----------------------------------------------------------------------
+void
+pylith::faults::TopologyOps::createFaultSieveFromFaces(const int dim,
+ const int firstCell,
+ const int numFaces,
+ const int faultVertices[],
+ const int faultCells[],
+ const ALE::Obj<SieveMesh>& mesh,
+ const ALE::Obj<ALE::Mesh::arrow_section_type>& orientation,
+ const ALE::Obj<ALE::Mesh::sieve_type>& faultSieve)
+{
+ typedef ALE::Selection<ALE::Mesh> selection;
+ int faceSize = 0; // The number of vertices in a mesh face
+ int curCell = firstCell;
+ int curVertex = 0;
+ int newElement = curCell + dim*numFaces;
+ int o = 1;
+ int f = firstCell;
+ const int debug = mesh->debug();
+ std::map<int,int*> curElement;
+ std::map<int,PointArray> bdVertices;
+ std::map<int,oPointArray> oFaultFaces;
+
+ if (!faultSieve->commRank()) {
+ faceSize = selection::numFaceVertices(mesh);
+ }
+
+ curElement[0] = &curVertex;
+ curElement[dim] = &curCell;
+ for(int d = 1; d < dim; d++) {
+ curElement[d] = &newElement;
+ }
+
+ // Loop over fault faces
+ for(int face = 0; face < numFaces; ++face) {
+ // Push oriented vertices of face
+ bdVertices[dim].clear();
+ for(int i = 0; i < faceSize; ++i) {
+ bdVertices[dim].push_back(faultVertices[face*faceSize+i]);
+ if (debug) std::cout << " Boundary vertex " << faultVertices[face*faceSize+i] << std::endl;
+ }
+ // Create face
+ if (faceSize != dim+1) {
+ if (debug) std::cout << " Adding hex face " << f << std::endl;
+ ALE::SieveBuilder<ALE::Mesh>::buildHexFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
+ } else {
+ if (debug) std::cout << " Adding simplicial face " << f << std::endl;
+ ALE::SieveBuilder<ALE::Mesh>::buildFaces(faultSieve, orientation, dim, curElement, bdVertices, oFaultFaces, f, o);
+ }
+ // Add arrow to cells
+ faultSieve->addArrow(face, faultCells[face*2+0]);
+ faultSieve->addArrow(face, faultCells[face*2+1]);
+ }
+}
+
+// ----------------------------------------------------------------------
+void
+pylith::faults::TopologyOps::orientFaultSieve(const int dim,
+ const ALE::Obj<SieveMesh>& mesh,
+ const ALE::Obj<ALE::Mesh::arrow_section_type>& orientation,
+ const ALE::Obj<ALE::Mesh>& fault)
+{
+ // Must check the orientation here
+ typedef ALE::Selection<ALE::Mesh> selection;
+ const ALE::Obj<ALE::Mesh::sieve_type>& faultSieve = fault->getSieve();
+ const SieveMesh::point_type firstFaultCell = *fault->heightStratum(1)->begin();
+ const ALE::Obj<ALE::Mesh::label_sequence>& fFaces = fault->heightStratum(2);
+ const int numFaultFaces = fFaces->size();
+ const int faultDepth = fault->depth()-1; // Depth of fault cells
+ int numFaultCorners = 0; // The number of vertices in a fault cell
+ int faultFaceSize = 0; // The number of vertices in a face between fault cells
+ int faceSize = 0; // The number of vertices in a mesh face
+ const int debug = fault->debug();
+ ALE::Obj<PointSet> newCells = new PointSet();
+ ALE::Obj<PointSet> loopCells = new PointSet();
+ PointSet flippedCells; // Incorrectly oriented fault cells
+ PointSet facesSeen; // Fault faces already considered
+ PointSet cellsSeen; // Fault cells already matched
+ PointArray faceVertices;
+
+ if (!fault->commRank()) {
+ faceSize = selection::numFaceVertices(mesh);
+ numFaultCorners = faultSieve->nCone(firstFaultCell, faultDepth)->size();
+ if (debug) std::cout << " Fault corners " << numFaultCorners << std::endl;
+ if (dim == 0) {
+ assert(numFaultCorners == faceSize-1);
+ } else {
+ assert(numFaultCorners == faceSize);
+ }
+ if (faultDepth == 1) {
+ faultFaceSize = 1;
+ } else {
+ faultFaceSize = faultSieve->nCone(*fFaces->begin(), faultDepth-1)->size();
+ }
+ }
+ if (debug) std::cout << " Fault face size " << faultFaceSize << std::endl;
+
+ newCells->insert(firstFaultCell);
+ while(facesSeen.size() != numFaultFaces) {
+ ALE::Obj<PointSet> tmp = newCells; newCells = loopCells; loopCells = tmp;
+
+ newCells->clear();
+ if (!loopCells->size()) {throw ALE::Exception("Fault surface not a single connected component.");}
+ // Loop over new cells
+ for(PointSet::iterator c_iter = loopCells->begin(); c_iter != loopCells->end(); ++c_iter) {
+ // Loop over edges of this cell
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::coneSequence>& cone = faultSieve->cone(*c_iter);
+ const ALE::Mesh::sieve_type::traits::coneSequence::iterator eBegin = cone->begin();
+ const ALE::Mesh::sieve_type::traits::coneSequence::iterator eEnd = cone->end();
+
+ for(ALE::Mesh::sieve_type::traits::coneSequence::iterator e_iter = eBegin; e_iter != eEnd; ++e_iter) {
+ if (facesSeen.find(*e_iter) != facesSeen.end()) continue;
+ facesSeen.insert(*e_iter);
+ if (debug) std::cout << " Checking orientation of fault face " << *e_iter << std::endl;
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::supportSequence>& support = faultSieve->support(*e_iter);
+ ALE::Mesh::sieve_type::traits::supportSequence::iterator s_iter = support->begin();
+
+ // Throw out boundary fault faces
+ if (support->size() < 2) continue;
+ ALE::Mesh::point_type cellA = *s_iter; ++s_iter;
+ ALE::Mesh::point_type cellB = *s_iter;
+ bool flippedA = (flippedCells.find(cellA) != flippedCells.end());
+ bool flippedB = (flippedCells.find(cellB) != flippedCells.end());
+ bool seenA = (cellsSeen.find(cellA) != cellsSeen.end());
+ bool seenB = (cellsSeen.find(cellB) != cellsSeen.end());
+
+ if (!seenA) newCells->insert(cellA);
+ if (!seenB) newCells->insert(cellB);
+ if (debug) std::cout << " neighboring cells " << cellA << " and " << cellB << std::endl;
+ // In 1D, just check that vertices match
+ if (dim == 1) {
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneA = faultSieve->cone(cellA);
+ ALE::Mesh::sieve_type::traits::coneSequence::iterator iterA = coneA->begin();
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneB = faultSieve->cone(cellB);
+ ALE::Mesh::sieve_type::traits::coneSequence::iterator iterB = coneB->begin();
+ int posA, posB;
+
+ for(posA = 0; posA < 2; ++posA, ++iterA) if (*iterA == *e_iter) break;
+ for(posB = 0; posB < 2; ++posB, ++iterB) if (*iterB == *e_iter) break;
+ if (debug) std::cout << " with face positions " << posA << " and " << posB << std::endl;
+ if ((posA == 2) || (posB == 2)) {throw ALE::Exception("Could not find fault face in cone");}
+ if ((posA == posB) ^ (flippedA || flippedB)) {
+ if (debug) {
+ std::cout << "Invalid orientation in fault mesh" << std::endl;
+ std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
+ }
+ if (flippedA && flippedB) {throw ALE::Exception("Attempt to flip already flipped cell: Fault mesh is non-orientable");}
+ if (seenA && seenB) {throw ALE::Exception("Previous cells do not match: Fault mesh is non-orientable");}
+ if (!seenA && !flippedA) {
+ flippedCells.insert(cellA);
+ } else if (!seenB && !flippedB) {
+ flippedCells.insert(cellB);
+ } else {
+ throw ALE::Exception("Inconsistent mesh orientation: Fault mesh is non-orientable");
+ }
+ }
+ } else if (dim == 2) {
+ // Check orientation
+ ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowA(*e_iter, cellA);
+ const int oA = orientation->restrictPoint(arrowA)[0];
+ ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowB(*e_iter, cellB);
+ const int oB = orientation->restrictPoint(arrowB)[0];
+ const bool mismatch = (oA == oB);
+
+ // Truth Table
+ // mismatch flips action mismatch flipA ^ flipB action
+ // F 0 flips no F F F
+ // F 1 flip yes F T T
+ // F 2 flips no T F T
+ // T 0 flips yes T T F
+ // T 1 flip no
+ // T 2 flips yes
+ if (mismatch ^ (flippedA ^ flippedB)) {
+ if (debug) {
+ std::cout << "Invalid orientation in fault mesh" << std::endl;
+ std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
+ }
+ if (flippedA && flippedB) {throw ALE::Exception("Attempt to flip already flipped cell: Fault mesh is non-orientable");}
+ if (seenA && seenB) {throw ALE::Exception("Previous cells do not match: Fault mesh is non-orientable");}
+ if (!seenA && !flippedA) {
+ flippedCells.insert(cellA);
+ if (debug) {std::cout << " Scheduling cell " << cellA << " for flipping" << std::endl;}
+ } else if (!seenB && !flippedB) {
+ flippedCells.insert(cellB);
+ if (debug) {std::cout << " Scheduling cell " << cellB << " for flipping" << std::endl;}
+ } else {
+ throw ALE::Exception("Inconsistent mesh orientation: Fault mesh is non-orientable");
+ }
+ }
+ }
+ cellsSeen.insert(cellA);
+ cellsSeen.insert(cellB);
+ }
+ }
+ }
+ for(PointSet::const_iterator f_iter = flippedCells.begin(); f_iter != flippedCells.end(); ++f_iter) {
+ if (debug) std::cout << " Reversing fault face " << *f_iter << std::endl;
+ faceVertices.clear();
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::coneSequence>& cone = faultSieve->cone(*f_iter);
+ for(ALE::Mesh::sieve_type::traits::coneSequence::iterator v_iter = cone->begin(); v_iter != cone->end(); ++v_iter) {
+ faceVertices.insert(faceVertices.begin(), *v_iter);
+ }
+ faultSieve->clearCone(*f_iter);
+ int color = 0;
+ for(PointArray::const_iterator v_iter = faceVertices.begin(); v_iter != faceVertices.end(); ++v_iter) {
+ faultSieve->addArrow(*v_iter, *f_iter, color++);
+ }
+
+ if (dim > 1) {
+ // Here, they are edges, not vertices
+ for(PointArray::const_iterator e_iter = faceVertices.begin(); e_iter != faceVertices.end(); ++e_iter) {
+ ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrow(*e_iter, *f_iter);
+ int o = orientation->restrictPoint(arrow)[0];
+
+ if (debug) std::cout << " Reversing orientation of " << *e_iter <<"-->"<<*f_iter << " from " << o << " to " << -(o+1) << std::endl;
+ o = -(o+1);
+ orientation->updatePoint(arrow, &o);
+ }
+ }
+ }
+ flippedCells.clear();
+ for(ALE::Mesh::label_sequence::iterator e_iter = fFaces->begin(); e_iter != fFaces->end(); ++e_iter) {
+ if (debug) std::cout << " Checking orientation of fault face " << *e_iter << std::endl;
+ // for each face get the support (2 fault cells)
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::supportSequence>& support = faultSieve->support(*e_iter);
+ ALE::Mesh::sieve_type::traits::supportSequence::iterator s_iter = support->begin();
+
+ // Throw out boundary fault faces
+ if (support->size() > 1) {
+ ALE::Mesh::point_type cellA = *s_iter; ++s_iter;
+ ALE::Mesh::point_type cellB = *s_iter;
+
+ if (debug) std::cout << " neighboring cells " << cellA << " and " << cellB << std::endl;
+ // In 1D, just check that vertices match
+ if (dim == 1) {
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneA = faultSieve->cone(cellA);
+ ALE::Mesh::sieve_type::traits::coneSequence::iterator iterA = coneA->begin();
+ const ALE::Obj<ALE::Mesh::sieve_type::traits::coneSequence>& coneB = faultSieve->cone(cellB);
+ ALE::Mesh::sieve_type::traits::coneSequence::iterator iterB = coneB->begin();
+ int posA, posB;
+
+ for(posA = 0; posA < 2; ++posA, ++iterA) if (*iterA == *e_iter) break;
+ for(posB = 0; posB < 2; ++posB, ++iterB) if (*iterB == *e_iter) break;
+ if (debug) std::cout << " with face positions " << posA << " and " << posB << std::endl;
+ if ((posA == 2) || (posB == 2)) {throw ALE::Exception("Could not find fault face in cone");}
+ if (posA == posB) {
+ std::cout << "Invalid orientation in fault mesh" << std::endl;
+ std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
+ throw ALE::Exception("Invalid orientation in fault mesh");
+ }
+ } else {
+ // Check orientation
+ ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowA(*e_iter, cellA);
+ const int oA = orientation->restrictPoint(arrowA)[0];
+ ALE::MinimalArrow<ALE::Mesh::sieve_type::point_type,ALE::Mesh::sieve_type::point_type> arrowB(*e_iter, cellB);
+ const int oB = orientation->restrictPoint(arrowB)[0];
+
+ if (oA == oB) {
+ std::cout << "Invalid orientation in fault mesh" << std::endl;
+ std::cout << " fault face: " << *e_iter << " cellA: " << cellA << " cellB: " << cellB << std::endl;
+ throw ALE::Exception("Invalid orientation in fault mesh");
+ }
+ }
+ }
+ }
+ if (debug) fault->view("Oriented Fault mesh");
+}
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/faults/TopologyOps.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/faults/TopologyOps.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/TopologyOps.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/TopologyOps.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/faults/TopologyOps.hh
+ *
+ * @brief C++ object to manage creation of cohesive cells.
+ */
+
+#if !defined(pylith_faults_topologyops_hh)
+#define pylith_faults_topologyops_hh
+
+// Include directives ---------------------------------------------------
+#include "faultsfwd.hh" // forward declarations
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+
+// TopologyOps ----------------------------------------------------------
+class pylith::faults::TopologyOps
+{ // class TopologyOps
+
+ // PUBLIC TYPEDEFS ////////////////////////////////////////////////////
+public :
+ typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+ typedef std::set<SieveMesh::point_type> PointSet;
+ typedef std::vector<SieveMesh::sieve_type::point_type> PointArray;
+ typedef std::pair<SieveMesh::sieve_type::point_type, int> oPoint_type;
+ typedef std::vector<oPoint_type> oPointArray;
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ template<class InputPoints>
+ static
+ bool compatibleOrientation(const ALE::Obj<SieveMesh>& mesh,
+ const SieveMesh::point_type& p,
+ const SieveMesh::point_type& q,
+ const int numFaultCorners,
+ const int faultFaceSize,
+ const int faultDepth,
+ const ALE::Obj<InputPoints>& points,
+ int indices[],
+ PointArray *origVertices,
+ PointArray *faceVertices,
+ PointArray *neighborVertices);
+
+ static
+ void computeCensoredDepth(const ALE::Obj<SieveMesh::label_type>& depth,
+ const ALE::Obj<SieveMesh::sieve_type>& sieve,
+ const SieveMesh::point_type& firstCohesiveCell);
+
+ static
+ void classifyCells(const ALE::Obj<SieveMesh::sieve_type>& sieve,
+ const SieveMesh::point_type& vertex,
+ const int depth,
+ const int faceSize,
+ const SieveMesh::point_type& firstCohesiveCell,
+ PointSet& replaceCells,
+ PointSet& noReplaceCells,
+ const int debug);
+
+ static
+ void createFaultSieveFromVertices(const int dim,
+ const int firstCell,
+ const PointSet& faultVertices,
+ const ALE::Obj<SieveMesh>& mesh,
+ const ALE::Obj<ALE::Mesh::arrow_section_type>& orientation,
+ const ALE::Obj<ALE::Mesh::sieve_type>& faultSieve,
+ const bool flipFault);
+
+ static
+ void createFaultSieveFromFaces(const int dim,
+ const int firstCell,
+ const int numFaces,
+ const int faultVertices[],
+ const int faultCells[],
+ const ALE::Obj<SieveMesh>& mesh,
+ const ALE::Obj<ALE::Mesh::arrow_section_type>& orientation,
+ const ALE::Obj<ALE::Mesh::sieve_type>& faultSieve);
+
+ static
+ void orientFaultSieve(const int dim,
+ const ALE::Obj<SieveMesh>& mesh,
+ const ALE::Obj<ALE::Mesh::arrow_section_type>& orientation,
+ const ALE::Obj<ALE::Mesh>& fault);
+}; // class CohesiveTopology
+
+#endif // pylith_faults_cohesivetopology_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/faults/TopologyVisitors.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,257 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+// ----------------------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+pylith::faults::ReplaceVisitor<Sieve,Renumbering>::ReplaceVisitor(
+ Renumbering& r,
+ const int size,
+ const int debug) :
+ renumbering(r),
+ size(size),
+ i(0),
+ debug(debug)
+{ // constructor
+ this->points = new point_type[this->size];
+ this->mapped = false;
+} // constructor
+
+// ----------------------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+pylith::faults::ReplaceVisitor<Sieve,Renumbering>::~ReplaceVisitor()
+{ // destructor
+ delete[] this->points;
+} // destructor
+
+// ----------------------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+void
+pylith::faults::ReplaceVisitor<Sieve,Renumbering>::visitPoint(
+ const point_type& point)
+{ // visitPoint
+ if (i >= this->size)
+ throw ALE::Exception("Too many points for ReplaceVisitor");
+ if (this->renumbering.find(point) != this->renumbering.end()) {
+ if (debug)
+ std::cout << " point " << this->renumbering[point] << std::endl;
+ points[i] = this->renumbering[point];
+ this->mapped = true;
+ } else {
+ if (debug) std::cout << " point " << point << std::endl;
+ points[i] = point;
+ } // if/else
+ ++i;
+} // visitPoint
+
+// ----------------------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+void
+pylith::faults::ReplaceVisitor<Sieve,Renumbering>::visitArrow(
+ const typename Sieve::arrow_type&)
+{ // visitArrow
+} // visitArrow
+
+// ----------------------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+inline
+const typename Sieve::point_type*
+pylith::faults::ReplaceVisitor<Sieve,Renumbering>::getPoints(void)
+{ // getPoints
+ return this->points;
+} // getPoints
+
+// ----------------------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+inline
+bool
+pylith::faults::ReplaceVisitor<Sieve,Renumbering>::mappedPoint(void)
+{ // mappedPoint
+ return this->mapped;
+} // mappedPoint
+
+// ----------------------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+inline
+void
+pylith::faults::ReplaceVisitor<Sieve,Renumbering>::clear(void)
+{ // clear
+ this->i = 0; this->mapped = false;
+} // clear
+
+
+// ClassifyVisitor ------------------------------------------------------
+template<typename Sieve>
+pylith::faults::ClassifyVisitor<Sieve>::ClassifyVisitor(const Sieve& s,
+ const PointSet& rC,
+ const PointSet& nrC,
+ const point_type& fC,
+ const int fS,
+ const int debug) :
+ sieve(s),
+ replaceCells(rC),
+ noReplaceCells(nrC),
+ firstCohesiveCell(fC),
+ faceSize(fS),
+ debug(debug),
+ modified(false),
+ setupMode(true),
+ size(0)
+{ // constructor
+ pR.setSize(s.getMaxConeSize());
+} // constructor
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+pylith::faults::ClassifyVisitor<Sieve>::~ClassifyVisitor(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+void
+pylith::faults::ClassifyVisitor<Sieve>::visitPoint(const point_type& point)
+{ // visitPoint
+ if (this->setupMode) {
+ if (replaceCells.find(point) != replaceCells.end())
+ vReplaceCells.insert(point);
+ if (noReplaceCells.find(point) != noReplaceCells.end())
+ vNoReplaceCells.insert(point);
+ if (point >= firstCohesiveCell) return;
+ this->modified = true;
+ this->size++;
+ return;
+ } // if
+ bool classified = false;
+
+ if (debug)
+ std::cout << "Checking neighbor " << point << std::endl;
+ if (vReplaceCells.find(point) != vReplaceCells.end()) {
+ if (debug)
+ std::cout << " already in replaceCells" << std::endl;
+ return;
+ } // if
+ if (vNoReplaceCells.find(point) != vNoReplaceCells.end()) {
+ if (debug)
+ std::cout << " already in noReplaceCells" << std::endl;
+ return;
+ } // if
+ if (point >= firstCohesiveCell) {
+ if (debug)
+ std::cout << " already a cohesive cell" << std::endl;
+ return;
+ } // if
+ // If neighbor shares a face with anyone in replaceCells, then add
+ for (typename PointSet::const_iterator c_iter = vReplaceCells.begin();
+ c_iter != vReplaceCells.end();
+ ++c_iter) {
+ sieve.meet(*c_iter, point, pR);
+
+ if (pR.getSize() == faceSize) {
+ if (debug)
+ std::cout << " Scheduling " << point << " for replacement"
+ << std::endl;
+ vReplaceCells.insert(point);
+ modified = true;
+ classified = true;
+ pR.clear();
+ break;
+ } // if
+ pR.clear();
+ } // for
+ if (classified)
+ return;
+ // It is unclear whether taking out the noReplace cells will speed this up
+ for (typename PointSet::const_iterator c_iter = vNoReplaceCells.begin();
+ c_iter != vNoReplaceCells.end();
+ ++c_iter) {
+ sieve.meet(*c_iter, point, pR);
+
+ if (pR.getSize() == faceSize) {
+ if (debug)
+ std::cout << " Scheduling " << point << " for no replacement"
+ << std::endl;
+ vNoReplaceCells.insert(point);
+ modified = true;
+ classified = true;
+ pR.clear();
+ break;
+ } // for
+ pR.clear();
+ } // for
+} // visitPoint
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+inline
+void
+pylith::faults::ClassifyVisitor<Sieve>::visitArrow(const typename Sieve::arrow_type&)
+{ // visitArrow
+} // visitArrow
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+inline
+const std::set<typename Sieve::point_type>&
+pylith::faults::ClassifyVisitor<Sieve>::getReplaceCells(void) const
+{ // getReplaceCells
+ return this->vReplaceCells;
+} // getReplaceCells
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+inline
+const std::set<typename Sieve::point_type>&
+pylith::faults::ClassifyVisitor<Sieve>::getNoReplaceCells() const
+{ // getNoReplaceCells
+ return this->vNoReplaceCells;
+} // getNoReplaceCells
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+inline
+bool
+pylith::faults::ClassifyVisitor<Sieve>::getModified() const
+{ // getModified
+ return this->modified;
+} // getModified
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+inline
+int
+pylith::faults::ClassifyVisitor<Sieve>::getSize() const
+{ // getSize
+ return this->size;
+} // getSize
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+inline
+void
+pylith::faults::ClassifyVisitor<Sieve>::setMode(const bool isSetup)
+{ // setMode
+ this->setupMode = isSetup;
+} // setMode
+
+// ----------------------------------------------------------------------
+template<typename Sieve>
+inline
+void
+pylith::faults::ClassifyVisitor<Sieve>::reset(void)
+{ // reset
+ this->modified = false;
+} // reset
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/faults/TopologyVisitors.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/TopologyVisitors.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file libsrc/faults/TopologyVisitors.hh
+ *
+ * @brief C++ objects for visitors to topology data structures.
+ */
+
+#if !defined(pylith_faults_topologyvisitors_hh)
+#define pylith_faults_topologyvisitors_hh
+
+// Include directives ---------------------------------------------------
+#include "faultsfwd.hh" // forward declarations
+
+// ReplaceVisitor -------------------------------------------------------
+template<typename Sieve, typename Renumbering>
+class pylith::faults::ReplaceVisitor {
+private:
+ typedef typename Sieve::point_type point_type;
+protected:
+ Renumbering& renumbering;
+ const int size;
+ int i;
+ const int debug;
+ point_type *points;
+ bool mapped;
+public:
+ ReplaceVisitor(Renumbering& r,
+ const int size,
+ const int debug =0);
+ ~ReplaceVisitor(void);
+ void visitPoint(const point_type& point);
+ void visitArrow(const typename Sieve::arrow_type&);
+ const point_type *getPoints(void);
+ bool mappedPoint(void);
+ void clear(void);
+};
+
+// ClassifyVisitor ------------------------------------------------------
+template<typename Sieve>
+class pylith::faults::ClassifyVisitor {
+public:
+ typedef typename Sieve::point_type point_type;
+ typedef std::set<point_type> PointSet;
+protected:
+ const Sieve& sieve;
+ const PointSet& replaceCells;
+ const PointSet& noReplaceCells;
+ const point_type firstCohesiveCell;
+ const int faceSize;
+ const int debug;
+ PointSet vReplaceCells;
+ PointSet vNoReplaceCells;
+ bool modified;
+ bool setupMode;
+ int size;
+ ALE::ISieveVisitor::PointRetriever<Sieve> pR;
+public:
+ ClassifyVisitor(const Sieve& s,
+ const PointSet& rC,
+ const PointSet& nrC,
+ const point_type& fC,
+ const int fS,
+ const int debug =0);
+ ~ClassifyVisitor(void);
+ void visitPoint(const point_type& point);
+ void visitArrow(const typename Sieve::arrow_type&);
+ const PointSet& getReplaceCells() const;
+ const PointSet& getNoReplaceCells() const;
+ bool getModified() const;
+ int getSize() const;
+ void setMode(const bool isSetup);
+ void reset();
+};
+
+#include "TopologyVisitors.cc" // template definitions
+
+#endif // pylith_faults_topologyvisitors_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/faults/faultsfwd.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/faults/faultsfwd.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/faults/faultsfwd.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/faults/faultsfwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/faults/faultsfwd.hh
+ *
+ * @brief Forward declarations for PyLith faults objects.
+ *
+ * Including this header file eliminates the need to use separate
+ * forward declarations.
+ */
+
+#if !defined(pylith_faults_faultsfwd_hh)
+#define pylith_faults_faultsfwd_hh
+
+namespace pylith {
+ namespace faults {
+
+ class CohesiveTopology;
+
+ class Fault;
+ class FaultCohesive;
+ class FaultCohesiveDyn;
+ class FaultCohesiveKin;
+
+ class EqKinSrc;
+ class SlipTimeFn;
+ class BruneSlipFn;
+ class ConstRateSlipFn;
+ class LiuCosSlipFn;
+ class StepSlipFn;
+
+ class TopologyOps;
+ template<typename Sieve, typename Renumbering> class ReplaceVisitor;
+ template<typename Sieve> class ClassifyVisitor;
+
+ } // faults
+} // pylith
+
+
+#endif // pylith_faults_bcfwd_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/CellGeometry.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/CellGeometry.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/CellGeometry.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,16 +19,12 @@
#if !defined(pylith_feassemble_cellgeometry_hh)
#define pylith_feassemble_cellgeometry_hh
+// Include directives ---------------------------------------------------
+#include "feassemblefwd.hh" // forwward declarations
+
#include "pylith/utils/array.hh" // HASA double_array
-namespace pylith {
- namespace feassemble {
- class CellGeometry;
-
- class TestCellGeometry; // unit testing
- } // feassemble
-} // pylith
-
+// CellGeometry ---------------------------------------------------------
class pylith::feassemble::CellGeometry
{ // CellGeometry
friend class TestCellGeometry; // unit testing
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Constraint.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,24 +19,13 @@
#if !defined(pylith_feassemble_constraint_hh)
#define pylith_feassemble_constraint_hh
-#include "pylith/utils/sievetypes.hh" // USES real_section_type
+// Include directives ---------------------------------------------------
+#include "feassemblefwd.hh"
-/// Namespace for pylith package
-namespace pylith {
- namespace feassemble {
- class Constraint;
- class TestConstraint; // unit testing
- } // feassemble
-} // pylith
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field
+#include "spatialdata/units/unitsfwd.hh" // USES Nondimensional
-namespace spatialdata {
- namespace units {
- class Nondimensional; // USES Nondimensional
- } // units
-} // spatialdata
-
-/// C++ abstract base class defining interface for constraints applied
-/// to finite-elements.
+// Constraint -----------------------------------------------------------
class pylith::feassemble::Constraint
{ // class Constraint
friend class TestConstraint; // unit testing
@@ -60,20 +49,16 @@
/** Set number of degrees of freedom that are constrained at points in field.
*
* @param field Solution field
- * @param mesh PETSc mesh
*/
virtual
- void setConstraintSizes(const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh) = 0;
+ void setConstraintSizes(const topology::Field<topology::Mesh>& field) = 0;
/** Set which degrees of freedom are constrained at points in field.
*
* @param field Solution field
- * @param mesh PETSc mesh
*/
virtual
- void setConstraints(const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh) = 0;
+ void setConstraints(const topology::Field<topology::Mesh>& field) = 0;
/** Set flag for setting constraints for total field solution or
* incremental field solution.
@@ -87,12 +72,10 @@
*
* @param t Current time
* @param field Solution field
- * @param mesh PETSc mesh
*/
virtual
void setField(const double t,
- const ALE::Obj<real_section_type>& field,
- const ALE::Obj<Mesh>& mesh) = 0;
+ const topology::Field<topology::Mesh>& field) = 0;
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,17 +18,27 @@
#include "CellGeometry.hh" // USES CellGeometry
#include "pylith/materials/ElasticMaterial.hh" // USES ElasticMaterial
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-#include "pylith/utils/array.hh" // USES double_array
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
+
+#include "pylith/utils/array.hh" // USES double_array
#include "pylith/utils/macrodefs.h" // USES CALL_MEMBER_FN
+#include "pylith/utils/lapack.h" // USES LAPACKdgesvd
#include "petscmat.h" // USES PetscMat
#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimendional
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
#include <cassert> // USES assert()
#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Constructor
pylith::feassemble::ElasticityExplicit::ElasticityExplicit(void) :
_dtm1(-1.0)
@@ -72,11 +82,9 @@
// Integrate constributions to residual term (r) for operator.
void
pylith::feassemble::ElasticityExplicit::integrateResidual(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateResidual
/// Member prototype for _elasticityResidualXD()
typedef void (pylith::feassemble::ElasticityExplicit::*elasticityResidual_fn_type)
@@ -84,31 +92,53 @@
assert(0 != _quadrature);
assert(0 != _material);
- assert(!residual.isNull());
+ assert(0 != _logger);
assert(0 != fields);
- assert(!mesh.isNull());
- PetscErrorCode err = 0;
+ const int setupEvent = _logger->eventId("ElIR setup");
+ const int geometryEvent = _logger->eventId("ElIR geometry");
+ const int computeEvent = _logger->eventId("ElIR compute");
+ const int restrictEvent = _logger->eventId("ElIR restrict");
+ const int stateVarsEvent = _logger->eventId("ElIR stateVars");
+ const int stressEvent = _logger->eventId("ElIR stress");
+ const int updateEvent = _logger->eventId("ElIR update");
+ _logger->eventBegin(setupEvent);
+
+ // Get cell geometry information that doesn't depend on cell
+ const int numQuadPts = _quadrature->numQuadPts();
+ const double_array& quadWts = _quadrature->quadWts();
+ assert(quadWts.size() == numQuadPts);
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
+ const int cellDim = _quadrature->cellDim();
+ const int tensorSize = _material->tensorSize();
+ /** :TODO:
+ *
+ * If cellDim and spaceDim are different, we need to transform
+ * displacements into cellDim, compute action, and transform result
+ * back into spaceDim. We get this information from the Jacobian and
+ * inverse of the Jacobian.
+ */
+ if (cellDim != spaceDim)
+ throw std::logic_error("Integration for cells with spatial dimensions "
+ "different than the spatial dimension of the "
+ "domain not implemented yet.");
+
// Set variables dependent on dimension of cell
- const int cellDim = _quadrature->cellDim();
- int tensorSize = 0;
totalStrain_fn_type calcTotalStrainFn;
elasticityResidual_fn_type elasticityResidualFn;
if (1 == cellDim) {
- tensorSize = 1;
elasticityResidualFn =
&pylith::feassemble::ElasticityExplicit::_elasticityResidual1D;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain1D;
} else if (2 == cellDim) {
- tensorSize = 3;
elasticityResidualFn =
&pylith::feassemble::ElasticityExplicit::_elasticityResidual2D;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain2D;
} else if (3 == cellDim) {
- tensorSize = 6;
elasticityResidualFn =
&pylith::feassemble::ElasticityExplicit::_elasticityResidual3D;
calcTotalStrainFn =
@@ -116,72 +146,76 @@
} else
assert(0);
+ // Allocate vectors for cell values.
+ double_array dispTCell(numBasis*spaceDim);
+ double_array dispTmdtCell(numBasis*spaceDim);
+ double_array strainCell(numQuadPts*tensorSize);
+ strainCell = 0.0;
+ double_array gravVec(spaceDim);
+ double_array quadPtsGlobal(numQuadPts*spaceDim);
+
// Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = fields->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
const int materialId = _material->id();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", materialId);
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
// Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const ALE::Obj<real_section_type>& dispT = fields->getFieldByHistory(1);
- assert(!dispT.isNull());
- const ALE::Obj<real_section_type>& dispTmdt = fields->getFieldByHistory(2);
- assert(!dispTmdt.isNull());
+ const ALE::Obj<RealSection>& dispTSection = fields->get("disp(t)").section();
+ assert(!dispTSection.isNull());
+ topology::Mesh::RestrictVisitor dispTVisitor(*dispTSection,
+ numBasis*spaceDim,
+ &dispTCell[0]);
+ const ALE::Obj<RealSection>& dispTmdtSection =
+ fields->get("disp(t-dt)").section();
+ assert(!dispTmdtSection.isNull());
+ topology::Mesh::RestrictVisitor dispTmdtVisitor(*dispTmdtSection,
+ numBasis*spaceDim,
+ &dispTmdtCell[0]);
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ topology::Mesh::UpdateAddVisitor residualVisitor(*residualSection,
+ &_cellVector[0]);
+ assert(0 != _normalizer);
+ const double lengthScale = _normalizer->lengthScale();
+ const double gravityScale =
+ _normalizer->pressureScale() / (_normalizer->lengthScale() *
+ _normalizer->densityScale());
+
// Get parameters used in integration.
const double dt = _dt;
const double dt2 = dt*dt;
assert(dt > 0);
- // Get cell geometry information that doesn't depend on cell
- const int numQuadPts = _quadrature->numQuadPts();
- const double_array& quadWts = _quadrature->quadWts();
- assert(quadWts.size() == numQuadPts);
- const int numBasis = _quadrature->numBasis();
- const int spaceDim = _quadrature->spaceDim();
+ _logger->eventEnd(setupEvent);
- /** :TODO:
- *
- * If cellDim and spaceDim are different, we need to transform
- * displacements into cellDim, compute action, and transform result
- * back into spaceDim. We get this information from the Jacobian and
- * inverse of the Jacobian.
- */
- if (cellDim != spaceDim)
- throw std::logic_error("Not implemented yet.");
-
- // Precompute the geometric and function space information
- _quadrature->precomputeGeometry(mesh, coordinates, cells);
-
- // Allocate vectors for cell values.
- _initCellVector();
- const int cellVecSize = numBasis*spaceDim;
- double_array dispTCell(cellVecSize);
- double_array dispTmdtCell(cellVecSize);
-
- // Allocate vector for total strain
- double_array totalStrain(numQuadPts*tensorSize);
- totalStrain = 0.0;
-
- int c_index = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ // Loop over cells
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
- ++c_iter, ++c_index) {
+ ++c_iter) {
// Compute geometry information for current cell
- _quadrature->retrieveGeometry(mesh, coordinates, *c_iter, c_index);
+ _logger->eventBegin(geometryEvent);
+ _quadrature->retrieveGeometry(*c_iter);
+ _logger->eventEnd(geometryEvent);
// Get state variables for cell.
- _material->getPropertiesCell(*c_iter, numQuadPts);
+ _logger->eventBegin(stateVarsEvent);
+ _material->retrievePropsAndVars(*c_iter);
+ _logger->eventEnd(stateVarsEvent);
// Reset element vector to zero
_resetCellVector();
- mesh->restrictClosure(dispT, *c_iter, &dispTCell[0], cellVecSize);
- mesh->restrictClosure(dispTmdt, *c_iter, &dispTmdtCell[0], cellVecSize);
+ // Restrict input fields to cell
+ _logger->eventBegin(restrictEvent);
+ dispTVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, dispTVisitor);
+ dispTmdtVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, dispTmdtVisitor);
+ _logger->eventEnd(restrictEvent);
// Get cell geometry information that depends on cell
const double_array& basis = _quadrature->basis();
@@ -189,6 +223,7 @@
const double_array& jacobianDet = _quadrature->jacobianDet();
// Compute action for inertial terms
+ _logger->eventBegin(computeEvent);
const double_array& density = _material->calcDensity();
for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
const double wt =
@@ -205,15 +240,24 @@
} // for
} // for
PetscLogFlops(numQuadPts*(3+numBasis*(1+numBasis*(6*spaceDim))));
+ _logger->eventEnd(computeEvent);
// Compute B(transpose) * sigma, first computing strains
- calcTotalStrainFn(&totalStrain, basisDeriv, dispTCell,
+ _logger->eventBegin(stressEvent);
+ calcTotalStrainFn(&strainCell, basisDeriv, dispTCell,
numBasis, numQuadPts);
- const double_array& stress = _material->calcStress(totalStrain, true);
- CALL_MEMBER_FN(*this, elasticityResidualFn)(stress);
+ const double_array& stressCell = _material->calcStress(strainCell, true);
+ _logger->eventEnd(stressEvent);
+ _logger->eventBegin(computeEvent);
+ CALL_MEMBER_FN(*this, elasticityResidualFn)(stressCell);
+ _logger->eventEnd(computeEvent);
+
// Assemble cell contribution into field
- mesh->updateAdd(residual, *c_iter, _cellVector);
+ _logger->eventBegin(updateEvent);
+ residualVisitor.clear();
+ sieveMesh->updateAdd(*c_iter, residualVisitor);
+ _logger->eventEnd(updateEvent);
} // for
} // integrateResidual
@@ -221,65 +265,88 @@
// Compute matrix associated with operator.
void
pylith::feassemble::ElasticityExplicit::integrateJacobian(
- PetscMat* jacobian,
+ topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* fields,
- const ALE::Obj<Mesh>& mesh)
+ topology::SolutionFields* fields)
{ // integrateJacobian
assert(0 != _quadrature);
assert(0 != _material);
assert(0 != jacobian);
assert(0 != fields);
- assert(!mesh.isNull());
- typedef ALE::ISieveVisitor::IndicesVisitor<Mesh::real_section_type,Mesh::order_type,PetscInt> visitor_type;
- // Get cell information
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", _material->id());
- assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const int setupEvent = _logger->eventId("ElIJ setup");
+ const int geometryEvent = _logger->eventId("ElIJ geometry");
+ const int computeEvent = _logger->eventId("ElIJ compute");
+ const int restrictEvent = _logger->eventId("ElIJ restrict");
+ const int stateVarsEvent = _logger->eventId("ElIJ stateVars");
+ const int updateEvent = _logger->eventId("ElIJ update");
- // Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const ALE::Obj<real_section_type>& dispT = fields->getFieldByHistory(1);
- assert(!dispT.isNull());
+ _logger->eventBegin(setupEvent);
- // Get parameters used in integration.
- const double dt = _dt;
- const double dt2 = dt*dt;
- assert(dt > 0);
-
// Get cell geometry information that doesn't depend on cell
const int numQuadPts = _quadrature->numQuadPts();
const double_array& quadWts = _quadrature->quadWts();
+ assert(quadWts.size() == numQuadPts);
const int numBasis = _quadrature->numBasis();
const int spaceDim = _quadrature->spaceDim();
const int cellDim = _quadrature->cellDim();
+ const int tensorSize = _material->tensorSize();
+ if (cellDim != spaceDim)
+ throw std::logic_error("Don't know how to integrate elasticity " \
+ "contribution to Jacobian matrix for cells with " \
+ "different dimensions than the spatial dimension.");
- // Precompute the geometric and function space information
- _quadrature->precomputeGeometry(mesh, coordinates, cells);
+ // Allocate vectors for cell data.
+ double_array dispTCell(numBasis*spaceDim);
- // Allocate vector for cell values (if necessary)
- _initCellMatrix();
+ // Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = fields->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const int materialId = _material->id();
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ assert(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
- const ALE::Obj<Mesh::order_type>& globalOrder = mesh->getFactory()->getGlobalOrder(mesh, "default", dispT);
+ // Get sections
+ const ALE::Obj<RealSection>& dispTSection =
+ fields->get("disp(t)").section();
+ assert(!dispTSection.isNull());
+
+ // Get sparse matrix
+ const PetscMat jacobianMat = jacobian->matrix();
+ assert(0 != jacobianMat);
+
+ // Get parameters used in integration.
+ const double dt = _dt;
+ const double dt2 = dt*dt;
+ assert(dt > 0);
+
+ const ALE::Obj<SieveMesh::order_type>& globalOrder =
+ sieveMesh->getFactory()->getGlobalOrder(sieveMesh, "default", dispTSection);
assert(!globalOrder.isNull());
// We would need to request unique points here if we had an interpolated mesh
- visitor_type iV(*dispT, *globalOrder, (int) pow(mesh->getSieve()->getMaxConeSize(), mesh->depth())*spaceDim);
+ topology::Mesh::IndicesVisitor jacobianVisitor(*dispTSection, *globalOrder,
+ (int) pow(sieveMesh->getSieve()->getMaxConeSize(),
+ sieveMesh->depth())*spaceDim);
- int c_index = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ _logger->eventEnd(setupEvent);
+
+ // Loop over cells
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
- ++c_iter, ++c_index) {
+ ++c_iter) {
// Compute geometry information for current cell
- _quadrature->retrieveGeometry(mesh, coordinates, *c_iter, c_index);
+ _logger->eventBegin(geometryEvent);
+ _quadrature->retrieveGeometry(*c_iter);
+ _logger->eventEnd(geometryEvent);
// Get state variables for cell.
- _material->getPropertiesCell(*c_iter, numQuadPts);
+ _logger->eventBegin(stateVarsEvent);
+ _material->retrievePropsAndVars(*c_iter);
+ _logger->eventEnd(stateVarsEvent);
- // Reset element vector to zero
+ // Reset element matrix to zero
_resetCellMatrix();
// Get cell geometry information that depends on cell
@@ -290,6 +357,7 @@
const double_array& density = _material->calcDensity();
// Compute Jacobian for inertial terms
+ _logger->eventBegin(computeEvent);
for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
const double wt =
quadWts[iQuad] * jacobianDet[iQuad] * density[iQuad] / dt2;
@@ -306,12 +374,16 @@
} // for
} // for
PetscLogFlops(numQuadPts*(3+numBasis*(1+numBasis*(1+spaceDim))));
+ _logger->eventEnd(computeEvent);
- // Assemble cell contribution into PETSc Matrix
- PetscErrorCode err = updateOperator(*jacobian, *mesh->getSieve(), iV, *c_iter, _cellMatrix, ADD_VALUES);
- if (err)
- throw std::runtime_error("Update to PETSc Mat failed.");
- iV.clear();
+ // Assemble cell contribution into PETSc matrix.
+ _logger->eventBegin(updateEvent);
+ jacobianVisitor.clear();
+ PetscErrorCode err = updateOperator(jacobianMat, *sieveMesh->getSieve(),
+ jacobianVisitor, *c_iter,
+ &_cellMatrix[0], ADD_VALUES);
+ CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
+ _logger->eventEnd(updateEvent);
} // for
_needNewJacobian = false;
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityExplicit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -55,25 +55,10 @@
#if !defined(pylith_feassemble_elasticityexplicit_hh)
#define pylith_feassemble_elasticityexplicit_hh
+// Include directives ---------------------------------------------------
#include "IntegratorElasticity.hh" // ISA IntegratorElasticity
-#include "pylith/utils/array.hh" // USES std::vector, double_array
-namespace pylith {
- namespace feassemble {
- class ElasticityExplicit;
- class TestElasticityExplicit;
- } // feassemble
-} // pylith
-
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB; // USES SpatialDB
- } // spatialdb
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-
+// ElasticityExplicit ---------------------------------------------------
class pylith::feassemble::ElasticityExplicit : public IntegratorElasticity
{ // ElasticityExplicit
friend class TestElasticityExplicit; // unit testing
@@ -105,32 +90,27 @@
* @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
- void integrateResidual(const ALE::Obj<real_section_type>& residual,
+ void integrateResidual(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
/** Integrate contributions to Jacobian matrix (A) associated with
* operator.
*
- * @param jacobian Sparse matrix to hold Jacobian of operator.
+ * @param jacobian Sparse matrix for Jacobian of system.
* @param t Current time
- * @param fields Solution fields.
- * @param mesh Finite-element mesh.
+ * @param fields Solution fields
*/
- void integrateJacobian(PetscMat* jacobian,
+ void integrateJacobian(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
/// Not implemented.
- ElasticityExplicit(const ElasticityExplicit& i);
+ ElasticityExplicit(const ElasticityExplicit&);
/// Not implemented
const ElasticityExplicit& operator=(const ElasticityExplicit&);
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,7 +18,11 @@
#include "CellGeometry.hh" // USES CellGeometry
#include "pylith/materials/ElasticMaterial.hh" // USES ElasticMaterial
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
+
+#include "pylith/utils/EventLogger.hh" // USES EventLogger
#include "pylith/utils/array.hh" // USES double_array
#include "pylith/utils/macrodefs.h" // USES CALL_MEMBER_FN
#include "pylith/utils/lapack.h" // USES LAPACKdgesvd
@@ -28,10 +32,15 @@
#include "spatialdata/units/Nondimensional.hh" // USES Nondimendional
#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
#include <cassert> // USES assert()
#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Constructor
pylith::feassemble::ElasticityImplicit::ElasticityImplicit(void) :
_dtm1(-1.0)
@@ -61,10 +70,10 @@
// ----------------------------------------------------------------------
// Get stable time step for advancing from time t to time t+dt.
double
-pylith::feassemble::ElasticityImplicit::stableTimeStep(void) const
+pylith::feassemble::ElasticityImplicit::stableTimeStep(const topology::Mesh& mesh) const
{ // stableTimeStep
assert(0 != _material);
- return _material->stableTimeStepImplicit();
+ return _material->stableTimeStepImplicit(mesh);
} // stableTimeStep
// ----------------------------------------------------------------------
@@ -82,11 +91,9 @@
// Integrate constributions to residual term (r) for operator.
void
pylith::feassemble::ElasticityImplicit::integrateResidual(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields)
{ // integrateResidual
/// Member prototype for _elasticityResidualXD()
typedef void (pylith::feassemble::ElasticityImplicit::*elasticityResidual_fn_type)
@@ -94,49 +101,46 @@
assert(0 != _quadrature);
assert(0 != _material);
- assert(!residual.isNull());
+ assert(0 != _logger);
assert(0 != fields);
- assert(!mesh.isNull());
- static PetscLogEvent setupEvent = 0, cellGeomEvent = 0, stateVarsEvent = 0, restrictEvent = 0, computeEvent = 0, updateEvent = 0, stressEvent;
+ const int setupEvent = _logger->eventId("ElIR setup");
+ const int geometryEvent = _logger->eventId("ElIR geometry");
+ const int computeEvent = _logger->eventId("ElIR compute");
+ const int restrictEvent = _logger->eventId("ElIR restrict");
+ const int stateVarsEvent = _logger->eventId("ElIR stateVars");
+ const int stressEvent = _logger->eventId("ElIR stress");
+ const int updateEvent = _logger->eventId("ElIR update");
- if (!setupEvent)
- PetscLogEventRegister("IRSetup", 0, &setupEvent);
- if (!cellGeomEvent)
- PetscLogEventRegister("IRCellGeom", 0, &cellGeomEvent);
- if (!stateVarsEvent)
- PetscLogEventRegister("IRProperties", 0, &stateVarsEvent);
- if (!restrictEvent)
- PetscLogEventRegister("IRRestrict", 0, &restrictEvent);
- if (!computeEvent)
- PetscLogEventRegister("IRCompute", 0, &computeEvent);
- if (!updateEvent)
- PetscLogEventRegister("IRUpdate", 0, &updateEvent);
- if (!stressEvent)
- PetscLogEventRegister("IRMaterialStress", 0, &stressEvent);
+ _logger->eventBegin(setupEvent);
- const Obj<sieve_type>& sieve = mesh->getSieve();
+ // Get cell geometry information that doesn't depend on cell
+ const int numQuadPts = _quadrature->numQuadPts();
+ const double_array& quadWts = _quadrature->quadWts();
+ assert(quadWts.size() == numQuadPts);
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
+ const int cellDim = _quadrature->cellDim();
+ const int tensorSize = _material->tensorSize();
+ if (cellDim != spaceDim)
+ throw std::logic_error("Integration for cells with spatial dimensions "
+ "different than the spatial dimension of the "
+ "domain not implemented yet.");
- PetscLogEventBegin(setupEvent,0,0,0,0);
// Set variables dependent on dimension of cell
- const int cellDim = _quadrature->cellDim();
- int tensorSize = 0;
totalStrain_fn_type calcTotalStrainFn;
elasticityResidual_fn_type elasticityResidualFn;
if (1 == cellDim) {
- tensorSize = 1;
elasticityResidualFn =
&pylith::feassemble::ElasticityImplicit::_elasticityResidual1D;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain1D;
} else if (2 == cellDim) {
- tensorSize = 3;
elasticityResidualFn =
&pylith::feassemble::ElasticityImplicit::_elasticityResidual2D;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain2D;
} else if (3 == cellDim) {
- tensorSize = 6;
elasticityResidualFn =
&pylith::feassemble::ElasticityImplicit::_elasticityResidual3D;
calcTotalStrainFn =
@@ -144,93 +148,63 @@
} else
assert(0);
+ // Allocate vectors for cell values.
+ double_array dispTBctpdtCell(numBasis*spaceDim);
+ double_array strainCell(numQuadPts*tensorSize);
+ strainCell = 0.0;
+ double_array gravVec(spaceDim);
+ double_array quadPtsGlobal(numQuadPts*spaceDim);
+
// Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = fields->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
const int materialId = _material->id();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", materialId);
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
// Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const ALE::Obj<real_section_type>& dispTBctpdt =
- fields->getReal("dispTBctpdt");
- assert(!dispTBctpdt.isNull());
+ const ALE::Obj<RealSection>& dispTBctpdtSection =
+ fields->get("disp(t), bc(t+dt)").section();
+ assert(!dispTBctpdtSection.isNull());
+ topology::Mesh::RestrictVisitor dispTBctpdtVisitor(*dispTBctpdtSection,
+ numBasis*spaceDim,
+ &dispTBctpdtCell[0]);
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ topology::Mesh::UpdateAddVisitor residualVisitor(*residualSection,
+ &_cellVector[0]);
- // Get cell geometry information that doesn't depend on cell
- const int numQuadPts = _quadrature->numQuadPts();
- const double_array& quadWts = _quadrature->quadWts();
- assert(quadWts.size() == numQuadPts);
- const int numBasis = _quadrature->numBasis();
- const int spaceDim = _quadrature->spaceDim();
-
- // Precompute the geometric and function space information
- _quadrature->precomputeGeometry(mesh, coordinates, cells);
-
- // Allocate vectors for cell values.
- _initCellVector();
- const int cellVecSize = numBasis*spaceDim;
- double_array dispTBctpdtCell(cellVecSize);
- double_array totalStrain(numQuadPts*tensorSize);
- totalStrain = 0.0;
- double_array gravVec(spaceDim);
- double_array quadPtsGlobal(numQuadPts*spaceDim);
-
- // Set up gravity field database for querying
- if (0 != _gravityField) {
- _gravityField->open();
- if (1 == spaceDim){
- const char* queryNames[] = { "x"};
- _gravityField->queryVals(queryNames, spaceDim);
- } else if (2 == spaceDim){
- const char* queryNames[] = { "x", "y"};
- _gravityField->queryVals(queryNames, spaceDim);
- } else if (3 == spaceDim){
- const char* queryNames[] = { "x", "y", "z"};
- _gravityField->queryVals(queryNames, spaceDim);
- } else {
- assert(0);
- } // else
- } // if
-
- PetscLogEventEnd(setupEvent,0,0,0,0);
-
- ALE::ISieveVisitor::RestrictVisitor<real_section_type> rV(*dispTBctpdt, cellVecSize, &dispTBctpdtCell[0]);
- if (mesh->depth() > 1) {
- //ISieveVisitor::PointRetriever<sieve_type,ISieveVisitor::RestrictVisitor<Section> > pV((int) pow((double) mesh->getSieve()->getMaxConeSize(), this->depth())+1, rV, true);
- throw ALE::Exception("Need to reorganize to use a different visitor class");
- } // if
-
assert(0 != _normalizer);
const double lengthScale = _normalizer->lengthScale();
const double gravityScale =
_normalizer->pressureScale() / (_normalizer->lengthScale() *
_normalizer->densityScale());
+ _logger->eventEnd(setupEvent);
+
// Loop over cells
- int c_index = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
- ++c_iter, ++c_index) {
+ ++c_iter) {
// Compute geometry information for current cell
- PetscLogEventBegin(cellGeomEvent,0,0,0,0);
- _quadrature->retrieveGeometry(mesh, coordinates, *c_iter, c_index);
- PetscLogEventEnd(cellGeomEvent,0,0,0,0);
+ _logger->eventBegin(geometryEvent);
+ _quadrature->retrieveGeometry(*c_iter);
+ _logger->eventEnd(geometryEvent);
// Get state variables for cell.
- PetscLogEventBegin(stateVarsEvent,0,0,0,0);
- _material->getPropertiesCell(*c_iter, numQuadPts);
- PetscLogEventEnd(stateVarsEvent,0,0,0,0);
+ _logger->eventBegin(stateVarsEvent);
+ _material->retrievePropsAndVars(*c_iter);
+ _logger->eventEnd(stateVarsEvent);
// Reset element vector to zero
_resetCellVector();
// Restrict input fields to cell
- PetscLogEventBegin(restrictEvent,0,0,0,0);
- mesh->restrictClosure(*c_iter, rV);
- PetscLogEventEnd(restrictEvent,0,0,0,0);
+ _logger->eventBegin(restrictEvent);
+ dispTBctpdtVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, dispTBctpdtVisitor);
+ _logger->eventBegin(restrictEvent);
// Get cell geometry information that depends on cell
const double_array& basis = _quadrature->basis();
@@ -238,13 +212,12 @@
const double_array& jacobianDet = _quadrature->jacobianDet();
const double_array& quadPtsNondim = _quadrature->quadPts();
- if (cellDim != spaceDim)
- throw std::logic_error("Integration for cells with spatial dimensions "
- "different than the spatial dimension of the "
- "domain not implemented yet.");
-
// Compute body force vector if gravity is being used.
if (0 != _gravityField) {
+ _logger->eventBegin(computeEvent);
+ const spatialdata::geocoords::CoordSys* cs = fields->mesh().coordsys();
+ assert(0 != cs);
+
// Get density at quadrature points for this cell
const double_array& density = _material->calcDensity();
@@ -270,31 +243,31 @@
} // for
} // for
PetscLogFlops(numQuadPts*(2+numBasis*(1+2*spaceDim)));
- _gravityField->close();
+ _logger->eventEnd(computeEvent);
} // if
// Compute B(transpose) * sigma, first computing strains
- PetscLogEventBegin(stressEvent,0,0,0,0);
- calcTotalStrainFn(&totalStrain, basisDeriv, dispTBctpdtCell,
+ _logger->eventBegin(stressEvent);
+ calcTotalStrainFn(&strainCell, basisDeriv, dispTBctpdtCell,
numBasis, numQuadPts);
- const double_array& stress = _material->calcStress(totalStrain, true);
- PetscLogEventEnd(stressEvent,0,0,0,0);
+ const double_array& stressCell = _material->calcStress(strainCell, true);
+ _logger->eventEnd(stressEvent);
- PetscLogEventBegin(computeEvent,0,0,0,0);
- CALL_MEMBER_FN(*this, elasticityResidualFn)(stress);
- PetscLogEventEnd(computeEvent,0,0,0,0);
+ _logger->eventBegin(computeEvent);
+ CALL_MEMBER_FN(*this, elasticityResidualFn)(stressCell);
+ _logger->eventEnd(computeEvent);
-#if 0
+#if 0 // DEBUGGING
std::cout << "Updating residual for cell " << *c_iter << std::endl;
for(int i = 0; i < _quadrature->spaceDim() * _quadrature->numBasis(); ++i) {
std::cout << " v["<<i<<"]: " << _cellVector[i] << std::endl;
}
#endif
// Assemble cell contribution into field
- PetscLogEventBegin(updateEvent,0,0,0,0);
- mesh->updateAdd(residual, *c_iter, _cellVector);
- PetscLogEventEnd(updateEvent,0,0,0,0);
- rV.clear();
+ _logger->eventBegin(updateEvent);
+ residualVisitor.clear();
+ sieveMesh->updateAdd(*c_iter, residualVisitor);
+ _logger->eventEnd(updateEvent);
} // for
} // integrateResidual
@@ -302,10 +275,9 @@
// Compute stiffness matrix.
void
pylith::feassemble::ElasticityImplicit::integrateJacobian(
- PetscMat* mat,
+ topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* fields,
- const ALE::Obj<Mesh>& mesh)
+ topology::SolutionFields* fields)
{ // integrateJacobian
/// Member prototype for _elasticityJacobianXD()
typedef void (pylith::feassemble::ElasticityImplicit::*elasticityJacobian_fn_type)
@@ -313,30 +285,46 @@
assert(0 != _quadrature);
assert(0 != _material);
- assert(0 != mat);
+ assert(0 != _logger);
+ assert(0 != jacobian);
assert(0 != fields);
- assert(!mesh.isNull());
- typedef ALE::ISieveVisitor::IndicesVisitor<Mesh::real_section_type,Mesh::order_type,PetscInt> visitor_type;
- // Set variables dependent on dimension of cell
+ const int setupEvent = _logger->eventId("ElIJ setup");
+ const int geometryEvent = _logger->eventId("ElIJ geometry");
+ const int computeEvent = _logger->eventId("ElIJ compute");
+ const int restrictEvent = _logger->eventId("ElIJ restrict");
+ const int stateVarsEvent = _logger->eventId("ElIJ stateVars");
+ const int updateEvent = _logger->eventId("ElIJ update");
+
+ _logger->eventBegin(setupEvent);
+
+ // Get cell geometry information that doesn't depend on cell
+ const int numQuadPts = _quadrature->numQuadPts();
+ const double_array& quadWts = _quadrature->quadWts();
+ assert(quadWts.size() == numQuadPts);
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
const int cellDim = _quadrature->cellDim();
- int tensorSize = 0;
+ const int tensorSize = _material->tensorSize();
+ if (cellDim != spaceDim)
+ throw std::logic_error("Don't know how to integrate elasticity " \
+ "contribution to Jacobian matrix for cells with " \
+ "different dimensions than the spatial dimension.");
+
+ // Set variables dependent on dimension of cell
totalStrain_fn_type calcTotalStrainFn;
elasticityJacobian_fn_type elasticityJacobianFn;
if (1 == cellDim) {
- tensorSize = 1;
elasticityJacobianFn =
&pylith::feassemble::ElasticityImplicit::_elasticityJacobian1D;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain1D;
} else if (2 == cellDim) {
- tensorSize = 3;
elasticityJacobianFn =
&pylith::feassemble::ElasticityImplicit::_elasticityJacobian2D;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain2D;
} else if (3 == cellDim) {
- tensorSize = 6;
elasticityJacobianFn =
&pylith::feassemble::ElasticityImplicit::_elasticityJacobian3D;
calcTotalStrainFn =
@@ -344,85 +332,87 @@
} else
assert(0);
+ // Allocate vector for total strain
+ double_array dispTBctpdtCell(numBasis*spaceDim);
+ double_array strainCell(numQuadPts*tensorSize);
+ strainCell = 0.0;
+
// Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = fields->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
const int materialId = _material->id();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", materialId);
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
// Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const ALE::Obj<real_section_type>& dispTBctpdt =
- fields->getReal("dispTBctpdt");
- assert(!dispTBctpdt.isNull());
+ const ALE::Obj<RealSection>& dispTBctpdtSection =
+ fields->get("disp(t), bc(t+dt)").section();
+ assert(!dispTBctpdtSection.isNull());
+ topology::Mesh::RestrictVisitor dispTBctpdtVisitor(*dispTBctpdtSection,
+ numBasis*spaceDim,
+ &dispTBctpdtCell[0]);
+ // Get sparse matrix
+ const PetscMat jacobianMat = jacobian->matrix();
+ assert(0 != jacobianMat);
+
// Get parameters used in integration.
const double dt = _dt;
assert(dt > 0);
- // Get cell geometry information that doesn't depend on cell
- const int numQuadPts = _quadrature->numQuadPts();
- const double_array& quadWts = _quadrature->quadWts();
- const int numBasis = _quadrature->numBasis();
- const int spaceDim = _quadrature->spaceDim();
-
- if (cellDim != spaceDim)
- throw std::logic_error("Don't know how to integrate elasticity " \
- "contribution to Jacobian matrix for cells with " \
- "different dimensions than the spatial dimension.");
-
- // Precompute the geometric and function space information
- _quadrature->precomputeGeometry(mesh, coordinates, cells);
-
- // Allocate matrix and vectors for cell values.
- _initCellMatrix();
- const int cellVecSize = numBasis*spaceDim;
- double_array dispTBctpdtCell(cellVecSize);
-
- // Allocate vector for total strain
- double_array totalStrain(numQuadPts*tensorSize);
- totalStrain = 0.0;
-
- const ALE::Obj<Mesh::order_type>& globalOrder = mesh->getFactory()->getGlobalOrder(mesh, "default", dispTBctpdt);
+ const ALE::Obj<SieveMesh::order_type>& globalOrder =
+ sieveMesh->getFactory()->getGlobalOrder(sieveMesh, "default",
+ dispTBctpdtSection);
assert(!globalOrder.isNull());
// We would need to request unique points here if we had an interpolated mesh
- visitor_type iV(*dispTBctpdt, *globalOrder, (int) pow(mesh->getSieve()->getMaxConeSize(), mesh->depth())*spaceDim);
- ALE::ISieveVisitor::RestrictVisitor<real_section_type> rV(*dispTBctpdt, cellVecSize, &dispTBctpdtCell[0]);
+ topology::Mesh::IndicesVisitor jacobianVisitor(*dispTBctpdtSection,
+ *globalOrder,
+ (int) pow(sieveMesh->getSieve()->getMaxConeSize(),
+ sieveMesh->depth())*spaceDim);
+ _logger->eventEnd(setupEvent);
+
// Loop over cells
- int c_index = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
- ++c_iter, ++c_index) {
+ ++c_iter) {
// Compute geometry information for current cell
- _quadrature->retrieveGeometry(mesh, coordinates, *c_iter, c_index);
+ _logger->eventBegin(geometryEvent);
+ _quadrature->retrieveGeometry(*c_iter);
+ _logger->eventEnd(geometryEvent);
// Get state variables for cell.
- _material->getPropertiesCell(*c_iter, numQuadPts);
+ _logger->eventBegin(stateVarsEvent);
+ _material->retrievePropsAndVars(*c_iter);
+ _logger->eventEnd(stateVarsEvent);
// Reset element matrix to zero
_resetCellMatrix();
// Restrict input fields to cell
- mesh->restrictClosure(*c_iter, rV);
+ _logger->eventBegin(restrictEvent);
+ dispTBctpdtVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, dispTBctpdtVisitor);
+ _logger->eventBegin(restrictEvent);
// Get cell geometry information that depends on cell
const double_array& basis = _quadrature->basis();
const double_array& basisDeriv = _quadrature->basisDeriv();
const double_array& jacobianDet = _quadrature->jacobianDet();
+ _logger->eventBegin(computeEvent);
// Compute strains
- calcTotalStrainFn(&totalStrain, basisDeriv, dispTBctpdtCell,
+ calcTotalStrainFn(&strainCell, basisDeriv, dispTBctpdtCell,
numBasis, numQuadPts);
// Get "elasticity" matrix at quadrature points for this cell
const double_array& elasticConsts =
- _material->calcDerivElastic(totalStrain);
+ _material->calcDerivElastic(strainCell);
CALL_MEMBER_FN(*this, elasticityJacobianFn)(elasticConsts);
+ _logger->eventEnd(computeEvent);
if (_quadrature->checkConditioning()) {
int n = numBasis*spaceDim;
@@ -446,7 +436,7 @@
throw std::runtime_error("Lapack SVD failed");
minSV = svalues[n-7];
maxSV = svalues[0];
- std::cout << "Element " << c_index << std::endl;
+ std::cout << "Element " << *c_iter << std::endl;
for(int i = 0; i < n; ++i)
std::cout << " sV["<<i<<"] = " << svalues[i] << std::endl;
std::cout << " kappa(elemMat) = " << maxSV/minSV << std::endl;
@@ -455,13 +445,14 @@
delete [] work;
} // if
- // Assemble cell contribution into field. Not sure if this is correct for
- // global stiffness matrix.
- PetscErrorCode err = updateOperator(*mat, *mesh->getSieve(), iV, *c_iter, _cellMatrix, ADD_VALUES);
- if (err)
- throw std::runtime_error("Update to PETSc Mat failed.");
- iV.clear();
- rV.clear();
+ // Assemble cell contribution into PETSc matrix.
+ _logger->eventBegin(updateEvent);
+ jacobianVisitor.clear();
+ PetscErrorCode err = updateOperator(jacobianMat, *sieveMesh->getSieve(),
+ jacobianVisitor, *c_iter,
+ &_cellMatrix[0], ADD_VALUES);
+ CHECK_PETSC_ERROR_MSG(err, "Update to PETSc Mat failed.");
+ _logger->eventEnd(updateEvent);
} // for
_needNewJacobian = false;
_material->resetNeedNewJacobian();
Modified: short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/ElasticityImplicit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -47,25 +47,10 @@
#if !defined(pylith_feassemble_elasticityimplicit_hh)
#define pylith_feassemble_elasticityimplicit_hh
+// Include directives ---------------------------------------------------
#include "IntegratorElasticity.hh" // ISA IntegratorElasticity
-#include "pylith/utils/array.hh" // USES std::vector, double_array
-namespace pylith {
- namespace feassemble {
- class ElasticityImplicit;
- class TestElasticityImplicit;
- } // feassemble
-} // pylith
-
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB; // USES SpatialDB
- } // spatialdb
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-
+// ElasticityImplicit ---------------------------------------------------
class pylith::feassemble::ElasticityImplicit : public IntegratorElasticity
{ // ElasticityImplicit
friend class TestElasticityImplicit; // unit testing
@@ -89,9 +74,10 @@
*
* Default is current time step.
*
+ * @param mesh Finite-element mesh.
* @returns Time step
*/
- double stableTimeStep(void) const;
+ double stableTimeStep(const topology::Mesh& mesh) const;
/** Set flag for setting constraints for total field solution or
* incremental field solution.
@@ -110,35 +96,30 @@
* external loads due to body forces plus the
* element internal forces for the current stress state.
*
- * @param residual Residual field (output)
+ * @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Mesh object
- * @param cs Coordinate system
*/
- void integrateResidual(const ALE::Obj<real_section_type>& residual,
+ void integrateResidual(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
- /** Compute Jacobian matrix (A) associated with operator.
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
*
- * @param mat Sparse matrix
+ * @param jacobian Sparse matrix for Jacobian of system.
* @param t Current time
* @param fields Solution fields
- * @param mesh Mesh object
*/
- void integrateJacobian(PetscMat* mat,
+ void integrateJacobian(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
/// Not implemented.
- ElasticityImplicit(const ElasticityImplicit& i);
+ ElasticityImplicit(const ElasticityImplicit&);
/// Not implemented
const ElasticityImplicit& operator=(const ElasticityImplicit&);
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryHex3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryHex3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryHex3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -32,14 +32,10 @@
#if !defined(pylith_feassemble_geometryhex3d_hh)
#define pylith_feassemble_geometryhex3d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryHex3D;
- } // feassemble
-} // pylith
-
+// GeometryHex3D --------------------------------------------------------
class pylith::feassemble::GeometryHex3D : public CellGeometry
{ // GeometryHex3D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine1D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,14 +20,10 @@
#if !defined(pylith_feassemble_geometryline1d_hh)
#define pylith_feassemble_geometryline1d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryLine1D;
- } // feassemble
-} // pylith
-
+// GeometryLine1D -------------------------------------------------------
class pylith::feassemble::GeometryLine1D : public CellGeometry
{ // GeometryLine1D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine2D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,14 +20,10 @@
#if !defined(pylith_feassemble_geometryline2d_hh)
#define pylith_feassemble_geometryline2d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryLine2D;
- } // feassemble
-} // pylith
-
+// GeometryLine2D -------------------------------------------------------
class pylith::feassemble::GeometryLine2D : public CellGeometry
{ // GeometryLine2D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryLine3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,14 +20,10 @@
#if !defined(pylith_feassemble_geometryline3d_hh)
#define pylith_feassemble_geometryline3d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryLine3D;
- } // feassemble
-} // pylith
-
+// GeometryLine3D -------------------------------------------------------
class pylith::feassemble::GeometryLine3D : public CellGeometry
{ // GeometryLine3D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint1D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,14 +20,10 @@
#if !defined(pylith_feassemble_geometrypoint1d_hh)
#define pylith_feassemble_geometrypoint1d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryPoint1D;
- } // feassemble
-} // pylith
-
+// GeometryPoint1D ------------------------------------------------------
class pylith::feassemble::GeometryPoint1D : public CellGeometry
{ // GeometryPoint1D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint2D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,14 +20,10 @@
#if !defined(pylith_feassemble_geometrypoint2d_hh)
#define pylith_feassemble_geometrypoint2d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryPoint2D;
- } // feassemble
-} // pylith
-
+// GeometryPoint2D ------------------------------------------------------
class pylith::feassemble::GeometryPoint2D : public CellGeometry
{ // GeometryPoint2D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryPoint3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,14 +20,10 @@
#if !defined(pylith_feassemble_geometrypoint3d_hh)
#define pylith_feassemble_geometrypoint3d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryPoint3D;
- } // feassemble
-} // pylith
-
+// GeometryPoint3D ------------------------------------------------------
class pylith::feassemble::GeometryPoint3D : public CellGeometry
{ // GeometryPoint3D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad2D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -33,14 +33,10 @@
#if !defined(pylith_feassemble_geometryquad2d_hh)
#define pylith_feassemble_geometryquad2d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryQuad2D;
- } // feassemble
-} // pylith
-
+// GeometryQuad2D -------------------------------------------------------
class pylith::feassemble::GeometryQuad2D : public CellGeometry
{ // GeometryQuad2D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryQuad3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -33,14 +33,10 @@
#if !defined(pylith_feassemble_geometryquad3d_hh)
#define pylith_feassemble_geometryquad3d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryQuad3D;
- } // feassemble
-} // pylith
-
+// GeometryQuad3D -------------------------------------------------------
class pylith::feassemble::GeometryQuad3D : public CellGeometry
{ // GeometryQuad3D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryTet3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryTet3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryTet3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -28,14 +28,10 @@
#if !defined(pylith_feassemble_geometrytet3d_hh)
#define pylith_feassemble_geometrytet3d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryTet3D;
- } // feassemble
-} // pylith
-
+// GeometryTet3D --------------------------------------------------------
class pylith::feassemble::GeometryTet3D : public CellGeometry
{ // GeometryTet3D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri2D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -27,14 +27,10 @@
#if !defined(pylith_feassemble_geometrytri2d_hh)
#define pylith_feassemble_geometrytri2d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryTri2D;
- } // feassemble
-} // pylith
-
+// GeometryTri2D --------------------------------------------------------
class pylith::feassemble::GeometryTri2D : public CellGeometry
{ // GeometryTri2D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/GeometryTri3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -27,14 +27,10 @@
#if !defined(pylith_feassemble_geometrytri3d_hh)
#define pylith_feassemble_geometrytri3d_hh
+// Include directives ---------------------------------------------------
#include "CellGeometry.hh" // ISA CellGeometry
-namespace pylith {
- namespace feassemble {
- class GeometryTri3D;
- } // feassemble
-} // pylith
-
+// GeometryTri3D --------------------------------------------------------
class pylith::feassemble::GeometryTri3D : public CellGeometry
{ // GeometryTri3D
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Integrator.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Integrator.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Integrator.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,9 +12,8 @@
#include <portinfo>
-#include "Integrator.hh" // implementation of class methods
-
#include "Quadrature.hh" // USES Quadrature
+#include "pylith/utils/EventLogger.hh" // USES EventLogger
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -24,13 +23,13 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Integrator::Integrator(void) :
+template<typename quadrature_type>
+pylith::feassemble::Integrator<quadrature_type>::Integrator(void) :
_dt(-1.0),
_quadrature(0),
_normalizer(new spatialdata::units::Nondimensional),
_gravityField(0),
- _cellVector(0),
- _cellMatrix(0),
+ _logger(0),
_needNewJacobian(true),
_useSolnIncr(false)
{ // constructor
@@ -38,31 +37,34 @@
// ----------------------------------------------------------------------
// Destructor
-pylith::feassemble::Integrator::~Integrator(void)
+template<typename quadrature_type>
+pylith::feassemble::Integrator<quadrature_type>::~Integrator(void)
{ // destructor
delete _quadrature; _quadrature = 0;
delete _normalizer; _normalizer = 0;
- delete[] _cellVector; _cellVector = 0;
- delete[] _cellMatrix; _cellMatrix = 0;
+ delete _logger; _logger = 0;
+ _gravityField = 0; /// Memory managed elsewhere :TODO: use shared pointer
} // destructor
// ----------------------------------------------------------------------
// Set quadrature for integrating finite-element quantities.
+template<typename quadrature_type>
void
-pylith::feassemble::Integrator::quadrature(const Quadrature* q)
+pylith::feassemble::Integrator<quadrature_type>::quadrature(const quadrature_type* q)
{ // quadrature
delete _quadrature;
- _quadrature = (0 != q) ? q->clone() : 0;
+ _quadrature = (0 != q) ? new quadrature_type(*q) : 0;
// Deallocate cell vector and matrix since size may change
- delete[] _cellVector; _cellVector = 0;
- delete[] _cellMatrix; _cellMatrix = 0;
+ _cellVector.resize(0);
+ _cellMatrix.resize(0);
} // quadrature
// ----------------------------------------------------------------------
// Set manager of scales used to nondimensionalize problem.
+template<typename quadrature_type>
void
-pylith::feassemble::Integrator::normalizer(const spatialdata::units::Nondimensional& dim)
+pylith::feassemble::Integrator<quadrature_type>::normalizer(const spatialdata::units::Nondimensional& dim)
{ // normalizer
if (0 == _normalizer)
_normalizer = new spatialdata::units::Nondimensional(dim);
@@ -72,16 +74,18 @@
// ----------------------------------------------------------------------
// Set gravity field.
+template<typename quadrature_type>
void
-pylith::feassemble::Integrator::gravityField(spatialdata::spatialdb::GravityField* const gravityField)
+pylith::feassemble::Integrator<quadrature_type>::gravityField(spatialdata::spatialdb::GravityField* const gravityField)
{ // gravityField
_gravityField = gravityField;
} // gravityField
// ----------------------------------------------------------------------
// Get stable time step for advancing from time t to time t+dt.
+template<typename quadrature_type>
double
-pylith::feassemble::Integrator::stableTimeStep(void) const
+pylith::feassemble::Integrator<quadrature_type>::stableTimeStep(const topology::Mesh& mesh)
{ // stableTimeStep
// Assume any time step will work.
return pylith::PYLITH_MAXDOUBLE;
@@ -89,56 +93,46 @@
// ----------------------------------------------------------------------
// Initialize vector containing result of integration action for cell.
+template<typename quadrature_type>
void
-pylith::feassemble::Integrator::_initCellVector(void)
+pylith::feassemble::Integrator<quadrature_type>::_initCellVector(void)
{ // _initCellVector
assert(0 != _quadrature);
const int size = _quadrature->spaceDim() * _quadrature->numBasis();
- if (0 == _cellVector)
- _cellVector = (size > 0) ? new real_section_type::value_type[size] : 0;
- for (int i=0; i < size; ++i)
- _cellVector[i] = 0.0;
+ _cellVector.resize(size);
+ _cellVector = 0.0;
} // _initCellVector
// ----------------------------------------------------------------------
// Zero out vector containing result of integration actions for cell.
+template<typename quadrature_type>
void
-pylith::feassemble::Integrator::_resetCellVector(void)
+pylith::feassemble::Integrator<quadrature_type>::_resetCellVector(void)
{ // _resetCellVector
- assert(0 != _quadrature);
- assert(0 != _cellVector);
- const int size = _quadrature->spaceDim() * _quadrature->numBasis();
- for (int i=0; i < size; ++i)
- _cellVector[i] = 0.0;
+ _cellVector = 0.0;
} // _resetCellVector
// ----------------------------------------------------------------------
// Initialize matrix containing result of integration for cell.
+template<typename quadrature_type>
void
-pylith::feassemble::Integrator::_initCellMatrix(void)
+pylith::feassemble::Integrator<quadrature_type>::_initCellMatrix(void)
{ // _initCellMatrix
assert(0 != _quadrature);
const int size =
_quadrature->spaceDim() * _quadrature->numBasis() *
_quadrature->spaceDim() * _quadrature->numBasis();
- if (0 == _cellMatrix)
- _cellMatrix = (size > 0) ? new real_section_type::value_type[size] : 0;
- for (int i=0; i < size; ++i)
- _cellMatrix[i] = 0.0;
+ _cellMatrix.resize(size);
+ _cellMatrix = 0.0;
} // _initCellMatrix
// ----------------------------------------------------------------------
// Zero out matrix containing result of integration for cell.
+template<typename quadrature_type>
void
-pylith::feassemble::Integrator::_resetCellMatrix(void)
+pylith::feassemble::Integrator<quadrature_type>::_resetCellMatrix(void)
{ // _resetCellMatrix
- assert(0 != _quadrature);
- assert(0 != _cellMatrix);
- const int size =
- _quadrature->spaceDim() * _quadrature->numBasis() *
- _quadrature->spaceDim() * _quadrature->numBasis();
- for (int i=0; i < size; ++i)
- _cellMatrix[i] = 0.0;
+ _cellMatrix = 0.0;
} // _resetCellMatrix
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Integrator.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,34 +24,19 @@
#if !defined(pylith_feassemble_integrator_hh)
#define pylith_feassemble_integrator_hh
-#include "pylith/utils/sievetypes.hh" // USES real_section_type
-#include "pylith/utils/petscfwd.h" // USES PetscMat
+// Include directives ---------------------------------------------------
+#include "feassemblefwd.hh" // forward declarations
-namespace pylith {
- namespace feassemble {
- class Integrator;
- class TestIntegrator;
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field, SolutionFields
+#include "pylith/utils/utilsfwd.hh" // HOLDSA EventLogger
- class Quadrature; // HOLDSA Quadrature
- } // feassemble
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // USES GravityField
+#include "spatialdata/units/unitsfwd.hh" // USES Nondimensional
- namespace topology {
- class FieldsManager;
- } // topology
-} // pylith
+#include "pylith/utils/array.hh" // HASA double_array
-namespace spatialdata {
- namespace spatialdb {
- class GravityField; // HOLDSA GravityField
- } // spatialdb
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
- namespace units {
- class Nondimensional; // USES Nondimensional
- } // units
-} // spatialdata
-
+// Integrator -----------------------------------------------------------
+template<typename quadrature_type>
class pylith::feassemble::Integrator
{ // Integrator
friend class TestIntegrator; // unit testing
@@ -71,7 +56,7 @@
*
* @param q Quadrature for integrating.
*/
- void quadrature(const Quadrature* q);
+ void quadrature(const quadrature_type* q);
/** Set manager of scales used to nondimensionalize problem.
*
@@ -79,7 +64,7 @@
*/
void normalizer(const spatialdata::units::Nondimensional& dim);
- /** Set gravity field. Gravity Field should already be initialized.
+ /** Set gravity field.
*
* @param g Gravity field.
*/
@@ -96,10 +81,11 @@
*
* Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
+ * @param mesh Finite-element mesh.
* @returns Time step
*/
virtual
- double stableTimeStep(void) const;
+ double stableTimeStep(const topology::Mesh& mesh);
/** Check whether Jacobian needs to be recomputed.
*
@@ -116,34 +102,35 @@
virtual
void useSolnIncr(const bool flag);
+ /** Initialize integrator.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ virtual
+ void initialize(const topology::Mesh& mesh);
+
/** Integrate contributions to residual term (r) for operator.
*
* @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
- * @param cs Mesh coordinate system
*/
virtual
- void integrateResidual(const ALE::Obj<real_section_type>& residual,
+ void integrateResidual(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
/** Integrate contributions to Jacobian matrix (A) associated with
* operator.
*
- * @param mat Sparse matrix
+ * @param jacobian Sparse matrix for Jacobian of system.
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
virtual
- void integrateJacobian(PetscMat* mat,
+ void integrateJacobian(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
/** Integrate contributions to residual term (r) for operator that
* do not require assembly over cells, vertices, or processors.
@@ -151,30 +138,24 @@
* @param residual Field containing values for residual
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
- * @param cs Mesh coordinate system
*/
virtual
- void integrateResidualAssembled(const ALE::Obj<real_section_type>& residual,
+ void integrateResidualAssembled(const topology::Field<topology::Mesh>& residual,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ topology::SolutionFields* const fields);
/** Integrate contributions to Jacobian matrix (A) associated with
* operator that do not require assembly over cells, vertices, or
* processors
*
- * @param mat Sparse matrix
+ * @param jacobian Sparse matrix for Jacobian of system.
* @param t Current time
* @param fields Solution fields
- * @param mesh Finite-element mesh
*/
virtual
- void integrateJacobianAssembled(PetscMat* mat,
+ void integrateJacobianAssembled(topology::Jacobian* jacobian,
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ topology::SolutionFields* const fields);
/** Update state variables as needed.
*
@@ -183,16 +164,15 @@
* @param mesh Finite-element mesh
*/
virtual
- void updateState(const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ void updateStateVars(const double t,
+ topology::SolutionFields* const fields);
/** Verify configuration is acceptable.
*
* @param mesh Finite-element mesh
*/
virtual
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const = 0;
+ void verifyConfiguration(const topology::Mesh& mesh) const = 0;
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -209,30 +189,23 @@
/// Zero out matrix containing result of integration for cell.
void _resetCellMatrix(void);
-// PRIVATE METHODS //////////////////////////////////////////////////////
-private :
-
- // Not implemented.
- Integrator(const Integrator& i);
-
- /// Not implemented
- const Integrator& operator=(const Integrator&);
-
// PROTECTED MEMBERS ////////////////////////////////////////////////////
protected :
double _dt; ///< Time step for t -> t+dt
- Quadrature* _quadrature; ///< Quadrature for integrating finite-element
+ quadrature_type* _quadrature; ///< Quadrature for integrating finite-element
spatialdata::units::Nondimensional* _normalizer; ///< Nondimensionalizer.
spatialdata::spatialdb::GravityField* _gravityField; ///< Gravity field.
+ utils::EventLogger* _logger; ///< Event logger.
+
/// Vector local to cell containing result of integration action
- real_section_type::value_type* _cellVector;
+ double_array _cellVector;
/// Matrix local to cell containing result of integration
- real_section_type::value_type* _cellMatrix;
+ double_array _cellMatrix;
/// True if we need to recompute Jacobian for operator, false otherwise.
/// Default is false;
@@ -242,10 +215,18 @@
/// solution or an incremental field solution
bool _useSolnIncr;
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ Integrator(const Integrator& i); ///< Not implemented
+ const Integrator& operator=(const Integrator&); ///< Not implemented
+
}; // Integrator
#include "Integrator.icc" // inline methods
+#include "Integrator.cc" // template methods
#endif // pylith_feassemble_integrator_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Integrator.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Integrator.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Integrator.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,81 +15,89 @@
#else
// Set time step for advancing from time t to time t+dt.
+template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator::timeStep(const double dt) {
+pylith::feassemble::Integrator<quadrature_type>::timeStep(const double dt) {
_dt = dt;
} // timeStep
// Check whether Jacobian needs to be recomputed.
+template<typename quadrature_type>
inline
bool
-pylith::feassemble::Integrator::needNewJacobian(void) const {
+pylith::feassemble::Integrator<quadrature_type>::needNewJacobian(void) const {
return _needNewJacobian;
} // needNewJacobian
// Set flag for setting constraints for total field solution or
+template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator::useSolnIncr(const bool flag) {
+pylith::feassemble::Integrator<quadrature_type>::useSolnIncr(const bool flag) {
_useSolnIncr = flag;
} // useSolnIncr
+// Initialize integrator.
+template<typename quadrature_type>
+inline
+void
+pylith::feassemble::Integrator<quadrature_type>::initialize(const topology::Mesh& mesh) {
+} // initialize
+
// Integrate contributions to residual term (r) for operator.
+template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator::integrateResidual(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs) {
+pylith::feassemble::Integrator<quadrature_type>::integrateResidual(
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields) {
} // integrateResidual
// Integrate contributions to Jacobian matrix (A) associated with
// operator.
+template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator::integrateJacobian(
- PetscMat* mat,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh) {
+pylith::feassemble::Integrator<quadrature_type>::integrateJacobian(
+ topology::Jacobian* jacobian,
+ const double t,
+ topology::SolutionFields* const fields) {
_needNewJacobian = false;
} // integrateJacobian
// Integrate contributions to residual term (r) for operator that
// do not require assembly over cells, vertices, or processors.
+template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator::integrateResidualAssembled(
- const ALE::Obj<real_section_type>& residual,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs) {
+pylith::feassemble::Integrator<quadrature_type>::integrateResidualAssembled(
+ const topology::Field<topology::Mesh>& residual,
+ const double t,
+ topology::SolutionFields* const fields) {
_needNewJacobian = false;
} // integrateResidualAssembled
// Integrate contributions to Jacobian matrix (A) associated with
// operator that do not require assembly over cells, vertices, or
// processors
+template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator::integrateJacobianAssembled(
- PetscMat* mat,
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh) {
+pylith::feassemble::Integrator<quadrature_type>::integrateJacobianAssembled(
+ topology::Jacobian* jacobian,
+ const double t,
+ topology::SolutionFields* const fields) {
} // integrateJacobianAssembled
// Update state variables as needed.
+template<typename quadrature_type>
inline
void
-pylith::feassemble::Integrator::updateState(
+pylith::feassemble::Integrator<quadrature_type>::updateStateVars(
const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh) {
+ topology::SolutionFields* const fields) {
} // updateState
Modified: short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,7 +18,9 @@
#include "CellGeometry.hh" // USES CellGeometry
#include "pylith/materials/ElasticMaterial.hh" // USES ElasticMaterial
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/utils/EventLogger.hh" // USES EventLogger
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -30,9 +32,15 @@
#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Constructor
pylith::feassemble::IntegratorElasticity::IntegratorElasticity(void) :
- _material(0)
+ _material(0),
+ _bufferFieldTensor(0),
+ _bufferFieldOther(0)
{ // constructor
} // constructor
@@ -41,6 +49,8 @@
pylith::feassemble::IntegratorElasticity::~IntegratorElasticity(void)
{ // destructor
_material = 0; // Don't manage memory for material
+ delete _bufferFieldTensor; _bufferFieldTensor = 0;
+ delete _bufferFieldOther; _bufferFieldOther = 0;
} // destructor
// ----------------------------------------------------------------------
@@ -69,93 +79,151 @@
void
pylith::feassemble::IntegratorElasticity::useSolnIncr(const bool flag)
{ // useSolnIncr
- Integrator::useSolnIncr(flag);
+ Integrator<Quadrature<topology::Mesh> >::useSolnIncr(flag);
assert(0 != _material);
_material->useElasticBehavior(!flag);
} // useSolnIncr
// ----------------------------------------------------------------------
+// Initialize integrator.
+void
+pylith::feassemble::IntegratorElasticity::initialize(const topology::Mesh& mesh)
+{ // initialize
+ assert(0 != _quadrature);
+ assert(0 != _material);
+
+ // Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const int materialId = _material->id();
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+
+ // Compute geometry for quadrature operations.
+ _quadrature->computeGeometry(mesh, cells);
+
+ // Initialize material.
+ _material->initialize(mesh, _quadrature);
+
+ // Allocate vectors and matrices for cell values.
+ _initCellVector();
+ _initCellMatrix();
+
+ // Setup event logger.
+ delete _logger; _logger = new utils::EventLogger;
+ assert(0 != _logger);
+ _logger->className("ElasticityIntegrator");
+ _logger->initialize();
+ _logger->registerEvent("ElIR setup");
+ _logger->registerEvent("ElIR geometry");
+ _logger->registerEvent("ElIR compute");
+ _logger->registerEvent("ElIR restrict");
+ _logger->registerEvent("ElIR stateVars");
+ _logger->registerEvent("ElIR stress");
+ _logger->registerEvent("ElIR update");
+
+ _logger->registerEvent("ElIJ setup");
+ _logger->registerEvent("ElIJ geometry");
+ _logger->registerEvent("ElIJ compute");
+ _logger->registerEvent("ElIJ restrict");
+ _logger->registerEvent("ElIJ stateVars");
+ _logger->registerEvent("ElIJ update");
+
+ // Set up gravity field database for querying
+ if (0 != _gravityField) {
+ const int spaceDim = _quadrature->spaceDim();
+ _gravityField->open();
+ if (1 == spaceDim){
+ const char* queryNames[] = { "x"};
+ _gravityField->queryVals(queryNames, spaceDim);
+ } else if (2 == spaceDim){
+ const char* queryNames[] = { "x", "y"};
+ _gravityField->queryVals(queryNames, spaceDim);
+ } else if (3 == spaceDim){
+ const char* queryNames[] = { "x", "y", "z"};
+ _gravityField->queryVals(queryNames, spaceDim);
+ } else {
+ assert(0);
+ } // else
+ } // if
+} // initialize
+
+// ----------------------------------------------------------------------
// Update state variables as needed.
void
-pylith::feassemble::IntegratorElasticity::updateState(
- const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh)
+pylith::feassemble::IntegratorElasticity::updateStateVars(
+ const double t,
+ topology::SolutionFields* const fields)
{ // updateState
assert(0 != _quadrature);
assert(0 != _material);
assert(0 != fields);
- // No need to update state if using elastic behavior
- if (!_material->usesUpdateProperties())
+ // No need to update state vars if material doesn't have any.
+ if (!_material->hasStateVars())
return;
- // Set variables dependent on dimension of cell
+ // Get cell information that doesn't depend on particular cell
const int cellDim = _quadrature->cellDim();
- int tensorSize = 0;
+ const int numQuadPts = _quadrature->numQuadPts();
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
+ const int tensorSize = _material->tensorSize();
totalStrain_fn_type calcTotalStrainFn;
if (1 == cellDim) {
- tensorSize = 1;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain1D;
} else if (2 == cellDim) {
- tensorSize = 3;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain2D;
} else if (3 == cellDim) {
- tensorSize = 6;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain3D;
} else
assert(0);
+ // Allocate arrays for cell data.
+ double_array dispCell(numBasis*spaceDim);
+ double_array strainCell(numQuadPts*tensorSize);
+ strainCell = 0.0;
+
// Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = fields->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
const int materialId = _material->id();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", materialId);
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
- // Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
+ // Get fields
+ const topology::Field<topology::Mesh>& solution = fields->solution();
+ const ALE::Obj<RealSection>& disp = solution.section();
+ assert(!disp.isNull());
+ topology::Mesh::RestrictVisitor dispVisitor(*disp,
+ dispCell.size(), &dispCell[0]);
- // Get cell geometry information that doesn't depend on cell
- const int numQuadPts = _quadrature->numQuadPts();
- const int numBasis = _quadrature->numBasis();
- const int spaceDim = _quadrature->spaceDim();
-
- const int cellVecSize = numBasis*spaceDim;
- double_array dispCell(cellVecSize);
-
- // Allocate vector for total strain
- double_array totalStrain(numQuadPts*tensorSize);
- totalStrain = 0.0;
-
- const ALE::Obj<real_section_type>& disp = fields->getSolution();
- /// const int dispAtlasTag = fields->getSolutionAtlasTag(materialId);
-
// Loop over cells
- int c_index = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
- ++c_iter, ++c_index) {
- // Compute geometry information for current cell
- _quadrature->retrieveGeometry(mesh, coordinates, *c_iter, c_index);
+ ++c_iter) {
+ // Retrieve geometry information for current cell
+ _quadrature->retrieveGeometry(*c_iter);
// Restrict input fields to cell
- mesh->restrictClosure(disp, *c_iter, &dispCell[0], cellVecSize);
+ dispVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, dispVisitor);
// Get cell geometry information that depends on cell
const double_array& basisDeriv = _quadrature->basisDeriv();
// Compute strains
- calcTotalStrainFn(&totalStrain, basisDeriv, dispCell, numBasis, numQuadPts);
+ calcTotalStrainFn(&strainCell, basisDeriv, dispCell,
+ numBasis, numQuadPts);
// Update material state
- _material->updateProperties(totalStrain, *c_iter);
+ _material->updateStateVars(strainCell, *c_iter);
} // for
} // updateState
@@ -163,12 +231,12 @@
// Verify configuration is acceptable.
void
pylith::feassemble::IntegratorElasticity::verifyConfiguration(
- const ALE::Obj<Mesh>& mesh) const
+ const topology::Mesh& mesh) const
{ // verifyConfiguration
assert(0 != _quadrature);
assert(0 != _material);
- const int dimension = mesh->getDimension();
+ const int dimension = mesh.dimension();
// check compatibility of mesh and material
if (_material->dimension() != dimension) {
@@ -192,14 +260,17 @@
throw std::runtime_error(msg.str());
} // if
const int numCorners = _quadrature->refGeometry().numCorners();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", _material->id());
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", _material->id());
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- const int cellNumCorners = mesh->getNumCellCorners(*c_iter);
+ const int cellNumCorners = sieveMesh->getNumCellCorners(*c_iter);
if (numCorners != cellNumCorners) {
std::ostringstream msg;
msg << "Quadrature is incompatible with cell in material '"
@@ -214,160 +285,162 @@
// ----------------------------------------------------------------------
// Get cell field associated with integrator.
-const ALE::Obj<pylith::real_section_type>&
+const pylith::topology::Field<pylith::topology::Mesh>&
pylith::feassemble::IntegratorElasticity::cellField(
- VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields)
+ const char* name,
+ const topology::Mesh& mesh,
+ topology::SolutionFields* fields)
{ // cellField
assert(0 != _material);
- // We assume the material stores the total-strain field if
- // usesUpdateProperties() is TRUE.
+ // We assume the material stores the total_strain field if
+ // hasStateVars() is TRUE.
- const int numQuadPts = _quadrature->numQuadPts();
-
- if (!_material->usesUpdateProperties() &&
+ if (!_material->hasStateVars() &&
(0 == strcasecmp(name, "total_strain") ||
- 0 == strcasecmp(name, "stress")) ) {
+ 0 == strcasecmp(name, "stress") )) {
assert(0 != fields);
- _calcStrainStressField(&_bufferCellOther, name, mesh, fields);
- return _bufferCellOther;
-
+ _allocateTensorField(mesh);
+ _calcStrainStressField(_bufferFieldTensor, name, fields);
+ _bufferFieldTensor->label(name);
+ return *_bufferFieldTensor;
} else if (0 == strcasecmp(name, "stress")) {
- _material->propertyField(&_bufferCellOther,
- "total_strain", mesh, numQuadPts);
- _calcStressFromStrain(&_bufferCellOther, mesh);
- return _bufferCellOther;
-
+ assert(0 != fields);
+ _allocateTensorField(mesh);
+ _material->getField(_bufferFieldTensor, "total_strain");
+ _calcStressFromStrain(_bufferFieldTensor);
+ _bufferFieldTensor->label(name);
+ return *_bufferFieldTensor;
} else {
- const VectorFieldEnum fieldType = _material->propertyFieldType(name);
- switch (fieldType)
- { // switch
- case SCALAR_FIELD :
- _material->propertyField(&_bufferCellScalar, name, mesh, numQuadPts);
- return _bufferCellScalar;
- break;
- case VECTOR_FIELD :
- _material->propertyField(&_bufferCellVector, name, mesh, numQuadPts);
- return _bufferCellVector;
- break;
- case TENSOR_FIELD :
- _material->propertyField(&_bufferCellTensor, name, mesh, numQuadPts);
- return _bufferCellTensor;
- break;
- case OTHER_FIELD :
- _material->propertyField(&_bufferCellOther, name, mesh, numQuadPts);
- return _bufferCellOther;
- break;
- default:
- assert(0);
- } // switch
- } // else
-
- // Return scalar section to satisfy member function definition.
- return _bufferCellScalar;
+ if (0 == _bufferFieldOther)
+ _bufferFieldOther = new topology::Field<topology::Mesh>(mesh);
+ _material->getField(_bufferFieldOther, name);
+ return *_bufferFieldOther;
+ } // if/else
+
+ // Return tensor section to satisfy member function definition. Code
+ // should never get here.
+ return *_bufferFieldTensor;
} // cellField
// ----------------------------------------------------------------------
+// Allocate buffer for tensor field at quadrature points.
void
+pylith::feassemble::IntegratorElasticity::_allocateTensorField(
+ const topology::Mesh& mesh)
+{ // _allocateTensorField
+ assert(0 != _quadrature);
+ assert(0 != _material);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const int materialId = _material->id();
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ assert(!cells.isNull());
+
+ const int numQuadPts = _quadrature->numQuadPts();
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
+ const int tensorSize = _material->tensorSize();
+
+ if (0 == _bufferFieldTensor) {
+ _bufferFieldTensor = new topology::Field<topology::Mesh>(mesh);
+ assert(0 != _bufferFieldTensor);
+ _bufferFieldTensor->newSection(cells, numQuadPts*tensorSize);
+ _bufferFieldTensor->allocate();
+ _bufferFieldTensor->vectorFieldType(topology::FieldBase::MULTI_TENSOR);
+ } // if
+} // _allocateTensorField
+
+// ----------------------------------------------------------------------
+void
pylith::feassemble::IntegratorElasticity::_calcStrainStressField(
- ALE::Obj<real_section_type>* field,
+ topology::Field<topology::Mesh>* field,
const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields)
+ topology::SolutionFields* const fields)
{ // _calcStrainStressField
+ assert(0 != field);
assert(0 != _quadrature);
assert(0 != _material);
const bool calcStress = (0 == strcasecmp(name, "stress")) ? true : false;
+ // Get cell information that doesn't depend on particular cell
const int cellDim = _quadrature->cellDim();
- int tensorSize = 0;
+ const int numQuadPts = _quadrature->numQuadPts();
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
+ const int tensorSize = _material->tensorSize();
totalStrain_fn_type calcTotalStrainFn;
if (1 == cellDim) {
- tensorSize = 1;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain1D;
} else if (2 == cellDim) {
- tensorSize = 3;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain2D;
} else if (3 == cellDim) {
- tensorSize = 6;
calcTotalStrainFn =
&pylith::feassemble::IntegratorElasticity::_calcTotalStrain3D;
} else
assert(0);
+ // Allocate arrays for cell data.
+ double_array dispCell(numBasis*spaceDim);
+ double_array strainCell(numQuadPts*tensorSize);
+ strainCell = 0.0;
+ double_array stressCell(numQuadPts*tensorSize);
+ stressCell = 0.0;
+
+ // Get normalizer
+ assert(0 != _normalizer);
+ const double pressureScale = _normalizer->pressureScale();
+
// Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = field->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
const int materialId = _material->id();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", materialId);
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
-
- // Get sections
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- assert(!coordinates.isNull());
- const ALE::Obj<real_section_type>& disp = fields->getSolution();
-
- // Get cell geometry information that doesn't depend on cell
- const int numQuadPts = _quadrature->numQuadPts();
- const int numBasis = _quadrature->numBasis();
- const int spaceDim = _quadrature->spaceDim();
-
- const int cellVecSize = numBasis*spaceDim;
- double_array dispCell(cellVecSize);
-
- // Allocate array for total strain
- const int totalFiberDim = numQuadPts * tensorSize;
- double_array totalStrain(totalFiberDim);
- totalStrain = 0.0;
- double_array stress(totalFiberDim);
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
- assert(0 != _normalizer);
- const double pressureScale = _normalizer->pressureScale();
-
- // Allocate buffer for property field.
- if (field->isNull() ||
- totalFiberDim != (*field)->getFiberDimension(*cells->begin())) {
- *field = new real_section_type(mesh->comm(), mesh->debug());
- (*field)->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- (*field)->setFiberDimension(cells, totalFiberDim);
- mesh->allocate(*field);
- } // if
-
-
+ // Get field
+ const topology::Field<topology::Mesh>& solution = fields->solution();
+ const ALE::Obj<RealSection>& disp = solution.section();
+ assert(!disp.isNull());
+ topology::Mesh::RestrictVisitor dispVisitor(*disp,
+ dispCell.size(), &dispCell[0]);
+
+ const ALE::Obj<RealSection>& fieldSection = field->section();
+ assert(!fieldSection.isNull());
+
// Loop over cells
- int c_index = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
- ++c_iter, ++c_index) {
- // Compute geometry information for current cell
- _quadrature->retrieveGeometry(mesh, coordinates, *c_iter, c_index);
-
+ ++c_iter) {
+ // Retrieve geometry information for current cell
+ _quadrature->retrieveGeometry(*c_iter);
+
// Restrict input fields to cell
- mesh->restrictClosure(disp, *c_iter, &dispCell[0], cellVecSize);
-
+ dispVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, dispVisitor);
+
// Get cell geometry information that depends on cell
const double_array& basisDeriv = _quadrature->basisDeriv();
// Compute strains
- calcTotalStrainFn(&totalStrain, basisDeriv, dispCell, numBasis,
- numQuadPts);
+ calcTotalStrainFn(&strainCell, basisDeriv, dispCell,
+ numBasis, numQuadPts);
- if (!calcStress) {
- (*field)->updatePoint(*c_iter, &totalStrain[0]);
- } else {
- _material->getPropertiesCell(*c_iter, numQuadPts);
- stress = _material->calcStress(totalStrain);
- _normalizer->dimensionalize(&stress[0], stress.size(),
+ if (!calcStress)
+ fieldSection->updatePoint(*c_iter, &strainCell[0]);
+ else {
+ _material->retrievePropsAndVars(*c_iter);
+ stressCell = _material->calcStress(strainCell);
+ _normalizer->dimensionalize(&stressCell[0], stressCell.size(),
pressureScale);
- (*field)->updatePoint(*c_iter, &stress[0]);
+ fieldSection->updatePoint(*c_iter, &stressCell[0]);
} // else
} // for
} // _calcStrainStressField
@@ -375,62 +448,51 @@
// ----------------------------------------------------------------------
void
pylith::feassemble::IntegratorElasticity::_calcStressFromStrain(
- ALE::Obj<real_section_type>* field,
- const ALE::Obj<Mesh>& mesh)
+ topology::Field<topology::Mesh>* field)
{ // _calcStressFromStrain
+ assert(0 != field);
assert(0 != _quadrature);
assert(0 != _material);
const int cellDim = _quadrature->cellDim();
- int tensorSize = 0;
- if (1 == cellDim) {
- tensorSize = 1;
- } else if (2 == cellDim) {
- tensorSize = 3;
- } else if (3 == cellDim) {
- tensorSize = 6;
- } else
- assert(0);
-
- // Get cell information
- const int materialId = _material->id();
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", materialId);
- assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
-
- // Get cell geometry information that doesn't depend on cell
const int numQuadPts = _quadrature->numQuadPts();
+ const int numBasis = _quadrature->numBasis();
+ const int spaceDim = _quadrature->spaceDim();
+ const int tensorSize = _material->tensorSize();
- // Allocate vector for total strain
- const int totalFiberDim = numQuadPts*tensorSize;
- double_array totalStrain(totalFiberDim);
- totalStrain = 0.0;
- double_array stress(totalFiberDim);
-
+ // Allocate arrays for cell data.
+ double_array strainCell(numQuadPts*tensorSize);
+ strainCell = 0.0;
+ double_array stressCell(numQuadPts*tensorSize);
+ stressCell = 0.0;
+
+ // Get normalizer
assert(0 != _normalizer);
const double pressureScale = _normalizer->pressureScale();
- // Allocate buffer for tensor field.
- if (field->isNull()) {
- const int fiberDim = numQuadPts * tensorSize;
- *field = new real_section_type(mesh->comm(), mesh->debug());
- (*field)->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- (*field)->setFiberDimension(cells, fiberDim);
- mesh->allocate(*field);
- } // if
-
+ // Get cell information
+ const ALE::Obj<SieveMesh>& sieveMesh = field->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const int materialId = _material->id();
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ assert(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+
+ // Get field
+ const ALE::Obj<RealSection>& fieldSection = field->section();
+ assert(!fieldSection.isNull());
+
// Loop over cells
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- (*field)->restrictPoint(*c_iter, &totalStrain[0], totalStrain.size());
- _material->getPropertiesCell(*c_iter, numQuadPts);
- stress = _material->calcStress(totalStrain);
- _normalizer->dimensionalize(&stress[0], stress.size(),
+ fieldSection->restrictPoint(*c_iter, &strainCell[0], strainCell.size());
+ _material->retrievePropsAndVars(*c_iter);
+ stressCell = _material->calcStress(strainCell);
+ _normalizer->dimensionalize(&stressCell[0], stressCell.size(),
pressureScale);
- (*field)->updatePoint(*c_iter, &stress[0]);
+ fieldSection->updatePoint(*c_iter, &stressCell[0]);
} // for
} // _calcStressFromStrain
Modified: short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/IntegratorElasticity.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,22 +20,20 @@
#if !defined(pylith_feassemble_integratorelasticity_hh)
#define pylith_feassemble_integratorelasticity_hh
-#include "Integrator.hh" // ISA Integrator
-#include "pylith/utils/array.hh" // USES std::vector, double_array
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+// Include directives ---------------------------------------------------
+#include "feassemblefwd.hh" // forward declarations
-namespace pylith {
- namespace feassemble {
- class IntegratorElasticity;
- class TestIntegratorElasticity;
- } // feassemble
+#include "pylith/topology/topologyfwd.hh" // HOLDSA Field
+#include "pylith/materials/materialsfwd.hh" // HOLDSA Material
- namespace materials {
- class ElasticMaterial;
- } // feassemble
-} // pylith
+#include "pylith/topology/Mesh.hh" // ISA Integrator<Mesh>
+#include "Integrator.hh" // ISA Integrator
-class pylith::feassemble::IntegratorElasticity : public Integrator
+#include "pylith/utils/arrayfwd.hh" // USES std::vector, double_array
+
+// IntegratorElasticity -------------------------------------------------
+class pylith::feassemble::IntegratorElasticity :
+ public Integrator<Quadrature<topology::Mesh> >
{ // IntegratorElasticity
friend class TestIntegratorElasticity; // unit testing
@@ -77,60 +75,64 @@
*/
void useSolnIncr(const bool flag);
+ /** Initialize integrator.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ void initialize(const topology::Mesh& mesh);
+
/** Update state variables as needed.
*
* @param t Current time
* @param fields Solution fields
* @param mesh Finite-element mesh
*/
- void updateState(const double t,
- topology::FieldsManager* const fields,
- const ALE::Obj<Mesh>& mesh);
+ void updateStateVars(const double t,
+ topology::SolutionFields* const fields);
/** Verify configuration is acceptable.
*
* @param mesh Finite-element mesh
*/
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const;
+ void verifyConfiguration(const topology::Mesh& mesh) const;
/** Get cell field associated with integrator.
*
- * @param fieldType Type of field.
* @param name Name of vertex field.
- * @param mesh PETSc mesh for problem.
+ * @param mesh Finite-element mesh for problem.
* @param fields Fields manager.
* @returns Cell field.
*/
- const ALE::Obj<real_section_type>&
- cellField(VectorFieldEnum* fieldType,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ const topology::Field<topology::Mesh>&
+ cellField(const char* name,
+ const topology::Mesh& mesh,
+ topology::SolutionFields* const fields =0);
-
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
+ /** Allocate buffer for tensor field at quadrature points.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ void _allocateTensorField(const topology::Mesh& mesh);
+
/** Calculate stress or strain field from solution field.
*
* @param field Field in which to store stress or strain.
* @param name Name of field to compute ('total-strain' or 'stress')
- * @param mesh PETSc mesh for problem.
- * @param fields Fields manager with solution.
+ * @param fields Manager for solution fields.
*/
- void _calcStrainStressField(ALE::Obj<real_section_type>* field,
+ void _calcStrainStressField(topology::Field<topology::Mesh>* field,
const char* name,
- const ALE::Obj<Mesh>& mesh,
- topology::FieldsManager* const fields);
+ topology::SolutionFields* const fields);
/** Calculate stress field from total strain field. Stress field
* replaces strain field in section.
*
* @param field Field in which to store stress.
- * @param mesh PETSc mesh for problem.
*/
- void _calcStressFromStrain(ALE::Obj<real_section_type>* field,
- const ALE::Obj<Mesh>& mesh);
+ void _calcStressFromStrain(topology::Field<topology::Mesh>* field);
/** Integrate elasticity term in residual for 1-D cells.
@@ -215,33 +217,27 @@
const int numBasis,
const int numQuadPts);
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- /// Not implemented.
- IntegratorElasticity(const IntegratorElasticity& i);
-
- /// Not implemented
- const IntegratorElasticity& operator=(const IntegratorElasticity&);
-
// PROTECTED MEMBERS ////////////////////////////////////////////////////
protected :
/// Elastic material associated with integrator
materials::ElasticMaterial* _material;
- /// Buffer for storing scalar cell field.
- ALE::Obj<real_section_type> _bufferCellScalar;
+ /// Buffer for storing cell tensor field.
+ topology::Field<topology::Mesh>* _bufferFieldTensor;
- /// Buffer for storing vector cell field.
- ALE::Obj<real_section_type> _bufferCellVector;
+ /// Buffer for storing cell state-variable field.
+ topology::Field<topology::Mesh>* _bufferFieldOther;
- /// Buffer for storing cell tensor field.
- ALE::Obj<real_section_type> _bufferCellTensor;
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
- /// Buffer for storing other cell fields.
- ALE::Obj<real_section_type> _bufferCellOther;
+ /// Not implemented.
+ IntegratorElasticity(const IntegratorElasticity&);
+ /// Not implemented
+ const IntegratorElasticity& operator=(const IntegratorElasticity&);
+
}; // IntegratorElasticity
#endif // pylith_feassemble_integratorelasticity_hh
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,6 +22,7 @@
ElasticityImplicit.hh \
Integrator.hh \
Integrator.icc \
+ Integrator.cc \
IntegratorElasticity.hh \
GeometryPoint1D.hh \
GeometryPoint2D.hh \
@@ -35,8 +36,13 @@
GeometryQuad2D.hh \
GeometryQuad3D.hh \
GeometryHex3D.hh \
+ QuadratureRefCell.hh \
+ QuadratureRefCell.icc \
+ QuadratureEngine.hh \
+ QuadratureEngine.icc \
Quadrature.hh \
Quadrature.icc \
+ Quadrature.cc \
Quadrature0D.hh \
Quadrature0D.icc \
Quadrature1D.hh \
@@ -50,7 +56,8 @@
Quadrature2Din3D.hh \
Quadrature2Din3D.icc \
Quadrature3D.hh \
- Quadrature3D.icc
+ Quadrature3D.icc \
+ feassemblefwd.hh
noinst_HEADERS =
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,10 +12,19 @@
#include <portinfo>
-#include "Quadrature.hh" // implementation of class methods
-
#include "CellGeometry.hh" // USES CellGeometry
+#include "QuadratureEngine.hh" // USES QuadratureEngine
+#include "Quadrature0D.hh"
+#include "Quadrature1D.hh"
+#include "Quadrature1Din2D.hh"
+#include "Quadrature1Din3D.hh"
+#include "Quadrature2D.hh"
+#include "Quadrature2Din3D.hh"
+#include "Quadrature3D.hh"
+
+#include "pylith/topology/Field.hh" // HOLDSA Field
+
#include <cstring> // USES memcpy()
#include <cassert> // USES assert()
#include <stdexcept> // USES std::runtime_error
@@ -23,357 +32,263 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature::Quadrature(void) :
- _minJacobian(0),
- _cellDim(0),
- _numBasis(0),
- _numQuadPts(0),
- _spaceDim(0),
- _geometry(0),
- _precomputed(false),
+template<typename mesh_type>
+pylith::feassemble::Quadrature<mesh_type>::Quadrature(void) :
+ _engine(0),
+ _quadPtsField(0),
+ _jacobianField(0),
+ _jacobianDetField(0),
+ _basisDerivField(0),
_checkConditioning(false)
{ // constructor
- _quadPtsPre = new real_section_type(PETSC_COMM_WORLD);
- _jacobianPre = new real_section_type(PETSC_COMM_WORLD);
- _jacobianDetPre = new real_section_type(PETSC_COMM_WORLD);
- _jacobianInvPre = new real_section_type(PETSC_COMM_WORLD);
- _basisDerivPre = new real_section_type(PETSC_COMM_WORLD);
} // constructor
// ----------------------------------------------------------------------
// Destructor
-pylith::feassemble::Quadrature::~Quadrature(void)
+template<typename mesh_type>
+pylith::feassemble::Quadrature<mesh_type>::~Quadrature(void)
{ // destructor
- delete _geometry; _geometry = 0;
+ delete _engine; _engine = 0;
+ delete _quadPtsField; _quadPtsField = 0;
+ delete _jacobianField; _jacobianField = 0;
+ delete _jacobianDetField; _jacobianDetField = 0;
+ delete _basisDerivField; _basisDerivField = 0;
} // destructor
// ----------------------------------------------------------------------
// Copy constructor
-pylith::feassemble::Quadrature::Quadrature(const Quadrature& q) :
- _minJacobian(q._minJacobian),
- _quadPtsRef(q._quadPtsRef),
- _quadPts(q._quadPts),
- _quadWts(q._quadWts),
- _basis(q._basis),
- _basisDerivRef(q._basisDerivRef),
- _basisDeriv(q._basisDeriv),
- _jacobian(q._jacobian),
- _jacobianInv(q._jacobianInv),
- _jacobianDet(q._jacobianDet),
- _cellDim(q._cellDim),
- _numBasis(q._numBasis),
- _numQuadPts(q._numQuadPts),
- _spaceDim(q._spaceDim),
- _geometry(0),
- _precomputed(q._precomputed),
+template<typename mesh_type>
+pylith::feassemble::Quadrature<mesh_type>::Quadrature(const Quadrature& q) :
+ QuadratureRefCell(q),
+ _engine(0),
+ _quadPtsField(0),
+ _jacobianField(0),
+ _jacobianDetField(0),
+ _basisDerivField(0),
_checkConditioning(q._checkConditioning)
{ // copy constructor
- if (0 != q._geometry)
- _geometry = q._geometry->clone();
- _quadPtsPre = q._quadPtsPre;
- _jacobianPre = q._jacobianPre;
- _jacobianDetPre = q._jacobianDetPre;
- _jacobianInvPre = q._jacobianInvPre;
- _basisDerivPre = q._basisDerivPre;
+ if (0 != q._engine)
+ _engine = q._engine->clone();
} // copy constructor
// ----------------------------------------------------------------------
-// Set basis functions and their derivatives and coordinates and
-// weights of the quadrature points.
+template<typename mesh_type>
void
-pylith::feassemble::Quadrature::initialize(const double* basis,
- const double* basisDerivRef,
- const double* quadPtsRef,
- const double* quadWts,
- const int cellDim,
- const int numBasis,
- const int numQuadPts,
- const int spaceDim)
-{ // initialize
- if (0 == basis ||
- 0 == basisDerivRef ||
- 0 == quadPtsRef ||
- 0 == quadWts ||
- cellDim < 0 || cellDim > 3 ||
- numBasis < 1 ||
- numQuadPts < 1 ||
- spaceDim < 1 || spaceDim > 3) {
- std::ostringstream msg;
- msg << "Incompatible values for quadrature information. Basis functions,\n"
- << "their derivatives, and coordinates and weights of quadrature\n"
- << "points must all be specified.\n"
- << "Values:\n"
- << " basis pointer: " << basis << "\n"
- << " basis derivatites pointer: " << basisDerivRef << "\n"
- << " quadrature points pointer: " << quadPtsRef << "\n"
- << " quadrature weights pointer: " << quadWts << "\n"
- << " space dimension: " << spaceDim << "\n"
- << " # basis functions: " << numBasis << "\n"
- << " # quadrature points: " << numQuadPts << "\n"
- << " dimension of coordinate space: " << spaceDim << "\n";
- throw std::runtime_error(msg.str());
- } // if
+pylith::feassemble::Quadrature<mesh_type>::computeGeometry(
+ const mesh_type& mesh,
+ const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& cells)
+{ // precomputeGeometry
+ typedef typename mesh_type::RealSection RealSection;
+ typedef typename mesh_type::SieveMesh::label_sequence label_sequence;
+ typedef typename mesh_type::RestrictVisitor RestrictVisitor;
- if (cellDim > 0) {
- int size = numBasis * numQuadPts; assert(size > 0);
- _basis.resize(size);
- for (int i=0; i < size; ++i)
- _basis[i] = basis[i];
+ const char* loggingStage = "QuadratureCreation";
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.stagePush(loggingStage);
- size = numQuadPts * numBasis * cellDim; assert(size > 0);
- _basisDerivRef.resize(size);
- for (int i=0; i < size; ++i)
- _basisDerivRef[i] = basisDerivRef[i];
+ clear();
+ _setupEngine();
+ assert(0 != _engine);
- size = numQuadPts * cellDim; assert(size > 0);
- _quadPtsRef.resize(size);
- for (int i=0; i < size; ++i)
- _quadPtsRef[i] = quadPtsRef[i];
+ // Allocate field and cell buffer for quadrature points
+ int fiberDim = _numQuadPts * _spaceDim;
+ _quadPtsField = new topology::Field<mesh_type>(mesh);
+ assert(0 != _quadPtsField);
+ _quadPtsField->newSection(cells, fiberDim);
+ _quadPtsField->allocate();
- size = numQuadPts; assert(size > 0);
- _quadWts.resize(size);
- for (int i=0; i < size; ++i)
- _quadWts[i] = quadWts[i];
+ // Get chart for reuse in other fields
+ const ALE::Obj<RealSection>& section = _quadPtsField->section();
+ assert(!section.isNull());
+ const typename RealSection::chart_type& chart = section->getChart();
- _cellDim = cellDim;
- _numBasis = numBasis;
- _numQuadPts = numQuadPts;
- _spaceDim = spaceDim;
+ // Allocate field and cell buffer for Jacobian at quadrature points
+ fiberDim = (_cellDim > 0) ?
+ _numQuadPts * _cellDim * _spaceDim :
+ _numQuadPts * 1 * _spaceDim;
+ _jacobianField = new topology::Field<mesh_type>(mesh);
+ assert(0 != _jacobianField);
+ _jacobianField->newSection(chart, fiberDim);
+ _jacobianField->allocate();
+
+ // Allocate field and cell buffer for determinant of Jacobian at quad pts
+ fiberDim = _numQuadPts;
+ _jacobianDetField = new topology::Field<mesh_type>(mesh);
+ assert(0 != _jacobianDetField);
+ _jacobianDetField->newSection(chart, fiberDim);
+ _jacobianDetField->allocate();
+
+ // Allocate field for derivatives of basis functions at quad pts
+ fiberDim = _numQuadPts * _numBasis * _spaceDim;
+ _basisDerivField = new topology::Field<mesh_type>(mesh);
+ assert(0 != _basisDerivField);
+ _basisDerivField->newSection(chart, fiberDim);
+ _basisDerivField->allocate();
- // Allocate for Jacobian and its inverse
- size = numQuadPts * cellDim * spaceDim; assert(size > 0);
- _jacobian.resize(size);
- _jacobianInv.resize(size);
+ logger.stagePop();
- // Allocate for Jacobian determinant
- size = numQuadPts; assert(size > 0);
- _jacobianDet.resize(size);
+#if defined(ALE_MEM_LOGGING)
+ std::cout
+ << loggingStage << ": "
+ << logger.getNumAllocations(loggingStage)
+ << " allocations " << logger.getAllocationTotal(loggingStage)
+ << " bytes"
+ << std::endl
+ << loggingStage << ": "
+ << logger.getNumDeallocations(loggingStage)
+ << " deallocations " << logger.getDeallocationTotal(loggingStage)
+ << " bytes"
+ << std::endl;
+#endif
- // Allocate for basis derivatives (in global coordinates)
- size = numQuadPts * numBasis * spaceDim; assert(size > 0);
- _basisDeriv.resize(size);
+ const typename label_sequence::iterator cellsEnd = cells->end();
+ assert(0 != _geometry);
+ const int numBasis = _numBasis;
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<RealSection>& coordinates =
+ sieveMesh->getRealSection("coordinates");
+ RestrictVisitor coordsVisitor(*coordinates, numBasis*_spaceDim);
- // Allocate for quad pts
- size = numQuadPts*spaceDim; assert(size > 0);
- _quadPts.resize(size);
- } else {
- if (1 != numBasis ||
- 1 != numQuadPts ||
- 1 != spaceDim) {
- std::ostringstream msg;
- msg << "0-D quadrature only works in 1-D and is limited to 1 basis "
- << "function and 1 quadrature point.\n"
- << "Values:\n"
- << " cell dimension: " << cellDim << "\n"
- << " spatial dimension: " << spaceDim << "\n"
- << " # basis functions: " << numBasis << "\n"
- << " # quadrature points: " << numQuadPts << "\n";
- throw std::runtime_error(msg.str());
- } // if
+ const ALE::Obj<RealSection>& quadPtsSection = _quadPtsField->section();
+ const ALE::Obj<RealSection>& jacobianSection = _jacobianField->section();
+ const ALE::Obj<RealSection>& jacobianDetSection =
+ _jacobianDetField->section();
+ const ALE::Obj<RealSection>& basisDerivSection = _basisDerivField->section();
- int size = 1;
- _basis.resize(size);
- for (int i=0; i < size; ++i)
- _basis[i] = basis[i];
+ const double_array& quadPts = _engine->quadPts();
+ const double_array& jacobian = _engine->jacobian();
+ const double_array& jacobianDet = _engine->jacobianDet();
+ const double_array& basisDeriv = _engine->basisDeriv();
- size = 1;
- _basisDerivRef.resize(size);
- for (int i=0; i < size; ++i)
- _basisDerivRef[i] = basisDerivRef[i];
+ for(typename label_sequence::iterator c_iter = cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter) {
+ coordsVisitor.clear();
+ sieveMesh->restrictClosure(*c_iter, coordsVisitor);
+ const double* cellVertexCoords = coordsVisitor.getValues();
+ assert(0 != cellVertexCoords);
+ _engine->computeGeometry(cellVertexCoords, _spaceDim, *c_iter);
- size = 1;
- _quadPtsRef.resize(size);
- for (int i=0; i < size; ++i)
- _quadPtsRef[i] = quadPtsRef[i];
+ // Update fields with cell data
+ quadPtsSection->updatePoint(*c_iter, &quadPts[0]);
+ jacobianSection->updatePoint(*c_iter, &jacobian[0]);
+ jacobianDetSection->updatePoint(*c_iter, &jacobianDet[0]);
+ basisDerivSection->updatePoint(*c_iter, &basisDeriv[0]);
+ } // for
+} // computeGeometry
- size = 1;
- _quadWts.resize(size);
- for (int i=0; i < size; ++i)
- _quadWts[i] = quadWts[i];
+// ----------------------------------------------------------------------
+template<typename mesh_type>
+void
+pylith::feassemble::Quadrature<mesh_type>::retrieveGeometry(const typename mesh_type::SieveMesh::point_type& cell)
+{ // retrieveGeometry
+ typedef typename mesh_type::RealSection RealSection;
- _cellDim = cellDim;
- _numBasis = numBasis;
- _numQuadPts = numQuadPts;
- _spaceDim = spaceDim;
+ assert(0 != _quadPtsField);
+ assert(0 != _jacobianField);
+ assert(0 != _jacobianDetField);
+ assert(0 != _basisDerivField);
+ assert(0 != _engine);
- // Allocate for Jacobian and its inverse
- size = 1;
- _jacobian.resize(size);
- _jacobianInv.resize(size);
+ const double_array& quadPts = _engine->quadPts();
+ const double_array& jacobian = _engine->jacobian();
+ const double_array& jacobianDet = _engine->jacobianDet();
+ const double_array& basisDeriv = _engine->basisDeriv();
- // Allocate for Jacobian determinant
- size = 1;
- _jacobianDet.resize(size);
+ const ALE::Obj<RealSection>& quadPtsSection = _quadPtsField->section();
+ quadPtsSection->restrictPoint(cell, const_cast<double*>(&quadPts[0]),
+ quadPts.size());
- // Allocate for basis derivatives (in global coordinates)
- size = numQuadPts * numBasis * spaceDim; assert(size > 0);
- _basisDeriv.resize(size);
+ const ALE::Obj<RealSection>& jacobianSection = _jacobianField->section();
+ jacobianSection->restrictPoint(cell, const_cast<double*>(&jacobian[0]),
+ jacobian.size());
- // Allocate for quad pts
- size = spaceDim; assert(size > 0);
- _quadPts.resize(size);
- } // else
-} // initialize
+ const ALE::Obj<RealSection>& jacobianDetSection =
+ _jacobianDetField->section();
+ jacobianDetSection->restrictPoint(cell, const_cast<double*>(&jacobianDet[0]),
+ jacobianDet.size());
-// ----------------------------------------------------------------------
-// Set geometry associated with reference cell.
-void
-pylith::feassemble::Quadrature::refGeometry(CellGeometry* const geometry)
-{ // refGeometry
- delete _geometry; _geometry = (0 != geometry) ? geometry->clone() : 0;
-} // refGeometry
+ const ALE::Obj<RealSection>& basisDerivSection = _basisDerivField->section();
+ basisDerivSection->restrictPoint(cell, const_cast<double*>(&basisDeriv[0]),
+ basisDeriv.size());
+} // retrieveGeometry
// ----------------------------------------------------------------------
-// Get geometry associated with reference cell.
-const pylith::feassemble::CellGeometry&
-pylith::feassemble::Quadrature::refGeometry(void) const
-{ // refGeometry
- assert(0 != _geometry);
- return *_geometry;
-} // refGeometry
-
-// ----------------------------------------------------------------------
-// Set entries in geometry arrays to zero.
+// Deallocate temporary storage;
+template<typename mesh_type>
void
-pylith::feassemble::Quadrature::_resetGeometry(void)
-{ // _resetGeometry
- _jacobian = 0.0;
- _jacobianDet = 0.0;
- _jacobianInv = 0.0;
- _basisDeriv = 0.0;
- _quadPts = 0.0;
-} // _resetGeometry
+pylith::feassemble::Quadrature<mesh_type>::clear(void)
+{ // clear
+ delete _engine; _engine = 0;
-// ----------------------------------------------------------------------
-// Check determinant of Jacobian against minimum allowable value
-void
-pylith::feassemble::Quadrature::_checkJacobianDet(const double det,
- const Mesh::point_type& cell) const
-{ // _checkJacobianDet
- if (det < _minJacobian) {
- std::ostringstream msg;
- msg << "Determinant of Jacobian (" << det << ") for cell " << cell
- << " is smaller than minimum permissible value (" << _minJacobian
- << ")!\n";
- throw std::runtime_error(msg.str());
- } // if
-} // _checkJacobianDet
+ // Clear storage for fields
+ delete _quadPtsField; _quadPtsField = 0;
+ delete _jacobianField; _jacobianField = 0;
+ delete _jacobianDetField; _jacobianDetField = 0;
+ delete _basisDerivField; _basisDerivField = 0;
+} // clear
// ----------------------------------------------------------------------
+// Setup quadrature engine.
+template<typename mesh_type>
void
-pylith::feassemble::Quadrature::resetPrecomputation()
-{ // resetPrecomputation
- _precomputed = false;
- _quadPtsPre->clear();
- _jacobianPre->clear();
- _jacobianDetPre->clear();
- _jacobianInvPre->clear();
- _basisDerivPre->clear();
-} // resetPrecomputation
+pylith::feassemble::Quadrature<mesh_type>::_setupEngine(void)
+{ // clear
+ delete _engine; _engine = 0;
-// ----------------------------------------------------------------------
-void
-pylith::feassemble::Quadrature::precomputeGeometry(
- const ALE::Obj<Mesh>& mesh,
- const ALE::Obj<real_section_type>& coordinates,
- const ALE::Obj<Mesh::label_sequence>& cells)
-{ // precomputeGeometry
- if (_precomputed)
- return;
+ const int cellDim = _cellDim;
+ const int spaceDim = _spaceDim;
- _quadPtsPre->setChart(real_section_type::chart_type(
- *std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- _quadPtsPre->setFiberDimension(cells, _numQuadPts*_spaceDim);
- _quadPtsPre->allocatePoint();
- _quadPtsPreV = new ALE::ISieveVisitor::RestrictVisitor<real_section_type>(
- *_quadPtsPre, _numQuadPts*_spaceDim, &_quadPts[0]);
+ if (1 == spaceDim)
+ if (1 == cellDim)
+ _engine = new Quadrature1D(*this);
+ else if (0 == cellDim)
+ _engine = new Quadrature0D(*this);
+ else {
+ std::cerr << "Unknown quadrature case with cellDim '"
+ << cellDim << "' and spaceDim '" << spaceDim << "'"
+ << std::endl;
+ assert(0);
+ } // if/else
+ else if (2 == spaceDim)
+ if (2 == cellDim)
+ _engine = new Quadrature2D(*this);
+ else if (1 == cellDim)
+ _engine = new Quadrature1Din2D(*this);
+ else if (0 == cellDim)
+ _engine = new Quadrature0D(*this);
+ else {
+ std::cerr << "Unknown quadrature case with cellDim '"
+ << cellDim << "' and spaceDim '" << spaceDim << "'"
+ << std::endl;
+ assert(0);
+ } // if/else
+ else if (3 == spaceDim)
+ if (3 == cellDim)
+ _engine = new Quadrature3D(*this);
+ else if (2 == cellDim)
+ _engine = new Quadrature2Din3D(*this);
+ else if (1 == cellDim)
+ _engine = new Quadrature1Din3D(*this);
+ else if (0 == cellDim)
+ _engine = new Quadrature0D(*this);
+ else {
+ std::cerr << "Unknown quadrature case with cellDim '"
+ << cellDim << "' and spaceDim '" << spaceDim << "'"
+ << std::endl;
+ assert(0);
+ } // if/else
+ else {
+ std::cerr << "Unknown quadrature case with cellDim '"
+ << cellDim << "' and spaceDim '" << spaceDim << "'"
+ << std::endl;
+ assert(0);
+ } // if/else
- _jacobianPre->getAtlas()->setAtlas(_quadPtsPre->getAtlas()->getAtlas());
- _jacobianPre->getAtlas()->allocatePoint();
- _jacobianPre->setFiberDimension(cells, _numQuadPts*_cellDim*_spaceDim);
- _jacobianPre->allocatePoint();
- _jacobianPreV = new ALE::ISieveVisitor::RestrictVisitor<real_section_type>(
- *_jacobianPre, _numQuadPts*_cellDim*_spaceDim, &_jacobian[0]);
+ assert(0 != _engine);
+ _engine->initialize();
+} // _setupEngine
- _jacobianDetPre->getAtlas()->setAtlas(_quadPtsPre->getAtlas()->getAtlas());
- _jacobianDetPre->getAtlas()->allocatePoint();
- _jacobianDetPre->setFiberDimension(cells, _numQuadPts);
- _jacobianDetPre->allocatePoint();
- _jacobianDetPreV = new ALE::ISieveVisitor::RestrictVisitor<real_section_type>(*_jacobianDetPre, _numQuadPts, &_jacobianDet[0]);
- _jacobianInvPre->setAtlas(_jacobianPre->getAtlas());
- _jacobianInvPre->setFiberDimension(cells, _numQuadPts*_cellDim*_spaceDim);
- _jacobianInvPre->allocatePoint();
- _jacobianInvPreV = new ALE::ISieveVisitor::RestrictVisitor<real_section_type>(*_jacobianInvPre, _numQuadPts*_cellDim*_spaceDim, &_jacobianInv[0]);
- //_jITag = _jacobianInvPre->copyCustomAtlas(_jacobianPre, _jTag);
-
- _basisDerivPre->getAtlas()->setAtlas(_quadPtsPre->getAtlas()->getAtlas());
- _basisDerivPre->getAtlas()->allocatePoint();
- _basisDerivPre->setFiberDimension(cells, _numQuadPts*_numBasis*_spaceDim);
- _basisDerivPre->allocatePoint();
- _basisDerivPreV = new ALE::ISieveVisitor::RestrictVisitor<real_section_type>(*_basisDerivPre, _numQuadPts*_numBasis*_spaceDim, &_basisDeriv[0]);
-
-#if 0
- const int ncells = cells->size();
- const int nbytes = (_numQuadPts*_spaceDim + // quadPts
- _numQuadPts*_cellDim*_spaceDim + // jacobian
- _numQuadPts*_cellDim*_spaceDim + // jacobianInv
- _numQuadPts + // jacobianDet
- _numQuadPts*_numBasis*_spaceDim // basisDeriv
- ) * ncells * sizeof(double);
-
- std::cout << "Quadrature::precomputeGeometry() allocating "
- << nbytes/(1024*1024) << " MB."
- << std::endl;
-#endif
-
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
- for(Mesh::label_sequence::iterator c_iter = cells->begin();
- c_iter != cellsEnd;
- ++c_iter) {
- this->computeGeometry(mesh, coordinates, *c_iter);
-
- // Set coordinates of quadrature points in cell
- _quadPtsPre->updatePoint(*c_iter, &_quadPts[0]);
-
- // Set Jacobian at quadrature points in cell
- _jacobianPre->updatePoint(*c_iter, &_jacobian[0]);
-
- // Set determinant of Jacobian at quadrature points in cell
- _jacobianDetPre->updatePoint(*c_iter, &_jacobianDet[0]);
-
- // Set inverse of Jacobian at quadrature points in cell
- _jacobianInvPre->updatePoint(*c_iter, &_jacobianInv[0]);
-
- // Set derivatives of basis functions with respect to global
- _basisDerivPre->updatePoint(*c_iter, &_basisDeriv[0]);
- } // for
- _precomputed = true;
-} // precomputeGeometry
-
-// ----------------------------------------------------------------------
-void
-pylith::feassemble::Quadrature::retrieveGeometry(
- const ALE::Obj<Mesh>& mesh,
- const ALE::Obj<real_section_type>& coordinates,
- const Mesh::point_type& cell,
- const int c)
-{ // retrieveGeometry
- _quadPtsPreV->clear();
- mesh->restrictClosure(cell, *_quadPtsPreV);
-
- _jacobianPreV->clear();
- mesh->restrictClosure(cell, *_jacobianPreV);
-
- _jacobianDetPreV->clear();
- mesh->restrictClosure(cell, *_jacobianDetPreV);
-
- _jacobianInvPreV->clear();
- mesh->restrictClosure(cell, *_jacobianInvPreV);
-
- _basisDerivPreV->clear();
- mesh->restrictClosure(cell, *_basisDerivPreV);
-} // retrieveGeometry
-
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,34 +16,29 @@
* @brief Abstract base class for integrating over finite-elements
* using quadrature.
*
- * This object contains the basis functions and their derivatives
- * evaluated at the quadrature points of the reference element, and
- * the coordinates and weights of the quadrature points. Given a cell
- * this object will compute the cell's Jacobian, the determinant of
- * the Jacobian, the inverse of the Jacobian, and the coordinates in
- * the domain of the cell's quadrature points. The Jacobian and its
- * inverse are computed at the quadrature points.
- *
- * The memory for the Jacobian and its associated information are
- * managed locally.
+ * This object contains the informatio needed to perform numerical
+ * quadrature over a finite-element cell. It inherits quadrature
+ * information over the reference cell from the QuadratureRefCell object.
+
+ * Given a cell this object will compute the cell's Jacobian, the
+ * determinant of the Jacobian, the inverse of the Jacobian, and the
+ * coordinates in the domain of the cell's quadrature points. The
+ * Jacobian and its inverse are computed at the quadrature points.
*/
#if !defined(pylith_feassemble_quadrature_hh)
#define pylith_feassemble_quadrature_hh
-#include "pylith/utils/array.hh" // HASA double_array
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+// Include directives ---------------------------------------------------
+#include "QuadratureRefCell.hh" // ISA QuadratureRefCell
-namespace pylith {
- namespace feassemble {
- class Quadrature;
+#include "pylith/topology/topologyfwd.hh" // forward declarations
- class CellGeometry; // HOLDSA CellGeometry
- class TestQuadrature;
- } // feassemble
-} // pylith
+#include "pylith/utils/array.hh" // HASA double_array
-class pylith::feassemble::Quadrature
+// Quadrature -----------------------------------------------------------
+template<typename mesh_type>
+class pylith::feassemble::Quadrature : public QuadratureRefCell
{ // Quadrature
friend class TestQuadrature; // unit testing
@@ -54,81 +49,14 @@
Quadrature(void);
/// Destructor
- virtual
~Quadrature(void);
- /// Create a copy of this object.
- virtual
- Quadrature* clone(void) const = 0;
-
- /** Set basis functions and their derivatives, and coordinates and
- * weights of the quadrature points.
+ /** Copy constructor.
*
- * @param basis Array of basis functions evaluated at quadrature pts
- * N0Qp0, N1Qp0, ...
- * N0Qp1, N1Qp1, ...
- * ...
- * size = numQuadPts * numBasis
- * index = iQuadPt*numBasis + iBasis
- *
- * @param basisDerivRef Array of basis function derivaties evaluated at
- * quadrature pts, where derivatives are with respect to cell's
- * local coordinates.
- * N0pQp0, N0qQp0, N0rQp0, N1pQp0, N1qQp0, N1rQp0, ...
- * N0pQp1, N0qQp1, N0rQp1, N1pQp1, N1qQp1, N1rQp1, ...
- * ...
- * size = numQuadPts * numBasis * cellDim
- * index = iQuadPt*numBasis*cellDim + iBasis*cellDim + iDim
- *
- * @param quadPts Array of coordinates of quadrature points in
- * reference cell
- * Qp0p, Qp0q, Qp0r
- * Qp1p, Qp1q, Qp1r
- * size = numQuadPts * numDims
- * index = iQuadPt*numDims + iDim
- *
- * @param quadWts Array of weights of quadrature points
- * WtQp0, WtQp1, ...
- * index = iQuadPt
- *
- * @param cellDim Number of dimensions in reference cell
- * @param numBasis Number of basis functions for a cell
- * @param numQuadPts Number of quadrature points
- * @param spaceDim Number of dimensions in coordinates of cell vertices
+ * @param q Quadrature to copy
*/
- void initialize(const double* basis,
- const double* basisDerivRef,
- const double* quadPtsRef,
- const double* quadWts,
- const int cellDim,
- const int numBasis,
- const int numQuadPts,
- const int spaceDim);
+ Quadrature(const Quadrature& q);
- /** Set geometry associated with reference cell.
- *
- * @param geometry Geometry of reference cell.
- */
- void refGeometry(CellGeometry* const geometry);
-
- /** Get geometry associated with reference cell.
- *
- * @returns Geometry of reference cell.
- */
- const CellGeometry& refGeometry(void) const;
-
- /** Set minimum allowable determinant of Jacobian.
- *
- * @param tolerance Minimum allowable value for Jacobian
- */
- void minJacobian(const double min);
-
- /** Get minimum allowable determinant of Jacobian.
- *
- * @returns Minimum allowable value for Jacobian
- */
- double minJacobian(void) const;
-
/** Set flag for checking ill-conditioning.
*
* @param flag True to check for ill-conditioning, false otherwise.
@@ -141,30 +69,12 @@
*/
bool checkConditioning(void) const;
- /** Get coordinates of quadrature points in reference cell.
- *
- * @returns Array of coordinates of quadrature points in reference cell.
- */
- const double_array& quadPtsRef(void) const;
-
/** Get coordinates of quadrature points in cell (NOT reference cell).
*
* @returns Array of coordinates of quadrature points in cell
*/
const double_array& quadPts(void) const;
- /** Get weights of quadrature points.
- *
- * @returns Weights of quadrature points
- */
- const double_array& quadWts(void) const;
-
- /** Get basis fns evaluated at quadrature points.
- *
- * @returns Array of basis fns evaluated at quadrature points
- */
- const double_array& basis(void) const;
-
/** Get derivatives of basis fns evaluated at quadrature points.
*
* @returns Array of derivatives of basis fns evaluated at
@@ -184,229 +94,58 @@
*/
const double_array& jacobianDet(void) const;
- /** Get Jacobian inverses evaluated at quadrature points.
- *
- * @returns Array of Jacobian inverses evaluated at quadrature points.
- */
- const double_array& jacobianInv(void) const;
-
- /** Get number of dimensions in reference cell.
- *
- * @returns Number of dimensions in reference cell
- */
- int cellDim(void) const;
-
- /** Get number of basis functions for cell.
- *
- * @returns Number of basis functions for cell
- */
- int numBasis(void) const;
-
- /** Get number of quadrature points.
- *
- * @returns Number of quadrature points
- */
- int numQuadPts(void) const;
-
- /** Get number of dimensions in coordinates of cell vertices.
- *
- * @returns Number of dimensions in coordinates of cell vertices
- */
- int spaceDim(void) const;
-
- /** Compute geometric quantities for a cell at quadrature points.
- *
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
- * @param cell Finite-element cell
- */
- virtual
- void computeGeometry(const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell) = 0;
-
- template<typename mesh_type>
- void computeGeometry(const ALE::Obj<mesh_type>& mesh,
- const ALE::Obj<real_section_type>& coordinates,
- const Mesh::point_type& cell) {
- computeGeometry(mesh->restrictClosure(coordinates, cell),
- coordinates->getFiberDimension(*mesh->depthStratum(0)->begin()),
- cell);
- };
-
- /** Reset the precomputation structures. */
- void resetPrecomputation(void);
-
/** Precompute geometric quantities for each cell.
*
* @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param cells Finite-element cells for geometry.
*/
- void precomputeGeometry(const ALE::Obj<Mesh>& mesh,
- const ALE::Obj<real_section_type>& coordinates,
- const ALE::Obj<Mesh::label_sequence>& cells);
+ void computeGeometry(const mesh_type& mesh,
+ const ALE::Obj<typename mesh_type::SieveMesh::label_sequence>& cells);
/** Retrieve precomputed geometric quantities for a cell.
*
* @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
* @param cell Finite-element cell
*/
- void retrieveGeometry(const ALE::Obj<Mesh>& mesh,
- const ALE::Obj<real_section_type>& coordinates,
- const Mesh::point_type& cell,
- const int c);
+ void retrieveGeometry(const typename mesh_type::SieveMesh::point_type& cell);
-// PROTECTED METHODS ////////////////////////////////////////////////////
-protected :
+ /// Deallocate temporary storage.
+ void clear(void);
- /** Copy constructor.
- *
- * @param q Quadrature to copy
- */
- Quadrature(const Quadrature& q);
-
- /* Check determinant of Jacobian against minimum allowable value.
- *
- * @param det Value of determinant of Jacobian
- * @param cell Finite-element cell
- */
- void _checkJacobianDet(const double det,
- const Mesh::point_type& cell) const;
-
- /// Set entries in geometry arrays to zero.
- void _resetGeometry(void);
-
// PRIVATE METHODS //////////////////////////////////////////////////////
private :
- const Quadrature& operator=(const Quadrature&); ///< Not implemented
+ /// Setup quadrature engine.
+ void _setupEngine(void);
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-protected :
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
- double _minJacobian; ///< Minium allowable Jacobian determinant
-
- /** Array of coordinates of quadrature points in reference cell.
- *
- * Reference coordinates: (p,q,r)
- *
- * Qp0p, Qp0q, Qp0r
- * Qp1p, Qp1q, Qp1r
- *
- * size = numQuadPts * cellDim
- * index = iQuadPts*cellDim + iDim
- */
- double_array _quadPtsRef;
+ QuadratureEngine* _engine; ///< Quadrature geometry engine.
- /** Array of coordinates of quadrature points in cell (global coordinates).
- *
- * Qp0x, Qp0y, Qp0z
- * Qp1x, Qp1y, Qp1z
- *
- * size = numQuadPts * spaceDim
- * index = iQuadPts*spaceDim + iDim
+ /** Fields and visitors for precomputing geometry information for
+ * cells associated with this quadrature.
*/
- double_array _quadPts;
+ topology::Field<mesh_type>* _quadPtsField; ///< Coordinates of quad pts.
+ topology::Field<mesh_type>* _jacobianField; ///< Jacobian at quad pts.
+ topology::Field<mesh_type>* _jacobianDetField; ///< |J| at quad pts.
- /** Array of weights of quadrature points.
- *
- * WtQp0, WtQp1, ...
- * size = numQuadPts
- * index = iQuadPt
- */
- double_array _quadWts;
+ /// Derivatives of basis fns at quad pts.
+ topology::Field<mesh_type>* _basisDerivField;
- /** Array of basis functions evaluated at the quadrature points.
- *
- * N0Qp0, N1Qp0, ...
- * N0Qp1, N1Qp1, ...
- *
- * size = numQuadPts * numBasis
- * index = iQuadPt*numBasis + iBasis
- */
- double_array _basis;
+ bool _checkConditioning; ///< True if checking for ill-conditioning.
- /** Array of basis function derivatives evaluated at the quadrature
- * points, where derivatives are with respect to cell's local
- * coordinates.
- *
- * N0pQp0, N0qQp0, N0rQp0, N1pQp0, N1qQp0, N1rQp0, ...
- * N0pQp1, N0qQp1, N0rQp1, N1pQp1, N1qQp1, N1rQp1, ...
- *
- * size = numQuadPts * numBasis * cellDim
- * index = iQuadPt*numBasis*cellDim + iBasis*cellDim + iDim
- */
- double_array _basisDerivRef;
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
- /** Array of basis function derivatives evaluated at the quadrature
- * points, where derivatives are with respect to global coordinates.
- *
- * N0xQp0, N0yQp0, N0zQp0, N1xQp0, N1yQp0, N1zQp0, ...
- * N0xQp1, N0yQp1, N0zQp1, N1xQp1, N1yQp1, N1zQp1, ...
- *
- * size = numQuadPts * numBasis * spaceDim
- * index = iQuadPt*numBasis*spaceDim + iBasis*spaceDim + iDim
- */
- double_array _basisDeriv;
+ const Quadrature& operator=(const Quadrature&); ///< Not implemented
- /** Array of Jacobians evaluated at quadrature points.
- *
- * Qp0J00, Qp0J01, Qp0J02, ...
- * Qp1J00, Qp1J01, Qp1J02, ...
- * ...
- *
- * size = numQuadPts*cellDim*spaceDim
- * index = iQuadPt*cellDim*spaceDim + iRow*spaceDim + iCol
- */
- double_array _jacobian;
-
- /** Array of determinant of Jacobian evaluated at quadrature points.
- *
- * JdetQp0, JdetQp1, ...
- *
- * size = numQuadPts
- * index = iQuadPt
- */
- double_array _jacobianDet;
-
- /** Array of Jacobian inverses evaluated at quadrature points.
- *
- * Qp0Jinv00, Qp0Jinv01, Qp0Jinv02, ...
- * Qp1Jinv00, Qp1Jinv01, Qp1Jinv02, ...
- * ...
- *
- * size = numQuadPts*spaceDim*cellDim
- * index = iQuadPt*spaceDim*cellDim + iRow*cellDim + iCol
- */
- double_array _jacobianInv;
-
- int _cellDim; ///< Number of dimensions in reference cell
- int _numBasis; ///< Number of basis functions (and vertices) for cell
- int _numQuadPts; ///< Number of quadrature points
- int _spaceDim; ///< Number of dimensions in coordinates of cell vertices
-
- CellGeometry* _geometry; ///< Geometry of reference cell
-
- /* Precomputation sections */
- int _qTag, _jTag, _jDTag, _jITag, _bTag;
- Obj<real_section_type> _quadPtsPre;
- Obj<ALE::ISieveVisitor::RestrictVisitor<real_section_type> > _quadPtsPreV;
- Obj<real_section_type> _jacobianPre;
- Obj<ALE::ISieveVisitor::RestrictVisitor<real_section_type> > _jacobianPreV;
- Obj<real_section_type> _jacobianDetPre;
- Obj<ALE::ISieveVisitor::RestrictVisitor<real_section_type> > _jacobianDetPreV;
- Obj<real_section_type> _jacobianInvPre;
- Obj<ALE::ISieveVisitor::RestrictVisitor<real_section_type> > _jacobianInvPreV;
- Obj<real_section_type> _basisDerivPre;
- Obj<ALE::ISieveVisitor::RestrictVisitor<real_section_type> > _basisDerivPreV;
-
- bool _precomputed; ///< True if we have computed geometry info
- bool _checkConditioning; ///< True if checking for ill-conditioning
}; // Quadrature
#include "Quadrature.icc" // inline methods
+#include "Quadrature.cc" // template methods
#endif // pylith_feassemble_quadrature_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,118 +14,61 @@
#error "Quadrature.icc must be included only from Quadrature.hh"
#else
-// Get minimum allowable Jacobian.
-inline
-double
-pylith::feassemble::Quadrature::minJacobian(void) const {
- return _minJacobian;
-}
+#include <cassert> // USES assert()
+#include "QuadratureEngine.hh" // USES QuadratureEngine
-// Set minimum allowable Jacobian.
-inline
-void
-pylith::feassemble::Quadrature::minJacobian(const double min) {
- _minJacobian = min;
-}
-
// Set flag for checking ill-conditioning.
+template<typename mesh_type>
inline
void
-pylith::feassemble::Quadrature::checkConditioning(const bool flag) {
+pylith::feassemble::Quadrature<mesh_type>::checkConditioning(const bool flag) {
_checkConditioning = flag;
}
// Get flag for checking ill-conditioning.
+template<typename mesh_type>
inline
bool
-pylith::feassemble::Quadrature::checkConditioning(void) const {
+pylith::feassemble::Quadrature<mesh_type>::checkConditioning(void) const {
return _checkConditioning;
}
-// Get coordinates of quadrature points in reference cell.
-inline
-const pylith::double_array&
-pylith::feassemble::Quadrature::quadPtsRef(void) const {
- return _quadPtsRef;
-}
-
// Get coordinates of quadrature points in cell (NOT reference cell).
+template<typename mesh_type>
inline
const pylith::double_array&
-pylith::feassemble::Quadrature::quadPts(void) const {
- return _quadPts;
+pylith::feassemble::Quadrature<mesh_type>::quadPts(void) const {
+ assert(0 != _engine);
+ return _engine->quadPts();
}
-// Get weights of quadrature points.
-inline
-const pylith::double_array&
-pylith::feassemble::Quadrature::quadWts(void) const {
- return _quadWts;
-}
-
-// Get basis fns evaluated at quadrature points.
-inline
-const pylith::double_array&
-pylith::feassemble::Quadrature::basis(void) const {
- return _basis;
-}
-
// Get derivatives of basis fns evaluated at quadrature points.
+template<typename mesh_type>
inline
const pylith::double_array&
-pylith::feassemble::Quadrature::basisDeriv(void) const {
- return _basisDeriv;
+pylith::feassemble::Quadrature<mesh_type>::basisDeriv(void) const {
+ assert(0 != _engine);
+ return _engine->basisDeriv();
}
// Get Jacobians evaluated at quadrature points.
+template<typename mesh_type>
inline
const pylith::double_array&
-pylith::feassemble::Quadrature::jacobian(void) const {
- return _jacobian;
+pylith::feassemble::Quadrature<mesh_type>::jacobian(void) const {
+ assert(0 != _engine);
+ return _engine->jacobian();
}
// Get determinants of Jacobian evaluated at quadrature points.
+template<typename mesh_type>
inline
const pylith::double_array&
-pylith::feassemble::Quadrature::jacobianDet(void) const {
- return _jacobianDet;
+pylith::feassemble::Quadrature<mesh_type>::jacobianDet(void) const {
+ assert(0 != _engine);
+ return _engine->jacobianDet();
}
-// Get Jacobian inverses evaluated at quadrature points.
-inline
-const pylith::double_array&
-pylith::feassemble::Quadrature::jacobianInv(void) const {
- return _jacobianInv;
-}
-
-// Get number of dimensions in reference cell.
-inline
-int
-pylith::feassemble::Quadrature::cellDim(void) const {
- return _cellDim;
-}
-
-// Get number of basis functions for cell.
-inline
-int
-pylith::feassemble::Quadrature::numBasis(void) const {
- return _numBasis;
-}
-
-// Get number of quadrature points.
-inline
-int
-pylith::feassemble::Quadrature::numQuadPts(void) const {
- return _numQuadPts;
-}
-
-// Get number of dimensions in coordinates of cell vertices.
-inline
-int
-pylith::feassemble::Quadrature::spaceDim(void) const {
- return _spaceDim;
-}
-
#endif
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,7 +14,8 @@
#include "Quadrature0D.hh" // implementation of class methods
-#include "pylith/utils/array.hh" // USES double_array
+#include "QuadratureRefCell.hh" // USES QuadratureRefCell
+#include "CellGeometry.hh" // USES CellGeometry
#include "petsc.h" // USES PetscLogFlops()
@@ -22,7 +23,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature0D::Quadrature0D(void) : Quadrature()
+pylith::feassemble::Quadrature0D::Quadrature0D(const QuadratureRefCell& q) :
+ QuadratureEngine(q)
{ // constructor
} // constructor
@@ -35,32 +37,38 @@
// ----------------------------------------------------------------------
// Copy constructor.
pylith::feassemble::Quadrature0D::Quadrature0D(const Quadrature0D& q) :
- Quadrature(q)
+ QuadratureEngine(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
void
-pylith::feassemble::Quadrature0D::computeGeometry(
- const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell)
+pylith::feassemble::Quadrature0D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(0 == _cellDim);
- assert(1 == _numQuadPts);
- assert(1 == _numBasis);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
- _resetGeometry();
+ const double_array& basisDerivRef = _quadRefCell.basisDerivRef();
+
+ assert(0 == cellDim);
+ assert(1 == numQuadPts);
+ assert(1 == numBasis);
+
+ zero();
assert(1 == coordDim);
- for (int i=0; i < _spaceDim; ++i)
+ for (int i=0; i < spaceDim; ++i)
_quadPts[i] = vertCoords[i];
_jacobian[0] = 1.0;
_jacobianDet[0] = 1.0;
_jacobianInv[0] = 1.0;
- _basisDeriv[0] = _basisDerivRef[0];
+ _basisDeriv[0] = basisDerivRef[0];
PetscLogFlops(0);
} // computeGeometry
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,40 +22,42 @@
#if !defined(pylith_feassemble_quadrature0d_hh)
#define pylith_feassemble_quadrature0d_hh
-#include "Quadrature.hh"
+#include "QuadratureEngine.hh"
namespace pylith {
namespace feassemble {
- class Quadrature0D;
class TestQuadrature0D;
} // feassemble
} // pylith
-class pylith::feassemble::Quadrature0D : public Quadrature
+class pylith::feassemble::Quadrature0D : public QuadratureEngine
{ // Quadrature0D
friend class TestQuadrature0D; // unit testing
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
- /// Constructor
- Quadrature0D(void);
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ Quadrature0D(const QuadratureRefCell& q);
/// Destructor
~Quadrature0D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param vertCoords Coordinates of vertices of finite-element cell.
+ * @param coordDim Spatial dimension of coordinate system.
* @param cell Finite-element cell
*/
- void computeGeometry(const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell);
+ void computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -77,4 +79,5 @@
#endif // pylith_feassemble_quadrature0d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature0D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature0D::clone(void) const {
return new Quadrature0D(*this);
} // clone
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,7 +14,7 @@
#include "Quadrature1D.hh" // implementation of class methods
-#include "pylith/utils/array.hh" // USES double_array
+#include "QuadratureRefCell.hh" // USES QuadratureRefCell
#include "CellGeometry.hh" // USES CellGeometry
#include "petsc.h" // USES PetscLogFlops
@@ -25,7 +25,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature1D::Quadrature1D(void) : Quadrature()
+pylith::feassemble::Quadrature1D::Quadrature1D(const QuadratureRefCell& q) :
+ QuadratureEngine(q)
{ // constructor
} // constructor
@@ -38,45 +39,54 @@
// ----------------------------------------------------------------------
// Copy constructor.
pylith::feassemble::Quadrature1D::Quadrature1D(const Quadrature1D& q) :
- Quadrature(q)
+ QuadratureEngine(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
void
-pylith::feassemble::Quadrature1D::computeGeometry(
- const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell)
+pylith::feassemble::Quadrature1D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(1 == _cellDim);
- assert(1 == _spaceDim);
+ assert(0 != vertCoords);
+ assert(1 == coordDim);
- _resetGeometry();
- assert(1 == coordDim);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+
+ const double_array& basis = _quadRefCell.basis();
+ const double_array& quadPtsRef = _quadRefCell.quadPtsRef();
+ const double_array& basisDerivRef = _quadRefCell.basisDerivRef();
+ const CellGeometry& geometry = _quadRefCell.refGeometry();
+
+ assert(1 == cellDim);
+ assert(1 == spaceDim);
+ zero();
// Loop over quadrature points
- for (int iQuadPt=0; iQuadPt < _numQuadPts; ++iQuadPt) {
+ for (int iQuadPt=0; iQuadPt < numQuadPts; ++iQuadPt) {
// Compute coordinates of quadrature point in cell
#if defined(ISOPARAMETRIC)
// x = sum[i=0,n-1] (Ni * xi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
_quadPts[iQuadPt] +=
- _basis[iQuadPt*_numBasis+iBasis]*vertCoords[iBasis];
+ basis[iQuadPt*numBasis+iBasis]*vertCoords[iBasis];
#else
- assert(0 != _geometry);
- _geometry->coordsRefToGlobal(&_quadPts[iQuadPt], &_quadPtsRef[iQuadPt],
- vertCoords, _spaceDim);
+ geometry.coordsRefToGlobal(&_quadPts[iQuadPt], &quadPtsRef[iQuadPt],
+ vertCoords, spaceDim);
#endif
#if defined(ISOPARAMETRIC)
// Compute Jacobian at quadrature point
// J = dx/dp = sum[i=0,n-1] (dNi/dp * xi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
_jacobian[iQuadPt] +=
- _basisDerivRef[iQuadPt*_numBasis+iBasis] * vertCoords[iBasis];
+ basisDerivRef[iQuadPt*numBasis+iBasis] * vertCoords[iBasis];
// Compute determinant of Jacobian at quadrature point
// |J| = j00
@@ -86,8 +96,8 @@
#else
// Compute Jacobian and determinant of Jacobian at quadrature point
assert(0 != _geometry);
- _geometry->jacobian(&_jacobian[iQuadPt], &_jacobianDet[iQuadPt],
- vertCoords, &_quadPtsRef[iQuadPt], _spaceDim);
+ geometry->jacobian(&_jacobian[iQuadPt], &_jacobianDet[iQuadPt],
+ vertCoords, &quadPtsRef[iQuadPt], spaceDim);
_checkJacobianDet(_jacobianDet[iQuadPt], cell);
#endif
@@ -95,20 +105,20 @@
// Jinv = 1/j00
_jacobianInv[iQuadPt] = 1.0 / _jacobianDet[iQuadPt];
- assert(_numQuadPts*_numBasis*_spaceDim == _basisDeriv.size());
- assert(_numQuadPts*_numBasis*_cellDim == _basisDerivRef.size());
- assert(_numQuadPts*_cellDim*_spaceDim == _jacobianInv.size());
+ assert(numQuadPts*numBasis*spaceDim == _basisDeriv.size());
+ assert(numQuadPts*numBasis*cellDim == basisDerivRef.size());
+ assert(numQuadPts*cellDim*spaceDim == _jacobianInv.size());
// Compute derivatives of basis functions with respect to global
// coordinates
// dNi/dx = dNi/dp dp/dx + dNi/dq dq/dx + dNi/dr dr/dx
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- _basisDeriv[iQuadPt*_numBasis+iBasis] +=
- _basisDerivRef[iQuadPt*_numBasis+iBasis] *
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ _basisDeriv[iQuadPt*numBasis+iBasis] +=
+ basisDerivRef[iQuadPt*numBasis+iBasis] *
_jacobianInv[iQuadPt];
} // for
- PetscLogFlops(_numQuadPts * (1 + _numBasis * 4));
+ PetscLogFlops(numQuadPts * (1 + numBasis * 4));
} // computeGeometry
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,43 +19,39 @@
#if !defined(pylith_feassemble_quadrature1d_hh)
#define pylith_feassemble_quadrature1d_hh
-#include "Quadrature.hh"
+#include "QuadratureEngine.hh" // ISA Quadrature
-namespace pylith {
- namespace feassemble {
- class Quadrature1D;
- class TestQuadrature1D;
- } // feassemble
-} // pylith
-
-class pylith::feassemble::Quadrature1D : public Quadrature
+class pylith::feassemble::Quadrature1D : public QuadratureEngine
{ // Quadrature1D
friend class TestQuadrature1D; // unit testing
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
- /// Constructor
- Quadrature1D(void);
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ Quadrature1D(const QuadratureRefCell& q);
/// Destructor
~Quadrature1D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param vertCoords Coordinates of vertices of finite-element cell.
+ * @param coordDim Spatial dimension of coordinate system.
* @param cell Finite-element cell
*/
- void computeGeometry(const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell);
+ void computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell);
-// PROTECTED METHODS ////////////////////////////////////////////////////
-protected :
+// PRIVATE METHODS //////////////////////////////////////////////////////
+private :
/** Copy constructor.
*
@@ -63,7 +59,7 @@
*/
Quadrature1D(const Quadrature1D& q);
-// PRIVATE METHODS //////////////////////////////////////////////////////
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
const Quadrature1D& operator=(const Quadrature1D&); ///< Not implemented
@@ -74,4 +70,5 @@
#endif // pylith_feassemble_quadrature1d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature1D::clone(void) const {
return new Quadrature1D(*this);
} // clone
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,7 @@
#include "Quadrature1Din2D.hh" // implementation of class methods
+#include "QuadratureRefCell.hh" // USES QuadratureRefCell
#include "CellGeometry.hh" // USES CellGeometry
#include "petsc.h" // USES PetscLogFlops
@@ -24,7 +25,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature1Din2D::Quadrature1Din2D(void) : Quadrature()
+pylith::feassemble::Quadrature1Din2D::Quadrature1Din2D(const QuadratureRefCell& q) :
+ QuadratureEngine(q)
{ // constructor
} // constructor
@@ -37,42 +39,51 @@
// ----------------------------------------------------------------------
// Copy constructor.
pylith::feassemble::Quadrature1Din2D::Quadrature1Din2D(const Quadrature1Din2D& q) :
- Quadrature(q)
+ QuadratureEngine(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
void
-pylith::feassemble::Quadrature1Din2D::computeGeometry(
- const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell)
+pylith::feassemble::Quadrature1Din2D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(1 == _cellDim);
- assert(2 == _spaceDim);
-
- _resetGeometry();
+ assert(0 != vertCoords);
assert(2 == coordDim);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+
+ const double_array& basis = _quadRefCell.basis();
+ const double_array& quadPtsRef = _quadRefCell.quadPtsRef();
+ const double_array& basisDerivRef = _quadRefCell.basisDerivRef();
+ const CellGeometry& geometry = _quadRefCell.refGeometry();
+
+ assert(1 == cellDim);
+ assert(2 == spaceDim);
+ zero();
+
// Loop over quadrature points
- for (int iQuadPt=0; iQuadPt < _numQuadPts; ++iQuadPt) {
+ for (int iQuadPt=0; iQuadPt < numQuadPts; ++iQuadPt) {
// Compute coordinates of quadrature point in cell
#if defined(ISOPARAMETRIC)
// x = sum[i=0,n-1] (Ni * xi)
// y = sum[i=0,n-1] (Ni * yi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double basis = _basis[iQuadPt*_numBasis+iBasis];
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _quadPts[iQuadPt*_spaceDim+iDim] +=
- basis * vertCoords[iBasis*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double valueBasis = basis[iQuadPt*numBasis+iBasis];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _quadPts[iQuadPt*spaceDim+iDim] +=
+ valueBasis * vertCoords[iBasis*spaceDim+iDim];
} // for
#else
- assert(0 != _geometry);
- _geometry->coordsRefToGlobal(&_quadPts[iQuadPt*_spaceDim],
- &_quadPtsRef[iQuadPt*_cellDim],
- vertCoords, _spaceDim);
+ geometry.coordsRefToGlobal(&_quadPts[iQuadPt*spaceDim],
+ &quadPtsRef[iQuadPt*cellDim],
+ vertCoords, spaceDim);
#endif
#if defined(ISOPARAMETRIC)
@@ -81,51 +92,50 @@
// dy/dp]
// dx/dp = sum[i=0,n-1] (dNi/dp * xi)
// dy/dp = sum[i=0,n-1] (dNi/dp * yi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double deriv = _basisDerivRef[iQuadPt*_numBasis+iBasis];
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _jacobian[iQuadPt*_spaceDim+iDim] +=
- deriv * vertCoords[iBasis*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double deriv = basisDerivRef[iQuadPt*numBasis+iBasis];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _jacobian[iQuadPt*spaceDim+iDim] +=
+ deriv * vertCoords[iBasis*spaceDim+iDim];
} // for
// Compute determinant of Jacobian at quadrature point
// |J| = sqrt(transpose(J) J)
double det = 0.0;
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- det += _jacobian[iQuadPt*_spaceDim+iDim] *
- _jacobian[iQuadPt*_spaceDim+iDim];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ det += _jacobian[iQuadPt*spaceDim+iDim] *
+ _jacobian[iQuadPt*spaceDim+iDim];
det = sqrt(det);
_checkJacobianDet(det, cell);
_jacobianDet[iQuadPt] = det;
#else
// Compute Jacobian and determinant of Jacobian at quadrature point
- assert(0 != _geometry);
- _geometry->jacobian(&_jacobian[iQuadPt*_cellDim*_spaceDim],
- &_jacobianDet[iQuadPt],
- vertCoords, &_quadPtsRef[iQuadPt*_cellDim], _spaceDim);
+ geometry.jacobian(&_jacobian[iQuadPt*_cellDim*spaceDim],
+ &_jacobianDet[iQuadPt],
+ vertCoords, &quadPtsRef[iQuadPt*cellDim], spaceDim);
_checkJacobianDet(_jacobianDet[iQuadPt], cell);
#endif
// Compute inverse of Jacobian at quadrature point
// Jinv = 1.0/[J]
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _jacobianInv[iQuadPt*_spaceDim+iDim] =
- 1.0 / _jacobian[iQuadPt*_spaceDim+iDim];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _jacobianInv[iQuadPt*spaceDim+iDim] =
+ 1.0 / _jacobian[iQuadPt*spaceDim+iDim];
// Compute derivatives of basis functions with respect to global
// coordinates
// dNi/dx = dNi/dp dp/dx + dNi/dq dq/dx + dNi/dr dr/dx
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- for (int jDim=0; jDim < _cellDim; ++jDim)
- _basisDeriv[iQuadPt*_numBasis*_spaceDim+iBasis*_spaceDim+iDim] +=
- _basisDerivRef[iQuadPt*_numBasis*_cellDim+iBasis*_cellDim+jDim] *
- _jacobianInv[iQuadPt*_cellDim*_spaceDim+jDim*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ for (int jDim=0; jDim < cellDim; ++jDim)
+ _basisDeriv[iQuadPt*numBasis*spaceDim+iBasis*spaceDim+iDim] +=
+ basisDerivRef[iQuadPt*numBasis*cellDim+iBasis*cellDim+jDim] *
+ _jacobianInv[iQuadPt*cellDim*spaceDim+jDim*spaceDim+iDim];
} // for
- PetscLogFlops(_numQuadPts * (1+_numBasis*_spaceDim*2+
- _spaceDim*1 +
- _numBasis*_spaceDim*_cellDim*2));
+ PetscLogFlops(numQuadPts * (1 + numBasis*spaceDim*2 +
+ spaceDim*1 +
+ numBasis*spaceDim*cellDim*2));
} // computeGeometry
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,40 +19,42 @@
#if !defined(pylith_feassemble_quadrature1din2d_hh)
#define pylith_feassemble_quadrature1din2d_hh
-#include "Quadrature.hh"
+#include "QuadratureEngine.hh"
namespace pylith {
namespace feassemble {
class Quadrature1Din2D;
- class TestQuadrature1Din2D;
} // feassemble
} // pylith
-class pylith::feassemble::Quadrature1Din2D : public Quadrature
+class pylith::feassemble::Quadrature1Din2D : public QuadratureEngine
{ // Quadrature1Din2D
friend class TestQuadrature1Din2D; // unit testing
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
- /// Constructor
- Quadrature1Din2D(void);
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ Quadrature1Din2D(const QuadratureRefCell& q);
/// Destructor
~Quadrature1Din2D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param vertCoords Coordinates of vertices of finite-element cell.
+ * @param coordDim Spatial dimension of coordinate system.
* @param cell Finite-element cell
*/
- void computeGeometry(const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell);
+ void computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -75,4 +77,5 @@
#endif // pylith_feassemble_quadrature1din2d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din2D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature1Din2D::clone(void) const {
return new Quadrature1Din2D(*this);
} // clone
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,7 @@
#include "Quadrature1Din3D.hh" // implementation of class methods
+#include "QuadratureRefCell.hh" // USES QuadratureRefCell
#include "CellGeometry.hh" // USES CellGeometry
#include "petsc.h" // USES PetscLogFlops
@@ -24,7 +25,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature1Din3D::Quadrature1Din3D(void) : Quadrature()
+pylith::feassemble::Quadrature1Din3D::Quadrature1Din3D(const QuadratureRefCell& q) :
+ QuadratureEngine(q)
{ // constructor
} // constructor
@@ -37,43 +39,52 @@
// ----------------------------------------------------------------------
// Copy constructor.
pylith::feassemble::Quadrature1Din3D::Quadrature1Din3D(const Quadrature1Din3D& q) :
- Quadrature(q)
+ QuadratureEngine(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
void
-pylith::feassemble::Quadrature1Din3D::computeGeometry(
- const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell)
+pylith::feassemble::Quadrature1Din3D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(1 == _cellDim);
- assert(3 == _spaceDim);
-
- _resetGeometry();
+ assert(0 != vertCoords);
assert(3 == coordDim);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+
+ const double_array& basis = _quadRefCell.basis();
+ const double_array& quadPtsRef = _quadRefCell.quadPtsRef();
+ const double_array& basisDerivRef = _quadRefCell.basisDerivRef();
+ const CellGeometry& geometry = _quadRefCell.refGeometry();
+
+ assert(1 == cellDim);
+ assert(3 == spaceDim);
+ zero();
+
// Loop over quadrature points
- for (int iQuadPt=0; iQuadPt < _numQuadPts; ++iQuadPt) {
+ for (int iQuadPt=0; iQuadPt < numQuadPts; ++iQuadPt) {
// Compute coordinates of quadrature point in cell
#if defined(ISOPARAMETRIC)
// x = sum[i=0,n-1] (Ni * xi)
// y = sum[i=0,n-1] (Ni * yi)
// z = sum[i=0,n-1] (Ni * zi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double basis = _basis[iQuadPt*_numBasis+iBasis];
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _quadPts[iQuadPt*_spaceDim+iDim] +=
- basis * vertCoords[iBasis*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double valueBasis = basis[iQuadPt*numBasis+iBasis];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _quadPts[iQuadPt*spaceDim+iDim] +=
+ valueBasis * vertCoords[iBasis*spaceDim+iDim];
} // for
#else
- assert(0 != _geometry);
- _geometry->coordsRefToGlobal(&_quadPts[iQuadPt*_spaceDim],
- &_quadPtsRef[iQuadPt*_cellDim],
- vertCoords, _spaceDim);
+ geometry.coordsRefToGlobal(&_quadPts[iQuadPt*spaceDim],
+ &quadPtsRef[iQuadPt*cellDim],
+ vertCoords, spaceDim);
#endif
#if defined(ISOPARAMETRIC)
@@ -84,52 +95,51 @@
// dx/dp = sum[i=0,n-1] (dNi/dp * xi)
// dy/dp = sum[i=0,n-1] (dNi/dp * yi)
// dz/dp = sum[i=0,n-1] (dNi/dp * zi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double deriv = _basisDerivRef[iQuadPt*_numBasis+iBasis];
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _jacobian[iQuadPt*_spaceDim+iDim] +=
- deriv * vertCoords[iBasis*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double deriv = basisDerivRef[iQuadPt*numBasis+iBasis];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _jacobian[iQuadPt*spaceDim+iDim] +=
+ deriv * vertCoords[iBasis*spaceDim+iDim];
} // for
// Compute determinant of Jacobian at quadrature point
// |J| = sqrt(transpose(J) J)
double det = 0.0;
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- det += _jacobian[iQuadPt*_spaceDim+iDim] *
- _jacobian[iQuadPt*_spaceDim+iDim];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ det += _jacobian[iQuadPt*spaceDim+iDim] *
+ _jacobian[iQuadPt*spaceDim+iDim];
det = sqrt(det);
_checkJacobianDet(det, cell);
_jacobianDet[iQuadPt] = det;
#else
// Compute Jacobian and determinant of Jacobian at quadrature point
- assert(0 != _geometry);
- _geometry->jacobian(&_jacobian[iQuadPt*_cellDim*_spaceDim],
- &_jacobianDet[iQuadPt],
- vertCoords, &_quadPtsRef[iQuadPt*_cellDim], _spaceDim);
+ geometry.jacobian(&_jacobian[iQuadPt*cellDim*spaceDim],
+ &_jacobianDet[iQuadPt],
+ vertCoords, &quadPtsRef[iQuadPt*cellDim], spaceDim);
_checkJacobianDet(_jacobianDet[iQuadPt], cell);
#endif
// Compute inverse of Jacobian at quadrature point
// Jinv = 1.0/[J]
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _jacobianInv[iQuadPt*_spaceDim+iDim] =
- 1.0 / _jacobian[iQuadPt*_spaceDim+iDim];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _jacobianInv[iQuadPt*spaceDim+iDim] =
+ 1.0 / _jacobian[iQuadPt*spaceDim+iDim];
// Compute derivatives of basis functions with respect to global
// coordinates
// dNi/dx = dNi/dp dp/dx + dNi/dq dq/dx + dNi/dr dr/dx
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- for (int jDim=0; jDim < _cellDim; ++jDim)
- _basisDeriv[iQuadPt*_numBasis*_spaceDim+iBasis*_spaceDim+iDim] +=
- _basisDerivRef[iQuadPt*_numBasis*_cellDim+iBasis*_cellDim+jDim] *
- _jacobianInv[iQuadPt*_cellDim*_spaceDim+jDim*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ for (int jDim=0; jDim < cellDim; ++jDim)
+ _basisDeriv[iQuadPt*numBasis*spaceDim+iBasis*spaceDim+iDim] +=
+ basisDerivRef[iQuadPt*numBasis*cellDim+iBasis*cellDim+jDim] *
+ _jacobianInv[iQuadPt*cellDim*spaceDim+jDim*spaceDim+iDim];
} // for
+
+ PetscLogFlops(numQuadPts * (1 + numBasis*spaceDim*2 +
+ spaceDim*1 +
+ numBasis*spaceDim*cellDim*2));
- PetscLogFlops(_numQuadPts * (1+_numBasis*_spaceDim*2 +
- _spaceDim*1 +
- _numBasis*_spaceDim*_cellDim*2));
-
} // computeGeometry
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,40 +19,42 @@
#if !defined(pylith_feassemble_quadrature1din3d_hh)
#define pylith_feassemble_quadrature1din3d_hh
-#include "Quadrature.hh"
+#include "QuadratureEngine.hh"
namespace pylith {
namespace feassemble {
class Quadrature1Din3D;
- class TestQuadrature1Din3D;
} // feassemble
} // pylith
-class pylith::feassemble::Quadrature1Din3D : public Quadrature
+class pylith::feassemble::Quadrature1Din3D : public QuadratureEngine
{ // Quadrature1Din3D
friend class TestQuadrature1Din3D; // unit testing
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
- /// Constructor
- Quadrature1Din3D(void);
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ Quadrature1Din3D(const QuadratureRefCell& q);
/// Destructor
~Quadrature1Din3D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param vertCoords Coordinates of vertices of finite-element cell.
+ * @param coordDim Spatial dimension of coordinate system.
* @param cell Finite-element cell
*/
- void computeGeometry(const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell);
+ void computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -75,4 +77,5 @@
#endif // pylith_feassemble_quadrature1din3d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature1Din3D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature1Din3D::clone(void) const {
return new Quadrature1Din3D(*this);
} // clone
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,7 @@
#include "Quadrature2D.hh" // implementation of class methods
+#include "QuadratureRefCell.hh" // USES QuadratureRefCell
#include "CellGeometry.hh" // USES CellGeometry
#include "petsc.h" // USES PetscLogFlops
@@ -24,7 +25,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature2D::Quadrature2D(void) : Quadrature()
+pylith::feassemble::Quadrature2D::Quadrature2D(const QuadratureRefCell& q) :
+ QuadratureEngine(q)
{ // constructor
} // constructor
@@ -37,42 +39,51 @@
// ----------------------------------------------------------------------
// Copy constructor.
pylith::feassemble::Quadrature2D::Quadrature2D(const Quadrature2D& q) :
- Quadrature(q)
+ QuadratureEngine(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
void
-pylith::feassemble::Quadrature2D::computeGeometry(
- const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell)
+pylith::feassemble::Quadrature2D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(2 == _cellDim);
- assert(2 == _spaceDim);
-
- _resetGeometry();
+ assert(0 != vertCoords);
assert(2 == coordDim);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+
+ const double_array& basis = _quadRefCell.basis();
+ const double_array& quadPtsRef = _quadRefCell.quadPtsRef();
+ const double_array& basisDerivRef = _quadRefCell.basisDerivRef();
+ const CellGeometry& geometry = _quadRefCell.refGeometry();
+
+ assert(2 == cellDim);
+ assert(2 == spaceDim);
+ zero();
+
// Loop over quadrature points
- for (int iQuadPt=0; iQuadPt < _numQuadPts; ++iQuadPt) {
+ for (int iQuadPt=0; iQuadPt < numQuadPts; ++iQuadPt) {
// Compute coordinates of quadrature point in cell
#if defined(ISOPARAMETRIC)
// x = sum[i=0,n-1] (Ni * xi)
// y = sum[i=0,n-1] (Ni * yi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double basis = _basis[iQuadPt*_numBasis+iBasis];
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _quadPts[iQuadPt*_spaceDim+iDim] +=
- basis * vertCoords[iBasis*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double valueBasis = basis[iQuadPt*numBasis+iBasis];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _quadPts[iQuadPt*spaceDim+iDim] +=
+ valueBasis * vertCoords[iBasis*spaceDim+iDim];
} // for
#else
- assert(0 != _geometry);
- _geometry->coordsRefToGlobal(&_quadPts[iQuadPt*_spaceDim],
- &_quadPtsRef[iQuadPt*_cellDim],
- vertCoords, _spaceDim);
+ geometry.coordsRefToGlobal(&_quadPts[iQuadPt*spaceDim],
+ &quadPtsRef[iQuadPt*cellDim],
+ vertCoords, spaceDim);
#endif
#if defined(ISOPARAMETRIC)
@@ -83,22 +94,22 @@
// dx/dq = sum[i=0,n-1] (dNi/dq * xi)
// dy/dp = sum[i=0,n-1] (dNi/dp * yi)
// dy/dq = sum[i=0,n-1] (dNi/dq * yi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iCol=0; iCol < _cellDim; ++iCol) {
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iCol=0; iCol < cellDim; ++iCol) {
const double deriv =
- _basisDerivRef[iQuadPt*_numBasis*_spaceDim+iBasis*_cellDim+iCol];
- for (int iRow=0; iRow < _spaceDim; ++iRow)
- _jacobian[iQuadPt*_cellDim*_spaceDim+iRow*_cellDim+iCol] +=
- deriv * vertCoords[iBasis*_spaceDim+iRow];
+ basisDerivRef[iQuadPt*numBasis*spaceDim+iBasis*cellDim+iCol];
+ for (int iRow=0; iRow < spaceDim; ++iRow)
+ _jacobian[iQuadPt*cellDim*spaceDim+iRow*cellDim+iCol] +=
+ deriv * vertCoords[iBasis*spaceDim+iRow];
} // for
// Compute determinant of Jacobian at quadrature point
// |J| = j00*j11-j01*j10
- const int iJ = iQuadPt*_cellDim*_spaceDim;
- const int i00 = iJ + 0*_spaceDim + 0;
- const int i01 = iJ + 0*_spaceDim + 1;
- const int i10 = iJ + 1*_spaceDim + 0;
- const int i11 = iJ + 1*_spaceDim + 1;
+ const int iJ = iQuadPt*cellDim*spaceDim;
+ const int i00 = iJ + 0*spaceDim + 0;
+ const int i01 = iJ + 0*spaceDim + 1;
+ const int i10 = iJ + 1*spaceDim + 0;
+ const int i11 = iJ + 1*spaceDim + 1;
const double det =
_jacobian[i00]*_jacobian[i11] -
_jacobian[i01]*_jacobian[i10];
@@ -106,17 +117,16 @@
_jacobianDet[iQuadPt] = det;
#else
// Compute Jacobian and determinant of Jacobian at quadrature point
- assert(0 != _geometry);
- _geometry->jacobian(&_jacobian[iQuadPt*_cellDim*_spaceDim],
- &_jacobianDet[iQuadPt],
- vertCoords, &_quadPtsRef[iQuadPt*_cellDim], _spaceDim);
+ geometry.jacobian(&_jacobian[iQuadPt*cellDim*spaceDim],
+ &_jacobianDet[iQuadPt],
+ vertCoords, &quadPtsRef[iQuadPt*cellDim], spaceDim);
_checkJacobianDet(_jacobianDet[iQuadPt], cell);
- const int iJ = iQuadPt*_cellDim*_spaceDim;
- const int i00 = iJ + 0*_spaceDim + 0;
- const int i01 = iJ + 0*_spaceDim + 1;
- const int i10 = iJ + 1*_spaceDim + 0;
- const int i11 = iJ + 1*_spaceDim + 1;
+ const int iJ = iQuadPt*cellDim*spaceDim;
+ const int i00 = iJ + 0*spaceDim + 0;
+ const int i01 = iJ + 0*spaceDim + 1;
+ const int i10 = iJ + 1*spaceDim + 0;
+ const int i11 = iJ + 1*spaceDim + 1;
const double det = _jacobianDet[iQuadPt];
#endif
@@ -131,17 +141,17 @@
// Compute derivatives of basis functions with respect to global
// coordinates
// dNi/dx = dNi/dp dp/dx + dNi/dq dq/dx + dNi/dr dr/dx
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- for (int jDim=0; jDim < _cellDim; ++jDim)
- _basisDeriv[iQuadPt*_numBasis*_spaceDim+iBasis*_spaceDim+iDim] +=
- _basisDerivRef[iQuadPt*_numBasis*_cellDim+iBasis*_cellDim+jDim] *
- _jacobianInv[iQuadPt*_cellDim*_spaceDim+jDim*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ for (int jDim=0; jDim < cellDim; ++jDim)
+ _basisDeriv[iQuadPt*numBasis*spaceDim+iBasis*spaceDim+iDim] +=
+ basisDerivRef[iQuadPt*numBasis*cellDim+iBasis*cellDim+jDim] *
+ _jacobianInv[iQuadPt*cellDim*spaceDim+jDim*spaceDim+iDim];
} // for
- PetscLogFlops(_numQuadPts*(4 +
- _numBasis*_spaceDim*2 +
- _numBasis*_spaceDim*_cellDim*2));
+ PetscLogFlops(numQuadPts*(4 +
+ numBasis*spaceDim*2 +
+ numBasis*spaceDim*cellDim*2));
} // computeGeometry
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,7 +19,7 @@
#if !defined(pylith_feassemble_quadrature2d_hh)
#define pylith_feassemble_quadrature2d_hh
-#include "Quadrature.hh"
+#include "QuadratureEngine.hh"
namespace pylith {
namespace feassemble {
@@ -28,31 +28,34 @@
} // feassemble
} // pylith
-class pylith::feassemble::Quadrature2D : public Quadrature
+class pylith::feassemble::Quadrature2D : public QuadratureEngine
{ // Quadrature2D
friend class TestQuadrature2D; // unit testing
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
- /// Constructor
- Quadrature2D(void);
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ Quadrature2D(const QuadratureRefCell& q);
/// Destructor
~Quadrature2D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param vertCoords Coordinates of vertices of finite-element cell.
+ * @param coordDim Spatial dimension of coordinate system.
* @param cell Finite-element cell
*/
- void computeGeometry(const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell);
+ void computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -74,4 +77,5 @@
#endif // pylith_feassemble_quadrature2d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature2D::clone(void) const {
return new Quadrature2D(*this);
} // clone
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,19 +14,21 @@
#include "Quadrature2Din3D.hh" // implementation of class methods
+#include "QuadratureRefCell.hh" // USES QuadratureRefCell
#include "CellGeometry.hh" // USES CellGeometry
#include "petsc.h" // USES PetscLogFlops
#include <cmath> // USES fabs()
#include <cassert> // USES assert()
-#include <stdexcept> // USES internal_error
+#include <stdexcept> // USES std::runtime_error()
#define ISOPARAMETRIC
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature2Din3D::Quadrature2Din3D(void) : Quadrature()
+pylith::feassemble::Quadrature2Din3D::Quadrature2Din3D(const QuadratureRefCell& q) :
+ QuadratureEngine(q)
{ // constructor
} // constructor
@@ -39,43 +41,53 @@
// ----------------------------------------------------------------------
// Copy constructor.
pylith::feassemble::Quadrature2Din3D::Quadrature2Din3D(const Quadrature2Din3D& q) :
- Quadrature(q)
+ QuadratureEngine(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
void
-pylith::feassemble::Quadrature2Din3D::computeGeometry(
- const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell)
+pylith::feassemble::Quadrature2Din3D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(2 == _cellDim);
- assert(3 == _spaceDim);
-
- _resetGeometry();
+ assert(0 != vertCoords);
assert(3 == coordDim);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+
+ const double_array& basis = _quadRefCell.basis();
+ const double_array& quadPtsRef = _quadRefCell.quadPtsRef();
+ const double_array& basisDerivRef = _quadRefCell.basisDerivRef();
+ const CellGeometry& geometry = _quadRefCell.refGeometry();
+ const double minJacobian = _quadRefCell.minJacobian();
+
+ assert(2 == cellDim);
+ assert(3 == spaceDim);
+ zero();
+
// Loop over quadrature points
- for (int iQuadPt=0; iQuadPt < _numQuadPts; ++iQuadPt) {
+ for (int iQuadPt=0; iQuadPt < numQuadPts; ++iQuadPt) {
// Compute coordinates of quadrature point in cell
#if defined(ISOPARAMETRIC)
// x = sum[i=0,n-1] (Ni * xi)
// y = sum[i=0,n-1] (Ni * yi)
// z = sum[i=0,n-1] (Ni * zi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double basis = _basis[iQuadPt*_numBasis+iBasis];
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _quadPts[iQuadPt*_spaceDim+iDim] +=
- basis * vertCoords[iBasis*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double valueBasis = basis[iQuadPt*numBasis+iBasis];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _quadPts[iQuadPt*spaceDim+iDim] +=
+ valueBasis * vertCoords[iBasis*spaceDim+iDim];
} // for
#else
- assert(0 != _geometry);
- _geometry->coordsRefToGlobal(&_quadPts[iQuadPt*_spaceDim],
- &_quadPtsRef[iQuadPt*_cellDim],
- vertCoords, _spaceDim);
+ geometry.coordsRefToGlobal(&_quadPts[iQuadPt*spaceDim],
+ &quadPtsRef[iQuadPt*cellDim],
+ vertCoords, spaceDim);
#endif
#if defined(ISOPARAMETRIC)
@@ -89,24 +101,24 @@
// dy/dq = sum[i=0,n-1] (dNi/dq * yi)
// dz/dp = sum[i=0,n-1] (dNi/dp * zi)
// dz/dq = sum[i=0,n-1] (dNi/dq * zi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iCol=0; iCol < _cellDim; ++iCol) {
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iCol=0; iCol < cellDim; ++iCol) {
const double deriv =
- _basisDerivRef[iQuadPt*_numBasis*_cellDim+iBasis*_cellDim+iCol];
- for (int iRow=0; iRow < _spaceDim; ++iRow)
- _jacobian[iQuadPt*_cellDim*_spaceDim+iRow*_cellDim+iCol] +=
- deriv * vertCoords[iBasis*+_spaceDim+iRow];
+ basisDerivRef[iQuadPt*numBasis*cellDim+iBasis*cellDim+iCol];
+ for (int iRow=0; iRow < spaceDim; ++iRow)
+ _jacobian[iQuadPt*cellDim*spaceDim+iRow*cellDim+iCol] +=
+ deriv * vertCoords[iBasis*+spaceDim+iRow];
} // for
// Compute determinant of Jacobian at quadrature point
// |J| = sqrt(transpose(J) J)
- const int iJ = iQuadPt*_cellDim*_spaceDim;
- const int i00 = iJ + 0*_cellDim + 0;
- const int i01 = iJ + 0*_cellDim + 1;
- const int i10 = iJ + 1*_cellDim + 0;
- const int i11 = iJ + 1*_cellDim + 1;
- const int i20 = iJ + 2*_cellDim + 0;
- const int i21 = iJ + 2*_cellDim + 1;
+ const int iJ = iQuadPt*cellDim*spaceDim;
+ const int i00 = iJ + 0*cellDim + 0;
+ const int i01 = iJ + 0*cellDim + 1;
+ const int i10 = iJ + 1*cellDim + 0;
+ const int i11 = iJ + 1*cellDim + 1;
+ const int i20 = iJ + 2*cellDim + 0;
+ const int i21 = iJ + 2*cellDim + 1;
// JJ = transpose(J) J
const double jj00 =
_jacobian[i00]*_jacobian[i00] +
@@ -126,19 +138,18 @@
_jacobianDet[iQuadPt] = det;
#else
// Compute Jacobian and determinant of Jacobian at quadrature point
- assert(0 != _geometry);
- _geometry->jacobian(&_jacobian[iQuadPt*_cellDim*_spaceDim],
- &_jacobianDet[iQuadPt],
- vertCoords, &_quadPtsRef[iQuadPt*_cellDim], _spaceDim);
+ geometry.jacobian(&_jacobian[iQuadPt*cellDim*spaceDim],
+ &_jacobianDet[iQuadPt],
+ vertCoords, &quadPtsRef[iQuadPt*cellDim], spaceDim);
_checkJacobianDet(_jacobianDet[iQuadPt], cell);
- const int iJ = iQuadPt*_cellDim*_spaceDim;
- const int i00 = iJ + 0*_cellDim + 0;
- const int i01 = iJ + 0*_cellDim + 1;
- const int i10 = iJ + 1*_cellDim + 0;
- const int i11 = iJ + 1*_cellDim + 1;
- const int i20 = iJ + 2*_cellDim + 0;
- const int i21 = iJ + 2*_cellDim + 1;
+ const int iJ = iQuadPt*cellDim*spaceDim;
+ const int i00 = iJ + 0*cellDim + 0;
+ const int i01 = iJ + 0*cellDim + 1;
+ const int i10 = iJ + 1*cellDim + 0;
+ const int i11 = iJ + 1*cellDim + 1;
+ const int i20 = iJ + 2*cellDim + 0;
+ const int i21 = iJ + 2*cellDim + 1;
#endif
// Compute inverse of Jacobian at quadrature point
@@ -151,7 +162,7 @@
const double d02 =
_jacobian[i00]*_jacobian[i21] -
_jacobian[i20]*_jacobian[i01];
- if (fabs(d01) > _minJacobian) {
+ if (fabs(d01) > minJacobian) {
// Jinv00 = 1/d01 * J11
// Jinv01 = 1/d01 * -J01
// Jinv10 = 1/d01 * -J10
@@ -160,13 +171,13 @@
_jacobianInv[iJ+1] = -_jacobian[i01] / d01; // Jinv01
_jacobianInv[iJ+3] = -_jacobian[i10] / d01; // Jinv10
_jacobianInv[iJ+4] = _jacobian[i00] / d01; // Jinv11
- if (fabs(d12) > _minJacobian) {
+ if (fabs(d12) > minJacobian) {
// Jinv02 = 1/d12 -J11
// Jinv12 = 1/d12 J10
_jacobianInv[iJ+2] = -_jacobian[i11] / d12; // Jinv02
_jacobianInv[iJ+5] = _jacobian[i10] / d12; // Jinv12
- } else if (fabs(d02) > _minJacobian) {
+ } else if (fabs(d02) > minJacobian) {
// Jinv02 = 1/d02 -J01
// Jinv12 = 1/d02 J00
_jacobianInv[iJ+2] = -_jacobian[i01] / d02; // Jinv02
@@ -175,7 +186,7 @@
_jacobianInv[iJ+2] = 0.0; // Jinv02
_jacobianInv[iJ+5] = 0.0; // Jinv12
} // if/else
- } else if (fabs(d02) > _minJacobian) {
+ } else if (fabs(d02) > minJacobian) {
// Jinv00 = 1/d02 * J21
// Jinv02 = 1/d02 * -J01
// Jinv10 = 1/d02 * -J20
@@ -184,7 +195,7 @@
_jacobianInv[iJ+2] = -_jacobian[i01] / d02; // Jinv02
_jacobianInv[iJ+3] = -_jacobian[i20] / d02; // Jinv10
_jacobianInv[iJ+5] = _jacobian[i00] / d02; // Jinv12
- if (fabs(d12) > _minJacobian) {
+ if (fabs(d12) > minJacobian) {
// Jinv01 = 1/d12 J21
// Jinv11 = 1/d12 -J20
_jacobianInv[iJ+1] = -_jacobian[i21] / d12; // Jinv01
@@ -193,7 +204,7 @@
_jacobianInv[iJ+1] = 0.0; // Jinv01
_jacobianInv[iJ+4] = 0.0; // Jinv11
} // if/else
- } else if (fabs(d12) > _minJacobian) {
+ } else if (fabs(d12) > minJacobian) {
_jacobianInv[iJ+0] = 0.0; // Jinv00
_jacobianInv[iJ+3] = 0.0; // Jinv10
// Jinv01 = 1/d12 J21
@@ -210,17 +221,17 @@
// Compute derivatives of basis functions with respect to global
// coordinates
// dNi/dx = dNi/dp dp/dx + dNi/dq dq/dx + dNi/dr dr/dx
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- for (int jDim=0; jDim < _cellDim; ++jDim)
- _basisDeriv[iQuadPt*_numBasis*_spaceDim+iBasis*_spaceDim+iDim] +=
- _basisDerivRef[iQuadPt*_numBasis*_cellDim + iBasis*_cellDim+jDim] *
- _jacobianInv[iQuadPt*_cellDim*_spaceDim+jDim*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ for (int jDim=0; jDim < cellDim; ++jDim)
+ _basisDeriv[iQuadPt*numBasis*spaceDim+iBasis*spaceDim+iDim] +=
+ basisDerivRef[iQuadPt*numBasis*cellDim + iBasis*cellDim+jDim] *
+ _jacobianInv[iQuadPt*cellDim*spaceDim+jDim*spaceDim+iDim];
} // for
-
- PetscLogFlops(_numQuadPts*(15 +
- _numBasis*_spaceDim*2 +
- _numBasis*_spaceDim*_cellDim*2));
+
+ PetscLogFlops(numQuadPts*(15 +
+ numBasis*spaceDim*2 +
+ numBasis*spaceDim*cellDim*2));
} // computeGeometry
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,7 +19,7 @@
#if !defined(pylith_feassemble_quadrature2din3d_hh)
#define pylith_feassemble_quadrature2din3d_hh
-#include "Quadrature.hh"
+#include "QuadratureEngine.hh"
namespace pylith {
namespace feassemble {
@@ -28,31 +28,34 @@
} // feassemble
} // pylith
-class pylith::feassemble::Quadrature2Din3D : public Quadrature
+class pylith::feassemble::Quadrature2Din3D : public QuadratureEngine
{ // Quadrature2Din3D
friend class TestQuadrature2Din3D; // unit testing
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
- /// Constructor
- Quadrature2Din3D(void);
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ Quadrature2Din3D(const QuadratureRefCell& q);
/// Destructor
~Quadrature2Din3D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param vertCoords Coordinates of vertices of finite-element cell.
+ * @param coordDim Spatial dimension of coordinate system.
* @param cell Finite-element cell
*/
- void computeGeometry(const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell);
+ void computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -75,4 +78,5 @@
#endif // pylith_feassemble_quadrature2din3d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature2Din3D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature2Din3D::clone(void) const {
return new Quadrature2Din3D(*this);
} // clone
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,7 @@
#include "Quadrature3D.hh" // implementation of class methods
+#include "QuadratureRefCell.hh" // USES QuadratureRefCell
#include "CellGeometry.hh" // USES CellGeometry
#include "petsc.h" // USES PetscLogFlops
@@ -24,7 +25,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::feassemble::Quadrature3D::Quadrature3D(void) : pylith::feassemble::Quadrature::Quadrature()
+pylith::feassemble::Quadrature3D::Quadrature3D(const QuadratureRefCell& q) :
+ QuadratureEngine(q)
{ // constructor
} // constructor
@@ -37,43 +39,52 @@
// ----------------------------------------------------------------------
// Copy constructor.
pylith::feassemble::Quadrature3D::Quadrature3D(const Quadrature3D& q) :
- Quadrature(q)
+ QuadratureEngine(q)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Compute geometric quantities for a cell at quadrature points.
void
-pylith::feassemble::Quadrature3D::computeGeometry(
- const real_section_type::value_type* vertCoords,
- const int coordDim,
- const Mesh::point_type& cell)
+pylith::feassemble::Quadrature3D::computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell)
{ // computeGeometry
- assert(3 == _cellDim);
- assert(3 == _spaceDim);
-
- _resetGeometry();
+ assert(0 != vertCoords);
assert(3 == coordDim);
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+
+ const double_array& basis = _quadRefCell.basis();
+ const double_array& quadPtsRef = _quadRefCell.quadPtsRef();
+ const double_array& basisDerivRef = _quadRefCell.basisDerivRef();
+ const CellGeometry& geometry = _quadRefCell.refGeometry();
+
+ assert(3 == cellDim);
+ assert(3 == spaceDim);
+ zero();
+
// Loop over quadrature points
- for (int iQuadPt=0; iQuadPt < _numQuadPts; ++iQuadPt) {
+ for (int iQuadPt=0; iQuadPt < numQuadPts; ++iQuadPt) {
// Compute coordinates of quadrature point in cell
#if defined(ISOPARAMETRIC)
// x = sum[i=0,n-1] (Ni * xi)
// y = sum[i=0,n-1] (Ni * yi)
// z = sum[i=0,n-1] (Ni * zi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis) {
- const double basis = _basis[iQuadPt*_numBasis+iBasis];
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- _quadPts[iQuadPt*_spaceDim+iDim] +=
- basis * vertCoords[iBasis*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis) {
+ const double valueBasis = basis[iQuadPt*numBasis+iBasis];
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ _quadPts[iQuadPt*spaceDim+iDim] +=
+ valueBasis * vertCoords[iBasis*spaceDim+iDim];
} // for
#else
- assert(0 != _geometry);
- _geometry->coordsRefToGlobal(&_quadPts[iQuadPt*_spaceDim],
- &_quadPtsRef[iQuadPt*_cellDim],
- vertCoords, _spaceDim);
+ geometry.coordsRefToGlobal(&quadPts[iQuadPt*spaceDim],
+ &quadPtsRef[iQuadPt*cellDim],
+ vertCoords, spaceDim);
#endif
#if defined(ISOPARAMETRIC)
@@ -90,29 +101,29 @@
// dz/dp = sum[i=0,n-1] (dNi/dp * zi)
// dz/dq = sum[i=0,n-1] (dNi/dq * zi)
// dz/dr = sum[i=0,n-1] (dNi/dr * zi)
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iCol=0; iCol < _cellDim; ++iCol) {
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iCol=0; iCol < cellDim; ++iCol) {
const double deriv =
- _basisDerivRef[iQuadPt*_numBasis*_spaceDim+iBasis*_cellDim+iCol];
- for (int iRow=0; iRow < _spaceDim; ++iRow)
- _jacobian[iQuadPt*_cellDim*_spaceDim+iRow*_cellDim+iCol] +=
- deriv * vertCoords[iBasis*_spaceDim+iRow];
+ basisDerivRef[iQuadPt*numBasis*spaceDim+iBasis*cellDim+iCol];
+ for (int iRow=0; iRow < spaceDim; ++iRow)
+ _jacobian[iQuadPt*cellDim*spaceDim+iRow*cellDim+iCol] +=
+ deriv * vertCoords[iBasis*spaceDim+iRow];
} // for
// Compute determinant of Jacobian at quadrature point
// |J| = j00*(j11*j22-j12*j21) +
// -j01*(j10*j22-j12*j20) +
// j02*(j10*j21-j11*j20)
- const int iJ = iQuadPt*_cellDim*_spaceDim;
- const int i00 = iJ + 0*_spaceDim + 0;
- const int i01 = iJ + 0*_spaceDim + 1;
- const int i02 = iJ + 0*_spaceDim + 2;
- const int i10 = iJ + 1*_spaceDim + 0;
- const int i11 = iJ + 1*_spaceDim + 1;
- const int i12 = iJ + 1*_spaceDim + 2;
- const int i20 = iJ + 2*_spaceDim + 0;
- const int i21 = iJ + 2*_spaceDim + 1;
- const int i22 = iJ + 2*_spaceDim + 2;
+ const int iJ = iQuadPt*cellDim*spaceDim;
+ const int i00 = iJ + 0*spaceDim + 0;
+ const int i01 = iJ + 0*spaceDim + 1;
+ const int i02 = iJ + 0*spaceDim + 2;
+ const int i10 = iJ + 1*spaceDim + 0;
+ const int i11 = iJ + 1*spaceDim + 1;
+ const int i12 = iJ + 1*spaceDim + 2;
+ const int i20 = iJ + 2*spaceDim + 0;
+ const int i21 = iJ + 2*spaceDim + 1;
+ const int i22 = iJ + 2*spaceDim + 2;
const double det =
_jacobian[i00]*(_jacobian[i11]*_jacobian[i22] -
_jacobian[i12]*_jacobian[i21]) -
@@ -124,22 +135,21 @@
_jacobianDet[iQuadPt] = det;
#else
// Compute Jacobian and determinant of Jacobian at quadrature point
- assert(0 != _geometry);
- _geometry->jacobian(&_jacobian[iQuadPt*_cellDim*_spaceDim],
- &_jacobianDet[iQuadPt],
- vertCoords, &_quadPtsRef[iQuadPt*_cellDim], _spaceDim);
+ geometry.jacobian(&_jacobian[iQuadPt*cellDim*spaceDim],
+ &_jacobianDet[iQuadPt],
+ vertCoords, &quadPtsRef[iQuadPt*cellDim], spaceDim);
_checkJacobianDet(_jacobianDet[iQuadPt], cell);
- const int iJ = iQuadPt*_cellDim*_spaceDim;
- const int i00 = iJ + 0*_spaceDim + 0;
- const int i01 = iJ + 0*_spaceDim + 1;
- const int i02 = iJ + 0*_spaceDim + 2;
- const int i10 = iJ + 1*_spaceDim + 0;
- const int i11 = iJ + 1*_spaceDim + 1;
- const int i12 = iJ + 1*_spaceDim + 2;
- const int i20 = iJ + 2*_spaceDim + 0;
- const int i21 = iJ + 2*_spaceDim + 1;
- const int i22 = iJ + 2*_spaceDim + 2;
+ const int iJ = iQuadPt*cellDim*spaceDim;
+ const int i00 = iJ + 0*spaceDim + 0;
+ const int i01 = iJ + 0*spaceDim + 1;
+ const int i02 = iJ + 0*spaceDim + 2;
+ const int i10 = iJ + 1*spaceDim + 0;
+ const int i11 = iJ + 1*spaceDim + 1;
+ const int i12 = iJ + 1*spaceDim + 2;
+ const int i20 = iJ + 2*spaceDim + 0;
+ const int i21 = iJ + 2*spaceDim + 1;
+ const int i22 = iJ + 2*spaceDim + 2;
const double det = _jacobianDet[iQuadPt];
#endif
@@ -166,16 +176,16 @@
// Compute derivatives of basis functions with respect to global
// coordinates
// dNi/dx = dNi/dp dp/dx + dNi/dq dq/dx + dNi/dr dr/dx
- for (int iBasis=0; iBasis < _numBasis; ++iBasis)
- for (int iDim=0; iDim < _spaceDim; ++iDim)
- for (int jDim=0; jDim < _cellDim; ++jDim)
- _basisDeriv[iQuadPt*_numBasis*_spaceDim+iBasis*_spaceDim+iDim] +=
- _basisDerivRef[iQuadPt*_numBasis*_cellDim+iBasis*_cellDim+jDim] *
- _jacobianInv[iQuadPt*_cellDim*_spaceDim+jDim*_spaceDim+iDim];
+ for (int iBasis=0; iBasis < numBasis; ++iBasis)
+ for (int iDim=0; iDim < spaceDim; ++iDim)
+ for (int jDim=0; jDim < cellDim; ++jDim)
+ _basisDeriv[iQuadPt*numBasis*spaceDim+iBasis*spaceDim+iDim] +=
+ basisDerivRef[iQuadPt*numBasis*cellDim+iBasis*cellDim+jDim] *
+ _jacobianInv[iQuadPt*cellDim*spaceDim+jDim*spaceDim+iDim];
} // for
-
- PetscLogFlops(_numQuadPts*(2+36 +
- _numBasis*_spaceDim*_cellDim*4));
+
+ PetscLogFlops(numQuadPts*(2+36 +
+ numBasis*spaceDim*cellDim*4));
} // computeGeometry
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,40 +19,36 @@
#if !defined(pylith_feassemble_quadrature3d_hh)
#define pylith_feassemble_quadrature3d_hh
-#include "Quadrature.hh"
+#include "QuadratureEngine.hh" // ISA QuadratureEngine
-namespace pylith {
- namespace feassemble {
- class Quadrature3D;
- class TestQuadrature3D;
- } // feassemble
-} // pylith
-
-class pylith::feassemble::Quadrature3D : public Quadrature
+class pylith::feassemble::Quadrature3D : public QuadratureEngine
{ // Quadrature3D
friend class TestQuadrature3D; // unit testing
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
- /// Constructor
- Quadrature3D(void);
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ Quadrature3D(const QuadratureRefCell& q);
/// Destructor
~Quadrature3D(void);
/// Create a copy of this object.
- Quadrature* clone(void) const;
+ QuadratureEngine* clone(void) const;
/** Compute geometric quantities for a cell at quadrature points.
*
- * @param mesh Finite-element mesh
- * @param coordinates Section containing vertex coordinates
+ * @param vertCoords Coordinates of vertices of finite-element cell.
+ * @param coordDim Spatial dimension of coordinate system.
* @param cell Finite-element cell
*/
- void computeGeometry(const real_section_type::value_type* vertCoords,
+ void computeGeometry(const double* vertCoords,
const int coordDim,
- const Mesh::point_type& cell);
+ const int cell);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -75,4 +71,5 @@
#endif // pylith_feassemble_quadrature3d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/feassemble/Quadrature3D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,11 +16,12 @@
// Create a copy of this object.
inline
-pylith::feassemble::Quadrature*
+pylith::feassemble::QuadratureEngine*
pylith::feassemble::Quadrature3D::clone(void) const {
return new Quadrature3D(*this);
} // clone
#endif
+
// End of file
Copied: short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "QuadratureEngine.hh" // implementation of class methods
+
+#include "CellGeometry.hh" // USES CellGeometry
+#include "QuadratureRefCell.hh" // QuadratureRefCell
+
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
+// ----------------------------------------------------------------------
+// Constructor.
+pylith::feassemble::QuadratureEngine::QuadratureEngine(const QuadratureRefCell& q) :
+ _quadRefCell(q)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::feassemble::QuadratureEngine::~QuadratureEngine(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+// Allocate cell buffers.
+void
+pylith::feassemble::QuadratureEngine::initialize(void)
+{ // initialize
+ const int numQuadPts = _quadRefCell.numQuadPts();
+ const int numBasis = _quadRefCell.numBasis();
+ const int cellDim = _quadRefCell.cellDim();
+ const int spaceDim = _quadRefCell.spaceDim();
+
+ if (cellDim > 0) {
+ _quadPts.resize(numQuadPts*spaceDim);
+ _jacobian.resize(numQuadPts*cellDim*spaceDim);
+ _jacobianInv.resize(numQuadPts*cellDim*spaceDim);
+ _jacobianDet.resize(numQuadPts);
+ _basisDeriv.resize(numQuadPts*numBasis*spaceDim);
+ } else {
+ _quadPts.resize(numQuadPts*spaceDim);
+ _jacobian.resize(1);
+ _jacobianInv.resize(1);
+ _jacobianDet.resize(1);
+ _basisDeriv.resize(numQuadPts*numBasis*spaceDim);
+ } // if/else
+} // initialize
+
+// ----------------------------------------------------------------------
+// Fill cell buffers with zeros.
+void
+pylith::feassemble::QuadratureEngine::zero(void)
+{ // zero
+ _quadPts = 0.0;
+ _jacobian = 0.0;
+ _jacobianDet = 0.0;
+ _jacobianInv = 0.0;
+ _basisDeriv = 0.0;
+} // zero
+
+// ----------------------------------------------------------------------
+// Copy constructor.
+pylith::feassemble::QuadratureEngine::QuadratureEngine(const QuadratureEngine& q) :
+ _quadPts(q._quadPts),
+ _jacobian(q._jacobian),
+ _jacobianDet(q._jacobianDet),
+ _jacobianInv(q._jacobianInv),
+ _basisDeriv(q._basisDeriv),
+ _quadRefCell(q._quadRefCell)
+{ // copy constructor
+} // copy constructor
+
+// ----------------------------------------------------------------------
+// Check determinant of Jacobian against minimum allowable value
+void
+pylith::feassemble::QuadratureEngine::_checkJacobianDet(const double det,
+ const int cell) const
+{ // _checkJacobianDet
+ const double minJacobian = _quadRefCell.minJacobian();
+ if (det < minJacobian) {
+ std::ostringstream msg;
+ msg << "Determinant of Jacobian (" << det << ") for cell " << cell
+ << " is smaller than minimum permissible value (" << minJacobian
+ << ")!\n";
+ throw std::runtime_error(msg.str());
+ } // if
+} // _checkJacobianDet
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/feassemble/QuadratureEngine.hh
+ *
+ * @brief Abstract base class for quadrature computation engine.
+ */
+
+#if !defined(pylith_feassemble_quadratureengine_hh)
+#define pylith_feassemble_quadratureengine_hh
+
+#include "feassemblefwd.hh" // forward declaration
+#include "pylith/utils/array.hh" // USES double_array
+
+class pylith::feassemble::QuadratureEngine
+{ // QuadratureEngine
+ friend class TestQuadratureEngine;
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Constructor.
+ *
+ * @param q Quadrature information for reference cell.
+ */
+ QuadratureEngine(const QuadratureRefCell& q);
+
+ /// Destructor
+ ~QuadratureEngine(void);
+
+ /** Create a copy of this object.
+ *
+ * @returns Copy of this.
+ */
+ virtual
+ QuadratureEngine* clone(void) const = 0;
+
+ /** Get coordinates of quadrature points in cell (NOT reference cell).
+ *
+ * @returns Array of coordinates of quadrature points in cell
+ */
+ const double_array& quadPts(void) const;
+
+ /** Get derivatives of basis fns evaluated at quadrature points.
+ *
+ * @returns Array of derivatives of basis fns evaluated at
+ * quadrature points
+ */
+ const double_array& basisDeriv(void) const;
+
+ /** Get Jacobians evaluated at quadrature points.
+ *
+ * @returns Array of Jacobian inverses evaluated at quadrature points.
+ */
+ const double_array& jacobian(void) const;
+
+ /** Get determinants of Jacobian evaluated at quadrature points.
+ *
+ * @returns Array of determinants of Jacobian evaluated at quadrature pts
+ */
+ const double_array& jacobianDet(void) const;
+
+ /// Allocate cell buffers.
+ void initialize(void);
+
+ /// Fill cell buffers with zeros.
+ void zero(void);
+
+ /** Compute geometric quantities for a cell at quadrature points.
+ *
+ * @param mesh Finite-element mesh
+ * @param coordinates Section containing vertex coordinates
+ * @param cell Finite-element cell
+ */
+ virtual
+ void computeGeometry(const double* vertCoords,
+ const int coordDim,
+ const int cell) = 0;
+
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
+
+ /** Copy constructor.
+ *
+ * @param q QuadratureEngine to copy
+ */
+ QuadratureEngine(const QuadratureEngine& q);
+
+ /* Check determinant of Jacobian against minimum allowable value.
+ *
+ * @param det Value of determinant of Jacobian
+ * @param cell Label of finite-element cell
+ */
+ void _checkJacobianDet(const double det,
+ const int cell) const;
+
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+protected :
+
+ /** Buffers for cell data */
+ double_array _quadPts; ///< Coordinates of quad pts.
+ double_array _jacobian; ///< Jacobian at quad pts;
+ double_array _jacobianDet; ///< |J| at quad pts.
+ double_array _jacobianInv; /// Inverse of Jacobian at quad pts.
+ double_array _basisDeriv; ///< Deriv. of basis fns at quad pts.
+
+ const QuadratureRefCell& _quadRefCell;
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ /// Not implemented.
+ const QuadratureEngine& operator=(const QuadratureEngine&);
+
+}; // QuadratureEngine
+
+#include "QuadratureEngine.icc" // inline methods
+
+#endif // pylith_feassemble_quadratureengine_hh
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.icc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureEngine.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/feassemble/QuadratureEngine.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_feassemble_quadratureengine_hh)
+#error "QuadratureEngine.icc must be included only from QuadratureEngine.hh"
+#else
+
+// Get coordinates of quadrature points in cell (NOT reference cell).
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::quadPts(void) const {
+ return _quadPts;
+}
+
+// Get derivatives of basis fns evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::basisDeriv(void) const {
+ return _basisDeriv;
+}
+
+// Get Jacobians evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::jacobian(void) const {
+ return _jacobian;
+}
+
+// Get determinants of Jacobian evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureEngine::jacobianDet(void) const {
+ return _jacobianDet;
+}
+
+#endif
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureRefCell.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,200 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "QuadratureRefCell.hh" // implementation of class methods
+
+#include "CellGeometry.hh" // USES CellGeometry
+
+#include <cstring> // USES memcpy()
+#include <cassert> // USES assert()
+#include <stdexcept> // USES std::runtime_error
+#include <sstream> // USES std::ostringstream
+
+// ----------------------------------------------------------------------
+// Constructor
+pylith::feassemble::QuadratureRefCell::QuadratureRefCell(void) :
+ _minJacobian(0),
+ _cellDim(0),
+ _numBasis(0),
+ _numQuadPts(0),
+ _spaceDim(0),
+ _geometry(0)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor
+pylith::feassemble::QuadratureRefCell::~QuadratureRefCell(void)
+{ // destructor
+ delete _geometry; _geometry = 0;
+} // destructor
+
+// ----------------------------------------------------------------------
+// Copy constructor
+pylith::feassemble::QuadratureRefCell::QuadratureRefCell(const QuadratureRefCell& q) :
+ _minJacobian(q._minJacobian),
+ _quadPtsRef(q._quadPtsRef),
+ _quadWts(q._quadWts),
+ _basis(q._basis),
+ _basisDerivRef(q._basisDerivRef),
+ _cellDim(q._cellDim),
+ _numBasis(q._numBasis),
+ _numQuadPts(q._numQuadPts),
+ _spaceDim(q._spaceDim),
+ _geometry(0)
+{ // copy constructor
+ if (0 != q._geometry)
+ _geometry = q._geometry->clone();
+} // copy constructor
+
+// ----------------------------------------------------------------------
+// Set basis functions and their derivatives and coordinates and
+// weights of the quadrature points.
+void
+pylith::feassemble::QuadratureRefCell::initialize(const double* basis,
+ const int numQuadPts1,
+ const int numBasis1,
+ const double* basisDerivRef,
+ const int numQuadPts2,
+ const int numBasis2,
+ const int cellDim2,
+ const double* quadPtsRef,
+ const int numQuadPts3,
+ const int cellDim3,
+ const double* quadWts,
+ const int numQuadPts4,
+ const int spaceDim)
+{ // initialize
+ const int numQuadPts = numQuadPts1;
+ const int numBasis = numBasis1;
+ const int cellDim = cellDim2;
+
+ assert(numQuadPts == numQuadPts2);
+ assert(numQuadPts == numQuadPts3);
+ assert(numQuadPts == numQuadPts4);
+ assert(numBasis == numBasis2);
+ assert(cellDim == cellDim3);
+
+ if (0 == basis ||
+ 0 == basisDerivRef ||
+ 0 == quadPtsRef ||
+ 0 == quadWts ||
+ cellDim < 0 || cellDim > 3 ||
+ numBasis < 1 ||
+ numQuadPts < 1 ||
+ spaceDim < 1 || spaceDim > 3) {
+ std::ostringstream msg;
+ msg << "Incompatible values for quadrature information. Basis functions,\n"
+ << "their derivatives, and coordinates and weights of quadrature\n"
+ << "points must all be specified.\n"
+ << "Values:\n"
+ << " basis pointer: " << basis << "\n"
+ << " basis derivatites pointer: " << basisDerivRef << "\n"
+ << " quadrature points pointer: " << quadPtsRef << "\n"
+ << " quadrature weights pointer: " << quadWts << "\n"
+ << " space dimension: " << spaceDim << "\n"
+ << " # basis functions: " << numBasis << "\n"
+ << " # quadrature points: " << numQuadPts << "\n"
+ << " dimension of coordinate space: " << spaceDim << "\n";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ if (cellDim > 0) {
+ int size = numBasis * numQuadPts; assert(size > 0);
+ _basis.resize(size);
+ for (int i=0; i < size; ++i)
+ _basis[i] = basis[i];
+
+ size = numQuadPts * numBasis * cellDim; assert(size > 0);
+ _basisDerivRef.resize(size);
+ for (int i=0; i < size; ++i)
+ _basisDerivRef[i] = basisDerivRef[i];
+
+ size = numQuadPts * cellDim; assert(size > 0);
+ _quadPtsRef.resize(size);
+ for (int i=0; i < size; ++i)
+ _quadPtsRef[i] = quadPtsRef[i];
+
+ size = numQuadPts; assert(size > 0);
+ _quadWts.resize(size);
+ for (int i=0; i < size; ++i)
+ _quadWts[i] = quadWts[i];
+
+ _cellDim = cellDim;
+ _numBasis = numBasis;
+ _numQuadPts = numQuadPts;
+ _spaceDim = spaceDim;
+
+ } else {
+ if (1 != numBasis ||
+ 1 != numQuadPts ||
+ 1 != spaceDim) {
+ std::ostringstream msg;
+ msg << "0-D quadrature only works in 1-D and is limited to 1 basis "
+ << "function and 1 quadrature point.\n"
+ << "Values:\n"
+ << " cell dimension: " << cellDim << "\n"
+ << " spatial dimension: " << spaceDim << "\n"
+ << " # basis functions: " << numBasis << "\n"
+ << " # quadrature points: " << numQuadPts << "\n";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ int size = 1;
+ _basis.resize(size);
+ for (int i=0; i < size; ++i)
+ _basis[i] = basis[i];
+
+ size = 1;
+ _basisDerivRef.resize(size);
+ for (int i=0; i < size; ++i)
+ _basisDerivRef[i] = basisDerivRef[i];
+
+ size = 1;
+ _quadPtsRef.resize(size);
+ for (int i=0; i < size; ++i)
+ _quadPtsRef[i] = quadPtsRef[i];
+
+ size = 1;
+ _quadWts.resize(size);
+ for (int i=0; i < size; ++i)
+ _quadWts[i] = quadWts[i];
+
+ _cellDim = cellDim;
+ _numBasis = numBasis;
+ _numQuadPts = numQuadPts;
+ _spaceDim = spaceDim;
+
+ } // else
+} // initialize
+
+// ----------------------------------------------------------------------
+// Set geometry associated with reference cell.
+void
+pylith::feassemble::QuadratureRefCell::refGeometry(CellGeometry* const geometry)
+{ // refGeometry
+ delete _geometry; _geometry = (0 != geometry) ? geometry->clone() : 0;
+} // refGeometry
+
+// ----------------------------------------------------------------------
+// Get geometry associated with reference cell.
+const pylith::feassemble::CellGeometry&
+pylith::feassemble::QuadratureRefCell::refGeometry(void) const
+{ // refGeometry
+ assert(0 != _geometry);
+ return *_geometry;
+} // refGeometry
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureRefCell.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,249 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/feassemble/QuadratureRefCell.hh
+ *
+ * @brief Object with basic quadrature information for the reference cell.
+ *
+ * This object contains the basis functions and their derivatives
+ * evaluated at the quadrature points of the reference element, and
+ * the coordinates and weights of the quadrature points.
+ *
+ * The Quadrature object manages the general functionality of the
+ * numerical quadrature.
+ */
+
+#if !defined(pylith_feassemble_quadraturerefcell_hh)
+#define pylith_feassemble_quadraturerefcell_hh
+
+// Include directives ---------------------------------------------------
+#include "feassemblefwd.hh" // forward declarations
+
+#include "pylith/utils/array.hh" // HASA double_array
+
+// Quadrature -----------------------------------------------------------
+class pylith::feassemble::QuadratureRefCell
+{ // Quadrature
+ friend class TestQuadratureRefCell; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Constructor
+ QuadratureRefCell(void);
+
+ /// Destructor
+ ~QuadratureRefCell(void);
+
+ /** Set basis functions and their derivatives, and coordinates and
+ * weights of the quadrature points.
+ *
+ * @param basis Array of basis functions evaluated at quadrature pts
+ * N0Qp0, N1Qp0, ...
+ * N0Qp1, N1Qp1, ...
+ * ...
+ * size = numQuadPts * numBasis
+ * index = iQuadPt*numBasis + iBasis
+ * @param numQuadPts1 Dimension of basis.
+ * @param numBasis1 Dimension of basis.
+ *
+ * @param basisDerivRef Array of basis function derivaties evaluated at
+ * quadrature pts, where derivatives are with respect to cell's
+ * local coordinates.
+ * N0pQp0, N0qQp0, N0rQp0, N1pQp0, N1qQp0, N1rQp0, ...
+ * N0pQp1, N0qQp1, N0rQp1, N1pQp1, N1qQp1, N1rQp1, ...
+ * ...
+ * size = numQuadPts * numBasis * cellDim
+ * index = iQuadPt*numBasis*cellDim + iBasis*cellDim + iDim
+ * @param numQuadPts2 Dimension of basisDerivRef.
+ * @param numBasis2 Dimension of basisDerivRef.
+ * @param cellDim2 Dimension of basisDerivRef.
+ *
+ * @param quadPtsRef Array of coordinates of quadrature points in
+ * reference cell
+ * Qp0p, Qp0q, Qp0r
+ * Qp1p, Qp1q, Qp1r
+ * size = numQuadPts * cellDim
+ * index = iQuadPt*numDims + iDim
+ * @param numQuadPts3 Dimension of quadPtsRef.
+ * @param cellDim3 Dimension of quadPtsRef.
+ *
+ * @param quadWts Array of weights of quadrature points
+ * WtQp0, WtQp1, ...
+ * index = iQuadPt
+ * @param numQuadPts4 Dimension of quadWts.
+ *
+ * @param spaceDim Number of dimensions in coordinates of cell vertices
+ */
+ void initialize(const double* basis,
+ const int numQuadPts1,
+ const int numBasis1,
+ const double* basisDerivRef,
+ const int numQuadPts2,
+ const int numBasis2,
+ const int cellDim2,
+ const double* quadPtsRef,
+ const int numQuadPts3,
+ const int cellDim3,
+ const double* quadWts,
+ const int numQuadPts4,
+ const int spaceDim);
+
+ /** Set geometry associated with reference cell.
+ *
+ * @param geometry Geometry of reference cell.
+ */
+ void refGeometry(CellGeometry* const geometry);
+
+ /** Get geometry associated with reference cell.
+ *
+ * @returns Geometry of reference cell.
+ */
+ const CellGeometry& refGeometry(void) const;
+
+ /** Set minimum allowable determinant of Jacobian.
+ *
+ * @param tolerance Minimum allowable value for Jacobian
+ */
+ void minJacobian(const double min);
+
+ /** Get minimum allowable determinant of Jacobian.
+ *
+ * @returns Minimum allowable value for Jacobian
+ */
+ double minJacobian(void) const;
+
+ /** Get coordinates of quadrature points in reference cell.
+ *
+ * @returns Array of coordinates of quadrature points in reference cell.
+ */
+ const double_array& quadPtsRef(void) const;
+
+ /** Get weights of quadrature points.
+ *
+ * @returns Weights of quadrature points
+ */
+ const double_array& quadWts(void) const;
+
+ /** Get basis fns evaluated at quadrature points.
+ *
+ * @returns Array of basis fns evaluated at quadrature points
+ */
+ const double_array& basis(void) const;
+
+ /** Get derivates of basis fns evaluated at quadrature points.
+ *
+ * @returns Array of derivates of basis fns evaluated at quadrature points
+ */
+ const double_array& basisDerivRef(void) const;
+
+ /** Get number of dimensions in reference cell.
+ *
+ * @returns Number of dimensions in reference cell
+ */
+ int cellDim(void) const;
+
+ /** Get number of basis functions for cell.
+ *
+ * @returns Number of basis functions for cell
+ */
+ int numBasis(void) const;
+
+ /** Get number of quadrature points.
+ *
+ * @returns Number of quadrature points
+ */
+ int numQuadPts(void) const;
+
+ /** Get number of dimensions in coordinates of cell vertices.
+ *
+ * @returns Number of dimensions in coordinates of cell vertices
+ */
+ int spaceDim(void) const;
+
+// PROTECTED METHODS ////////////////////////////////////////////////////
+protected :
+
+ /** Copy constructor.
+ *
+ * @param q Quadrature to copy
+ */
+ QuadratureRefCell(const QuadratureRefCell& q);
+
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+protected :
+
+ double _minJacobian; ///< Minium allowable Jacobian determinant
+
+ /** Array of coordinates of quadrature points in reference cell.
+ *
+ * Reference coordinates: (p,q,r)
+ *
+ * Qp0p, Qp0q, Qp0r
+ * Qp1p, Qp1q, Qp1r
+ *
+ * size = numQuadPts * cellDim
+ * index = iQuadPts*cellDim + iDim
+ */
+ double_array _quadPtsRef;
+
+ /** Array of weights of quadrature points.
+ *
+ * WtQp0, WtQp1, ...
+ * size = numQuadPts
+ * index = iQuadPt
+ */
+ double_array _quadWts;
+
+ /** Array of basis functions evaluated at the quadrature points.
+ *
+ * N0Qp0, N1Qp0, ...
+ * N0Qp1, N1Qp1, ...
+ *
+ * size = numQuadPts * numBasis
+ * index = iQuadPt*numBasis + iBasis
+ */
+ double_array _basis;
+
+ /** Array of basis function derivatives evaluated at the quadrature
+ * points, where derivatives are with respect to cell's local
+ * coordinates.
+ *
+ * N0pQp0, N0qQp0, N0rQp0, N1pQp0, N1qQp0, N1rQp0, ...
+ * N0pQp1, N0qQp1, N0rQp1, N1pQp1, N1qQp1, N1rQp1, ...
+ *
+ * size = numQuadPts * numBasis * cellDim
+ * index = iQuadPt*numBasis*cellDim + iBasis*cellDim + iDim
+ */
+ double_array _basisDerivRef;
+
+ int _cellDim; ///< Number of dimensions in reference cell
+ int _numBasis; ///< Number of basis functions (and vertices) for cell
+ int _numQuadPts; ///< Number of quadrature points
+ int _spaceDim; ///< Number of dimensions in coordinates of cell vertices
+
+ CellGeometry* _geometry; ///< Geometry of reference cell
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ const QuadratureRefCell& operator=(const QuadratureRefCell&); ///< Not implemented
+
+}; // QuadratureRefCell
+
+#include "QuadratureRefCell.icc" // inline methods
+
+#endif // pylith_feassemble_quadraturerefcell_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.icc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/QuadratureRefCell.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/feassemble/QuadratureRefCell.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,89 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_feassemble_quadraturerefcell_hh)
+#error "QuadratureRefCell.icc must be included only from QuadratureRefCell.hh"
+#else
+
+// Get minimum allowable Jacobian.
+inline
+double
+pylith::feassemble::QuadratureRefCell::minJacobian(void) const {
+ return _minJacobian;
+}
+
+// Set minimum allowable Jacobian.
+inline
+void
+pylith::feassemble::QuadratureRefCell::minJacobian(const double min) {
+ _minJacobian = min;
+}
+
+// Get coordinates of quadrature points in reference cell.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureRefCell::quadPtsRef(void) const {
+ return _quadPtsRef;
+}
+
+// Get weights of quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureRefCell::quadWts(void) const {
+ return _quadWts;
+}
+
+// Get basis fns evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureRefCell::basis(void) const {
+ return _basis;
+}
+
+// Get derivates of basis fns evaluated at quadrature points.
+inline
+const pylith::double_array&
+pylith::feassemble::QuadratureRefCell::basisDerivRef(void) const {
+ return _basisDerivRef;
+}
+
+// Get number of dimensions in reference cell.
+inline
+int
+pylith::feassemble::QuadratureRefCell::cellDim(void) const {
+ return _cellDim;
+}
+
+// Get number of basis functions for cell.
+inline
+int
+pylith::feassemble::QuadratureRefCell::numBasis(void) const {
+ return _numBasis;
+}
+
+// Get number of quadrature points.
+inline
+int
+pylith::feassemble::QuadratureRefCell::numQuadPts(void) const {
+ return _numQuadPts;
+}
+
+// Get number of dimensions in coordinates of cell vertices.
+inline
+int
+pylith::feassemble::QuadratureRefCell::spaceDim(void) const {
+ return _spaceDim;
+}
+
+#endif
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/feassemble/feassemblefwd.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/feassemble/feassemblefwd.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/feassemble/feassemblefwd.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/feassemble/feassemblefwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/feassemble/feassemblefwd.hh
+ *
+ * @brief Forward declarations for PyLith feassemble objects.
+ *
+ * Including this header file eliminates the need to use separate
+ * forward declarations.
+ */
+
+#if !defined(pylith_feassemble_feassemblefwd_hh)
+#define pylith_feassemble_feassemblefwd_hh
+
+namespace pylith {
+ namespace feassemble {
+
+ class CellGeometry;
+ class GeometryPoint1D;
+ class GeometryPoint2D;
+ class GeometryPoint3D;
+ class GeometryLine1D;
+ class GeometryLine2D;
+ class GeometryLine3D;
+ class GeometryTri2D;
+ class GeometryTri3D;
+ class GeometryQuad2D;
+ class GeometryQuad3D;
+ class GeometryTet3D;
+ class GeometryHex3D;
+
+ class QuadratureRefCell;
+ class QuadratureEngine;
+ class Quadrature0D;
+ class Quadrature1D;
+ class Quadrature1Din2D;
+ class Quadrature1Din3D;
+ class Quadrature2D;
+ class Quadrature2Din3D;
+ class Quadrature3D;
+ template<typename mesh_type> class Quadrature;
+
+ class Constraint;
+ template<typename quadrature_type> class Integrator;
+
+ class IntegratorElasticity;
+ class ElasticityImplicit;
+ class ElasticityExplicit;
+
+ } // feassemble
+} // pylith
+
+
+#endif // pylith_feassemble_feassemblefwd_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,8 @@
#include "ElasticIsotropic3D.hh" // implementation of object methods
+#include "Metadata.hh" // USES Metadata
+
#include "pylith/utils/array.hh" // USES double_array
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
@@ -30,58 +32,64 @@
namespace materials {
namespace _ElasticIsotropic3D {
- /// Number of entries in stress tensor.
+ // Dimension of material.
+ const int dimension = 3;
+
+ // Number of entries in stress tensor.
const int tensorSize = 6;
- /// Number of elastic constants (for general 3-D elastic material)
+ // Number of elastic constants (for general 3-D elastic material)
const int numElasticConsts = 21;
- /// Number of physical properties.
+ // Number of physical properties.
const int numProperties = 3;
- /// Physical properties.
- const Material::PropMetaData properties[] = {
- { "density", 1, OTHER_FIELD },
- { "mu", 1, OTHER_FIELD },
- { "lambda", 1, OTHER_FIELD },
+ // Physical properties.
+ const Metadata::ParamDescription properties[] = {
+ { "density", 1, pylith::topology::FieldBase::SCALAR },
+ { "mu", 1, pylith::topology::FieldBase::SCALAR },
+ { "lambda", 1, pylith::topology::FieldBase::SCALAR },
};
- /// Indices of physical properties
- const int pidDensity = 0;
- const int pidMu = pidDensity + 1;
- const int pidLambda = pidMu + 1;
- /// Values expected in spatial database
- const int numDBValues = 3;
- const char* namesDBValues[] = { "density", "vs", "vp" };
+ // Values expected in spatial database
+ const int numDBProperties = 3;
+ const char* dbProperties[] = { "density", "vs", "vp" };
- /// Indices of database values
- const int didDensity = 0;
- const int didVs = 1;
- const int didVp = 2;
-
- /// Initial state values expected in spatial database
- const int numInitialStateDBValues = tensorSize;
- const char* namesInitialStateDBValues[] = { "stress_xx", "stress_yy",
- "stress_zz", "stress_xy",
- "stress_yz", "stress_xz" };
-
} // _ElasticIsotropic3D
} // materials
} // pylith
+// Indices of physical properties
+const int pylith::materials::ElasticIsotropic3D::p_density = 0;
+const int pylith::materials::ElasticIsotropic3D::p_mu =
+ pylith::materials::ElasticIsotropic3D::p_density + 1;
+
+const int pylith::materials::ElasticIsotropic3D::p_lambda =
+ pylith::materials::ElasticIsotropic3D::p_mu + 1;
+
+// Indices of database values (order must match dbProperties)
+const int pylith::materials::ElasticIsotropic3D::db_density = 0;
+
+const int pylith::materials::ElasticIsotropic3D::db_vs =
+ pylith::materials::ElasticIsotropic3D::db_density + 1;
+
+const int pylith::materials::ElasticIsotropic3D::db_vp =
+ pylith::materials::ElasticIsotropic3D::db_vs + 1;
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::materials::ElasticIsotropic3D::ElasticIsotropic3D(void) :
- ElasticMaterial(_ElasticIsotropic3D::tensorSize,
+ ElasticMaterial(_ElasticIsotropic3D::dimension,
+ _ElasticIsotropic3D::tensorSize,
_ElasticIsotropic3D::numElasticConsts,
- _ElasticIsotropic3D::namesDBValues,
- _ElasticIsotropic3D::namesInitialStateDBValues,
- _ElasticIsotropic3D::numDBValues,
- _ElasticIsotropic3D::properties,
- _ElasticIsotropic3D::numProperties)
+ Metadata(_ElasticIsotropic3D::properties,
+ _ElasticIsotropic3D::numProperties,
+ _ElasticIsotropic3D::dbProperties,
+ _ElasticIsotropic3D::numDBProperties,
+ 0, 0,
+ 0, 0))
{ // constructor
- _dimension = 3;
} // constructor
// ----------------------------------------------------------------------
@@ -94,16 +102,16 @@
// Compute properties from values in spatial database.
void
pylith::materials::ElasticIsotropic3D::_dbToProperties(
- double* const propValues,
- const double_array& dbValues) const
+ double* const propValues,
+ const double_array& dbValues) const
{ // _dbToProperties
assert(0 != propValues);
const int numDBValues = dbValues.size();
- assert(_ElasticIsotropic3D::numDBValues == numDBValues);
+ assert(_ElasticIsotropic3D::numDBProperties == numDBValues);
- const double density = dbValues[_ElasticIsotropic3D::didDensity];
- const double vs = dbValues[_ElasticIsotropic3D::didVs];
- const double vp = dbValues[_ElasticIsotropic3D::didVp];
+ const double density = dbValues[db_density];
+ const double vs = dbValues[db_vs];
+ const double vp = dbValues[db_vp];
if (density <= 0.0 || vs <= 0.0 || vp <= 0.0) {
std::ostringstream msg;
@@ -127,9 +135,9 @@
throw std::runtime_error(msg.str());
} // if
- propValues[_ElasticIsotropic3D::pidDensity] = density;
- propValues[_ElasticIsotropic3D::pidMu] = mu;
- propValues[_ElasticIsotropic3D::pidLambda] = lambda;
+ propValues[p_density] = density;
+ propValues[p_mu] = mu;
+ propValues[p_lambda] = lambda;
PetscLogFlops(6);
} // _dbToProperties
@@ -146,16 +154,14 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticIsotropic3D::pidDensity] =
- _normalizer->nondimensionalize(values[_ElasticIsotropic3D::pidDensity],
- densityScale);
- values[_ElasticIsotropic3D::pidMu] =
- _normalizer->nondimensionalize(values[_ElasticIsotropic3D::pidMu],
- pressureScale);
- values[_ElasticIsotropic3D::pidLambda] =
- _normalizer->nondimensionalize(values[_ElasticIsotropic3D::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->nondimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->nondimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->nondimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _nondimProperties
@@ -171,137 +177,120 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticIsotropic3D::pidDensity] =
- _normalizer->dimensionalize(values[_ElasticIsotropic3D::pidDensity],
- densityScale);
- values[_ElasticIsotropic3D::pidMu] =
- _normalizer->dimensionalize(values[_ElasticIsotropic3D::pidMu],
- pressureScale);
- values[_ElasticIsotropic3D::pidLambda] =
- _normalizer->dimensionalize(values[_ElasticIsotropic3D::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->dimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->dimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->dimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _dimProperties
// ----------------------------------------------------------------------
-// Nondimensionalize initial state.
-void
-pylith::materials::ElasticIsotropic3D::_nondimInitState(double* const values,
- const int nvalues) const
-{ // _nondimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticIsotropic3D::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->nondimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _nondimInitState
-
-// ----------------------------------------------------------------------
-// Dimensionalize initial state.
-void
-pylith::materials::ElasticIsotropic3D::_dimInitState(double* const values,
- const int nvalues) const
-{ // _dimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticIsotropic3D::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->dimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _dimInitState
-
-// ----------------------------------------------------------------------
// Compute density at location from properties.
void
-pylith::materials::ElasticIsotropic3D::_calcDensity(
- double* const density,
- const double* properties,
- const int numProperties)
+pylith::materials::ElasticIsotropic3D::_calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars)
{ // _calcDensity
assert(0 != density);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
- density[0] = properties[_ElasticIsotropic3D::pidDensity];
+ density[0] = properties[p_density];
} // _calcDensity
// ----------------------------------------------------------------------
// Compute stress tensor at location from properties.
void
-pylith::materials::ElasticIsotropic3D::_calcStress(
- double* const stress,
- const int stressSize,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize,
- const bool computeStateVars)
+pylith::materials::ElasticIsotropic3D::_calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars)
{ // _calcStress
assert(0 != stress);
assert(_ElasticIsotropic3D::tensorSize == stressSize);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticIsotropic3D::tensorSize == strainSize);
- assert(_ElasticIsotropic3D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticIsotropic3D::tensorSize == initialStrainSize);
- const double density = properties[_ElasticIsotropic3D::pidDensity];
- const double mu = properties[_ElasticIsotropic3D::pidMu];
- const double lambda = properties[_ElasticIsotropic3D::pidLambda];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
const double mu2 = 2.0*mu;
- const double e11 = totalStrain[0];
- const double e22 = totalStrain[1];
- const double e33 = totalStrain[2];
- const double e12 = totalStrain[3];
- const double e23 = totalStrain[4];
- const double e13 = totalStrain[5];
+ const double e11 = totalStrain[0] - initialStrain[0];
+ const double e22 = totalStrain[1] - initialStrain[1];
+ const double e33 = totalStrain[2] - initialStrain[2];
+ const double e12 = totalStrain[3] - initialStrain[3];
+ const double e23 = totalStrain[4] - initialStrain[4];
+ const double e13 = totalStrain[5] - initialStrain[5];
const double s123 = lambda * (e11 + e22 + e33);
- stress[0] = s123 + mu2*e11 + initialState[0];
- stress[1] = s123 + mu2*e22 + initialState[1];
- stress[2] = s123 + mu2*e33 + initialState[2];
- stress[3] = mu2 * e12 + initialState[3];
- stress[4] = mu2 * e23 + initialState[4];
- stress[5] = mu2 * e13 + initialState[5];
+ stress[0] = s123 + mu2*e11 + initialStress[0];
+ stress[1] = s123 + mu2*e22 + initialStress[1];
+ stress[2] = s123 + mu2*e33 + initialStress[2];
+ stress[3] = mu2 * e12 + initialStress[3];
+ stress[4] = mu2 * e23 + initialStress[4];
+ stress[5] = mu2 * e13 + initialStress[5];
- PetscLogFlops(19);
+ PetscLogFlops(25);
} // _calcStress
// ----------------------------------------------------------------------
// Compute derivative of elasticity matrix at location from properties.
void
pylith::materials::ElasticIsotropic3D::_calcElasticConsts(
- double* const elasticConsts,
- const int numElasticConsts,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // _calcElasticConsts
assert(0 != elasticConsts);
assert(_ElasticIsotropic3D::numElasticConsts == numElasticConsts);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticIsotropic3D::tensorSize == strainSize);
- assert(_ElasticIsotropic3D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticIsotropic3D::tensorSize == initialStrainSize);
- const double density = properties[_ElasticIsotropic3D::pidDensity];
- const double mu = properties[_ElasticIsotropic3D::pidMu];
- const double lambda = properties[_ElasticIsotropic3D::pidLambda];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
const double mu2 = 2.0 * mu;
const double lambda2mu = lambda + mu2;
@@ -334,8 +323,11 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
double
-pylith::materials::ElasticIsotropic3D::_stableTimeStepImplicit(const double* properties,
- const int numProperties) const
+pylith::materials::ElasticIsotropic3D::_stableTimeStepImplicit(
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const
{ // _stableTimeStepImplicit
return pylith::PYLITH_MAXDOUBLE;
} // _stableTimeStepImplicit
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticIsotropic3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,22 +20,20 @@
* internally using density, lambda, and mu, which are directly
* related to the elasticity constants used in the finite-element
* integration.
+ *
+ * $\sigma - \sigma_0 = C (\epsilon - \epsilon_0)
+ *
+ * This implies that when $\epsilon = \epsilon_0$, $\sigma =
+ * \sigma_0$.
*/
#if !defined(pylith_materials_elasticisotropic3d_hh)
#define pylith_materials_elasticisotropic3d_hh
-#include "ElasticMaterial.hh"
+// Include directives ---------------------------------------------------
+#include "ElasticMaterial.hh" // ISA ElasticMaterial
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class ElasticIsotropic3D;
- class TestElasticIsotropic3D; // unit testing
- } // materials
-} // pylith
-
-/// 3-D, isotropic, linear elastic material.
+// ElasticIsotropic3D ---------------------------------------------------
class pylith::materials::ElasticIsotropic3D : public ElasticMaterial
{ // class ElasticIsotropic3D
friend class TestElasticIsotropic3D; // unit testing
@@ -79,22 +77,6 @@
void _dimProperties(double* const values,
const int nvalues) const;
- /** Nondimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _nondimInitState(double* const values,
- const int nvalues) const;
-
- /** Dimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _dimInitState(double* const values,
- const int nvalues) const;
-
/** Compute density from properties.
*
* @param density Array for density.
@@ -103,31 +85,42 @@
*/
void _calcDensity(double* const density,
const double* properties,
- const int numProperties);
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
- /** Compute stress tensor from properties. If the state variables
- * are from the previous time step, then the computeStateVars flag
- * should be set to true so that the state variables are updated
- * (but not stored) when computing the stresses.
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStress(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute derivatives of elasticity matrix from properties.
@@ -136,27 +129,52 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConsts(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Get stable time step for implicit time integration.
*
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
* @returns Time step
*/
double _stableTimeStepImplicit(const double* properties,
- const int numProperties) const;
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ static const int p_density;
+ static const int p_mu;
+ static const int p_lambda;
+ static const int db_density;
+ static const int db_vs;
+ static const int db_vp;
+
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,23 +14,35 @@
#include "ElasticMaterial.hh" // implementation of object methods
-#include "pylith/utils/array.hh" // USES double_array
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
+#include "pylith/utils/array.hh" // USES double_array, std::vector
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+
#include <cstring> // USES memcpy()
+#include <strings.h> // USES strcasecmp()
#include <cassert> // USES assert()
+#include <stdexcept> // USES std::runtime_error
+#include <sstream> // USES std::ostringstream
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Default constructor.
-pylith::materials::ElasticMaterial::ElasticMaterial(const int tensorSize,
+pylith::materials::ElasticMaterial::ElasticMaterial(const int dimension,
+ const int tensorSize,
const int numElasticConsts,
- const char** dbValues,
- const char** initialStateDBValues,
- const int numDBValues,
- const PropMetaData* properties,
- const int numProperties) :
- Material(tensorSize, dbValues, initialStateDBValues, numDBValues, properties, numProperties),
+ const Metadata& metadata) :
+ Material(dimension, tensorSize, metadata),
+ _dbInitialStress(0),
+ _dbInitialStrain(0),
+ _initialStress(0),
+ _initialStrain(0),
_numQuadPts(0),
_numElasticConsts(numElasticConsts)
{ // constructor
@@ -40,23 +52,89 @@
// Destructor.
pylith::materials::ElasticMaterial::~ElasticMaterial(void)
{ // destructor
+ delete _initialStress; _initialStress = 0;
+ delete _initialStrain; _initialStrain = 0;
+
+ // Python db object owns databases, so just set point to null
+ // :KLUDGE: Should use shared pointer
+ _dbInitialStress = 0;
+ _dbInitialStrain = 0;
} // destructor
// ----------------------------------------------------------------------
+// Initialize material by getting physical property parameters from
+// database.
+void
+pylith::materials::ElasticMaterial::initialize(
+ const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature)
+{ // initialize
+ Material::initialize(mesh, quadrature);
+
+ assert(0 != quadrature);
+ _numQuadPts = quadrature->numQuadPts();
+
+ _initializeInitialStress(mesh, quadrature);
+ _initializeInitialStrain(mesh, quadrature);
+ _allocateCellArrays();
+} // initialize
+
+// ----------------------------------------------------------------------
+// Retrieve parameters for physical properties and state variables for cell.
+void
+pylith::materials::ElasticMaterial::retrievePropsAndVars(const int cell)
+{ // retrievePropsAndVars
+ assert(0 != _properties);
+ assert(0 != _stateVars);
+
+ const ALE::Obj<RealSection>& propertiesSection = _properties->section();
+ assert(!propertiesSection.isNull());
+ propertiesSection->restrictPoint(cell, &_propertiesCell[0],
+ _propertiesCell.size());
+
+ if (hasStateVars()) {
+ const ALE::Obj<RealSection>& stateVarsSection = _stateVars->section();
+ assert(!stateVarsSection.isNull());
+ stateVarsSection->restrictPoint(cell, &_stateVarsCell[0],
+ _stateVarsCell.size());
+ } // if
+
+ if (0 == _initialStress)
+ _initialStressCell = 0.0;
+ else {
+ const ALE::Obj<RealSection>& stressSection = _initialStress->section();
+ assert(!stressSection.isNull());
+ stressSection->restrictPoint(cell, &_initialStressCell[0],
+ _initialStressCell.size());
+ } // if/else
+ if (0 == _initialStrain)
+ _initialStrainCell = 0.0;
+ else {
+ const ALE::Obj<RealSection>& strainSection = _initialStrain->section();
+ assert(!strainSection.isNull());
+ strainSection->restrictPoint(cell, &_initialStrainCell[0],
+ _initialStrainCell.size());
+ } // if/else
+} // retrievePropsAndVars
+
+// ----------------------------------------------------------------------
// Compute density for cell at quadrature points.
const pylith::double_array&
pylith::materials::ElasticMaterial::calcDensity(void)
{ // calcDensity
const int numQuadPts = _numQuadPts;
- const int totalPropsQuadPt = _totalPropsQuadPt;
- assert(_propertiesCell.size() == numQuadPts*totalPropsQuadPt);
- assert(_density.size() == numQuadPts);
+ const int numPropsQuadPt = _numPropsQuadPt;
+ const int numVarsQuadPt = _numVarsQuadPt;
+ assert(_propertiesCell.size() == numQuadPts*numPropsQuadPt);
+ assert(_stateVarsCell.size() == numQuadPts*numVarsQuadPt);
+ assert(_densityCell.size() == numQuadPts*1);
for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
- _calcDensity(&_density[iQuad],
- &_propertiesCell[iQuad*totalPropsQuadPt], totalPropsQuadPt);
+ _calcDensity(&_densityCell[iQuad],
+ &_propertiesCell[iQuad*numPropsQuadPt], numPropsQuadPt,
+ &_stateVarsCell[iQuad*numVarsQuadPt], numVarsQuadPt);
- return _density;
+ return _densityCell;
} // calcDensity
// ----------------------------------------------------------------------
@@ -66,20 +144,26 @@
const bool computeStateVars)
{ // calcStress
const int numQuadPts = _numQuadPts;
- const int totalPropsQuadPt = _totalPropsQuadPt;
- assert(_propertiesCell.size() == numQuadPts*totalPropsQuadPt);
+ const int numPropsQuadPt = _numPropsQuadPt;
+ const int tensorSize = _tensorSize;
+ const int numVarsQuadPt = _numVarsQuadPt;
+ assert(_propertiesCell.size() == numQuadPts*numPropsQuadPt);
+ assert(_stateVarsCell.size() == numQuadPts*numVarsQuadPt);
+ assert(_stressCell.size() == numQuadPts*_tensorSize);
+ assert(_initialStressCell.size() == numQuadPts*_tensorSize);
+ assert(_initialStrainCell.size() == numQuadPts*_tensorSize);
assert(totalStrain.size() == numQuadPts*_tensorSize);
- assert(_stress.size() == numQuadPts*_tensorSize);
- assert(_initialStateCell.size() == numQuadPts*_initialStateSize);
for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
- _calcStress(&_stress[iQuad*_tensorSize], _tensorSize,
- &_propertiesCell[iQuad*totalPropsQuadPt], totalPropsQuadPt,
+ _calcStress(&_stressCell[iQuad*_tensorSize], _tensorSize,
+ &_propertiesCell[iQuad*numPropsQuadPt], numPropsQuadPt,
+ &_stateVarsCell[iQuad*numVarsQuadPt], numVarsQuadPt,
&totalStrain[iQuad*_tensorSize], _tensorSize,
- &_initialStateCell[iQuad*_initialStateSize],
- _initialStateSize, computeStateVars);
+ &_initialStressCell[iQuad*_tensorSize], _tensorSize,
+ &_initialStrainCell[iQuad*_tensorSize], _tensorSize,
+ computeStateVars);
- return _stress;
+ return _stressCell;
} // calcStress
// ----------------------------------------------------------------------
@@ -89,126 +173,417 @@
const double_array& totalStrain)
{ // calcDerivElastic
const int numQuadPts = _numQuadPts;
- const int totalPropsQuadPt = _totalPropsQuadPt;
- assert(_propertiesCell.size() == numQuadPts*totalPropsQuadPt);
+ const int numPropsQuadPt = _numPropsQuadPt;
+ const int tensorSize = _tensorSize;
+ const int numVarsQuadPt = _numVarsQuadPt;
+ assert(_propertiesCell.size() == numQuadPts*numPropsQuadPt);
+ assert(_stateVarsCell.size() == numQuadPts*numVarsQuadPt);
+ assert(_elasticConstsCell.size() == numQuadPts*_numElasticConsts);
+ assert(_initialStressCell.size() == numQuadPts*_tensorSize);
+ assert(_initialStrainCell.size() == numQuadPts*_tensorSize);
assert(totalStrain.size() == numQuadPts*_tensorSize);
- assert(_elasticConsts.size() == numQuadPts*_numElasticConsts);
- assert(_initialStateCell.size() == numQuadPts*_initialStateSize);
for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
- _calcElasticConsts(&_elasticConsts[iQuad*_numElasticConsts],
+ _calcElasticConsts(&_elasticConstsCell[iQuad*_numElasticConsts],
_numElasticConsts,
- &_propertiesCell[iQuad*totalPropsQuadPt],
- totalPropsQuadPt,
+ &_propertiesCell[iQuad*numPropsQuadPt],
+ numPropsQuadPt,
+ &_stateVarsCell[iQuad*numVarsQuadPt], numVarsQuadPt,
&totalStrain[iQuad*_tensorSize], _tensorSize,
- &_initialStateCell[iQuad*_initialStateSize],
- _initialStateSize);
+ &_initialStressCell[iQuad*_tensorSize], _tensorSize,
+ &_initialStrainCell[iQuad*_tensorSize], _tensorSize);
- return _elasticConsts;
+ return _elasticConstsCell;
} // calcDerivElastic
// ----------------------------------------------------------------------
+// Update state variables (for next time step).
+void
+pylith::materials::ElasticMaterial::updateStateVars(
+ const double_array& totalStrain,
+ const int cell)
+{ // updateStateVars
+ const int numQuadPts = _numQuadPts;
+ const int numPropsQuadPt = _numPropsQuadPt;
+ const int tensorSize = _tensorSize;
+ const int numVarsQuadPt = _numVarsQuadPt;
+ assert(_propertiesCell.size() == numQuadPts*numPropsQuadPt);
+ assert(_stateVarsCell.size() == numQuadPts*numVarsQuadPt);
+ assert(_initialStressCell.size() == numQuadPts*_tensorSize);
+ assert(_initialStrainCell.size() == numQuadPts*_tensorSize);
+ assert(totalStrain.size() == numQuadPts*_tensorSize);
+
+ const ALE::Obj<RealSection>& stateVarsSection = _stateVars->section();
+ assert(!stateVarsSection.isNull());
+ stateVarsSection->restrictPoint(cell, &_stateVarsCell[0],
+ _stateVarsCell.size());
+
+ for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
+ _updateStateVars(&_stateVarsCell[iQuad*numVarsQuadPt], numVarsQuadPt,
+ &_propertiesCell[iQuad*numPropsQuadPt],
+ numPropsQuadPt,
+ &totalStrain[iQuad*_tensorSize], _tensorSize,
+ &_initialStressCell[iQuad*_tensorSize], _tensorSize,
+ &_initialStrainCell[iQuad*_tensorSize], _tensorSize);
+
+ stateVarsSection->updatePoint(cell, &_stateVarsCell[0]);
+} // updateStateVars
+
+// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
double
-pylith::materials::ElasticMaterial::stableTimeStepImplicit(void) const
+pylith::materials::ElasticMaterial::stableTimeStepImplicit(const topology::Mesh& mesh)
{ // stableTimeStepImplicit
const int numQuadPts = _numQuadPts;
- const int totalPropsQuadPt = _totalPropsQuadPt;
- assert(_propertiesCell.size() == numQuadPts*totalPropsQuadPt);
+ const int numPropsQuadPt = _numPropsQuadPt;
+ const int tensorSize = _tensorSize;
+ const int numVarsQuadPt = _numVarsQuadPt;
+ assert(_propertiesCell.size() == numQuadPts*numPropsQuadPt);
+ assert(_stateVarsCell.size() == numQuadPts*numVarsQuadPt);
+ assert(_elasticConstsCell.size() == numQuadPts*_numElasticConsts);
+ assert(_initialStressCell.size() == numQuadPts*_tensorSize);
+ assert(_initialStrainCell.size() == numQuadPts*_tensorSize);
double dtStable = pylith::PYLITH_MAXDOUBLE;
- for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
- const double dt =
- _stableTimeStepImplicit(&_propertiesCell[iQuad*totalPropsQuadPt],
- totalPropsQuadPt);
- if (dt < dtStable)
- dtStable = dt;
+
+ // Get cells associated with material
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", id());
+ assert(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsBegin = cells->begin();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter) {
+ retrievePropsAndVars(*c_iter);
+
+ for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
+ const double dt =
+ _stableTimeStepImplicit(&_propertiesCell[iQuad*numPropsQuadPt],
+ numPropsQuadPt,
+ &_stateVarsCell[iQuad*numVarsQuadPt],
+ numVarsQuadPt);
+ if (dt < dtStable)
+ dtStable = dt;
+ } // for
} // for
-
+
return dtStable;
} // stableTimeStepImplicit
// ----------------------------------------------------------------------
-// Get cell's property information from material's sections.
-void
-pylith::materials::ElasticMaterial::getPropertiesCell(const Mesh::point_type& cell,
- const int numQuadPts)
-{ // getPropertiesCell
- if (_numQuadPts != numQuadPts) {
- const int totalPropsQuadPt = _totalPropsQuadPt;
+// Get initial stress field.
+const pylith::topology::Field<pylith::topology::Mesh>&
+pylith::materials::ElasticMaterial::initialStressField(void) const
+{ // initialStressField
+ if (0 == _initialStress)
+ throw std::runtime_error("Request for initial stress field, but field "
+ "does not exist.");
- _numQuadPts = numQuadPts;
+ return *_initialStress;
+} // initialStressField
- _propertiesCell.resize(numQuadPts*totalPropsQuadPt);
- _density.resize(numQuadPts*1);
- _stress.resize(numQuadPts*_tensorSize);
- _elasticConsts.resize(numQuadPts*_numElasticConsts);
- _initialStateCell.resize(numQuadPts*_tensorSize);
- } // if
+// ----------------------------------------------------------------------
+// Get initial strain field.
+const pylith::topology::Field<pylith::topology::Mesh>&
+pylith::materials::ElasticMaterial::initialStrainField(void) const
+{ // initialStrainField
+ if (0 == _initialStrain)
+ throw std::runtime_error("Request for initial strain field, but field "
+ "does not exist.");
- _getProperties(cell);
-} // getPropertiesCell
+ return *_initialStrain;
+} // initialStrainField
// ----------------------------------------------------------------------
-// Update properties (state variables for next time step).
+// Allocate cell arrays.
void
-pylith::materials::ElasticMaterial::updateProperties(
- const double_array& totalStrain,
- const Mesh::point_type& cell)
-{ // updateProperties
+pylith::materials::ElasticMaterial::_allocateCellArrays(void)
+{ // _allocateCellArrays
const int numQuadPts = _numQuadPts;
- const int totalPropsQuadPt = _totalPropsQuadPt;
- getPropertiesCell(cell, numQuadPts);
+ const int tensorSize = _tensorSize;
+ const int numPropsQuadPt = _numPropsQuadPt;
+ const int numVarsQuadPt = _numVarsQuadPt;
+ const int numElasticConsts = _numElasticConsts;
- for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
- _updateProperties(&_propertiesCell[iQuad*totalPropsQuadPt],
- totalPropsQuadPt,
- &totalStrain[iQuad*_tensorSize], _tensorSize,
- &_initialStateCell[iQuad*_initialStateSize],
- _initialStateSize);
+ _propertiesCell.resize(numQuadPts * numPropsQuadPt);
+ _stateVarsCell.resize(numQuadPts * numVarsQuadPt);
+ _initialStressCell.resize(numQuadPts * tensorSize);
+ _initialStrainCell.resize(numQuadPts * tensorSize);
+ _densityCell.resize(numQuadPts);
+ _stressCell.resize(numQuadPts * tensorSize);
+ _elasticConstsCell.resize(numQuadPts * numElasticConsts);
+} // _allocateCellArrays
+
+// ----------------------------------------------------------------------
+// Initialize initial stress field.
+void
+pylith::materials::ElasticMaterial::_initializeInitialStress(
+ const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature)
+{ // _initializeInitialStress
+ delete _initialStress; _initialStress = 0;
+ if (0 == _dbInitialStress)
+ return;
+
+ assert(0 != _dbInitialStress);
+ assert(0 != quadrature);
+
+ // Get quadrature information
+ const int numQuadPts = quadrature->numQuadPts();
+ const int spaceDim = quadrature->spaceDim();
+
+ // Create arrays for querying
+ const int tensorSize = _tensorSize;
+ double_array quadPtsGlobal(numQuadPts*spaceDim);
+ double_array stressCell(numQuadPts*tensorSize);
+
+ // Get cells associated with material
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", id());
+ assert(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
+
+ // Create field to hold initial stress state.
+ delete _initialStress; _initialStress = 0;
+ _initialStress = new topology::Field<topology::Mesh>(mesh);
+ assert(0 != _initialStress);
+ const int fiberDim = numQuadPts * tensorSize;
+ assert(fiberDim > 0);
+ _initialStress->newSection(cells, fiberDim);
+ _initialStress->allocate();
+ _initialStress->zero();
+ const ALE::Obj<RealSection>& initialStressSection =
+ _initialStress->section();
+
+ // Setup databases for querying
+ _dbInitialStress->open();
+ switch (dimension())
+ { // switch
+ case 1: {
+ const char* stressDBValues[] = { "stress" };
+ _dbInitialStress->queryVals(stressDBValues, tensorSize);
+ break;
+ } // case 1
+ case 2 : {
+ const char* stressDBValues[] = {
+ "stress-xx",
+ "stress-yy",
+ "stress-xy",
+ };
+ _dbInitialStress->queryVals(stressDBValues, tensorSize);
+ break;
+ } // case 2
+ case 3 : {
+ const char* stressDBValues[] = {
+ "stress-xx",
+ "stress-yy",
+ "stress-zz",
+ "stress-xy",
+ "stress-yz",
+ "stress-xz",
+ };
+ _dbInitialStress->queryVals(stressDBValues, tensorSize);
+ break;
+ } // case 3
+ default :
+ assert(0);
+ } // switch
- _properties->updatePoint(cell, &_propertiesCell[0]);
-} // updateProperties
+ assert(0 != _normalizer);
+ const double lengthScale = _normalizer->pressureScale();
+ const double pressureScale = _normalizer->pressureScale();
+ const ALE::Obj<RealSection>& stressSection = _initialStress->section();
+ assert(!stressSection.isNull());
+
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter) {
+ // Compute geometry information for current cell
+ quadrature->retrieveGeometry(*c_iter);
+
+ // Dimensionalize coordinates for querying
+ const double_array& quadPtsNonDim = quadrature->quadPts();
+ quadPtsGlobal = quadPtsNonDim;
+ _normalizer->dimensionalize(&quadPtsGlobal[0], quadPtsGlobal.size(),
+ lengthScale);
+
+ // Loop over quadrature points in cell and query database
+ for (int iQuadPt=0, iCoord=0, iStress=0;
+ iQuadPt < numQuadPts;
+ ++iQuadPt, iCoord+=spaceDim, iStress+=tensorSize) {
+ int err = _dbInitialStress->query(&stressCell[iStress], tensorSize,
+ &quadPtsGlobal[iCoord], spaceDim, cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find initial stress at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << quadPtsGlobal[iCoord+i];
+ msg << ") in material " << label() << "\n"
+ << "using spatial database '" << _dbInitialStress->label() << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+ } // for
+
+ // Nondimensionalize stress
+ _normalizer->nondimensionalize(&stressCell[0], stressCell.size(),
+ pressureScale);
+
+ stressSection->updatePoint(*c_iter, &stressCell[0]);
+ } // for
+
+ // Close databases
+ _dbInitialStress->close();
+} // _initializeInitialStress
+
// ----------------------------------------------------------------------
-// Get properties for cell.
+// Initialize initial strain field.
void
-pylith::materials::ElasticMaterial::_getProperties(const Mesh::point_type& cell)
-{ // _getProperties
- assert(!_properties.isNull());
+pylith::materials::ElasticMaterial::_initializeInitialStrain(
+ const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature)
+{ // _initializeInitialStrain
+ delete _initialStrain; _initialStrain = 0;
+ if (0 == _dbInitialStrain)
+ return;
- const int numQuadPts = _numQuadPts;
- const int totalPropsQuadPt = _totalPropsQuadPt;
- assert(_propertiesCell.size() == numQuadPts*totalPropsQuadPt);
- assert(_properties->getFiberDimension(cell) == numQuadPts*totalPropsQuadPt);
- assert(_initialStateCell.size() == numQuadPts*_initialStateSize);
- const real_section_type::value_type* parameterCell =
- _properties->restrictPoint(cell);
- memcpy(&_propertiesCell[0], parameterCell,
- numQuadPts*totalPropsQuadPt*sizeof(double));
- if (_initialState.isNull())
- _initialStateCell = 0.0;
- else {
- assert(_initialState->getFiberDimension(cell) == numQuadPts*_initialStateSize);
- const real_section_type::value_type* initialStateValuesCell =
- _initialState->restrictPoint(cell);
- memcpy(&_initialStateCell[0], initialStateValuesCell,
- numQuadPts*_initialStateSize*sizeof(double));
- } // else
+ assert(0 != _dbInitialStrain);
+ assert(0 != quadrature);
-} // _getProperties
+ // Get quadrature information
+ const int numQuadPts = quadrature->numQuadPts();
+ const int spaceDim = quadrature->spaceDim();
+ // Create arrays for querying
+ const int tensorSize = _tensorSize;
+ double_array quadPtsGlobal(numQuadPts*spaceDim);
+ double_array strainCell(numQuadPts*tensorSize);
+
+ // Get cells associated with material
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", id());
+ assert(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
+
+ // Create field to hold initial strain state.
+ delete _initialStrain; _initialStrain = 0;
+ _initialStrain = new topology::Field<topology::Mesh>(mesh);
+ assert(0 != _initialStrain);
+ const int fiberDim = numQuadPts * tensorSize;
+ assert(fiberDim > 0);
+ _initialStrain->newSection(cells, fiberDim);
+ _initialStrain->allocate();
+ _initialStrain->zero();
+ const ALE::Obj<RealSection>& initialStrainSection =
+ _initialStrain->section();
+
+ // Setup databases for querying
+ _dbInitialStrain->open();
+ switch (dimension())
+ { // switch
+ case 1: {
+ const char* strainDBValues[] = { "strain" };
+ _dbInitialStrain->queryVals(strainDBValues, tensorSize);
+ break;
+ } // case 1
+ case 2 : {
+ const char* strainDBValues[] = {
+ "strain-xx",
+ "strain-yy",
+ "strain-xy",
+ };
+ _dbInitialStrain->queryVals(strainDBValues, tensorSize);
+ break;
+ } // case 2
+ case 3 : {
+ const char* strainDBValues[] = {
+ "strain-xx",
+ "strain-yy",
+ "strain-zz",
+ "strain-xy",
+ "strain-yz",
+ "strain-xz",
+ };
+ _dbInitialStrain->queryVals(strainDBValues, tensorSize);
+ break;
+ } // case 3
+ default :
+ assert(0);
+ } // switch
+
+ assert(0 != _normalizer);
+ const double lengthScale = _normalizer->pressureScale();
+ const double pressureScale = _normalizer->pressureScale();
+
+ const ALE::Obj<RealSection>& strainSection = _initialStrain->section();
+ assert(!strainSection.isNull());
+
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter) {
+ // Compute geometry information for current cell
+ quadrature->retrieveGeometry(*c_iter);
+
+ // Dimensionalize coordinates for querying
+ const double_array& quadPtsNonDim = quadrature->quadPts();
+ quadPtsGlobal = quadPtsNonDim;
+ _normalizer->dimensionalize(&quadPtsGlobal[0], quadPtsGlobal.size(),
+ lengthScale);
+
+ // Loop over quadrature points in cell and query database
+ for (int iQuadPt=0, iCoord=0, iStrain=0;
+ iQuadPt < numQuadPts;
+ ++iQuadPt, iCoord+=spaceDim, iStrain+=tensorSize) {
+ int err = _dbInitialStrain->query(&strainCell[iStrain], tensorSize,
+ &quadPtsGlobal[iCoord], spaceDim, cs);
+ if (err) {
+ std::ostringstream msg;
+ msg << "Could not find initial strain at (";
+ for (int i=0; i < spaceDim; ++i)
+ msg << " " << quadPtsGlobal[iCoord+i];
+ msg << ") in material " << label() << "\n"
+ << "using spatial database '" << _dbInitialStrain->label() << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+ } // for
+
+ // Nondimensionalize strain
+ _normalizer->nondimensionalize(&strainCell[0], strainCell.size(),
+ pressureScale);
+
+ strainSection->updatePoint(*c_iter, &strainCell[0]);
+ } // for
+
+ // Close databases
+ _dbInitialStrain->close();
+} // _initializeInitialStrain
+
// ----------------------------------------------------------------------
-// Update properties (for next time step).
+// Update stateVars (for next time step).
void
-pylith::materials::ElasticMaterial::_updateProperties(double* const properties,
- const int totalPropsQuadPt,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
-{ // _updateProperties
-} // _updateProperties
+pylith::materials::ElasticMaterial::_updateStateVars(
+ double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
+{ // _updateStateVars
+} // _updateStateVars
// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,18 +20,10 @@
#if !defined(pylith_materials_elasticmaterial_hh)
#define pylith_materials_elasticmaterial_hh
+// Include directives ---------------------------------------------------
#include "Material.hh" // ISA Material
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class ElasticMaterial;
-
- class TestElasticMaterial; // unit testing
- } // materials
-} // pylith
-
-/// C++ object for material constitutive model.
+// ElasticMaterial ------------------------------------------------------
class pylith::materials::ElasticMaterial : public Material
{ // class ElasticMaterial
friend class TestElasticMaterial; ///< unit testing
@@ -41,36 +33,53 @@
/** Default constructor.
*
- * @param tensorSize Number of entries in stress tensor.
+ * @param dimension Spatial dimension associated with material.
+ * @param tensorSize Array of names of database values for material.
* @param numElasticConsts Number of elastic constants.
- * @param dbValues Array of names of database values for material.
- * @param InitialStateDBValues Names of initial state database values for material.
- * @param numDBValues Number of database values.
- * @param properties Array of physical property meta data.
- * @param numProperties Number of physical properties for material.
+ * @param metadata Metadata for physical properties and state variables.
*/
- ElasticMaterial(const int tensorSize,
+ ElasticMaterial(const int dimension,
+ const int tensorSize,
const int numElasticConsts,
- const char** dbValues,
- const char** initialStateDBValues,
- const int numDBValues,
- const PropMetaData* properties,
- const int numProperties);
+ const Metadata& metadata);
/// Destructor.
virtual
~ElasticMaterial(void);
- /** Get cell's property information from material's section.
+ /** Set database for initial stress state.
*
- * @param cell Finite element cell
- * @param numQuadPts Number of quadrature points
+ * @param db Spatial database.
*/
- void getPropertiesCell(const Mesh::point_type& cell,
- const int numQuadPts);
+ void dbInitialStress(spatialdata::spatialdb::SpatialDB* db);
+ /** Set database for initial strain state.
+ *
+ * @param db Spatial database.
+ */
+ void dbInitialStrain(spatialdata::spatialdb::SpatialDB* db);
+
+ /** Initialize material by getting physical property parameters from
+ * database.
+ *
+ * @param mesh Finite-element mesh.
+ * @param quadrature Quadrature for finite-element integration
+ */
+ void initialize(const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature);
+
+ /** Retrieve parameters for physical properties and state variables
+ * for cell.
+ *
+ * @param cell Finite-element cell
+ */
+ void retrievePropsAndVars(const int cell);
+
/** Compute density for cell at quadrature points.
*
+ * @pre Must call retrievePropsAndVars for cell before calling
+ * calcDensity().
+ *
* @returns Array of density values at cell's quadrature points.
*/
const double_array& calcDensity(void);
@@ -80,6 +89,9 @@
* should be set to true so that the state variables are updated
* (but not stored) when computing the stresses.
*
+ * @pre Must call retrievePropsAndVars for cell before calling
+ * calcStress().
+ *
* Size of array of stress tensors = [numQuadPts][tensorSize].
*
* Order of stresses for 3-D:
@@ -103,6 +115,9 @@
/** Compute derivative of elasticity matrix for cell at quadrature points.
*
+ * @pre Must call retrievePropsAndVars for cell before calling
+ * calcDerivElastic().
+ *
* Size of array of elasticity constants = [numQuadPts][numElasticConsts]
*
* Order of elasticity constants for 3-D:
@@ -127,24 +142,35 @@
const double_array&
calcDerivElastic(const double_array& totalStrain);
+ /** Update state variables (for next time step).
+ *
+ * @param totalStrain Total strain tensor at quadrature points
+ * [numQuadPts][tensorSize]
+ * @param cell Finite element cell
+ */
+ void updateStateVars(const double_array& totalStrain,
+ const int cell);
+
+ /** Get flag indicating whether material implements an empty
+ * _updateProperties() method.
+ *
+ * @returns False if _updateProperties() is empty, true otherwise.
+ */
+ bool hasStateVars(void) const;
+
/** Get stable time step for implicit time integration.
*
+ * @pre Must call retrievePropsAndVars for cell before calling
+ * stableTimeStep().
+ *
* Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
*
+ * @param mesh Finite-element mesh.
* @returns Time step
*/
virtual
- double stableTimeStepImplicit(void) const;
+ double stableTimeStepImplicit(const topology::Mesh& mesh);
- /** Update properties (for next time step).
- *
- * @param totalStrain Total strain tensor at quadrature points
- * [numQuadPts][tensorSize]
- * @param cell Finite element cell
- */
- void updateProperties(const double_array& totalStrain,
- const Mesh::point_type& cell);
-
/** Set whether elastic or inelastic constitutive relations are used.
*
* @param flag True to use elastic, false to use inelastic.
@@ -152,17 +178,24 @@
virtual
void useElasticBehavior(const bool flag);
- /** Get flag indicating whether material implements an empty
- * _updateProperties() method.
+ /** Get initial stress field.
*
- * @returns False if _updateProperties() is empty, true otherwise.
+ * @returns Initial stress field.
*/
- virtual
- bool usesUpdateProperties(void) const;
+ const topology::Field<topology::Mesh>& initialStressField(void) const;
+ /** Get initial strain field.
+ *
+ * @returns Initial strain field.
+ */
+ const topology::Field<topology::Mesh>& initialStrainField(void) const;
+
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
+ /// These methods must be implemented by every elasticity
+ /// constitutive model.
+
/** Compute density from properties.
*
* @param density Array for density.
@@ -172,32 +205,43 @@
virtual
void _calcDensity(double* const density,
const double* properties,
- const int numProperties) = 0;
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) = 0;
- /** Compute stress tensor from properties. If the state variables
- * are from the previous time step, then the computeStateVars flag
- * should be set to true so that the state variables are updated
- * (but not stored) when computing the stresses.
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state variable values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
virtual
void _calcStress(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars) = 0;
/** Compute derivatives of elasticity matrix from properties.
@@ -206,105 +250,167 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state variable values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
virtual
void _calcElasticConsts(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize) = 0;
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize) = 0;
- /** Get stable time step for implicit time integration.
+ /** Update state variables (for next time step).
*
- * @returns Time step
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
virtual
- double _stableTimeStepImplicit(const double* properties,
- const int numProperties) const = 0;
+ void _updateStateVars(double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
- /** Update properties (for next time step).
+ /** Get stable time step for implicit time integration.
*
* @param properties Properties at location.
* @param numProperties Number of properties.
- * @param totalStrain Total strain at location.
- * @param strainSize Size of strain tensor.
- * @param initialState Initial state variable values.
- * @param initialStateSize Size of initial state array.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
*/
virtual
- void _updateProperties(double* const properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const = 0;
- // NOT IMPLEMENTED ////////////////////////////////////////////////////
+ // PRIVATE METHODS ////////////////////////////////////////////////////
private :
- /// Not implemented
- ElasticMaterial(const ElasticMaterial& m);
+ /** Allocate cell arrays.
+ *
+ * @param numQuadPts Number of quadrature points.
+ */
+ void _allocateCellArrays(void);
- /// Not implemented
- const ElasticMaterial& operator=(const ElasticMaterial& m);
+ /** Initialize initial stress field.
+ *
+ * @param mesh Finite-element mesh.
+ * @param quadrature Quadrature for finite-element integration
+ */
+ void _initializeInitialStress(const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature);
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
-
- /** Get properties for cell.
+ /** Initialize initial strain field.
*
- * @param cell Finite-element cell
+ * @param mesh Finite-element mesh.
+ * @param quadrature Quadrature for finite-element integration
*/
- void _getProperties(const Mesh::point_type& cell);
+ void _initializeInitialStrain(const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature);
// PRIVATE MEMBERS ////////////////////////////////////////////////////
private :
- int _numQuadPts; ///< Number of quadrature points
- int _numElasticConsts; ///< Number of elastic constants.
+ /// Database for initial stress tensor;
+ spatialdata::spatialdb::SpatialDB* _dbInitialStress;
+ /// Database for initial strain tensor;
+ spatialdata::spatialdb::SpatialDB* _dbInitialStrain;
+
+ /// Initial stress field.
+ topology::Field<topology::Mesh>* _initialStress;
+
+ /// Initial strain field.
+ topology::Field<topology::Mesh>* _initialStrain;
+
/** Properties at quadrature points for current cell.
*
- * size = numQuadPts*numPropsQuadPt
- * index = iQuadPt*iParam*iValue
+ * size = numQuadPts * numPropsQuadPt
+ * index = iQuadPt * numPropsQuadPt + iPropQuadPt
*/
double_array _propertiesCell;
- /** Initial state values at quadrature points for current cell.
+ /** State variables at quadrature points for current cell.
*
- * size = numQuadPts*initialStateSize
- * index = iQuadPt*iValue
+ * size = numQuadPts * numVarsQuadPt
+ * index = iQuadPt * numVarsQuadPt + iStateVar
*/
- double_array _initialStateCell;
+ double_array _stateVarsCell;
+ /** Initial stress state for current cell.
+ *
+ * size = numQuadPts * tensorSize
+ * index = iQuadPt * tensorSize + iComponent
+ */
+ double_array _initialStressCell;
+
+ /** Initial strain state for current cell.
+ *
+ * size = numQuadPts * tensorSize
+ * index = iQuadPt * tensorSize + iComponent
+ */
+ double_array _initialStrainCell;
+
/** Density value at quadrature points for current cell.
*
* size = numQuadPts
* index = iQuadPt
*/
- double_array _density;
+ double_array _densityCell;
/** Stress tensor at quadrature points for current cell.
*
- * size = numQuadPts*tensorSize
- * index = *iQuadPt*tensorSize + iStress
+ * size = numQuadPts * tensorSize
+ * index = iQuadPt * tensorSize + iStress
*/
- double_array _stress;
+ double_array _stressCell;
/** Elasticity matrix at quadrature points for current cell.
*
- * size = numQuadPts*numElasticConsts
- * index = iQuadPt*numElasticConsts+iConstant
+ * size = numQuadPts * numElasticConsts
+ * index = iQuadPt * numElasticConsts + iConstant
*/
- double_array _elasticConsts;
+ double_array _elasticConstsCell;
+ int _numQuadPts; ///< Number of quadrature points
+ const int _numElasticConsts; ///< Number of elastic constants.
+
+ // NOT IMPLEMENTED ////////////////////////////////////////////////////
+private :
+
+ ElasticMaterial(const ElasticMaterial&); ///< Not implemented.
+ const ElasticMaterial& operator=(const ElasticMaterial&); ///< Not implemented
+
}; // class ElasticMaterial
#include "ElasticMaterial.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticMaterial.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,20 @@
#error "ElasticMaterial.icc can only be included from ElasticMaterial.hh"
#endif
+// Set database for initial stress state.
+inline
+void
+pylith::materials::ElasticMaterial::dbInitialStress(spatialdata::spatialdb::SpatialDB* db) {
+ _dbInitialStress = db;
+}
+
+// Set database for initial strain state.
+inline
+void
+pylith::materials::ElasticMaterial::dbInitialStrain(spatialdata::spatialdb::SpatialDB* db) {
+ _dbInitialStrain = db;
+}
+
// Set whether elastic or inelastic constitutive relations are used.
inline
void
@@ -24,8 +38,8 @@
// _updateProperties() method.
inline
bool
-pylith::materials::ElasticMaterial::usesUpdateProperties(void) const {
- return false;
+pylith::materials::ElasticMaterial::hasStateVars(void) const {
+ return _numVarsQuadPt > 0;
} // usesUpdateProperties
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,9 @@
#include "ElasticPlaneStrain.hh" // implementation of object methods
+#include "Metadata.hh" // USES Metadata
+
+#include "pylith/utils/array.hh" // USES double_array
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -24,63 +27,69 @@
#include <sstream> // USES std::ostringstream
#include <stdexcept> // USES std::runtime_error
-
// ----------------------------------------------------------------------
namespace pylith {
namespace materials {
namespace _ElasticPlaneStrain {
- /// Number of entries in stress tensor.
+ // Dimension of material.
+ const int dimension = 2;
+
+ // Number of entries in stress tensor.
const int tensorSize = 3;
- /// Number of elastic constants (for general 3-D elastic material)
+ // Number of elastic constants (for general 3-D elastic material)
const int numElasticConsts = 6;
- /// Number of physical properties.
+ // Number of physical properties.
const int numProperties = 3;
- /// Physical properties.
- const Material::PropMetaData properties[] = {
- { "density", 1, OTHER_FIELD },
- { "mu", 1, OTHER_FIELD },
- { "lambda", 1, OTHER_FIELD },
+ // Physical properties.
+ const Metadata::ParamDescription properties[] = {
+ { "density", 1, pylith::topology::FieldBase::SCALAR },
+ { "mu", 1, pylith::topology::FieldBase::SCALAR },
+ { "lambda", 1, pylith::topology::FieldBase::SCALAR },
};
- /// Indices of physical properties
- const int pidDensity = 0;
- const int pidMu = pidDensity + 1;
- const int pidLambda = pidMu + 1;
- /// Values expected in spatial database
- const int numDBValues = 3;
- const char* namesDBValues[] = { "density", "vs", "vp" };
+ // Values expected in spatial database
+ const int numDBProperties = 3;
+ const char* dbProperties[] = { "density", "vs", "vp" };
- /// Indices of database values
- const int didDensity = 0;
- const int didVs = 1;
- const int didVp = 2;
-
- /// Initial state values expected in spatial database
- const int numInitialStateDBValues = tensorSize;
- const char* namesInitialStateDBValues[] = { "stress_xx", "stress_yy",
- "stress_xy" };
-
} // _ElasticPlaneStrain
} // materials
} // pylith
+// Indices of physical properties
+const int pylith::materials::ElasticPlaneStrain::p_density = 0;
+const int pylith::materials::ElasticPlaneStrain::p_mu =
+ pylith::materials::ElasticPlaneStrain::p_density + 1;
+
+const int pylith::materials::ElasticPlaneStrain::p_lambda =
+ pylith::materials::ElasticPlaneStrain::p_mu + 1;
+
+// Indices of database values (order must match dbProperties)
+const int pylith::materials::ElasticPlaneStrain::db_density = 0;
+
+const int pylith::materials::ElasticPlaneStrain::db_vs =
+ pylith::materials::ElasticPlaneStrain::db_density + 1;
+
+const int pylith::materials::ElasticPlaneStrain::db_vp =
+ pylith::materials::ElasticPlaneStrain::db_vs + 1;
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::materials::ElasticPlaneStrain::ElasticPlaneStrain(void) :
- ElasticMaterial(_ElasticPlaneStrain::tensorSize,
+ ElasticMaterial(_ElasticPlaneStrain::dimension,
+ _ElasticPlaneStrain::tensorSize,
_ElasticPlaneStrain::numElasticConsts,
- _ElasticPlaneStrain::namesDBValues,
- _ElasticPlaneStrain::namesInitialStateDBValues,
- _ElasticPlaneStrain::numDBValues,
- _ElasticPlaneStrain::properties,
- _ElasticPlaneStrain::numProperties)
+ Metadata(_ElasticPlaneStrain::properties,
+ _ElasticPlaneStrain::numProperties,
+ _ElasticPlaneStrain::dbProperties,
+ _ElasticPlaneStrain::numDBProperties,
+ 0, 0,
+ 0, 0))
{ // constructor
- _dimension = 2;
} // constructor
// ----------------------------------------------------------------------
@@ -98,11 +107,11 @@
{ // _dbToProperties
assert(0 != propValues);
const int numDBValues = dbValues.size();
- assert(_ElasticPlaneStrain::numDBValues == numDBValues);
+ assert(_ElasticPlaneStrain::numDBProperties == numDBValues);
- const double density = dbValues[_ElasticPlaneStrain::didDensity];
- const double vs = dbValues[_ElasticPlaneStrain::didVs];
- const double vp = dbValues[_ElasticPlaneStrain::didVp];
+ const double density = dbValues[db_density];
+ const double vs = dbValues[db_vs];
+ const double vp = dbValues[db_vp];
if (density <= 0.0 || vs <= 0.0 || vp <= 0.0) {
std::ostringstream msg;
@@ -125,11 +134,11 @@
<< "vs: " << vs << "\n";
throw std::runtime_error(msg.str());
} // if
-
- propValues[_ElasticPlaneStrain::pidDensity] = density;
- propValues[_ElasticPlaneStrain::pidMu] = mu;
- propValues[_ElasticPlaneStrain::pidLambda] = lambda;
+ propValues[p_density] = density;
+ propValues[p_mu] = mu;
+ propValues[p_lambda] = lambda;
+
PetscLogFlops(6);
} // _dbToProperties
@@ -145,15 +154,15 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticPlaneStrain::pidDensity] =
- _normalizer->nondimensionalize(values[_ElasticPlaneStrain::pidDensity],
- densityScale);
- values[_ElasticPlaneStrain::pidMu] =
- _normalizer->nondimensionalize(values[_ElasticPlaneStrain::pidMu],
- pressureScale);
- values[_ElasticPlaneStrain::pidLambda] =
- _normalizer->nondimensionalize(values[_ElasticPlaneStrain::pidLambda],
- pressureScale);
+
+ values[p_density] =
+ _normalizer->nondimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->nondimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->nondimensionalize(values[p_lambda], pressureScale);
+
+ PetscLogFlops(3);
} // _nondimProperties
// ----------------------------------------------------------------------
@@ -168,129 +177,118 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticPlaneStrain::pidDensity] =
- _normalizer->dimensionalize(values[_ElasticPlaneStrain::pidDensity],
- densityScale);
- values[_ElasticPlaneStrain::pidMu] =
- _normalizer->dimensionalize(values[_ElasticPlaneStrain::pidMu],
- pressureScale);
- values[_ElasticPlaneStrain::pidLambda] =
- _normalizer->dimensionalize(values[_ElasticPlaneStrain::pidLambda],
- pressureScale);
-} // _dimProperties
-// ----------------------------------------------------------------------
-// Nondimensionalize initial state.
-void
-pylith::materials::ElasticPlaneStrain::_nondimInitState(double* const values,
- const int nvalues) const
-{ // _nondimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticPlaneStrain::numInitialStateDBValues);
+ values[p_density] =
+ _normalizer->dimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->dimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->dimensionalize(values[p_lambda], pressureScale);
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->nondimensionalize(values, nvalues, pressureScale);
-} // _nondimInitState
+ PetscLogFlops(3);
+} // _dimProperties
// ----------------------------------------------------------------------
-// Dimensionalize initial state.
-void
-pylith::materials::ElasticPlaneStrain::_dimInitState(double* const values,
- const int nvalues) const
-{ // _dimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticPlaneStrain::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->dimensionalize(values, nvalues, pressureScale);
-} // _dimInitState
-
-// ----------------------------------------------------------------------
// Compute density at location from properties.
void
-pylith::materials::ElasticPlaneStrain::_calcDensity(
- double* const density,
- const double* properties,
- const int numProperties)
+pylith::materials::ElasticPlaneStrain::_calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars)
{ // calcDensity
assert(0 != density);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
- density[0] = properties[_ElasticPlaneStrain::pidDensity];
+ density[0] = properties[p_density];
} // calcDensity
// ----------------------------------------------------------------------
// Compute stress tensor at location from properties.
void
-pylith::materials::ElasticPlaneStrain::_calcStress(
- double* const stress,
- const int stressSize,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize,
- const bool computeStateVars)
+pylith::materials::ElasticPlaneStrain::_calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars)
{ // _calcStress
assert(0 != stress);
assert(_ElasticPlaneStrain::tensorSize == stressSize);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticPlaneStrain::tensorSize == strainSize);
- assert(_ElasticPlaneStrain::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticPlaneStrain::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticPlaneStrain::tensorSize == initialStrainSize);
- const double density = properties[_ElasticPlaneStrain::pidDensity];
- const double mu = properties[_ElasticPlaneStrain::pidMu];
- const double lambda = properties[_ElasticPlaneStrain::pidLambda];
-
- const double mu2 = 2.0 * mu;
-
- const double e11 = totalStrain[0];
- const double e22 = totalStrain[1];
- const double e12 = totalStrain[2];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
+ const double mu2 = 2.0*mu;
+
+ const double e11 = totalStrain[0] - initialStrain[0];
+ const double e22 = totalStrain[1] - initialStrain[1];
+ const double e12 = totalStrain[2] - initialStrain[2];
+
const double s12 = lambda * (e11 + e22);
- stress[0] = s12 + mu2*e11 + initialState[0];
- stress[1] = s12 + mu2*e22 + initialState[1];
- stress[2] = mu2 * e12 + initialState[2];
+ stress[0] = s12 + mu2*e11 + initialStress[0];
+ stress[1] = s12 + mu2*e22 + initialStress[1];
+ stress[2] = mu2 * e12 + initialStress[2];
- PetscLogFlops(11);
+ PetscLogFlops(14);
} // _calcStress
// ----------------------------------------------------------------------
// Compute elastic constants at location from properties.
void
pylith::materials::ElasticPlaneStrain::_calcElasticConsts(
- double* const elasticConsts,
- const int numElasticConsts,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // calcElasticConsts
assert(0 != elasticConsts);
assert(_ElasticPlaneStrain::numElasticConsts == numElasticConsts);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticPlaneStrain::tensorSize == strainSize);
- assert(_ElasticPlaneStrain::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticPlaneStrain::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticPlaneStrain::tensorSize == initialStrainSize);
+
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
- const double density = properties[_ElasticPlaneStrain::pidDensity];
- const double mu = properties[_ElasticPlaneStrain::pidMu];
- const double lambda = properties[_ElasticPlaneStrain::pidLambda];
-
const double mu2 = 2.0 * mu;
const double lambda2mu = lambda + mu2;
-
+
elasticConsts[0] = lambda2mu; // C1111
elasticConsts[1] = lambda; // C1122
elasticConsts[2] = 0; // C1112
@@ -304,8 +302,11 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
double
-pylith::materials::ElasticPlaneStrain::_stableTimeStepImplicit(const double* properties,
- const int numProperties) const
+pylith::materials::ElasticPlaneStrain::_stableTimeStepImplicit(
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const
{ // _stableTimeStepImplicit
return pylith::PYLITH_MAXDOUBLE;
} // _stableTimeStepImplicit
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStrain.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,22 +20,20 @@
* internally using density, lambda, and mu, which are directly
* related to the elasticity constants used in the finite-element
* integration.
+ *
+ * $\sigma - \sigma_0 = C (\epsilon - \epsilon_0)
+ *
+ * This implies that when $\epsilon = \epsilon_0$, $\sigma =
+ * \sigma_0$.
*/
#if !defined(pylith_materials_elasticplanestrain_hh)
#define pylith_materials_elasticplanestrain_hh
-#include "ElasticMaterial.hh"
+// Include directives ---------------------------------------------------
+#include "ElasticMaterial.hh" // ISA ElasticMaterial
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class ElasticPlaneStrain;
- class TestElasticPlaneStrain; // unit testing
- } // materials
-} // pylith
-
-/// 3-D, isotropic, linear elastic material.
+// ElasticPlaneStrain ---------------------------------------------------
class pylith::materials::ElasticPlaneStrain : public ElasticMaterial
{ // class ElasticPlaneStrain
friend class TestElasticPlaneStrain; // unit testing
@@ -79,22 +77,6 @@
void _dimProperties(double* const values,
const int nvalues) const;
- /** Nondimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _nondimInitState(double* const values,
- const int nvalues) const;
-
- /** Dimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _dimInitState(double* const values,
- const int nvalues) const;
-
/** Compute density from properties.
*
* @param density Array for density.
@@ -103,31 +85,42 @@
*/
void _calcDensity(double* const density,
const double* properties,
- const int numProperties);
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
- /** Compute stress tensor from properties. If the state variables
- * are from the previous time step, then the computeStateVars flag
- * should be set to true so that the state variables are updated
- * (but not stored) when computing the stresses.
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStress(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute derivatives of elasticity matrix from properties.
@@ -136,27 +129,52 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConsts(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Get stable time step for implicit time integration.
*
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
* @returns Time step
*/
double _stableTimeStepImplicit(const double* properties,
- const int numProperties) const;
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ static const int p_density;
+ static const int p_mu;
+ static const int p_lambda;
+ static const int db_density;
+ static const int db_vs;
+ static const int db_vp;
+
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,9 @@
#include "ElasticPlaneStress.hh" // implementation of object methods
+#include "Metadata.hh" // USES Metadata
+
+#include "pylith/utils/array.hh" // USES double_array
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -29,56 +32,64 @@
namespace materials {
namespace _ElasticPlaneStress {
- /// Number of entries in stress tensor.
+ // Dimension of material.
+ const int dimension = 2;
+
+ // Number of entries in stress tensor.
const int tensorSize = 3;
- /// Number of elastic constants (for general 3-D elastic material)
+ // Number of elastic constants (for general 3-D elastic material)
const int numElasticConsts = 6;
- /// Number of physical properties.
+ // Number of physical properties.
const int numProperties = 3;
- /// Physical properties.
- const Material::PropMetaData properties[] = {
- { "density", 1, OTHER_FIELD },
- { "mu", 1, OTHER_FIELD },
- { "lambda", 1, OTHER_FIELD },
+ // Physical properties.
+ const Metadata::ParamDescription properties[] = {
+ { "density", 1, pylith::topology::FieldBase::SCALAR },
+ { "mu", 1, pylith::topology::FieldBase::SCALAR },
+ { "lambda", 1, pylith::topology::FieldBase::SCALAR },
};
- /// Indices of physical properties
- const int pidDensity = 0;
- const int pidMu = pidDensity + 1;
- const int pidLambda = pidMu + 1;
- /// Values expected in spatial database
- const int numDBValues = 3;
- const char* namesDBValues[] = { "density", "vs", "vp" };
+ // Values expected in spatial database
+ const int numDBProperties = 3;
+ const char* dbProperties[] = { "density", "vs", "vp" };
- /// Indices of database values
- const int didDensity = 0;
- const int didVs = 1;
- const int didVp = 2;
-
- /// Initial state values expected in spatial database
- const int numInitialStateDBValues = tensorSize;
- const char* namesInitialStateDBValues[] = { "stress_xx", "stress_yy",
- "stress_xy" };
-
} // _ElasticPlaneStress
} // materials
} // pylith
+// Indices of physical properties
+const int pylith::materials::ElasticPlaneStress::p_density = 0;
+
+const int pylith::materials::ElasticPlaneStress::p_mu =
+ pylith::materials::ElasticPlaneStress::p_density + 1;
+
+const int pylith::materials::ElasticPlaneStress::p_lambda =
+ pylith::materials::ElasticPlaneStress::p_mu + 1;
+
+// Indices of database values (order must match dbProperties)
+const int pylith::materials::ElasticPlaneStress::db_density = 0;
+
+const int pylith::materials::ElasticPlaneStress::db_vs =
+ pylith::materials::ElasticPlaneStress::db_density + 1;
+
+const int pylith::materials::ElasticPlaneStress::db_vp =
+ pylith::materials::ElasticPlaneStress::db_vs + 1;
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::materials::ElasticPlaneStress::ElasticPlaneStress(void) :
- ElasticMaterial(_ElasticPlaneStress::tensorSize,
+ ElasticMaterial(_ElasticPlaneStress::dimension,
+ _ElasticPlaneStress::tensorSize,
_ElasticPlaneStress::numElasticConsts,
- _ElasticPlaneStress::namesDBValues,
- _ElasticPlaneStress::namesInitialStateDBValues,
- _ElasticPlaneStress::numDBValues,
- _ElasticPlaneStress::properties,
- _ElasticPlaneStress::numProperties)
+ Metadata(_ElasticPlaneStress::properties,
+ _ElasticPlaneStress::numProperties,
+ _ElasticPlaneStress::dbProperties,
+ _ElasticPlaneStress::numDBProperties,
+ 0, 0,
+ 0, 0))
{ // constructor
- _dimension = 2;
} // constructor
// ----------------------------------------------------------------------
@@ -96,11 +107,11 @@
{ // _dbToProperties
assert(0 != propValues);
const int numDBValues = dbValues.size();
- assert(_ElasticPlaneStress::numDBValues == numDBValues);
+ assert(_ElasticPlaneStress::numDBProperties == numDBValues);
- const double density = dbValues[_ElasticPlaneStress::didDensity];
- const double vs = dbValues[_ElasticPlaneStress::didVs];
- const double vp = dbValues[_ElasticPlaneStress::didVp];
+ const double density = dbValues[db_density];
+ const double vs = dbValues[db_vs];
+ const double vp = dbValues[db_vp];
if (density <= 0.0 || vs <= 0.0 || vp <= 0.0) {
std::ostringstream msg;
@@ -124,9 +135,9 @@
throw std::runtime_error(msg.str());
} // if
- propValues[_ElasticPlaneStress::pidDensity] = density;
- propValues[_ElasticPlaneStress::pidMu] = mu;
- propValues[_ElasticPlaneStress::pidLambda] = lambda;
+ propValues[p_density] = density;
+ propValues[p_mu] = mu;
+ propValues[p_lambda] = lambda;
PetscLogFlops(6);
} // _dbToProperties
@@ -143,16 +154,14 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticPlaneStress::pidDensity] =
- _normalizer->nondimensionalize(values[_ElasticPlaneStress::pidDensity],
- densityScale);
- values[_ElasticPlaneStress::pidMu] =
- _normalizer->nondimensionalize(values[_ElasticPlaneStress::pidMu],
- pressureScale);
- values[_ElasticPlaneStress::pidLambda] =
- _normalizer->nondimensionalize(values[_ElasticPlaneStress::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->nondimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->nondimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->nondimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _nondimProperties
@@ -168,63 +177,32 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticPlaneStress::pidDensity] =
- _normalizer->dimensionalize(values[_ElasticPlaneStress::pidDensity],
- densityScale);
- values[_ElasticPlaneStress::pidMu] =
- _normalizer->dimensionalize(values[_ElasticPlaneStress::pidMu],
- pressureScale);
- values[_ElasticPlaneStress::pidLambda] =
- _normalizer->dimensionalize(values[_ElasticPlaneStress::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->dimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->dimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->dimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _dimProperties
// ----------------------------------------------------------------------
-// Nondimensionalize initial state.
-void
-pylith::materials::ElasticPlaneStress::_nondimInitState(double* const values,
- const int nvalues) const
-{ // _nondimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticPlaneStress::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->nondimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _nondimInitState
-
-// ----------------------------------------------------------------------
-// Dimensionalize initial state.
-void
-pylith::materials::ElasticPlaneStress::_dimInitState(double* const values,
- const int nvalues) const
-{ // _dimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticPlaneStress::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->dimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _dimInitState
-
-// ----------------------------------------------------------------------
// Compute density at location from properties.
void
pylith::materials::ElasticPlaneStress::_calcDensity(double* const density,
const double* properties,
- const int numProperties)
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars)
{ // calcDensity
assert(0 != density);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
- density[0] = properties[_ElasticPlaneStress::pidDensity];
+ density[0] = properties[p_density];
} // calcDensity
// ----------------------------------------------------------------------
@@ -234,64 +212,82 @@
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars)
{ // _calcStress
assert(0 != stress);
assert(_ElasticPlaneStress::tensorSize == stressSize);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticPlaneStress::tensorSize == strainSize);
- assert(_ElasticPlaneStress::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticPlaneStress::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticPlaneStress::tensorSize == initialStrainSize);
- const double density = properties[_ElasticPlaneStress::pidDensity];
- const double mu = properties[_ElasticPlaneStress::pidMu];
- const double lambda = properties[_ElasticPlaneStress::pidLambda];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
const double mu2 = 2.0 * mu;
const double lambda2mu = lambda + mu2;
const double lambdamu = lambda + mu;
- const double e11 = totalStrain[0];
- const double e22 = totalStrain[1];
- const double e12 = totalStrain[2];
+ const double e11 = totalStrain[0] - initialStrain[0];
+ const double e22 = totalStrain[1] - initialStrain[1];
+ const double e12 = totalStrain[2] - initialStrain[2];
- stress[0] = (2.0*mu2*lambdamu * e11 + mu2*lambda * e22) / lambda2mu + initialState[0];
- stress[1] = (mu2*lambda * e11 + 2.0*mu2*lambdamu * e22) / lambda2mu + initialState[1];
- stress[2] = mu2 * e12 + initialState[2];
+ stress[0] =
+ (2.0*mu2*lambdamu * e11 + mu2*lambda * e22) / lambda2mu + initialStress[0];
+ stress[1] =
+ (mu2*lambda * e11 + 2.0*mu2*lambdamu * e22) / lambda2mu + initialStress[1];
+ stress[2] = mu2 * e12 + initialStress[2];
- PetscLogFlops(18);
+ PetscLogFlops(21);
} // _calcStress
// ----------------------------------------------------------------------
// Compute density at location from properties.
void
pylith::materials::ElasticPlaneStress::_calcElasticConsts(
- double* const elasticConsts,
- const int numElasticConsts,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // calcElasticConsts
assert(0 != elasticConsts);
assert(_ElasticPlaneStress::numElasticConsts == numElasticConsts);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticPlaneStress::tensorSize == strainSize);
- assert(_ElasticPlaneStress::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticPlaneStress::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticPlaneStress::tensorSize == initialStrainSize);
+
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
- const double density = properties[_ElasticPlaneStress::pidDensity];
- const double mu = properties[_ElasticPlaneStress::pidMu];
- const double lambda = properties[_ElasticPlaneStress::pidLambda];
-
const double mu2 = 2.0 * mu;
const double lambda2mu = lambda + mu2;
const double c11 = 2.0 * mu2 * (lambda + mu) / lambda2mu;
@@ -309,8 +305,11 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
double
-pylith::materials::ElasticPlaneStress::_stableTimeStepImplicit(const double* properties,
- const int numProperties) const
+pylith::materials::ElasticPlaneStress::_stableTimeStepImplicit(
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const
{ // _stableTimeStepImplicit
return pylith::PYLITH_MAXDOUBLE;
} // _stableTimeStepImplicit
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticPlaneStress.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,22 +20,20 @@
* internally using density, lambda, and mu, which are directly
* related to the elasticity constants used in the finite-element
* integration.
+ *
+ * $\sigma - \sigma_0 = C (\epsilon - \epsilon_0)
+ *
+ * This implies that when $\epsilon = \epsilon_0$, $\sigma =
+ * \sigma_0$.
*/
#if !defined(pylith_materials_elasticplanestress_hh)
#define pylith_materials_elasticplanestress_hh
-#include "ElasticMaterial.hh"
+// Include directives ---------------------------------------------------
+#include "ElasticMaterial.hh" // ISA ElasticMaterial
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class ElasticPlaneStress;
- class TestElasticPlaneStress; // unit testing
- } // materials
-} // pylith
-
-/// 2-D, isotropic, linear elastic material for plane stress.
+// ElasticPlaneStrain ---------------------------------------------------
class pylith::materials::ElasticPlaneStress : public ElasticMaterial
{ // class ElasticPlaneStress
friend class TestElasticPlaneStress; // unit testing
@@ -60,7 +58,7 @@
* @param propValues Array of property values.
* @param dbValues Array of database values.
*/
- void _dbToProperties(double* const propertyValues,
+ void _dbToProperties(double* const propValues,
const double_array& dbValues) const;
/** Nondimensionalize properties.
@@ -79,22 +77,6 @@
void _dimProperties(double* const values,
const int nvalues) const;
- /** Nondimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _nondimInitState(double* const values,
- const int nvalues) const;
-
- /** Dimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _dimInitState(double* const values,
- const int nvalues) const;
-
/** Compute density from properties.
*
* @param density Array for density.
@@ -103,31 +85,42 @@
*/
void _calcDensity(double* const density,
const double* properties,
- const int numProperties);
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
- /** Compute stress tensor from properties. If the state variables
- * are from the previous time step, then the computeStateVars flag
- * should be set to true so that the state variables are updated
- * (but not stored) when computing the stresses.
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStress(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute derivatives of elasticity matrix from properties.
@@ -136,27 +129,52 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConsts(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Get stable time step for implicit time integration.
*
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
* @returns Time step
*/
double _stableTimeStepImplicit(const double* properties,
- const int numProperties) const;
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ static const int p_density;
+ static const int p_mu;
+ static const int p_lambda;
+ static const int db_density;
+ static const int db_vs;
+ static const int db_vp;
+
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,9 @@
#include "ElasticStrain1D.hh" // implementation of object methods
+#include "Metadata.hh" // USES Metadata
+
+#include "pylith/utils/array.hh" // USES double_array
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -21,12 +24,17 @@
#include "petsc.h" // USES PetscLogFlops
#include <cassert> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
namespace pylith {
namespace materials {
namespace _ElasticStrain1D {
+ // Dimension of material.
+ const int dimension = 1;
+
/// Number of entries in stress tensor.
const int tensorSize = 1;
@@ -36,47 +44,52 @@
/// Number of physical properties.
const int numProperties = 3;
- /// Physical properties.
- const Material::PropMetaData properties[] = {
- { "density", 1, OTHER_FIELD },
- { "mu", 1, OTHER_FIELD },
- { "lambda", 1, OTHER_FIELD },
+ // Physical properties.
+ const Metadata::ParamDescription properties[] = {
+ { "density", 1, pylith::topology::FieldBase::SCALAR },
+ { "mu", 1, pylith::topology::FieldBase::SCALAR },
+ { "lambda", 1, pylith::topology::FieldBase::SCALAR },
};
- /// Indices of physical properties
- const int pidDensity = 0;
- const int pidMu = pidDensity + 1;
- const int pidLambda = pidMu + 1;
- /// Values expected in spatial database
- const int numDBValues = 3;
- const char* namesDBValues[] = { "density", "vs", "vp" };
+ // Values expected in spatial database
+ const int numDBProperties = 3;
+ const char* dbProperties[] = { "density", "vs", "vp" };
- /// Indices of database values
- const int didDensity = 0;
- const int didVs = 1;
- const int didVp = 2;
-
- /// Initial state values expected in spatial database.
- const int numInitialStateDBValues = tensorSize;
- const char* namesInitialStateDBValues[] = { "stress_xx" };
-
} // _ElasticStrain1D
} // materials
} // pylith
+// Indices of physical properties
+const int pylith::materials::ElasticStrain1D::p_density = 0;
+const int pylith::materials::ElasticStrain1D::p_mu =
+ pylith::materials::ElasticStrain1D::p_density + 1;
+
+const int pylith::materials::ElasticStrain1D::p_lambda =
+ pylith::materials::ElasticStrain1D::p_mu + 1;
+
+// Indices of database values (order must match dbProperties)
+const int pylith::materials::ElasticStrain1D::db_density = 0;
+
+const int pylith::materials::ElasticStrain1D::db_vs =
+ pylith::materials::ElasticStrain1D::db_density + 1;
+
+const int pylith::materials::ElasticStrain1D::db_vp =
+ pylith::materials::ElasticStrain1D::db_vs + 1;
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::materials::ElasticStrain1D::ElasticStrain1D(void) :
- ElasticMaterial(_ElasticStrain1D::tensorSize,
+ ElasticMaterial(_ElasticStrain1D::dimension,
+ _ElasticStrain1D::tensorSize,
_ElasticStrain1D::numElasticConsts,
- _ElasticStrain1D::namesDBValues,
- _ElasticStrain1D::namesInitialStateDBValues,
- _ElasticStrain1D::numDBValues,
- _ElasticStrain1D::properties,
- _ElasticStrain1D::numProperties)
+ Metadata(_ElasticStrain1D::properties,
+ _ElasticStrain1D::numProperties,
+ _ElasticStrain1D::dbProperties,
+ _ElasticStrain1D::numDBProperties,
+ 0, 0,
+ 0, 0))
{ // constructor
- _dimension = 1;
} // constructor
// ----------------------------------------------------------------------
@@ -94,12 +107,12 @@
{ // _dbToProperties
assert(0 != propValues);
const int numDBValues = dbValues.size();
- assert(_ElasticStrain1D::numDBValues == numDBValues);
+ assert(_ElasticStrain1D::numDBProperties == numDBValues);
- const double density = dbValues[_ElasticStrain1D::didDensity];
- const double vp = dbValues[_ElasticStrain1D::didVp];
- const double vs = dbValues[_ElasticStrain1D::didVs];
-
+ const double density = dbValues[db_density];
+ const double vs = dbValues[db_vs];
+ const double vp = dbValues[db_vp];
+
if (density <= 0.0 || vs <= 0.0 || vp <= 0.0) {
std::ostringstream msg;
msg << "Spatial database returned nonpositive value for physical "
@@ -122,9 +135,9 @@
throw std::runtime_error(msg.str());
} // if
- propValues[_ElasticStrain1D::pidDensity] = density;
- propValues[_ElasticStrain1D::pidMu] = mu;
- propValues[_ElasticStrain1D::pidLambda] = lambda;
+ propValues[p_density] = density;
+ propValues[p_mu] = mu;
+ propValues[p_lambda] = lambda;
PetscLogFlops(6);
} // _dbToProperties
@@ -141,16 +154,14 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticStrain1D::pidDensity] =
- _normalizer->nondimensionalize(values[_ElasticStrain1D::pidDensity],
- densityScale);
- values[_ElasticStrain1D::pidMu] =
- _normalizer->nondimensionalize(values[_ElasticStrain1D::pidMu],
- pressureScale);
- values[_ElasticStrain1D::pidLambda] =
- _normalizer->nondimensionalize(values[_ElasticStrain1D::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->nondimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->nondimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->nondimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _nondimProperties
@@ -166,121 +177,105 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticStrain1D::pidDensity] =
- _normalizer->dimensionalize(values[_ElasticStrain1D::pidDensity],
- densityScale);
- values[_ElasticStrain1D::pidMu] =
- _normalizer->dimensionalize(values[_ElasticStrain1D::pidMu],
- pressureScale);
- values[_ElasticStrain1D::pidLambda] =
- _normalizer->dimensionalize(values[_ElasticStrain1D::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->dimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->dimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->dimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _dimProperties
// ----------------------------------------------------------------------
-// Nondimensionalize initial state.
-void
-pylith::materials::ElasticStrain1D::_nondimInitState(double* const values,
- const int nvalues) const
-{ // _nondimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticStrain1D::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->nondimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _nondimInitState
-
-// ----------------------------------------------------------------------
-// Dimensionalize initial state.
-void
-pylith::materials::ElasticStrain1D::_dimInitState(double* const values,
- const int nvalues) const
-{ // _dimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticStrain1D::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->dimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _dimInitState
-
-// ----------------------------------------------------------------------
// Compute density at location from properties.
void
pylith::materials::ElasticStrain1D::_calcDensity(double* const density,
const double* properties,
- const int numProperties)
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars)
{ // _calcDensity
assert(0 != density);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
- density[0] = properties[_ElasticStrain1D::pidDensity];
+ density[0] = properties[p_density];
} // _calcDensity
// ----------------------------------------------------------------------
// Compute stress tensor at location from properties.
void
-pylith::materials::ElasticStrain1D::_calcStress(
- double* const stress,
- const int stressSize,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize,
- const bool computeStateVars)
+pylith::materials::ElasticStrain1D::_calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars)
{ // _calcStress
assert(0 != stress);
assert(_ElasticStrain1D::tensorSize == stressSize);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticStrain1D::tensorSize == strainSize);
- assert(_ElasticStrain1D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticStrain1D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticStrain1D::tensorSize == initialStrainSize);
- const double density = properties[_ElasticStrain1D::pidDensity];
- const double lambda = properties[_ElasticStrain1D::pidLambda];
- const double mu = properties[_ElasticStrain1D::pidMu];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
- const double e11 = totalStrain[0];
- stress[0] = (lambda + 2.0*mu) * e11 + initialState[0];
+ const double e11 = totalStrain[0] - initialStrain[0];
+ stress[0] = (lambda + 2.0*mu) * e11 + initialStress[0];
- PetscLogFlops(4);
+ PetscLogFlops(5);
} // _calcStress
// ----------------------------------------------------------------------
// Compute derivative of elasticity matrix at location from properties.
void
pylith::materials::ElasticStrain1D::_calcElasticConsts(
- double* const elasticConsts,
- const int numElasticConsts,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // _calcElasticConsts
assert(0 != elasticConsts);
assert(_ElasticStrain1D::numElasticConsts == numElasticConsts);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticStrain1D::tensorSize == strainSize);
- assert(_ElasticStrain1D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticStrain1D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticStrain1D::tensorSize == initialStrainSize);
- const double density = properties[_ElasticStrain1D::pidDensity];
- const double lambda = properties[_ElasticStrain1D::pidLambda];
- const double mu = properties[_ElasticStrain1D::pidMu];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
elasticConsts[0] = lambda + 2.0*mu;
@@ -290,8 +285,11 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
double
-pylith::materials::ElasticStrain1D::_stableTimeStepImplicit(const double* properties,
- const int numProperties) const
+pylith::materials::ElasticStrain1D::_stableTimeStepImplicit(
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const
{ // _stableTimeStepImplicit
return pylith::PYLITH_MAXDOUBLE;
} // _stableTimeStepImplicit
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticStrain1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,22 +19,20 @@
* speed. The physical properties are stored internally using density
* and lambda + 2 mu, which are directly related to the elasticity
* constants used in the finite-element integration.
+ *
+ * $\sigma - \sigma_0 = (\lambda + 2 \mu) (\epislon - \epsilon_0)$
+ *
+ * This implies that when $\epsilon = \epsilon_0$, $\sigma =
+ * \sigma_0$.
*/
#if !defined(pylith_materials_elasticstrain1d_hh)
#define pylith_materials_elasticstrain1d_hh
-#include "ElasticMaterial.hh"
+// Include directives ---------------------------------------------------
+#include "ElasticMaterial.hh" // ISA ElasticMaterial
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class ElasticStrain1D;
- class TestElasticStrain1D; // unit testing
- } // materials
-} // pylith
-
-/// 3-D, linear elastic material with axial strain.
+// ElasticStrain1D ------------------------------------------------------
class pylith::materials::ElasticStrain1D : public ElasticMaterial
{ // class ElasticStrain1D
friend class TestElasticStrain1D; // unit testing
@@ -78,22 +76,6 @@
void _dimProperties(double* const values,
const int nvalues) const;
- /** Nondimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _nondimInitState(double* const values,
- const int nvalues) const;
-
- /** Dimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _dimInitState(double* const values,
- const int nvalues) const;
-
/** Compute density from properties.
*
* @param density Array for density.
@@ -102,31 +84,42 @@
*/
void _calcDensity(double* const density,
const double* properties,
- const int numProperties);
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
- /** Compute stress tensor from properties. If the state variables
- * are from the previous time step, then the computeStateVars flag
- * should be set to true so that the state variables are updated
- * (but not stored) when computing the stresses.
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStress(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute derivatives of elasticity matrix from properties.
@@ -135,27 +128,52 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConsts(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Get stable time step for implicit time integration.
*
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
* @returns Time step
*/
double _stableTimeStepImplicit(const double* properties,
- const int numProperties) const;
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ static const int p_density;
+ static const int p_mu;
+ static const int p_lambda;
+ static const int db_density;
+ static const int db_vs;
+ static const int db_vp;
+
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,9 @@
#include "ElasticStress1D.hh" // implementation of object methods
+#include "Metadata.hh" // USES Metadata
+
+#include "pylith/utils/array.hh" // USES double_array
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -21,12 +24,17 @@
#include "petsc.h" // USES PetscLogFlops
#include <cassert> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
namespace pylith {
namespace materials {
namespace _ElasticStress1D {
+ // Dimension of material.
+ const int dimension = 1;
+
/// Number of entries in stress tensor.
const int tensorSize = 1;
@@ -36,46 +44,52 @@
/// Number of physical properties.
const int numProperties = 3;
- /// Physical properties.
- const Material::PropMetaData properties[] = {
- { "density", 1, OTHER_FIELD },
- { "mu", 1, OTHER_FIELD },
- { "lambda", 1, OTHER_FIELD },
+ // Physical properties.
+ const Metadata::ParamDescription properties[] = {
+ { "density", 1, pylith::topology::FieldBase::SCALAR },
+ { "mu", 1, pylith::topology::FieldBase::SCALAR },
+ { "lambda", 1, pylith::topology::FieldBase::SCALAR },
};
- /// Indices of physical properties
- const int pidDensity = 0;
- const int pidMu = pidDensity + 1;
- const int pidLambda = pidMu + 1;
- /// Values expected in spatial database
- const int numDBValues = 3;
- const char* namesDBValues[] = { "density", "vs", "vp" };
+ // Values expected in spatial database
+ const int numDBProperties = 3;
+ const char* dbProperties[] = { "density", "vs", "vp" };
- /// Indices of database values
- const int didDensity = 0;
- const int didVs = 1;
- const int didVp = 2;
-
- /// Initial state values expected in spatial database
- const int numInitialStateDBValues = tensorSize;
- const char* namesInitialStateDBValues[] = { "stress_xx" };
-
} // _ElasticStress1D
} // materials
} // pylith
+// Indices of physical properties
+const int pylith::materials::ElasticStress1D::p_density = 0;
+
+const int pylith::materials::ElasticStress1D::p_mu =
+ pylith::materials::ElasticStress1D::p_density + 1;
+
+const int pylith::materials::ElasticStress1D::p_lambda =
+ pylith::materials::ElasticStress1D::p_mu + 1;
+
+// Indices of database values (order must match dbProperties)
+const int pylith::materials::ElasticStress1D::db_density = 0;
+
+const int pylith::materials::ElasticStress1D::db_vs =
+ pylith::materials::ElasticStress1D::db_density + 1;
+
+const int pylith::materials::ElasticStress1D::db_vp =
+ pylith::materials::ElasticStress1D::db_vs + 1;
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::materials::ElasticStress1D::ElasticStress1D(void) :
- ElasticMaterial(_ElasticStress1D::tensorSize,
+ ElasticMaterial(_ElasticStress1D::dimension,
+ _ElasticStress1D::tensorSize,
_ElasticStress1D::numElasticConsts,
- _ElasticStress1D::namesDBValues,
- _ElasticStress1D::namesInitialStateDBValues,
- _ElasticStress1D::numDBValues,
- _ElasticStress1D::properties,
- _ElasticStress1D::numProperties)
+ Metadata(_ElasticStress1D::properties,
+ _ElasticStress1D::numProperties,
+ _ElasticStress1D::dbProperties,
+ _ElasticStress1D::numDBProperties,
+ 0, 0,
+ 0, 0))
{ // constructor
- _dimension = 1;
} // constructor
// ----------------------------------------------------------------------
@@ -88,16 +102,16 @@
// Compute parameters from values in spatial database.
void
pylith::materials::ElasticStress1D::_dbToProperties(
- double* const propValues,
- const double_array& dbValues) const
+ double* const propValues,
+ const double_array& dbValues) const
{ // _dbToProperties
assert(0 != propValues);
const int numDBValues = dbValues.size();
- assert(_ElasticStress1D::numDBValues == numDBValues);
+ assert(_ElasticStress1D::numDBProperties == numDBValues);
- const double density = dbValues[_ElasticStress1D::didDensity];
- const double vs = dbValues[_ElasticStress1D::didVs];
- const double vp = dbValues[_ElasticStress1D::didVp];
+ const double density = dbValues[db_density];
+ const double vs = dbValues[db_vs];
+ const double vp = dbValues[db_vp];
if (density <= 0.0 || vs <= 0.0 || vp <= 0.0) {
std::ostringstream msg;
@@ -121,9 +135,9 @@
throw std::runtime_error(msg.str());
} // if
- propValues[_ElasticStress1D::pidDensity] = density;
- propValues[_ElasticStress1D::pidMu] = mu;
- propValues[_ElasticStress1D::pidLambda] = lambda;
+ propValues[p_density] = density;
+ propValues[p_mu] = mu;
+ propValues[p_lambda] = lambda;
PetscLogFlops(6);
} // _dbToProperties
@@ -132,7 +146,7 @@
// Nondimensionalize properties.
void
pylith::materials::ElasticStress1D::_nondimProperties(double* const values,
- const int nvalues) const
+ const int nvalues) const
{ // _nondimProperties
assert(0 != _normalizer);
assert(0 != values);
@@ -140,16 +154,14 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticStress1D::pidDensity] =
- _normalizer->nondimensionalize(values[_ElasticStress1D::pidDensity],
- densityScale);
- values[_ElasticStress1D::pidMu] =
- _normalizer->nondimensionalize(values[_ElasticStress1D::pidMu],
- pressureScale);
- values[_ElasticStress1D::pidLambda] =
- _normalizer->nondimensionalize(values[_ElasticStress1D::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->nondimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->nondimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->nondimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _nondimProperties
@@ -165,63 +177,32 @@
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
- values[_ElasticStress1D::pidDensity] =
- _normalizer->dimensionalize(values[_ElasticStress1D::pidDensity],
- densityScale);
- values[_ElasticStress1D::pidMu] =
- _normalizer->dimensionalize(values[_ElasticStress1D::pidMu],
- pressureScale);
- values[_ElasticStress1D::pidLambda] =
- _normalizer->dimensionalize(values[_ElasticStress1D::pidLambda],
- pressureScale);
+ values[p_density] =
+ _normalizer->dimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->dimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->dimensionalize(values[p_lambda], pressureScale);
+
PetscLogFlops(3);
} // _dimProperties
// ----------------------------------------------------------------------
-// Nondimensionalize initial state.
-void
-pylith::materials::ElasticStress1D::_nondimInitState(double* const values,
- const int nvalues) const
-{ // _nondimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticStress1D::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->nondimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _nondimInitState
-
-// ----------------------------------------------------------------------
-// Dimensionalize initial state.
-void
-pylith::materials::ElasticStress1D::_dimInitState(double* const values,
- const int nvalues) const
-{ // _dimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _ElasticStress1D::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->dimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _dimInitState
-
-// ----------------------------------------------------------------------
// Compute density at location from properties.
void
pylith::materials::ElasticStress1D::_calcDensity(double* const density,
const double* properties,
- const int numProperties)
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars)
{ // _calcDensity
assert(0 != density);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
- density[0] = properties[_ElasticStress1D::pidDensity];
+ density[0] = properties[p_density];
} // _calcDensity
// ----------------------------------------------------------------------
@@ -231,54 +212,70 @@
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars)
{ // _calcStress
assert(0 != stress);
assert(_ElasticStress1D::tensorSize == stressSize);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticStress1D::tensorSize == strainSize);
- assert(_ElasticStress1D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticStress1D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticStress1D::tensorSize == initialStrainSize);
- const double density = properties[_ElasticStress1D::pidDensity];
- const double mu = properties[_ElasticStress1D::pidMu];
- const double lambda = properties[_ElasticStress1D::pidLambda];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
- const double e11 = totalStrain[0];
- stress[0] = mu * (3.0*lambda+2.0*mu) / (lambda + mu) * e11 + initialState[0];
+ const double e11 = totalStrain[0] - initialStrain[0];
+ stress[0] = mu * (3.0*lambda+2.0*mu) / (lambda + mu) * e11 + initialStress[0];
- PetscLogFlops(7);
+ PetscLogFlops(9);
} // _calcStress
// ----------------------------------------------------------------------
// Compute derivative of elasticity matrix at location from properties.
void
pylith::materials::ElasticStress1D::_calcElasticConsts(
- double* const elasticConsts,
- const int numElasticConsts,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // _calcElasticConsts
assert(0 != elasticConsts);
assert(_ElasticStress1D::numElasticConsts == numElasticConsts);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 == numStateVars);
assert(0 != totalStrain);
assert(_ElasticStress1D::tensorSize == strainSize);
- assert(_ElasticStress1D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_ElasticStress1D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_ElasticStress1D::tensorSize == initialStrainSize);
- const double density = properties[_ElasticStress1D::pidDensity];
- const double mu = properties[_ElasticStress1D::pidMu];
- const double lambda = properties[_ElasticStress1D::pidLambda];
+ const double density = properties[p_density];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
elasticConsts[0] = mu * (3.0*lambda+2.0*mu) / (lambda + mu);
@@ -288,8 +285,11 @@
// ----------------------------------------------------------------------
// Get stable time step for implicit time integration.
double
-pylith::materials::ElasticStress1D::_stableTimeStepImplicit(const double* properties,
- const int numProperties) const
+pylith::materials::ElasticStress1D::_stableTimeStepImplicit(
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const
{ // _stableTimeStepImplicit
return pylith::PYLITH_MAXDOUBLE;
} // _stableTimeStepImplicit
Modified: short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ElasticStress1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,22 +20,21 @@
* internally using density, mu, and lambda, which are directly
* related to the elasticity constants used in the finite-element
* integration.
+ *
+ * $\sigma - \sigma_0 =
+ * \frac{\mu*(3+\lambda+2*\mu)}{\lambda+\mu} * (\epsilon - \epsilon_0)$
+ *
+ * This implies that when $\epsilon = \epsilon_0$, $\sigma =
+ * \sigma_0$.
*/
#if !defined(pylith_materials_elasticstress1d_hh)
#define pylith_materials_elasticstress1d_hh
-#include "ElasticMaterial.hh"
+// Include directives ---------------------------------------------------
+#include "ElasticMaterial.hh" // ISA ElasticMaterial
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class ElasticStress1D;
- class TestElasticStress1D; // unit testing
- } // materials
-} // pylith
-
-/// 1-D, linear elastic material with axial stres.
+// ElasticStress1D ------------------------------------------------------
class pylith::materials::ElasticStress1D : public ElasticMaterial
{ // class ElasticStress1D
friend class TestElasticStress1D; // unit testing
@@ -79,22 +78,6 @@
void _dimProperties(double* const values,
const int nvalues) const;
- /** Nondimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _nondimInitState(double* const values,
- const int nvalues) const;
-
- /** Dimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _dimInitState(double* const values,
- const int nvalues) const;
-
/** Compute density from properties.
*
* @param density Array for density.
@@ -103,31 +86,42 @@
*/
void _calcDensity(double* const density,
const double* properties,
- const int numProperties);
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
- /** Compute stress tensor from properties. If the state variables
- * are from the previous time step, then the computeStateVars flag
- * should be set to true so that the state variables are updated
- * (but not stored) when computing the stresses.
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStress(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute derivatives of elasticity matrix from properties.
@@ -136,27 +130,52 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConsts(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Get stable time step for implicit time integration.
*
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
* @returns Time step
*/
double _stableTimeStepImplicit(const double* properties,
- const int numProperties) const;
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ static const int p_density;
+ static const int p_mu;
+ static const int p_lambda;
+ static const int db_density;
+ static const int db_vs;
+ static const int db_vp;
+
// NOT IMPLEMENTED ////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -659,7 +659,7 @@
elasticConsts[19] = 0; // C2313
elasticConsts[20] = elasticConsts[15]; // C1313
-#if 0
+#if 0 // DEBUGGING
std::cout << "_calcElasticConstsViscoelastic" << std::endl;
std::cout << elasticConsts[0] << " " << elasticConsts[1] << " " << elasticConsts[2] << std::endl;
std::cout << elasticConsts[6] << " " << elasticConsts[7] << std::endl;
Modified: short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/GenMaxwellIsotropic3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -32,6 +32,10 @@
* model.
*/
+// :TODO: Rewrite as template over the number of Maxwell models?
+// We could instatiate for 2 and 3 models and provide example for how to
+// instantiate over other numbers of Maxwell models.
+
#if !defined(pylith_materials_genmaxwellisotropic3d_hh)
#define pylith_materials_genmaxwellisotropic3d_hh
Modified: short/3D/PyLith/trunk/libsrc/materials/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -25,10 +25,14 @@
GenMaxwellIsotropic3D.icc \
MaxwellIsotropic3D.hh \
MaxwellIsotropic3D.icc \
+ Metadata.hh \
+ Metadata.icc \
Material.hh \
Material.icc \
- ViscoelasticMaxwell.hh
+ ViscoelasticMaxwell.hh \
+ materialsfwd.hh
+
noinst_HEADERS =
# export
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,14 +14,14 @@
#include "Material.hh" // implementation of object methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/utils/array.hh" // USES double_array, std::vector
#include "spatialdata/spatialdb/SpatialDB.hh" // USES SpatialDB
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-#include "pylith/utils/sievetypes.hh" // USES Mesh
-
#include <cstring> // USES memcpy()
#include <strings.h> // USES strcasecmp()
#include <cassert> // USES assert()
@@ -29,33 +29,42 @@
#include <sstream> // USES std::ostringstream
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Default constructor.
-pylith::materials::Material::Material(const int tensorSize,
- const char** dbValues,
- const char** initialStateDBValues,
- const int numDBValues,
- const PropMetaData* properties,
- const int numProperties) :
+pylith::materials::Material::Material(const int dimension,
+ const int tensorSize,
+ const Metadata& metadata) :
_dt(0.0),
+ _properties(0),
+ _stateVars(0),
_normalizer(new spatialdata::units::Nondimensional),
- _totalPropsQuadPt(0),
- _dimension(0),
+ _numPropsQuadPt(0),
+ _numVarsQuadPt(0),
+ _dimension(dimension),
_tensorSize(tensorSize),
- _initialStateSize(tensorSize),
- _initialStateDBValues(initialStateDBValues),
_needNewJacobian(false),
- _db(0),
- _initialStateDB(0),
+ _dbProperties(0),
+ _dbInitialState(0),
_id(0),
_label(""),
- _propMetaData(properties),
- _numProperties(numProperties),
- _dbValues(dbValues),
- _numDBValues(numDBValues)
+ _metadata(metadata)
{ // constructor
+ const string_vector& properties = metadata.properties();
+ const int numProperties = properties.size();
for (int i=0; i < numProperties; ++i)
- _totalPropsQuadPt += properties[i].fiberDim;
- assert(_totalPropsQuadPt >= 0);
+ _numPropsQuadPt += metadata.fiberDim(properties[i].c_str(),
+ Metadata::PROPERTY);
+ assert(_numPropsQuadPt >= 0);
+
+ const string_vector& stateVars = metadata.stateVars();
+ const int numStateVars = stateVars.size();
+ for (int i=0; i < numStateVars; ++i)
+ _numVarsQuadPt += metadata.fiberDim(stateVars[i].c_str(),
+ Metadata::STATEVAR);
+ assert(_numVarsQuadPt >= 0);
} // constructor
// ----------------------------------------------------------------------
@@ -63,10 +72,13 @@
pylith::materials::Material::~Material(void)
{ // destructor
delete _normalizer; _normalizer = 0;
+ delete _properties; _properties = 0;
+ delete _stateVars; _stateVars = 0;
- // Python db object owns database, so just set pointer to null
- _db = 0;
- _initialStateDB = 0;
+ // Python db object owns databases, so just set pointer to null
+ // :KLUDGE: Should use shared pointer
+ _dbProperties = 0;
+ _dbInitialState = 0;
} // destructor
// ----------------------------------------------------------------------
@@ -84,78 +96,90 @@
// Get physical property parameters and initial state (if used) from database.
void
pylith::materials::Material::initialize(
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- pylith::feassemble::Quadrature* quadrature)
+ const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature)
{ // initialize
- assert(0 != _db);
- assert(0 != cs);
+ assert(0 != _dbProperties);
assert(0 != quadrature);
- assert(!mesh.isNull());
+ // Get quadrature information
+ const int numQuadPts = quadrature->numQuadPts();
+ const int spaceDim = quadrature->spaceDim();
+
// Get cells associated with material
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", _id);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", _id);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
+ assert(0 != cs);
- // Create sections to hold physical properties and state variables.
- _properties = new real_section_type(mesh->comm(), mesh->debug());
- assert(!_properties.isNull());
- _properties->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
+ // Create field to hold physical properties.
+ delete _properties; _properties = new topology::Field<topology::Mesh>(mesh);
+ assert(0 != _properties);
+ int fiberDim = numQuadPts * _numPropsQuadPt;
+ _properties->newSection(cells, fiberDim);
+ _properties->allocate();
+ _properties->zero();
+ const ALE::Obj<RealSection>& propertiesSection = _properties->section();
+ assert(!propertiesSection.isNull());
- const int numQuadPts = quadrature->numQuadPts();
- const int spaceDim = quadrature->spaceDim();
+ // Create arrays for querying.
+ const int numDBProperties = _metadata.numDBProperties();
double_array quadPtsGlobal(numQuadPts*spaceDim);
-
- // Fiber dimension is number of quadrature points times number of
- // values per parameter
- const int totalPropsQuadPt = _totalPropsQuadPt;
- const int fiberDim = totalPropsQuadPt * numQuadPts;
- _properties->setFiberDimension(cells, fiberDim);
- mesh->allocate(_properties);
+ double_array propertiesQuery(numDBProperties);
+ double_array propertiesCell(numQuadPts*numDBProperties);
- const int initialStateSize = _initialStateSize;
- const int initialStateFiberDim = initialStateSize * numQuadPts;
- double_array initialStateQueryData(initialStateSize);
- double_array initialStateCellData(initialStateFiberDim);
+ // Setup database for quering for physical properties
+ assert(0 != _dbProperties);
+ _dbProperties->open();
+ _dbProperties->queryVals(_metadata.dbProperties(),
+ _metadata.numDBProperties());
- // If initial state is being used, create a section to hold it.
- if (0 == _initialStateDB)
- assert(_initialState.isNull());
- else {
- _initialState = new real_section_type(mesh->comm(), mesh->debug());
- assert(!_initialState.isNull());
- _initialState->setChart(real_section_type::chart_type(
- *std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- _initialState->setFiberDimension(cells, initialStateFiberDim);
- mesh->allocate(_initialState);
+ // Create field to hold state variables. We create the field even
+ // if there is no initial state, because this we will use this field
+ // to hold the state variables.
+ delete _stateVars; _stateVars = new topology::Field<topology::Mesh>(mesh);
+ fiberDim = numQuadPts * _numVarsQuadPt;
+ if (fiberDim > 0) {
+ assert(0 != _stateVars);
+ const ALE::Obj<RealSection::chart_type>& chart =
+ propertiesSection->getChart();
+ assert(!chart.isNull());
+ _stateVars->newSection(*chart, fiberDim);
+ _stateVars->allocate();
+ _stateVars->zero();
+ } // if
+ const ALE::Obj<RealSection>& stateVarsSection =
+ (fiberDim > 0) ? _stateVars->section() : 0;
- // Setup database for querying
- _initialStateDB->open();
- _initialStateDB->queryVals(_initialStateDBValues, initialStateSize);
+ // Create arrays for querying
+ const int numDBStateVars = _metadata.numDBStateVars();
+ double_array stateVarsQuery;
+ double_array stateVarsCell;
+ if (0 != _dbInitialState) {
+ assert(!stateVarsSection.isNull());
+ assert(numDBStateVars > 0);
+ assert(_numVarsQuadPt > 0);
+ stateVarsQuery.resize(numDBStateVars);
+ stateVarsCell.resize(numQuadPts*numDBStateVars);
+
+ // Setup database for querying for initial state variables
+ _dbInitialState->open();
+ _dbInitialState->queryVals(_metadata.dbStateVars(),
+ _metadata.numDBStateVars());
} // if
- // Setup database for querying
- const int numValues = _numDBValues;
- _db->open();
- _db->queryVals(_dbValues, numValues);
-
assert(0 != _normalizer);
const double lengthScale = _normalizer->lengthScale();
-
- double_array queryData(numValues); // data returned in query
- double_array cellData(fiberDim); // Parameters at cell's quad pts
-
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
// Compute geometry information for current cell
- quadrature->computeGeometry(mesh, coordinates, *c_iter);
+ quadrature->retrieveGeometry(*c_iter);
const double_array& quadPtsNonDim = quadrature->quadPts();
quadPtsGlobal = quadPtsNonDim;
@@ -166,8 +190,8 @@
for (int iQuadPt=0, index=0;
iQuadPt < numQuadPts;
++iQuadPt, index+=spaceDim) {
- int err = _db->query(&queryData[0], numValues, &quadPtsGlobal[index],
- spaceDim, cs);
+ int err = _dbProperties->query(&propertiesQuery[0], numDBProperties,
+ &quadPtsGlobal[index], spaceDim, cs);
if (err) {
std::ostringstream msg;
msg << "Could not find parameters for physical properties at \n"
@@ -175,141 +199,216 @@
for (int i=0; i < spaceDim; ++i)
msg << " " << quadPtsGlobal[index+i];
msg << ") in material " << _label << "\n"
- << "using spatial database '" << _db->label() << "'.";
+ << "using spatial database '" << _dbProperties->label() << "'.";
throw std::runtime_error(msg.str());
} // if
- _dbToProperties(&cellData[totalPropsQuadPt*iQuadPt], queryData);
- _nondimProperties(&cellData[totalPropsQuadPt*iQuadPt], totalPropsQuadPt);
+ _dbToProperties(&propertiesCell[iQuadPt*_numPropsQuadPt],
+ propertiesQuery);
+ _nondimProperties(&propertiesCell[iQuadPt*_numPropsQuadPt],
+ _numPropsQuadPt);
- if (0 != _initialStateDB) {
- err = _initialStateDB->query(&initialStateQueryData[0],
- initialStateSize,
+ if (0 != _dbInitialState) {
+ err = _dbInitialState->query(&stateVarsQuery[0], numDBStateVars,
&quadPtsGlobal[index], spaceDim, cs);
if (err) {
std::ostringstream msg;
- msg << "Could not find initial state values at \n" << "(";
+ msg << "Could not find initial state variables at \n" << "(";
for (int i=0; i < spaceDim; ++i)
msg << " " << quadPtsGlobal[index+i];
msg << ") in material " << _label << "\n"
- << "using spatial database '" << _initialStateDB->label() << "'.";
+ << "using spatial database '" << _dbInitialState->label()
+ << "'.";
throw std::runtime_error(msg.str());
} // if
- // nondimensionalize initial state
- _nondimInitState(&initialStateQueryData[0], initialStateSize);
- memcpy(&initialStateCellData[iQuadPt*initialStateSize],
- &initialStateQueryData[0],
- initialStateSize*sizeof(double));
+ _dbToStateVars(&stateVarsCell[iQuadPt*_numVarsQuadPt],
+ stateVarsQuery);
+ _nondimStateVars(&stateVarsCell[iQuadPt*_numVarsQuadPt],
+ _numVarsQuadPt);
} // if
} // for
// Insert cell contribution into fields
- _properties->updatePoint(*c_iter, &cellData[0]);
- if (0 != _initialStateDB)
- _initialState->updatePoint(*c_iter, &initialStateCellData[0]);
+ propertiesSection->updatePoint(*c_iter, &propertiesCell[0]);
+ if (0 != _dbInitialState)
+ stateVarsSection->updatePoint(*c_iter, &stateVarsCell[0]);
} // for
// Close databases
- _db->close();
- if (0 != _initialStateDB)
- _initialStateDB->close();
+ _dbProperties->close();
+ if (0 != _dbInitialState)
+ _dbInitialState->close();
} // initialize
// ----------------------------------------------------------------------
-// Get type of field associated with physical property.
-pylith::VectorFieldEnum
-pylith::materials::Material::propertyFieldType(const char* name) const
-{ // propertyFieldType
- VectorFieldEnum fieldType = OTHER_FIELD;
+// Get physical property or state variable field.
+void
+pylith::materials::Material::getField(topology::Field<topology::Mesh>* field,
+ const char* name) const
+{ // getField
+ assert(0 != field);
+ assert(0 != _properties);
+ assert(0 != _stateVars);
- // Find property in list of physical properties.
- int i=0;
- while (i < _numProperties)
- if (0 == strcasecmp(name, _propMetaData[i].name))
- break;
- else
- ++i;
- if (i < _numProperties)
- fieldType = _propMetaData[i].fieldType;
- else {
- std::ostringstream msg;
- msg << "Unknown physical property '" << name << "' for material '"
- << _label << "'.";
- throw std::runtime_error(msg.str());
- } // else
-
- return fieldType;
-} // propertyFieldType
+ int propertyIndex = -1;
+ int stateVarIndex = -1;
+ _findField(&propertyIndex, &stateVarIndex, name);
-// ----------------------------------------------------------------------
-// Get physical property field.
-void
-pylith::materials::Material::propertyField(ALE::Obj<real_section_type>* field,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- const int numQuadPts) const
-{ // propertyField
- // Find property in list of physical properties.
- int i=0;
- int propOffset = 0;
- int fiberDim = 0;
- while (i < _numProperties)
- if (0 == strcasecmp(name, _propMetaData[i].name))
- break;
- else {
- propOffset += _propMetaData[i].fiberDim;
- ++i;
- } // else
- if (i < _numProperties)
- fiberDim = _propMetaData[i].fiberDim;
- else {
- std::ostringstream msg;
- msg << "Unknown physical property '" << name << "' for material '"
- << _label << "'.";
- throw std::runtime_error(msg.str());
- } // else
-
// Get cell information
- const ALE::Obj<Mesh::label_sequence>& cells =
- mesh->getLabelStratum("material-id", _id);
+ const ALE::Obj<SieveMesh>& sieveMesh = field->mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", _id);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
- const int totalFiberDim = numQuadPts * fiberDim;
+ if (propertyIndex >= 0) { // If field is a property
+ int propOffset = 0;
+ const string_vector& properties = _metadata.properties();
+ assert(propertyIndex < properties.size());
+ for (int i=0; i < propertyIndex; ++i)
+ propOffset +=
+ _metadata.fiberDim(properties[i].c_str(), Metadata::PROPERTY);
+ const int fiberDim = _metadata.fiberDim(name, Metadata::PROPERTY);
- // Allocate buffer for property field.
- if (field->isNull() ||
- totalFiberDim != (*field)->getFiberDimension(*cells->begin())) {
- *field = new real_section_type(mesh->comm(), mesh->debug());
- (*field)->setChart(real_section_type::chart_type(
- *std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- (*field)->setFiberDimension(cells, totalFiberDim);
- mesh->allocate(*field);
- } // if
+ // :TODO: Get scale information
+
+ // Get properties section
+ const ALE::Obj<RealSection>& propertiesSection = _properties->section();
+ assert(!propertiesSection.isNull());
+ const int totalPropsFiberDim =
+ propertiesSection->getFiberDimension(*cells->begin());
+ const int numPropsQuadPt = _numPropsQuadPt;
+ const int numQuadPts = totalPropsFiberDim / numPropsQuadPt;
+ assert(totalPropsFiberDim == numQuadPts * numPropsQuadPt);
+ const int totalFiberDim = numQuadPts * fiberDim;
+
+ // Allocate buffer for property field.
+ const ALE::Obj<RealSection>& fieldSection = field->section();
+ if ((fieldSection.isNull() && cells->size() > 0) ||
+ totalFiberDim != fieldSection->getFiberDimension(*cells->begin())) {
+ field->newSection(cells, totalFiberDim);
+ field->allocate();
+ } // if
+ assert(!fieldSection.isNull());
+ field->vectorFieldType(_metadata.fieldType(name, Metadata::PROPERTY));
+ field->label(name);
- // Buffer for property at cell's quadrature points
- const int totalPropsQuadPt = _totalPropsQuadPt;
- double_array fieldCell(fiberDim*numQuadPts);
- double_array propertiesCell(totalPropsQuadPt*numQuadPts);
+ // Buffer for property at cell's quadrature points
+ double_array fieldCell(numQuadPts*fiberDim);
+ double_array propertiesCell(numQuadPts*numPropsQuadPt);
- // Loop over cells
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
- c_iter != cellsEnd;
- ++c_iter) {
- _properties->restrictPoint(*c_iter,
- &propertiesCell[0], propertiesCell.size());
+ // Loop over cells
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter) {
+ propertiesSection->restrictPoint(*c_iter,
+ &propertiesCell[0], propertiesCell.size());
- for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
- _dimProperties(&propertiesCell[iQuad*totalPropsQuadPt],
- totalPropsQuadPt);
- memcpy(&fieldCell[iQuad*fiberDim],
- &propertiesCell[iQuad*totalPropsQuadPt+propOffset],
- fiberDim*sizeof(double));
+ for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
+ _dimProperties(&propertiesCell[iQuad*numPropsQuadPt],
+ numPropsQuadPt);
+ memcpy(&fieldCell[iQuad*fiberDim],
+ &propertiesCell[iQuad*numPropsQuadPt+propOffset],
+ fiberDim*sizeof(double));
+ } // for
+
+ fieldSection->updatePoint(*c_iter, &fieldCell[0]);
} // for
+ } else { // field is a state variable
+ assert(stateVarIndex >= 0);
+
+ int varOffset = 0;
+ const string_vector& stateVars = _metadata.stateVars();
+ assert(stateVarIndex < stateVars.size());
+ for (int i=0; i < stateVarIndex; ++i)
+ varOffset +=
+ _metadata.fiberDim(stateVars[i].c_str(), Metadata::STATEVAR);
+ const int fiberDim = _metadata.fiberDim(name, Metadata::STATEVAR);
- (*field)->updatePoint(*c_iter, &fieldCell[0]);
- } // for
-} // propertyField
+ // :TODO: Get scale information
+
+ // Get state variables section
+ const ALE::Obj<RealSection>& stateVarsSection = _stateVars->section();
+ assert(!stateVarsSection.isNull());
+ const int totalVarsFiberDim =
+ stateVarsSection->getFiberDimension(*cells->begin());
+ const int numVarsQuadPt = _numVarsQuadPt;
+ const int numQuadPts = totalVarsFiberDim / numVarsQuadPt;
+ assert(totalVarsFiberDim == numQuadPts * numVarsQuadPt);
+ const int totalFiberDim = numQuadPts * fiberDim;
+
+ // Allocate buffer for state variable field.
+ const ALE::Obj<RealSection>& fieldSection = field->section();
+ if (fieldSection.isNull() ||
+ totalFiberDim != fieldSection->getFiberDimension(*cells->begin())) {
+ field->newSection(cells, totalFiberDim);
+ field->allocate();
+ } // if
+ assert(!fieldSection.isNull());
+ field->vectorFieldType(_metadata.fieldType(name, Metadata::STATEVAR));
+ field->label(name);
+ // Buffer for state variable at cell's quadrature points
+ double_array fieldCell(numQuadPts*fiberDim);
+ double_array stateVarsCell(numQuadPts*numVarsQuadPt);
+
+ // Loop over cells
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter) {
+ stateVarsSection->restrictPoint(*c_iter,
+ &stateVarsCell[0], stateVarsCell.size());
+
+ for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
+ _dimStateVars(&stateVarsCell[iQuad*numVarsQuadPt],
+ numVarsQuadPt);
+ memcpy(&fieldCell[iQuad*fiberDim],
+ &stateVarsCell[iQuad*numVarsQuadPt+varOffset],
+ fiberDim*sizeof(double));
+ } // for
+ fieldSection->updatePoint(*c_iter, &fieldCell[0]);
+ } // for
+ } // if/else
+} // getField
+
+// ----------------------------------------------------------------------
+// Get indices for physical property or state variable field.
+void
+pylith::materials::Material::_findField(int* propertyIndex,
+ int* stateVarIndex,
+ const char* name) const
+{ // _findField
+ assert(0 != propertyIndex);
+ assert(0 != stateVarIndex);
+
+ *propertyIndex = -1;
+ *stateVarIndex = -1;
+
+ const std::string nameString = name;
+ const string_vector& properties = _metadata.properties();
+ const int numProperties = properties.size();
+ for (int i=0; i < numProperties; ++i)
+ if (nameString == properties[i]) {
+ *propertyIndex = i;
+ return;
+ } // if
+
+ const string_vector& stateVars = _metadata.stateVars();
+ const int numStateVars = stateVars.size();
+ for (int i=0; i < numStateVars; ++i)
+ if (nameString == stateVars[i]) {
+ *stateVarIndex = i;
+ return;
+ } // if
+
+ if (propertyIndex < 0 && stateVarIndex < 0) {
+ std::ostringstream msg;
+ msg << "Unknown physical property or state variable '" << name
+ << "' for material '" << _label << "'.";
+ throw std::runtime_error(msg.str());
+ } // else
+} // _findField
+
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,76 +15,42 @@
* @brief C++ abstract base class for Material object.
*
* Interface definition for a material. The physical properties for
- * the material include BOTH parameters for the physical properties
- * AND state variables associated with the material constitutive
+ * the material are associated with the constants in the constitutive
* model.
*/
#if !defined(pylith_materials_material_hh)
#define pylith_materials_material_hh
-#include "pylith/utils/array.hh" // USES double_array
-#include <string> // HASA std::string
-#include "pylith/utils/sievetypes.hh" // USES real_section_type
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+// Include directives ---------------------------------------------------
+#include "materialsfwd.hh" // forward declarations
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class Material;
- class TestMaterial; // unit testing
- } // materials
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // forward declarations
+#include "spatialdata/units/unitsfwd.hh" // forward declarations
- namespace feassemble {
- class Quadrature; // USES Quadrature
- } // feassemble
-} // pylith
+#include "Metadata.hh" // HASA Metadata
-/// Namespace for spatialdata package
-namespace spatialdata {
- namespace spatialdb {
- class SpatialDB; // forward declaration
- } // spatialdb
- namespace geocoords {
- class CoordSys; // forward declaration
- } // geocoords
- namespace units {
- class Nondimensional; // forward declaration
- } // units
-} // spatialdata
+#include <string> // HASA std::string
-/// C++ abstract base class for Material object.
+// Material -------------------------------------------------------------
class pylith::materials::Material
{ // class Material
friend class TestMaterial; // unit testing
- // PUBLIC STRUCTURES //////////////////////////////////////////////////
-public :
-
- struct PropMetaData {
- const char* name;
- int fiberDim;
- VectorFieldEnum fieldType;
- }; // PropMetaData
-
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
/** Default constructor.
*
+ * @param dimension Spatial dimension associated with material.
* @param tensorSize Array of names of database values for material.
- * @param initialStateDBValues Names of initial state database values for material.
- * @param dbValues Array of names of database values for material.
- * @param numDBValues Number of database values.
- * @param properties Array of physical property meta data.
- * @param numProperties Number of physical properties for material.
+ * @param metadata Metadata for physical properties and state variables.
*/
- Material(const int tensorSize,
- const char** dbValues,
- const char** initialStateDBValues,
- const int numDBValues,
- const PropMetaData* properties,
- const int numProperties);
+ Material(const int dimension,
+ const int tensorSize,
+ const Metadata& metadata);
/// Destructor.
virtual
@@ -96,18 +62,6 @@
*/
int dimension(void) const;
- /** Set database for physical property parameters.
- *
- * @param value Pointer to database.
- */
- void db(spatialdata::spatialdb::SpatialDB* value);
-
- /** Set database for initial state variables.
- *
- * @param value Pointer to database.
- */
- void initialStateDB(spatialdata::spatialdb::SpatialDB* value);
-
/** Set identifier of material.
*
* @param value Material identifier
@@ -130,7 +84,7 @@
*
* @returns Label of material
*/
- const std::string& label(void) const;
+ const char* label(void) const;
/** Set current time step.
*
@@ -145,6 +99,18 @@
*/
double timeStep(void) const;
+ /** Set database for physical property parameters.
+ *
+ * @param value Pointer to database.
+ */
+ void dbProperties(spatialdata::spatialdb::SpatialDB* value);
+
+ /** Set database for initial state variables.
+ *
+ * @param value Pointer to database.
+ */
+ void dbInitialState(spatialdata::spatialdb::SpatialDB* value);
+
/** Set scales used to nondimensionalize physical properties.
*
* @param dim Nondimensionalizer
@@ -154,14 +120,22 @@
/** Initialize material by getting physical property parameters from
* database.
*
- * @param mesh PETSc mesh
- * @param cs Coordinate system associated with mesh
+ * @pre Must call Quadrature::computeGeometry() before calling
+ * initialize().
+ *
+ * @param mesh Finite-element mesh.
* @param quadrature Quadrature for finite-element integration
*/
- void initialize(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs,
- pylith::feassemble::Quadrature* quadrature);
+ virtual
+ void initialize(const topology::Mesh& mesh,
+ feassemble::Quadrature<topology::Mesh>* quadrature);
+ /** Get size of stress/strain tensor associated with material.
+ *
+ * @returns Size of array holding stress/strain tensor.
+ */
+ int tensorSize(void) const;
+
/** Get flag indicating whether Jacobian matrix must be reformed for
* current state.
*
@@ -173,33 +147,23 @@
/// current state.
void resetNeedNewJacobian(void);
- /** Get type of field associated with physical property.
+ /** Get physical property or state variable field. Data is returned
+ * via the argument.
*
- * @param name Name of physical property.
- *
- * @returns Type of vector field associated with property.
+ * @param field Field over material cells.
+ * @param name Name of field to retrieve.
*/
- VectorFieldEnum propertyFieldType(const char* name) const;
+ void getField(topology::Field<topology::Mesh>* field,
+ const char* name) const;
- /** Get physical property field. Data is returned via the
- * argument.
- *
- * @param field Proeprty field.
- * @param name Name of physical property.
- * @param mesh PETSc mesh.
- * @param numQuadPoints Number of quadrature points.
- */
- void propertyField(ALE::Obj<real_section_type>* field,
- const char* name,
- const ALE::Obj<Mesh>& mesh,
- const int numQuadPts) const;
-
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
+ /// These methods should be implemented by every constitutive model.
+
/** Compute properties from values in spatial database.
*
- * @param propVals Array of property values.
+ * @param propValues Array of property values.
* @param dbValues Array of database values.
*/
virtual
@@ -224,71 +188,86 @@
void _dimProperties(double* const values,
const int nvalues) const = 0;
- /** Nondimensionalize initial state.
+ /** Compute initial state variables from values in spatial database.
*
+ * @param stateValues Array of state variable values.
+ * @param dbValues Array of database values.
+ */
+ virtual
+ void _dbToStateVars(double* const stateValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize state variables.
+ *
* @param values Array of initial state values.
* @param nvalues Number of values.
*/
virtual
- void _nondimInitState(double* const values,
- const int nvalues) const = 0;
-
- /** Dimensionalize initial state.
+ void _nondimStateVars(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize state variables.
*
* @param values Array of initial state values.
* @param nvalues Number of values.
*/
virtual
- void _dimInitState(double* const values,
- const int nvalues) const = 0;
+ void _dimStateVars(double* const values,
+ const int nvalues) const;
- // NOT IMPLEMENTED ////////////////////////////////////////////////////
-private :
-
- /// Not implemented
- Material(const Material& m);
-
- /// Not implemented
- const Material& operator=(const Material& m);
-
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
double _dt; ///< Current time step
- /// Section containing physical properties of material.
- ALE::Obj<real_section_type> _properties;
+ /// Field containing physical properties of material.
+ topology::Field<topology::Mesh>* _properties;
- /// Section containing the initial state variables for the material.
- ALE::Obj<real_section_type> _initialState;
+ /// Field containing the state variables for the material.
+ topology::Field<topology::Mesh>* _stateVars;
spatialdata::units::Nondimensional* _normalizer; ///< Nondimensionalizer
- int _totalPropsQuadPt; ///< Total # of property values per quad point.
- int _dimension; ///< Spatial dimension associated with material.
- int _tensorSize; ///< Tensor size for material.
- int _initialStateSize; ///< Initial state size for material.
+ int _numPropsQuadPt; ///< Number of properties per quad point.
+ int _numVarsQuadPt; ///< Number of state variables per quad point.
+ const int _dimension; ///< Spatial dimension associated with material.
+ const int _tensorSize; ///< Tensor size for material.
bool _needNewJacobian; ///< True if need to reform Jacobian, false otherwise.
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Get indices for physical property or state variable field. Index
+ * of physical property or state variable is set, unknown values are
+ * -1.
+ *
+ * @param propertyIndex Index of field in properties array.
+ * @param stateVarIndex Index of field in state variables array.
+ * @param name Name of field.
+ */
+ void _findField(int* propertyIndex,
+ int* stateVarIndex,
+ const char* name) const;
+
// PRIVATE MEMBERS ////////////////////////////////////////////////////
private :
- /// Database of parameters for physical properties of material
- spatialdata::spatialdb::SpatialDB* _db;
+ /// Database of parameters for physical properties of material.
+ spatialdata::spatialdb::SpatialDB* _dbProperties;
- /// Database of initial state values for the material
- spatialdata::spatialdb::SpatialDB* _initialStateDB;
+ /// Database of initial state variables for the material.
+ spatialdata::spatialdb::SpatialDB* _dbInitialState;
- int _id; ///< Material identifier
- std::string _label; ///< Label of material
+ int _id; ///< Material identifier.
+ std::string _label; ///< Label of material.
- const PropMetaData* _propMetaData; ///< Property meta data.
- const int _numProperties; ///< Number of properties
+ const Metadata _metadata; ///< Property and state variable metadata.
- const char** _dbValues; ///< Names of database values
- const int _numDBValues; ///< Number of database values
+ // NOT IMPLEMENTED ////////////////////////////////////////////////////
+private :
- const char** _initialStateDBValues; ///< Names of initial state database values
+ Material(const Material&); ///< Not implemented.
+ const Material& operator=(const Material&); ///< Not implemented
}; // class Material
Modified: short/3D/PyLith/trunk/libsrc/materials/Material.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Material.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/Material.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,15 +24,15 @@
// Set database for material parameters.
inline
void
-pylith::materials::Material::db(spatialdata::spatialdb::SpatialDB* value) {
- _db = value;
+pylith::materials::Material::dbProperties(spatialdata::spatialdb::SpatialDB* value) {
+ _dbProperties = value;
}
// Set database for initial state variables.
inline
void
-pylith::materials::Material::initialStateDB(spatialdata::spatialdb::SpatialDB* value) {
- _initialStateDB = value;
+pylith::materials::Material::dbInitialState(spatialdata::spatialdb::SpatialDB* value) {
+ _dbInitialState = value;
}
// Set identifier of material.
@@ -58,9 +58,9 @@
// Get label of material.
inline
-const std::string&
+const char*
pylith::materials::Material::label(void) const {
- return _label;
+ return _label.c_str();
}
// Set current time step.
@@ -77,10 +77,16 @@
return _dt;
} // timeStep
-/* Get flag indicating whether Jacobian matrix must be reformed for
- * current state.
- */
+// Get size of stress/strain tensor associated with material.
inline
+int
+pylith::materials::Material::tensorSize(void) const {
+ return _tensorSize;
+}
+
+// Get flag indicating whether Jacobian matrix must be reformed for
+// current state.
+inline
bool
pylith::materials::Material::needNewJacobian(void) const {
return _needNewJacobian;
@@ -94,5 +100,26 @@
_needNewJacobian = false;
} // resetNeedNewJacobian
+// Compute initial state variables from values in spatial database.
+inline
+void
+pylith::materials::Material::_dbToStateVars(double* const stateValues,
+ const double_array& dbValues) const
+{}
+// Nondimensionalize state variables.
+inline
+void
+pylith::materials::Material::_nondimStateVars(double* const values,
+ const int nvalues) const
+{}
+
+// Dimensionalize state variables.
+inline
+void
+pylith::materials::Material::_dimStateVars(double* const values,
+ const int nvalues) const
+{}
+
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,6 +15,7 @@
#include "MaxwellIsotropic3D.hh" // implementation of object methods
#include "ViscoelasticMaxwell.hh" // USES computeVisStrain
+#include "Metadata.hh" // USES Metadata
#include "pylith/utils/array.hh" // USES double_array
@@ -32,6 +33,9 @@
namespace materials {
namespace _MaxwellIsotropic3D{
+ // Dimension of material.
+ const int dimension = 3;
+
/// Number of entries in stress/strain tensors.
const int tensorSize = 6;
@@ -39,61 +43,105 @@
const int numElasticConsts = 21;
/// Number of physical properties.
- const int numProperties = 6;
-
+ const int numProperties = 4;
+
/// Physical properties.
- const Material::PropMetaData properties[] = {
- { "density", 1, OTHER_FIELD },
- { "mu", 1, OTHER_FIELD },
- { "lambda", 1, OTHER_FIELD },
- { "maxwell_time", 1, OTHER_FIELD },
- { "total_strain", 6, OTHER_FIELD },
- { "viscous_strain", 6, OTHER_FIELD },
+ const Metadata::ParamDescription properties[] = {
+ { "density", 1, pylith::topology::FieldBase::SCALAR },
+ { "mu", 1, pylith::topology::FieldBase::SCALAR },
+ { "lambda", 1, pylith::topology::FieldBase::SCALAR },
+ { "maxwell_time", 1, pylith::topology::FieldBase::SCALAR },
};
- /// Indices (order) of properties.
- const int pidDensity = 0;
- const int pidMu = pidDensity + 1;
- const int pidLambda = pidMu + 1;
- const int pidMaxwellTime = pidLambda + 1;
- const int pidStrainT = pidMaxwellTime + 1;
- const int pidVisStrain = pidStrainT + tensorSize;
+
+ // Values expected in properties spatial database
+ const int numDBProperties = 4;
+ const char* dbProperties[] = {"density", "vs", "vp" , "viscosity"};
- /// Values expected in spatial database
- const int numDBValues = 4;
- const char* namesDBValues[] = {"density", "vs", "vp" , "viscosity"};
+ /// Number of state variables.
+ const int numStateVars = 2;
+
+ /// State variables.
+ const Metadata::ParamDescription stateVars[] = {
+ { "total_strain", 6, pylith::topology::FieldBase::TENSOR },
+ { "viscous_strain", 6, pylith::topology::FieldBase::TENSOR },
+ };
- /// Indices (order) of database values
- const int didDensity = 0;
- const int didVs = 1;
- const int didVp = 2;
- const int didViscosity = 3;
+ // Values expected in state variables spatial database
+ const int numDBStateVars = 12;
+ const char* dbStateVars[] = {"total-strain-xx",
+ "total-strain-yy",
+ "total-strain-zz",
+ "total-strain-xy",
+ "total-strain-yz",
+ "total-strain-xz",
+ "viscous-strain-xx",
+ "viscous-strain-yy",
+ "viscous-strain-zz",
+ "viscous-strain-xy",
+ "viscous-strain-yz",
+ "viscous-strain-xz",
+ };
- /// Initial state values expected in spatial database
- const int numInitialStateDBValues = tensorSize;
- const char* namesInitialStateDBValues[] = { "stress_xx", "stress_yy",
- "stress_zz", "stress_xy",
- "stress_yz", "stress_xz" };
-
} // _MaxwellIsotropic3D
} // materials
} // pylith
+// Indices of physical properties
+const int pylith::materials::MaxwellIsotropic3D::p_density = 0;
+
+const int pylith::materials::MaxwellIsotropic3D::p_mu =
+ pylith::materials::MaxwellIsotropic3D::p_density + 1;
+
+const int pylith::materials::MaxwellIsotropic3D::p_lambda =
+ pylith::materials::MaxwellIsotropic3D::p_mu + 1;
+
+const int pylith::materials::MaxwellIsotropic3D::p_maxwellTime =
+ pylith::materials::MaxwellIsotropic3D::p_lambda + 1;
+
+// Indices of database values (order must match dbProperties)
+const int pylith::materials::MaxwellIsotropic3D::db_density = 0;
+
+const int pylith::materials::MaxwellIsotropic3D::db_vs =
+ pylith::materials::MaxwellIsotropic3D::db_density + 1;
+
+const int pylith::materials::MaxwellIsotropic3D::db_vp =
+ pylith::materials::MaxwellIsotropic3D::db_vs + 1;
+
+const int pylith::materials::MaxwellIsotropic3D::db_viscosity =
+ pylith::materials::MaxwellIsotropic3D::db_vp + 1;
+
+// Indices of state variables
+const int pylith::materials::MaxwellIsotropic3D::s_totalStrain = 0;
+
+const int pylith::materials::MaxwellIsotropic3D::s_viscousStrain =
+ pylith::materials::MaxwellIsotropic3D::s_totalStrain + 6;
+
+// Indices of database values (order must match dbStateVars)
+const int pylith::materials::MaxwellIsotropic3D::db_totalStrain = 0;
+
+const int pylith::materials::MaxwellIsotropic3D::db_viscousStrain =
+ pylith::materials::MaxwellIsotropic3D::db_totalStrain + 6;
+
// ----------------------------------------------------------------------
// Default constructor.
pylith::materials::MaxwellIsotropic3D::MaxwellIsotropic3D(void) :
- ElasticMaterial(_MaxwellIsotropic3D::tensorSize,
+ ElasticMaterial(_MaxwellIsotropic3D::dimension,
+ _MaxwellIsotropic3D::tensorSize,
_MaxwellIsotropic3D::numElasticConsts,
- _MaxwellIsotropic3D::namesDBValues,
- _MaxwellIsotropic3D::namesInitialStateDBValues,
- _MaxwellIsotropic3D::numDBValues,
- _MaxwellIsotropic3D::properties,
- _MaxwellIsotropic3D::numProperties),
- _calcElasticConstsFn(&pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic),
- _calcStressFn(&pylith::materials::MaxwellIsotropic3D::_calcStressElastic),
- _updatePropertiesFn(&pylith::materials::MaxwellIsotropic3D::_updatePropertiesElastic)
+ Metadata(_MaxwellIsotropic3D::properties,
+ _MaxwellIsotropic3D::numProperties,
+ _MaxwellIsotropic3D::dbProperties,
+ _MaxwellIsotropic3D::numDBProperties,
+ _MaxwellIsotropic3D::stateVars,
+ _MaxwellIsotropic3D::numStateVars,
+ _MaxwellIsotropic3D::dbStateVars,
+ _MaxwellIsotropic3D::numDBStateVars)),
+ _calcElasticConstsFn(0),
+ _calcStressFn(0),
+ _updateStateVarsFn(0)
{ // constructor
- _dimension = 3;
- _visStrain.resize(_MaxwellIsotropic3D::tensorSize);
+ useElasticBehavior(true);
+ _viscousStrain.resize(_tensorSize);
} // constructor
// ----------------------------------------------------------------------
@@ -103,6 +151,29 @@
} // destructor
// ----------------------------------------------------------------------
+// Set whether elastic or inelastic constitutive relations are used.
+void
+pylith::materials::MaxwellIsotropic3D::useElasticBehavior(const bool flag)
+{ // useElasticBehavior
+ if (flag) {
+ _calcStressFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcStressElastic;
+ _calcElasticConstsFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic;
+ _updateStateVarsFn =
+ &pylith::materials::MaxwellIsotropic3D::_updateStateVarsElastic;
+
+ } else {
+ _calcStressFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcStressViscoelastic;
+ _calcElasticConstsFn =
+ &pylith::materials::MaxwellIsotropic3D::_calcElasticConstsViscoelastic;
+ _updateStateVarsFn =
+ &pylith::materials::MaxwellIsotropic3D::_updateStateVarsViscoelastic;
+ } // if/else
+} // useElasticBehavior
+
+// ----------------------------------------------------------------------
// Compute properties from values in spatial database.
void
pylith::materials::MaxwellIsotropic3D::_dbToProperties(
@@ -111,12 +182,12 @@
{ // _dbToProperties
assert(0 != propValues);
const int numDBValues = dbValues.size();
- assert(_MaxwellIsotropic3D::numDBValues == numDBValues);
+ assert(_MaxwellIsotropic3D::numDBProperties == numDBValues);
- const double density = dbValues[_MaxwellIsotropic3D::didDensity];
- const double vs = dbValues[_MaxwellIsotropic3D::didVs];
- const double vp = dbValues[_MaxwellIsotropic3D::didVp];
- const double viscosity = dbValues[_MaxwellIsotropic3D::didViscosity];
+ const double density = dbValues[db_density];
+ const double vs = dbValues[db_vs];
+ const double vp = dbValues[db_vp];
+ const double viscosity = dbValues[db_viscosity];
if (density <= 0.0 || vs <= 0.0 || vp <= 0.0 || viscosity <= 0.0) {
std::ostringstream msg;
@@ -142,13 +213,13 @@
} // if
assert(mu > 0);
- const double maxwelltime = viscosity / mu;
- assert(maxwelltime > 0.0);
+ const double maxwellTime = viscosity / mu;
+ assert(maxwellTime > 0.0);
- propValues[_MaxwellIsotropic3D::pidDensity] = density;
- propValues[_MaxwellIsotropic3D::pidMu] = mu;
- propValues[_MaxwellIsotropic3D::pidLambda] = lambda;
- propValues[_MaxwellIsotropic3D::pidMaxwellTime] = maxwelltime;
+ propValues[p_density] = density;
+ propValues[p_mu] = mu;
+ propValues[p_lambda] = lambda;
+ propValues[p_maxwellTime] = maxwellTime;
PetscLogFlops(7);
} // _dbToProperties
@@ -161,23 +232,19 @@
{ // _nondimProperties
assert(0 != _normalizer);
assert(0 != values);
- assert(nvalues == _totalPropsQuadPt);
+ assert(nvalues == _numPropsQuadPt);
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
const double timeScale = _normalizer->timeScale();
- values[_MaxwellIsotropic3D::pidDensity] =
- _normalizer->nondimensionalize(values[_MaxwellIsotropic3D::pidDensity],
- densityScale);
- values[_MaxwellIsotropic3D::pidMu] =
- _normalizer->nondimensionalize(values[_MaxwellIsotropic3D::pidMu],
- pressureScale);
- values[_MaxwellIsotropic3D::pidLambda] =
- _normalizer->nondimensionalize(values[_MaxwellIsotropic3D::pidLambda],
- pressureScale);
- values[_MaxwellIsotropic3D::pidMaxwellTime] =
- _normalizer->nondimensionalize(values[_MaxwellIsotropic3D::pidMaxwellTime],
- timeScale);
+ values[p_density] =
+ _normalizer->nondimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->nondimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->nondimensionalize(values[p_lambda], pressureScale);
+ values[p_maxwellTime] =
+ _normalizer->nondimensionalize(values[p_maxwellTime], timeScale);
PetscLogFlops(4);
} // _nondimProperties
@@ -190,94 +257,112 @@
{ // _dimProperties
assert(0 != _normalizer);
assert(0 != values);
- assert(nvalues == _totalPropsQuadPt);
+ assert(nvalues == _numPropsQuadPt);
const double densityScale = _normalizer->densityScale();
const double pressureScale = _normalizer->pressureScale();
const double timeScale = _normalizer->timeScale();
- values[_MaxwellIsotropic3D::pidDensity] =
- _normalizer->dimensionalize(values[_MaxwellIsotropic3D::pidDensity],
- densityScale);
- values[_MaxwellIsotropic3D::pidMu] =
- _normalizer->dimensionalize(values[_MaxwellIsotropic3D::pidMu],
- pressureScale);
- values[_MaxwellIsotropic3D::pidLambda] =
- _normalizer->dimensionalize(values[_MaxwellIsotropic3D::pidLambda],
- pressureScale);
- values[_MaxwellIsotropic3D::pidMaxwellTime] =
- _normalizer->dimensionalize(values[_MaxwellIsotropic3D::pidMaxwellTime],
- timeScale);
+ values[p_density] =
+ _normalizer->dimensionalize(values[p_density], densityScale);
+ values[p_mu] =
+ _normalizer->dimensionalize(values[p_mu], pressureScale);
+ values[p_lambda] =
+ _normalizer->dimensionalize(values[p_lambda], pressureScale);
+ values[p_maxwellTime] =
+ _normalizer->dimensionalize(values[p_maxwellTime], timeScale);
PetscLogFlops(4);
} // _dimProperties
// ----------------------------------------------------------------------
-// Nondimensionalize initial state.
+// Compute initial state variables from values in spatial database.
void
-pylith::materials::MaxwellIsotropic3D::_nondimInitState(double* const values,
- const int nvalues) const
-{ // _nondimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _MaxwellIsotropic3D::numInitialStateDBValues);
+pylith::materials::MaxwellIsotropic3D::_dbToStateVars(
+ double* const stateValues,
+ const double_array& dbValues) const
+{ // _dbToStateVars
+ assert(0 != stateValues);
+ const int numDBValues = dbValues.size();
+ assert(_MaxwellIsotropic3D::numDBStateVars == numDBValues);
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->nondimensionalize(values, nvalues, pressureScale);
+ const int totalSize = 2 * _tensorSize;
+ assert(totalSize == _numVarsQuadPt);
+ assert(totalSize == numDBValues);
+ memcpy(stateValues, &dbValues[0], totalSize*sizeof(double));
- PetscLogFlops(nvalues);
-} // _nondimInitState
+ PetscLogFlops(0);
+} // _dbToStateVars
// ----------------------------------------------------------------------
-// Dimensionalize initial state.
-void
-pylith::materials::MaxwellIsotropic3D::_dimInitState(double* const values,
- const int nvalues) const
-{ // _dimInitState
- assert(0 != _normalizer);
- assert(0 != values);
- assert(nvalues == _MaxwellIsotropic3D::numInitialStateDBValues);
-
- const double pressureScale = _normalizer->pressureScale();
- _normalizer->dimensionalize(values, nvalues, pressureScale);
-
- PetscLogFlops(nvalues);
-} // _dimInitState
-
-// ----------------------------------------------------------------------
// Compute density at location from properties.
void
pylith::materials::MaxwellIsotropic3D::_calcDensity(double* const density,
const double* properties,
- const int numProperties)
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars)
{ // _calcDensity
assert(0 != density);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
- density[0] = properties[_MaxwellIsotropic3D::pidDensity];
+ density[0] = properties[p_density];
} // _calcDensity
// ----------------------------------------------------------------------
+// Get stable time step for implicit time integration.
+double
+pylith::materials::MaxwellIsotropic3D::_stableTimeStepImplicit(
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const
+{ // _stableTimeStepImplicit
+ assert(0 != properties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
+
+ const double maxwellTime = properties[p_maxwellTime];
+ const double dtStable = 0.1 * maxwellTime;
+
+ return dtStable;
+} // _stableTimeStepImplicit
+
+#include <iostream>
+// ----------------------------------------------------------------------
// Compute viscous strain for current time step.
// material.
void
pylith::materials::MaxwellIsotropic3D::_computeStateVars(
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ const double* stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // _computeStateVars
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
assert(0 != totalStrain);
assert(_MaxwellIsotropic3D::tensorSize == strainSize);
- assert(_MaxwellIsotropic3D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStrainSize);
- const int tensorSize = _MaxwellIsotropic3D::tensorSize;
- const double maxwelltime = properties[_MaxwellIsotropic3D::pidMaxwellTime];
+ const int tensorSize = _tensorSize;
+ const double maxwellTime = properties[p_maxwellTime];
+ // :TODO: Need to account for initial values for state variables
+ // and the initial strain??
+
const double e11 = totalStrain[0];
const double e22 = totalStrain[1];
const double e33 = totalStrain[2];
@@ -285,28 +370,26 @@
const double e23 = totalStrain[4];
const double e13 = totalStrain[5];
- const double meanStrainTpdt = (e11 + e22 + e33)/3.0;
+ const double meanStrainTpdt = (e11 + e22 + e33) / 3.0;
const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
const double meanStrainT =
- (properties[_MaxwellIsotropic3D::pidStrainT+0] +
- properties[_MaxwellIsotropic3D::pidStrainT+1] +
- properties[_MaxwellIsotropic3D::pidStrainT+2])/3.0;
+ ( stateVars[s_totalStrain+0] +
+ stateVars[s_totalStrain+1] +
+ stateVars[s_totalStrain+2] ) / 3.0;
// Time integration.
- double dq = ViscoelasticMaxwell::computeVisStrain(_dt, maxwelltime);
- const double expFac = exp(-_dt/maxwelltime);
+ double dq = ViscoelasticMaxwell::viscousStrainParam(_dt, maxwellTime);
+ const double expFac = exp(-_dt/maxwellTime);
double devStrainTpdt = 0.0;
double devStrainT = 0.0;
for (int iComp=0; iComp < tensorSize; ++iComp) {
devStrainTpdt = totalStrain[iComp] - diag[iComp] * meanStrainTpdt;
- devStrainT = properties[_MaxwellIsotropic3D::pidStrainT+iComp] -
- diag[iComp] * meanStrainT;
- _visStrain[iComp] = expFac *
- properties[_MaxwellIsotropic3D::pidVisStrain + iComp] +
+ devStrainT = stateVars[s_totalStrain+iComp] - diag[iComp] * meanStrainT;
+ _viscousStrain[iComp] = expFac * stateVars[s_viscousStrain+iComp] +
dq * (devStrainTpdt - devStrainT);
} // for
@@ -318,46 +401,55 @@
// material.
void
pylith::materials::MaxwellIsotropic3D::_calcStressElastic(
- double* const stress,
- const int stressSize,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize,
- const bool computeStateVars)
+ double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars)
{ // _calcStressElastic
assert(0 != stress);
assert(_MaxwellIsotropic3D::tensorSize == stressSize);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
assert(0 != totalStrain);
assert(_MaxwellIsotropic3D::tensorSize == strainSize);
- assert(_MaxwellIsotropic3D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStrainSize);
- const double mu = properties[_MaxwellIsotropic3D::pidMu];
- const double lambda = properties[_MaxwellIsotropic3D::pidLambda];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
const double mu2 = 2.0 * mu;
- const double e11 = totalStrain[0];
- const double e22 = totalStrain[1];
- const double e33 = totalStrain[2];
- const double e12 = totalStrain[3];
- const double e23 = totalStrain[4];
- const double e13 = totalStrain[5];
+ // :TODO: Need to consider initial state variables????
+ const double e11 = totalStrain[0] - initialStrain[0];
+ const double e22 = totalStrain[1] - initialStrain[1];
+ const double e33 = totalStrain[2] - initialStrain[2];
+ const double e12 = totalStrain[3] - initialStrain[3];
+ const double e23 = totalStrain[4] - initialStrain[4];
+ const double e13 = totalStrain[5] - initialStrain[5];
- const double traceStrainTpdt = e11 + e22 + e33;
- const double s123 = lambda * traceStrainTpdt;
+ const double s123 = lambda * (e11 + e22 + e33);
- stress[0] = s123 + mu2*e11 + initialState[0];
- stress[1] = s123 + mu2*e22 + initialState[1];
- stress[2] = s123 + mu2*e33 + initialState[2];
- stress[3] = mu2 * e12 + initialState[3];
- stress[4] = mu2 * e23 + initialState[4];
- stress[5] = mu2 * e13 + initialState[5];
+ stress[0] = s123 + mu2*e11 + initialStress[0];
+ stress[1] = s123 + mu2*e22 + initialStress[1];
+ stress[2] = s123 + mu2*e33 + initialStress[2];
+ stress[3] = mu2 * e12 + initialStress[3];
+ stress[4] = mu2 * e23 + initialStress[4];
+ stress[5] = mu2 * e13 + initialStress[5];
- PetscLogFlops(19);
+ PetscLogFlops(25);
} // _calcStressElastic
// ----------------------------------------------------------------------
@@ -365,65 +457,73 @@
// material.
void
pylith::materials::MaxwellIsotropic3D::_calcStressViscoelastic(
- double* const stress,
- const int stressSize,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize,
- const bool computeStateVars)
+ double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars)
{ // _calcStressViscoelastic
assert(0 != stress);
assert(_MaxwellIsotropic3D::tensorSize == stressSize);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
assert(0 != totalStrain);
assert(_MaxwellIsotropic3D::tensorSize == strainSize);
- assert(_MaxwellIsotropic3D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStrainSize);
const int tensorSize = _MaxwellIsotropic3D::tensorSize;
- const double mu = properties[_MaxwellIsotropic3D::pidMu];
- const double lambda = properties[_MaxwellIsotropic3D::pidLambda];
- const double maxwelltime = properties[_MaxwellIsotropic3D::pidMaxwellTime];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
+ const double maxwellTime = properties[p_maxwellTime];
const double mu2 = 2.0 * mu;
- const double bulkModulus = lambda + mu2/3.0;
+ const double bulkModulus = lambda + mu2 / 3.0;
- const double e11 = totalStrain[0];
- const double e22 = totalStrain[1];
- const double e33 = totalStrain[2];
+ // :TODO: Need to determine how to incorporate initial strain and
+ // state variables
+ const double e11 = totalStrain[0] - initialStrain[0];
+ const double e22 = totalStrain[1] - initialStrain[1];
+ const double e33 = totalStrain[2] - initialStrain[2];
- const double traceStrainTpdt = e11 + e22 + e33;
- const double meanStrainTpdt = traceStrainTpdt/3.0;
- const double meanStressTpdt = bulkModulus * traceStrainTpdt;
+ const double e123 = e11 + e22 + e33;
+ const double meanStrainTpdt = e123 / 3.0;
+ const double meanStressTpdt = bulkModulus * e123;
const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
// Get viscous strains
- if (computeStateVars) {
- pylith::materials::MaxwellIsotropic3D::_computeStateVars(properties,
- numProperties,
- totalStrain,
- strainSize,
- initialState,
- initialStateSize);
- } else {
- memcpy(&_visStrain[0], &properties[_MaxwellIsotropic3D::pidVisStrain],
- tensorSize * sizeof(double));
- } // else
+ if (computeStateVars)
+ _computeStateVars(stateVars, numStateVars,
+ properties, numProperties,
+ totalStrain, strainSize,
+ initialStress, initialStressSize,
+ initialStrain, initialStrainSize);
+ else
+ memcpy(&_viscousStrain[0], &stateVars[s_viscousStrain],
+ tensorSize*sizeof(double));
// Compute new stresses
double devStressTpdt = 0.0;
for (int iComp=0; iComp < tensorSize; ++iComp) {
- devStressTpdt = mu2 * _visStrain[iComp];
+ devStressTpdt = mu2 * _viscousStrain[iComp];
- // Later I will want to put in initial stresses.
stress[iComp] = diag[iComp] * meanStressTpdt + devStressTpdt +
- initialState[iComp];
+ initialStress[iComp];
} // for
PetscLogFlops(7 + 4 * tensorSize);
@@ -433,25 +533,34 @@
// Compute derivative of elasticity matrix at location from properties.
void
pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic(
- double* const elasticConsts,
- const int numElasticConsts,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // _calcElasticConstsElastic
assert(0 != elasticConsts);
assert(_MaxwellIsotropic3D::numElasticConsts == numElasticConsts);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
assert(0 != totalStrain);
assert(_MaxwellIsotropic3D::tensorSize == strainSize);
- assert(_MaxwellIsotropic3D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStrainSize);
- const double mu = properties[_MaxwellIsotropic3D::pidMu];
- const double lambda = properties[_MaxwellIsotropic3D::pidLambda];
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
const double mu2 = 2.0 * mu;
const double lambda2mu = lambda + mu2;
@@ -486,33 +595,42 @@
// as an elastic material.
void
pylith::materials::MaxwellIsotropic3D::_calcElasticConstsViscoelastic(
- double* const elasticConsts,
- const int numElasticConsts,
- const double* properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
+ double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
{ // _calcElasticConstsViscoelastic
assert(0 != elasticConsts);
assert(_MaxwellIsotropic3D::numElasticConsts == numElasticConsts);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
assert(0 != totalStrain);
assert(_MaxwellIsotropic3D::tensorSize == strainSize);
- assert(_MaxwellIsotropic3D::tensorSize == initialStateSize);
-
- const double mu = properties[_MaxwellIsotropic3D::pidMu];
- const double lambda = properties[_MaxwellIsotropic3D::pidLambda];
- const double maxwelltime = properties[_MaxwellIsotropic3D::pidMaxwellTime];
+ assert(0 != initialStress);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStrainSize);
+ const double mu = properties[p_mu];
+ const double lambda = properties[p_lambda];
+ const double maxwellTime = properties[p_maxwellTime];
+
const double mu2 = 2.0 * mu;
- const double bulkModulus = lambda + mu2/3.0;
+ const double bulkModulus = lambda + mu2 / 3.0;
- double dq = ViscoelasticMaxwell::computeVisStrain(_dt, maxwelltime);
+ double dq = ViscoelasticMaxwell::viscousStrainParam(_dt, maxwellTime);
- const double visFac = mu*dq/3.0;
+ const double visFac = mu * dq / 3.0;
elasticConsts[ 0] = bulkModulus + 4.0*visFac; // C1111
elasticConsts[ 1] = bulkModulus - 2.0*visFac; // C1122
elasticConsts[ 2] = elasticConsts[1]; // C1133
@@ -539,94 +657,96 @@
} // _calcElasticConstsViscoelastic
// ----------------------------------------------------------------------
-// Get stable time step for implicit time integration.
-double
-pylith::materials::MaxwellIsotropic3D::_stableTimeStepImplicit(const double* properties,
- const int numProperties) const
-{ // _stableTimeStepImplicit
- assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
-
- const double maxwellTime =
- properties[_MaxwellIsotropic3D::pidMaxwellTime];
- const double dtStable = 0.1*maxwellTime;
-
- return dtStable;
-} // _stableTimeStepImplicit
-
-// ----------------------------------------------------------------------
// Update state variables.
void
-pylith::materials::MaxwellIsotropic3D::_updatePropertiesElastic(
- double* const properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
-{ // _updatePropertiesElastic
+pylith::materials::MaxwellIsotropic3D::_updateStateVarsElastic(
+ double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
+{ // _updateStateVarsElastic
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
assert(0 != totalStrain);
assert(_MaxwellIsotropic3D::tensorSize == strainSize);
+ assert(0 != initialStress);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStrainSize);
- const double maxwelltime = properties[_MaxwellIsotropic3D::pidMaxwellTime];
+ const int tensorSize = _tensorSize;
+ const double maxwellTime = properties[p_maxwellTime];
const double e11 = totalStrain[0];
const double e22 = totalStrain[1];
const double e33 = totalStrain[2];
const double traceStrainTpdt = e11 + e22 + e33;
- const double meanStrainTpdt = traceStrainTpdt/3.0;
+ const double meanStrainTpdt = traceStrainTpdt / 3.0;
const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
- for (int iComp=0; iComp < _MaxwellIsotropic3D::tensorSize; ++iComp) {
- properties[_MaxwellIsotropic3D::pidStrainT+iComp] = totalStrain[iComp];
- properties[_MaxwellIsotropic3D::pidVisStrain+iComp] =
+ // :TODO: Need to account for initial values for state variables
+ // and the initial strain??
+ for (int iComp=0; iComp < tensorSize; ++iComp) {
+ stateVars[s_totalStrain+iComp] = totalStrain[iComp];
+ stateVars[s_viscousStrain+iComp] =
totalStrain[iComp] - diag[iComp] * meanStrainTpdt;
} // for
- PetscLogFlops(3 + 2 * _MaxwellIsotropic3D::tensorSize);
+ PetscLogFlops(3 + 2 * _tensorSize);
_needNewJacobian = true;
-} // _updatePropertiesElastic
+} // _updateStateVarsElastic
// ----------------------------------------------------------------------
// Update state variables.
void
-pylith::materials::MaxwellIsotropic3D::_updatePropertiesViscoelastic(
- double* const properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize)
-{ // _updatePropertiesViscoelastic
+pylith::materials::MaxwellIsotropic3D::_updateStateVarsViscoelastic(
+ double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize)
+{ // _updateStateVarsViscoelastic
+ assert(0 != stateVars);
+ assert(_numVarsQuadPt == numStateVars);
assert(0 != properties);
- assert(_totalPropsQuadPt == numProperties);
+ assert(_numPropsQuadPt == numProperties);
assert(0 != totalStrain);
assert(_MaxwellIsotropic3D::tensorSize == strainSize);
- assert(_MaxwellIsotropic3D::tensorSize == initialStateSize);
+ assert(0 != initialStress);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStressSize);
+ assert(0 != initialStrain);
+ assert(_MaxwellIsotropic3D::tensorSize == initialStrainSize);
- const int tensorSize = _MaxwellIsotropic3D::tensorSize;
+ const int tensorSize = _tensorSize;
- pylith::materials::MaxwellIsotropic3D::_computeStateVars(properties,
- numProperties,
- totalStrain,
- strainSize,
- initialState,
- initialStateSize);
+ _computeStateVars(stateVars, numStateVars,
+ properties, numProperties,
+ totalStrain, strainSize,
+ initialStress, initialStressSize,
+ initialStrain, initialStrainSize);
- memcpy(&properties[_MaxwellIsotropic3D::pidVisStrain],
- &_visStrain[0],
- tensorSize * sizeof(double));
- memcpy(&properties[_MaxwellIsotropic3D::pidStrainT],
- &totalStrain[0],
- tensorSize * sizeof(double));
+ memcpy(&stateVars[s_totalStrain], totalStrain, tensorSize*sizeof(double));
+ memcpy(&stateVars[s_viscousStrain], &_viscousStrain[0],
+ tensorSize*sizeof(double));
+
_needNewJacobian = false;
+} // _updateStateVarsViscoelastic
-} // _updatePropertiesViscoelastic
-
// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -25,17 +25,10 @@
#if !defined(pylith_materials_maxwellisotropic3d_hh)
#define pylith_materials_maxwellisotropic3d_hh
-#include "ElasticMaterial.hh"
+// Include directives ---------------------------------------------------
+#include "ElasticMaterial.hh" // ISA ElasticMaterial
-/// Namespace for pylith package
-namespace pylith {
- namespace materials {
- class MaxwellIsotropic3D;
- class TestMaxwellIsotropic3D; // unit testing
- } // materials
-} // pylith
-
-/// 3-D, isotropic, linear Maxwell viscoelastic material.
+// MaxwellIsotropic3D ---------------------------------------------------
class pylith::materials::MaxwellIsotropic3D : public ElasticMaterial
{ // class MaxwellIsotropic3D
friend class TestMaxwellIsotropic3D; // unit testing
@@ -61,13 +54,6 @@
*/
void useElasticBehavior(const bool flag);
- /** Get flag indicating whether material implements an empty
- * _updateProperties() method.
- *
- * @returns False if _updateProperties() is empty, true otherwise.
- */
- bool usesUpdateProperties(void) const;
-
// PROTECTED METHODS //////////////////////////////////////////////////
protected :
@@ -98,22 +84,18 @@
void _dimProperties(double* const values,
const int nvalues) const;
- /** Nondimensionalize initial state.
+ /** Compute initial state variables from values in spatial database.
*
- * @param values Array of initial state values.
- * @param nvalues Number of values.
+ * @param stateValues Array of state variable values.
+ * @param dbValues Array of database values.
*/
- void _nondimInitState(double* const values,
- const int nvalues) const;
+ void _dbToStateVars(double* const stateValues,
+ const double_array& dbValues) const;
- /** Dimensionalize initial state.
- *
- * @param values Array of initial state values.
- * @param nvalues Number of values.
- */
- void _dimInitState(double* const values,
- const int nvalues) const;
+ // Note: We do not need to dimensionalize or nondimensionalize state
+ // variables because there are strains, which are dimensionless.
+
/** Compute density from properties.
*
* @param density Array for density.
@@ -122,30 +104,42 @@
*/
void _calcDensity(double* const density,
const double* properties,
- const int numProperties);
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
- /** Compute stress tensor from properties. If the state variables
- * are from the previous time step, then the computeStateVars flag
- * should be set to true so that the state variables are updated
- * (but not stored) when computing the stresses.
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStress(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute derivatives of elasticity matrix from properties.
@@ -154,42 +148,65 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConsts(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
- /** Get stable time step for implicit time integration.
+ /** Update state variables (for next time step).
*
- * @returns Time step
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
- double _stableTimeStepImplicit(const double* properties,
- const int numProperties) const;
+ void _updateStateVars(double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
- /** Update properties (for next time step).
+ /** Get stable time step for implicit time integration.
*
* @param properties Properties at location.
* @param numProperties Number of properties.
- * @param totalStrain Total strain at location.
- * @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
*/
- void _updateProperties(double* const properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
// PRIVATE TYPEDEFS ///////////////////////////////////////////////////
private :
@@ -204,6 +221,10 @@
const int,
const double*,
const int,
+ const double*,
+ const int,
+ const double*,
+ const int,
const bool);
/// Member prototype for _calcElasticConsts()
@@ -215,78 +236,111 @@
const double*,
const int,
const double*,
+ const int,
+ const double*,
+ const int,
+ const double*,
const int);
- /// Member prototype for _updateProperties()
- typedef void (pylith::materials::MaxwellIsotropic3D::*updateProperties_fn_type)
+ /// Member prototype for _updateStateVars()
+ typedef void (pylith::materials::MaxwellIsotropic3D::*updateStateVars_fn_type)
(double* const,
const int,
const double*,
const int,
const double*,
+ const int,
+ const double*,
+ const int,
+ const double*,
const int);
// PRIVATE METHODS ////////////////////////////////////////////////////
private :
-/** Compute viscous strains (state variables) for the current time step.
+ /** Compute viscous strains (state variables) for the current time
+ * step.
*
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param properties Properties at location.
* @param numProperties Number of properties.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
- void _computeStateVars(const double* properties,
+ void _computeStateVars(const double* stateVars,
+ const int numStateVars,
+ const double* properties,
const int numProperties,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Compute stress tensor from properties as an elastic material.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
- * @param properties Properties at locations.
+ * @param properties Properties at location.
* @param numProperties Number of properties.
- * @param totalStrain Total strain at locations.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStressElastic(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute stress tensor from properties as an viscoelastic material.
*
* @param stress Array for stress tensor.
* @param stressSize Size of stress tensor.
- * @param properties Properties at locations.
+ * @param properties Properties at location.
* @param numProperties Number of properties.
- * @param totalStrain Total strain at locations.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
- * @param computeStateVars Flag indicating to compute updated state vars.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
*/
void _calcStressViscoelastic(double* const stress,
const int stressSize,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
const bool computeStateVars);
/** Compute derivatives of elasticity matrix from properties as an
@@ -296,19 +350,27 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConstsElastic(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Compute derivatives of elasticity matrix from properties as a
* viscoelastic material.
@@ -317,66 +379,80 @@
* @param numElasticConsts Number of elastic constants.
* @param properties Properties at location.
* @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
void _calcElasticConstsViscoelastic(double* const elasticConsts,
const int numElasticConsts,
const double* properties,
const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Update state variables after solve as an elastic material.
*
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param properties Properties at location.
* @param numProperties Number of properties.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
- void _updatePropertiesElastic(double* const properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ void _updateStateVarsElastic(double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
/** Update state variables after solve as a viscoelastic material.
*
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
* @param properties Properties at location.
* @param numProperties Number of properties.
* @param totalStrain Total strain at location.
* @param strainSize Size of strain tensor.
- * @param initialState Initial state values.
- * @param initialStateSize Size of initial state array.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
*/
- void _updatePropertiesViscoelastic(double* const properties,
- const int numProperties,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize);
+ void _updateStateVarsViscoelastic(double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
- // NOT IMPLEMENTED ////////////////////////////////////////////////////
-private :
-
- /// Not implemented
- MaxwellIsotropic3D(const MaxwellIsotropic3D& m);
-
- /// Not implemented
- const MaxwellIsotropic3D& operator=(const MaxwellIsotropic3D& m);
-
// PRIVATE MEMBERS ////////////////////////////////////////////////////
private :
- /// Viscous strain array.
- double_array _visStrain;
+ double_array _viscousStrain; ///< Array for viscous strain tensor
/// Method to use for _calcElasticConsts().
calcElasticConsts_fn_type _calcElasticConstsFn;
@@ -384,9 +460,35 @@
/// Method to use for _calcStress().
calcStress_fn_type _calcStressFn;
- /// Method to use for _updateProperties().
- updateProperties_fn_type _updatePropertiesFn;
+ /// Method to use for _updateStateVars().
+ updateStateVars_fn_type _updateStateVarsFn;
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ static const int p_density;
+ static const int p_mu;
+ static const int p_lambda;
+ static const int p_maxwellTime;
+ static const int db_density;
+ static const int db_vs;
+ static const int db_vp;
+ static const int db_viscosity;
+
+ static const int s_totalStrain;
+ static const int s_viscousStrain;
+ static const int db_totalStrain;
+ static const int db_viscousStrain;
+
+ // NOT IMPLEMENTED ////////////////////////////////////////////////////
+private :
+
+ /// Not implemented
+ MaxwellIsotropic3D(const MaxwellIsotropic3D&);
+
+ /// Not implemented
+ const MaxwellIsotropic3D& operator=(const MaxwellIsotropic3D&);
+
}; // class MaxwellIsotropic3D
#include "MaxwellIsotropic3D.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/MaxwellIsotropic3D.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,7 +14,7 @@
#error "MaxwellIsotropic3D.icc can only be included from MaxwellIsotropic3D.hh"
#endif
-#include <assert.h> // USES assert()
+#include <cassert> // USES assert()
#include "pylith/utils/macrodefs.h" // USES CALL_MEMBER_FN
// Set current time step.
@@ -27,51 +27,30 @@
_dt = dt;
} // timeStep
-// Set whether elastic or inelastic constitutive relations are used.
-inline
-void
-pylith::materials::MaxwellIsotropic3D::useElasticBehavior(const bool flag) {
- if (flag) {
- _calcStressFn =
- &pylith::materials::MaxwellIsotropic3D::_calcStressElastic;
- _calcElasticConstsFn =
- &pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic;
- _updatePropertiesFn =
- &pylith::materials::MaxwellIsotropic3D::_updatePropertiesElastic;
- } else {
- _calcStressFn =
- &pylith::materials::MaxwellIsotropic3D::_calcStressViscoelastic;
- _calcElasticConstsFn =
- &pylith::materials::MaxwellIsotropic3D::_calcElasticConstsViscoelastic;
- _updatePropertiesFn =
- &pylith::materials::MaxwellIsotropic3D::_updatePropertiesViscoelastic;
- } // if/else
-} // useElasticBehavior
-
-// Get flag indicating whether material implements an empty
-inline
-bool
-pylith::materials::MaxwellIsotropic3D::usesUpdateProperties(void) const {
- return true;
-} // usesUpdateProperties
-
// Compute stress tensor from parameters.
inline
void
pylith::materials::MaxwellIsotropic3D::_calcStress(double* const stress,
const int stressSize,
- const double* parameters,
- const int numParams,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize,
- const bool computeStateVars) {
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars)
+{
assert(0 != _calcStressFn);
CALL_MEMBER_FN(*this, _calcStressFn)(stress, stressSize,
- parameters, numParams,
+ properties, numProperties,
+ stateVars, numStateVars,
totalStrain, strainSize,
- initialState, initialStateSize,
+ initialStress, initialStressSize,
+ initialStrain, initialStrainSize,
computeStateVars);
} // _calcStress
@@ -81,32 +60,45 @@
pylith::materials::MaxwellIsotropic3D::_calcElasticConsts(
double* const elasticConsts,
const int numElasticConsts,
- const double* parameters,
- const int numParams,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
const double* totalStrain,
const int strainSize,
- const double* initialState,
- const int initialStateSize) {
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize) {
assert(0 != _calcElasticConstsFn);
CALL_MEMBER_FN(*this, _calcElasticConstsFn)(elasticConsts, numElasticConsts,
- parameters, numParams,
+ properties, numProperties,
+ stateVars, numStateVars,
totalStrain, strainSize,
- initialState, initialStateSize);
+ initialStress, initialStressSize,
+ initialStrain, initialStrainSize);
} // _calcElasticConsts
// Update state variables after solve.
inline
void
-pylith::materials::MaxwellIsotropic3D::_updateProperties(double* const parameters,
- const int numParams,
- const double* totalStrain,
- const int strainSize,
- const double* initialState,
- const int initialStateSize) {
- assert(0 != _updatePropertiesFn);
- CALL_MEMBER_FN(*this, _updatePropertiesFn)(parameters, numParams,
- totalStrain, strainSize,
- initialState, initialStateSize);
-} // _updateProperties
+pylith::materials::MaxwellIsotropic3D::_updateStateVars(double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize) {
+ assert(0 != _updateStateVarsFn);
+ CALL_MEMBER_FN(*this, _updateStateVarsFn)(stateVars, numStateVars,
+ properties, numProperties,
+ totalStrain, strainSize,
+ initialStress, initialStressSize,
+ initialStrain, initialStrainSize);
+} // _updateStateVars
+
// End of file
Copied: short/3D/PyLith/trunk/libsrc/materials/Metadata.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/materials/Metadata.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Metadata.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/materials/Metadata.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,164 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "Metadata.hh" // implementation of class methods
+
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+#include <cassert> // USES assert()
+
+// ----------------------------------------------------------------------
+// Constructor.
+pylith::materials::Metadata::Metadata(const ParamDescription* props,
+ const int numProps,
+ const char* dbProps[],
+ const int numDBProps,
+ const ParamDescription* vars,
+ const int numVars,
+ const char* dbVars[],
+ const int numDBVars) :
+ _numDBProperties(numDBProps),
+ _dbProperties(dbProps),
+ _numDBStateVars(numDBVars),
+ _dbStateVars(dbVars)
+{ // constructor
+ ParameterInfo info;
+
+ // Set physical property information.
+ _properties.clear();
+ _propertyNames.resize(numProps);
+ for (int i=0; i < numProps; ++i) {
+ info.fiberDim = props[i].fiberDim;
+ info.fieldType = props[i].fieldType;
+ _properties[props[i].name] = info;
+ _propertyNames[i] = props[i].name;
+ } // for
+
+ // Set state variable information.
+ _stateVars.clear();
+ _stateVarNames.resize(numVars);
+ for (int i=0; i < numVars; ++i) {
+ info.fiberDim = vars[i].fiberDim;
+ info.fieldType = vars[i].fieldType;
+ _stateVars[vars[i].name] = info;
+ _stateVarNames[i] = vars[i].name;
+ } // for
+} // constructor
+
+// ----------------------------------------------------------------------
+// Copy constructor.
+pylith::materials::Metadata::Metadata(const Metadata& m) :
+ _properties(m._properties),
+ _stateVars(m._stateVars),
+ _propertyNames(m._propertyNames),
+ _stateVarNames(m._stateVarNames),
+ _dbProperties(m._dbProperties),
+ _dbStateVars(m._dbStateVars),
+ _numDBProperties(m._numDBProperties),
+ _numDBStateVars(m._numDBStateVars)
+{ // copy constructor
+} // copy constructor
+
+// ----------------------------------------------------------------------
+// Default destructor
+pylith::materials::Metadata::~Metadata(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+// Get fiber dimension of value.
+int
+pylith::materials::Metadata::fiberDim(const char* name,
+ const ValueEnum valueType) const
+{ // fiberDim
+ int fiberDim = 0;
+
+ switch(valueType)
+ { // switch
+
+ case PROPERTY : {
+ ParameterMap::const_iterator iter = _properties.find(name);
+ if (iter == _properties.end()) {
+ std::ostringstream msg;
+ msg << "Could not find property '" << name
+ << "' in list of properties to get fiber dimension.";
+ throw std::runtime_error(msg.str());
+ } // if
+ fiberDim = iter->second.fiberDim;
+ break;
+ } // PROPERTY
+
+ case STATEVAR : {
+ ParameterMap::const_iterator iter = _stateVars.find(name);
+ if (iter == _stateVars.end()) {
+ std::ostringstream msg;
+ msg << "Could not find state variable '" << name
+ << "' in list of state variables to get fiber dimension.";
+ throw std::runtime_error(msg.str());
+ } // if
+ fiberDim = iter->second.fiberDim;
+ break;
+ } // STATEVAR
+
+ default :
+ assert(0);
+ } // switch
+
+ return fiberDim;
+} // fiberDim
+
+// ----------------------------------------------------------------------
+// Get type of vector field associated with value.
+pylith::topology::FieldBase::VectorFieldEnum
+pylith::materials::Metadata::fieldType(const char* name,
+ const ValueEnum valueType) const
+{ // fieldType
+ topology::FieldBase::VectorFieldEnum fieldType = topology::FieldBase::OTHER;
+
+ switch(valueType)
+ { // switch
+
+ case PROPERTY : {
+ ParameterMap::const_iterator iter = _properties.find(name);
+ if (iter == _properties.end()) {
+ std::ostringstream msg;
+ msg << "Could not find property '" << name
+ << "' in list of properties to get vector field type.";
+ throw std::runtime_error(msg.str());
+ } // if
+ fieldType = iter->second.fieldType;
+ break;
+ } // PROPERTY
+
+ case STATEVAR : {
+ ParameterMap::const_iterator iter = _stateVars.find(name);
+ if (iter == _stateVars.end()) {
+ std::ostringstream msg;
+ msg << "Could not find state variable '" << name
+ << "' in list of state variables to get vector field type.";
+ throw std::runtime_error(msg.str());
+ } // if
+ fieldType = iter->second.fieldType;
+ break;
+ } // STATEVAR
+
+ default :
+ assert(0);
+ } // switch
+
+ return fieldType;
+} // fieldType
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/materials/Metadata.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/materials/Metadata.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Metadata.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/materials/Metadata.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,180 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/Metadata.hh
+ *
+ * @brief C++ object for material metadata.
+ *
+ * Extends Sieve mesh to include coordinate system associated with
+ * domain.
+ */
+
+#if !defined(pylith_materials_metadata_hh)
+#define pylith_materials_metadata_hh
+
+// Include directives ---------------------------------------------------
+#include "materialsfwd.hh" // forward declarations
+
+#include "pylith/topology/FieldBase.hh" // USES FieldBase::VectorFieldEnum
+#include "pylith/utils/array.hh" // HASA string_vector
+
+#include <map> // HASA std::map
+
+// MaterialMetadata -----------------------------------------------------
+class pylith::materials::Metadata
+{ // Mesh
+ friend class TestMetadata; // unit testing
+
+// PUBLIC ENUMS /////////////////////////////////////////////////////////
+public :
+
+ enum ValueEnum {
+ PROPERTY=0, ///< Property value.
+ STATEVAR=1, ///< State variable value.
+ }; // ValueEnum
+
+// PUBLIC STRUCTS ///////////////////////////////////////////////////////
+public :
+
+ struct ParamDescription {
+ const char* name;
+ const int fiberDim;
+ topology::FieldBase::VectorFieldEnum fieldType;
+ }; // ParamDescription
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /** Constructor.
+ *
+ * @param properties Array of property descriptions.
+ * @param numProperties Number of physical properties for material.
+ * @param dbProperties Array of names for database values for properties.
+ * @param numDBProperties Number of database values for physical properties.
+ * @param stateVars Array of state variable descriptions.
+ * @param numStateVars Number of state variables for material.
+ * @param dbStateVars Array of names for database values for state variables.
+ * @param numDBStateVars Number of database values for state variables.
+ */
+ Metadata(const ParamDescription* properties,
+ const int numProperties,
+ const char* dbProperties[],
+ const int numDBProperties,
+ const ParamDescription* stateVars,
+ const int numStateVars,
+ const char* dbStateVars[],
+ const int numDBStateVars);
+
+ /** Copy constructor.
+ *
+ * @parameter m Metadataw to copy.
+ */
+ Metadata(const Metadata& m);
+
+ /// Default destructor
+ ~Metadata(void);
+
+ /** Get names of properties.
+ *
+ * @returns Array of names of properties.
+ */
+ const string_vector& properties(void) const;
+
+ /** Get names of state variables.
+ *
+ * @returns Array of names of state variables.
+ */
+ const string_vector& stateVars(void) const;
+
+ /** Get fiber dimension of value.
+ *
+ * @param name Name of value.
+ * @param valueType Type of value.
+ */
+ int fiberDim(const char* name,
+ const ValueEnum valueType) const;
+
+ /** Get type of vector field associated with value.
+ *
+ * @param name Name of value.
+ * @param valueType Type of value.
+ */
+ topology::FieldBase::VectorFieldEnum
+ fieldType(const char* name,
+ const ValueEnum valueType) const;
+
+ /** Get names of database values for physical properties.
+ *
+ * @returns Array of names.
+ */
+ const char* const* dbProperties(void) const;
+
+ /** Get number of database values for physical properties.
+ *
+ * @returns Number of database values.
+ */
+ int numDBProperties(void) const;
+
+ /** Get names of database values for state variables.
+ *
+ * @returns Array of names.
+ */
+ const char* const* dbStateVars(void) const;
+
+ /** Get number of database values for state variables.
+ *
+ * @returns Number of database values.
+ */
+ int numDBStateVars(void) const;
+
+
+// PRIVATE STRUCTS //////////////////////////////////////////////////////
+private :
+
+ struct ParameterInfo {
+ int fiberDim; ///< Fiber dimension for parameter.
+ topology::FieldBase::VectorFieldEnum fieldType; ///< Type of Vector field.
+ }; // ParameterInfo
+
+// PRIVATE TYPEDEFS /////////////////////////////////////////////////////
+private :
+
+ typedef std::map< std::string, ParameterInfo > ParameterMap;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ ParameterMap _properties; ///< Physical properties information.
+ ParameterMap _stateVars; ///< State variable information.
+
+ string_vector _propertyNames; ///< Names of physical properties.
+ string_vector _stateVarNames; ///< Names of state variables.
+
+ const char* const* _dbProperties; ///< Names of db values for properties.
+ const char* const* _dbStateVars; ///< Names of db values for state varaibles.
+ const int _numDBProperties; ///< Number of db values for properties.
+ const int _numDBStateVars; ///< Number of db values for state variables.
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ const Metadata& operator=(const Metadata&); ///< Not implemented
+
+}; // Metadata
+
+#include "Metadata.icc"
+
+#endif // pylith_materials_metadata_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/materials/Metadata.icc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/materials/Metadata.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/Metadata.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/materials/Metadata.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#if !defined(pylith_materials_metadata_hh)
+#error "Metadata.icc can only be included from Metadata.hh"
+#endif
+
+// Get names of properties.
+inline
+const pylith::string_vector&
+pylith::materials::Metadata::properties(void) const {
+ return _propertyNames;
+}
+
+// Get names of state variables.
+inline
+const pylith::string_vector&
+pylith::materials::Metadata::stateVars(void) const {
+ return _stateVarNames;
+}
+
+// Get names of database values for physical properties.
+inline
+const char* const*
+pylith::materials::Metadata::dbProperties(void) const {
+ return _dbProperties;
+}
+
+// Get number of database values for physical properties.
+inline
+int
+pylith::materials::Metadata::numDBProperties(void) const {
+ return _numDBProperties;
+}
+
+// Get names of database values for state variables.
+inline
+const char* const*
+pylith::materials::Metadata::dbStateVars(void) const {
+ return _dbStateVars;
+}
+
+// Get number of database values for state variables.
+inline
+int
+pylith::materials::Metadata::numDBStateVars(void) const {
+ return _numDBStateVars;
+}
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,45 +21,52 @@
// ----------------------------------------------------------------------
// Compute viscous strain parameter for a linear Maxwell model.
double
-pylith::materials::ViscoelasticMaxwell::computeVisStrain(const double dt,
- const double maxwelltime)
-{ // check parameters and define cutoff values
- if (maxwelltime <= 0.0)
- throw std::runtime_error("Maxwell time must be > 0.");
+pylith::materials::ViscoelasticMaxwell::viscousStrainParam(const double dt,
+ const double maxwellTime)
+{ // viscousStrainParam
+ // Check parameters
+ if (maxwellTime <= 0.0)
+ throw std::runtime_error("Maxwell time must be greater than 0.");
+
+ // Define cutoff values
const double timeFrac = 1.0e-10;
- const int numTerms = 5;
- // Compute viscous strain parameter.
- // The ratio of dt and maxwelltime should never approach timeFrac for any
- // reasonable computation, but I have put in alternative solutions just in
+ // Compute viscous strain parameter. The ratio of dt and
+ // maxwellTime should never approach timeFrac for any reasonable
+ // computation, but I have put in alternative solutions just in
// case.
+
double dq = 0.0;
- // Use series expansion if dt is very small, since default solution blows
- // up otherwise.
- if(dt < timeFrac*maxwelltime) {
+
+ // Use series expansion if dt is very small, since default solution
+ // blows up otherwise.
+
+ if (dt < timeFrac*maxwellTime) {
double fSign = 1.0;
double factorial = 1.0;
double fraction = 1.0;
dq = 1.0;
+
+ const int numTerms = 5;
for (int iTerm=2; iTerm <= numTerms; ++iTerm) {
factorial *= iTerm;
fSign *= -1.0;
- fraction *= dt/maxwelltime;
- dq += fSign*fraction/factorial;
+ fraction *= dt / maxwellTime;
+ dq += fSign * fraction / factorial;
} // for
PetscLogFlops(8*(numTerms-1));
- // Throw away exponential term if maxwelltime is very small.
- } else if (maxwelltime < timeFrac*dt) {
- dq = maxwelltime/dt;
+ } else if (maxwellTime < timeFrac*dt) {
+ // Throw away exponential term if maxwellTime is very small.
+ dq = maxwellTime / dt;
PetscLogFlops(1);
- // Default solution.
} else{
- dq = maxwelltime*(1.0-exp(-dt/maxwelltime))/dt;
+ // Default solution.
+ dq = maxwellTime*(1.0-exp(-dt/maxwellTime))/dt;
PetscLogFlops(6);
} // else
return dq;
-} // computeVisStrain
+} // viscousStrainParam
// End of file
Modified: short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/materials/ViscoelasticMaxwell.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,10 +38,13 @@
/** Compute viscous strain parameter.
*
+ * @param dt Time step.
+ * @param maxwellTime Maxwell time.
+ *
* @returns Viscous strain parameter.
*/
- static double computeVisStrain(const double dt,
- const double maxwelltime);
+ static double viscousStrainParam(const double dt,
+ const double maxwellTime);
}; // class ViscoelasticMaxwell
Copied: short/3D/PyLith/trunk/libsrc/materials/materialsfwd.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/materials/materialsfwd.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/materialsfwd.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/materials/materialsfwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/materials/materialsfwd.hh
+ *
+ * @brief Forward declarations for PyLith materials objects.
+ *
+ * Including this header file eliminates the need to use separate
+ * forward declarations.
+ */
+
+#if !defined(pylith_materials_materialsfwd_hh)
+#define pylith_materials_materialsfwd_hh
+
+namespace pylith {
+ namespace materials {
+
+ class Metadata;
+ class ElasticMetadata;
+
+ class Material;
+
+ class ElasticMaterial;
+ class ElasticStrain1D;
+ class ElasticStress1D;
+ class ElasticPlaneStrain;
+ class ElasticPlaneStress;
+ class ElasticIsotropic3D;
+ class MaxwellIsotropic3D;
+ class GenMaxwellIsotropic3D;
+
+ } // materials
+} // pylith
+
+
+#endif // pylith_materials_materialsfwd_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/BinaryIO.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,17 +10,21 @@
// ======================================================================
//
+/**
+ * @file pylith/meshio/MeshIOCubit.hh
+ *
+ * @brief C++ object for general binary input/output operations.
+ */
+
#if !defined(pylith_meshio_binaryio_hh)
#define pylith_meshio_binaryio_hh
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
+
#include <iosfwd>
-namespace pylith {
- namespace meshio {
- class BinaryIO;
- } // meshio
-} // pylith
-
+// BinaryIO -------------------------------------------------------------
class pylith::meshio::BinaryIO
{ // BinaryIO
Modified: short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/CellFilter.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,39 +12,42 @@
#include <portinfo>
-#include "CellFilter.hh" // implementation of class methods
-
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::CellFilter::CellFilter(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>::CellFilter(void) :
_quadrature(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-pylith::meshio::CellFilter::~CellFilter(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>::~CellFilter(void)
{ // destructor
delete _quadrature; _quadrature = 0;
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-pylith::meshio::CellFilter::CellFilter(const CellFilter& f) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>::CellFilter(const CellFilter& f) :
_quadrature(0)
{ // copy constructor
if (0 != f._quadrature)
- _quadrature = f._quadrature->clone();
+ _quadrature = new feassemble::Quadrature<mesh_type>(*f._quadrature);
} // copy constructor
// ----------------------------------------------------------------------
// Set quadrature associated with cells.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::CellFilter::quadrature(const feassemble::Quadrature* q)
+pylith::meshio::CellFilter<mesh_type, field_type>::quadrature(const feassemble::Quadrature<mesh_type>* q)
{ // quadrature
- delete _quadrature; _quadrature = (0 != q) ? q->clone() : 0;
+ delete _quadrature;
+ _quadrature = (0 != q) ? new feassemble::Quadrature<mesh_type>(*q) : 0;
} // quadrature
Modified: short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/CellFilter.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,22 +20,26 @@
#if !defined(pylith_meshio_cellfilter_hh)
#define pylith_meshio_cellfilter_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh, real_section_type
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
-namespace pylith {
- namespace meshio {
- class CellFilter;
- } // meshio
+#include "pylith/topology/topologyfwd.hh" // HOLDSA Quadrature<Mesh>
+#include "pylith/feassemble/feassemblefwd.hh" // HOLDSA Quadrature<Mesh>
- namespace feassemble {
- class Quadrature;
- } // meshio
-} // pylith
-
+// CellFilter -----------------------------------------------------------
+template<typename mesh_type, typename field_type>
class pylith::meshio::CellFilter
{ // CellFilter
+// PROTECTED TYPEDEFS ///////////////////////////////////////////////////
+protected:
+
+ // Convenience typedefs
+ typedef typename mesh_type::SieveMesh SieveMesh;
+ typedef typename SieveMesh::label_sequence label_sequence;
+ typedef typename field_type::Mesh::RealSection RealSection;
+ typedef typename RealSection::chart_type chart_type;
+
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
@@ -56,23 +60,19 @@
*
* @param q Quadrature for cells.
*/
- void quadrature(const feassemble::Quadrature* q);
+ void quadrature(const feassemble::Quadrature<mesh_type>* q);
/** Filter field. Field type of filtered field is returned via an argument.
*
- * @param fieldType Field type of filtered field.
* @param fieldIn Field to filter.
- * @param mesh PETSc mesh.
- * @param label Label identifying cells.
- * @param Value of label of cells to filter.
+ * @param label Value of label of cells to filter.
+ * @param labelId Id associated with label of cells to filter.
*
* @returns Averaged field.
*/
virtual
- const ALE::Obj<real_section_type>&
- filter(VectorFieldEnum* fieldType,
- const ALE::Obj<real_section_type>& fieldIn,
- const ALE::Obj<Mesh>& mesh,
+ const field_type&
+ filter(const field_type& fieldIn,
const char* label =0,
const int labelId =0) = 0;
@@ -95,10 +95,13 @@
// PROTECTED MEMBERS ////////////////////////////////////////////////////
protected :
- feassemble::Quadrature* _quadrature; ///< Quadrature associated with cells.
+ /// Quadrature associated with cells.
+ feassemble::Quadrature<mesh_type>* _quadrature;
}; // CellFilter
+#include "CellFilter.cc" // template definitions
+
#endif // pylith_meshio_cellfilter_hh
Modified: short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,75 +12,112 @@
#include <portinfo>
-#include "CellFilterAvg.hh" // implementation of class methods
-
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::CellFilterAvg::CellFilterAvg(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::CellFilterAvg(void) :
+ _fieldAvg(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-pylith::meshio::CellFilterAvg::~CellFilterAvg(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::~CellFilterAvg(void)
{ // destructor
+ delete _fieldAvg; _fieldAvg = 0;
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-pylith::meshio::CellFilterAvg::CellFilterAvg(const CellFilterAvg& f) :
- CellFilter(f)
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::CellFilterAvg(
+ const CellFilterAvg& f) :
+ CellFilter<mesh_type, field_type>(f),
+ _fieldAvg(0)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Create copy of filter.
-pylith::meshio::CellFilter*
-pylith::meshio::CellFilterAvg::clone(void) const
+template<typename mesh_type, typename field_type>
+pylith::meshio::CellFilter<mesh_type, field_type>*
+pylith::meshio::CellFilterAvg<mesh_type, field_type>::clone(void) const
{ // clone
- return new CellFilterAvg(*this);
+ return new CellFilterAvg<mesh_type,field_type>(*this);
} // clone
// ----------------------------------------------------------------------
// Filter field.
-const ALE::Obj<pylith::real_section_type>&
-pylith::meshio::CellFilterAvg::filter(
- VectorFieldEnum* fieldType,
- const ALE::Obj<real_section_type>& fieldIn,
- const ALE::Obj<Mesh>& mesh,
- const char* label,
- const int labelId)
+template<typename mesh_type, typename field_type>
+const field_type&
+pylith::meshio::CellFilterAvg<mesh_type,field_type>::filter(
+ const field_type& fieldIn,
+ const char* label,
+ const int labelId)
{ // filter
- assert(0 != fieldType);
- assert(0 != _quadrature);
+ typedef typename mesh_type::SieveMesh SieveMesh;
+ typedef typename SieveMesh::label_sequence label_sequence;
+ typedef typename field_type::Mesh::RealSection RealSection;
- const int numQuadPts = _quadrature->numQuadPts();
- const double_array& wts = _quadrature->quadWts();
+ const feassemble::Quadrature<mesh_type>* quadrature =
+ CellFilter<mesh_type, field_type>::_quadrature;
+ assert(0 != quadrature);
+
+ const int numQuadPts = quadrature->numQuadPts();
+ const double_array& wts = quadrature->quadWts();
- const ALE::Obj<Mesh::label_sequence>& cells = (0 == label) ?
- mesh->heightStratum(0) :
- mesh->getLabelStratum(label, labelId);
+ const ALE::Obj<SieveMesh>& sieveMesh = fieldIn.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<label_sequence>& cells = (0 == label) ?
+ sieveMesh->heightStratum(0) :
+ sieveMesh->getLabelStratum(label, labelId);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const typename label_sequence::iterator cellsEnd = cells->end();
// Only processors with cells for output get the correct fiber dimension.
- const int totalFiberDim = fieldIn->getFiberDimension(*cells->begin());
+ const ALE::Obj<RealSection>& sectionIn = fieldIn.section();
+ assert(!sectionIn.isNull());
+ const int totalFiberDim = sectionIn->getFiberDimension(*cells->begin());
const int fiberDim = totalFiberDim / numQuadPts;
assert(fiberDim * numQuadPts == totalFiberDim);
- *fieldType = OTHER_FIELD; // Don't know field type
-
- // Allocation field if necessary
- if (_fieldAvg.isNull() ||
- fiberDim != _fieldAvg->getFiberDimension(*cells->begin())) {
- _fieldAvg = new real_section_type(mesh->comm(), mesh->debug());
- _fieldAvg->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- _fieldAvg->setFiberDimension(cells, fiberDim);
- mesh->allocate(_fieldAvg);
+ // Allocate field if necessary
+ if (0 == _fieldAvg) {
+ _fieldAvg = new field_type(fieldIn.mesh());
+ assert(0 != _fieldAvg);
+ _fieldAvg->newSection(sectionIn->getChart(), fiberDim);
+ _fieldAvg->allocate();
+
+ _fieldAvg->label(fieldIn.label());
+ switch (fieldIn.vectorFieldType())
+ { // switch
+ case topology::FieldBase::MULTI_SCALAR:
+ _fieldAvg->vectorFieldType(topology::FieldBase::SCALAR);
+ break;
+ case topology::FieldBase::MULTI_VECTOR:
+ _fieldAvg->vectorFieldType(topology::FieldBase::VECTOR);
+ break;
+ case topology::FieldBase::MULTI_TENSOR:
+ _fieldAvg->vectorFieldType(topology::FieldBase::TENSOR);
+ break;
+ case topology::FieldBase::MULTI_OTHER:
+ _fieldAvg->vectorFieldType(topology::FieldBase::OTHER);
+ break;
+ case topology::FieldBase::SCALAR:
+ case topology::FieldBase::VECTOR:
+ case topology::FieldBase::TENSOR:
+ case topology::FieldBase::OTHER:
+ default :
+ std::cerr << "Bad vector field type for CellFilterAvg." << std::endl;
+ assert(0);
+ } // switch
} // if
+ assert(0 != _fieldAvg);
+ const ALE::Obj<RealSection>& sectionAvg = _fieldAvg->section();
double_array fieldAvgCell(fiberDim);
double scalar = 0.0;
@@ -88,22 +125,21 @@
scalar += wts[iQuad];
// Loop over cells
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (typename label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- const real_section_type::value_type* values =
- fieldIn->restrictPoint(*c_iter);
+ const double* values = sectionIn->restrictPoint(*c_iter);
fieldAvgCell = 0.0;
for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
for (int i=0; i < fiberDim; ++i)
fieldAvgCell[i] += wts[iQuad] / scalar * values[iQuad*fiberDim+i];
- _fieldAvg->updatePoint(*c_iter, &fieldAvgCell[0]);
+ sectionAvg->updatePoint(*c_iter, &fieldAvgCell[0]);
PetscLogFlops( numQuadPts*fiberDim*3 );
} // for
- return _fieldAvg;
+ return *_fieldAvg;
} // filter
Modified: short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/CellFilterAvg.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,15 +20,12 @@
#if !defined(pylith_meshio_cellfilteravg_hh)
#define pylith_meshio_cellfilteravg_hh
+// Include directives ---------------------------------------------------
#include "CellFilter.hh" // ISA CellFilter
-namespace pylith {
- namespace meshio {
- class CellFilterAvg;
- } // meshio
-} // pylith
-
-class pylith::meshio::CellFilterAvg : public CellFilter
+// CellFilter -----------------------------------------------------------
+template<typename mesh_type, typename field_type>
+class pylith::meshio::CellFilterAvg : public CellFilter<mesh_type, field_type>
{ // CellFilterAvg
// PUBLIC METHODS ///////////////////////////////////////////////////////
@@ -44,22 +41,18 @@
*
* @returns Copy of filter.
*/
- CellFilter* clone(void) const;
+ CellFilter<mesh_type,field_type>* clone(void) const;
- /** Filter field. Field type of filtered field is returned via an argument.
+ /** Filter field over cells.
*
- * @param fieldType Field type of filtered field.
* @param fieldIn Field to filter.
- * @param mesh PETSc mesh.
* @param label Label identifying cells.
- * @param Value of label of cells to filter.
+ * @param labelId Value of label of cells to filter.
*
* @returns Averaged field.
*/
- const ALE::Obj<real_section_type>&
- filter(VectorFieldEnum* fieldType,
- const ALE::Obj<real_section_type>& fieldIn,
- const ALE::Obj<Mesh>& mesh,
+ const field_type&
+ filter(const field_type& fieldIn,
const char* label =0,
const int labelId =0);
@@ -77,15 +70,17 @@
private :
/// Not implemented.
- const CellFilter& operator=(const CellFilter&);
+ const CellFilterAvg& operator=(const CellFilterAvg&);
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- ALE::Obj<real_section_type> _fieldAvg; ///< Averaged cell field
+ field_type* _fieldAvg; ///< Averaged cell field
}; // CellFilterAvg
+#include "CellFilterAvg.cc" // template definitions
+
#endif // pylith_meshio_cellfilteravg_hh
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriter.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,63 +12,64 @@
#include <portinfo>
-#include "DataWriter.hh" // implementation of class methods
-
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::DataWriter::DataWriter(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriter<mesh_type, field_type>::DataWriter(void) :
_numTimeSteps(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-pylith::meshio::DataWriter::~DataWriter(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriter<mesh_type, field_type>::~DataWriter(void)
{ // destructor
} // destructor
// ----------------------------------------------------------------------
// Prepare for writing files.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter::open(
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
- const int numTimeSteps,
- const char* label,
- const int labelId)
+pylith::meshio::DataWriter<mesh_type, field_type>::open(const mesh_type& mesh,
+ const int numTimeSteps,
+ const char* label,
+ const int labelId)
{ // open
_numTimeSteps = numTimeSteps;
} // open
// ----------------------------------------------------------------------
// Close output files.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter::close(void)
+pylith::meshio::DataWriter<mesh_type, field_type>::close(void)
{ // close
} // close
// ----------------------------------------------------------------------
// Prepare file for data at a new time step.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter::openTimeStep(
- const double t,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
- const char* label,
- const int labelId)
+pylith::meshio::DataWriter<mesh_type, field_type>::openTimeStep(const double t,
+ const mesh_type& mesh,
+ const char* label,
+ const int labelId)
{ // openTimeStep
} // openTimeStep
// ----------------------------------------------------------------------
// Cleanup after writing data for a time step.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriter::closeTimeStep(void)
+pylith::meshio::DataWriter<mesh_type, field_type>::closeTimeStep(void)
{ // closeTimeStep
} // closeTimeStep
// ----------------------------------------------------------------------
// Copy constructor.
-pylith::meshio::DataWriter::DataWriter(const DataWriter& w)
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriter<mesh_type, field_type>::DataWriter(const DataWriter& w)
{ // copy constructor
} // copy constructor
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriter.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,21 +19,13 @@
#if !defined(pylith_meshio_datawriter_hh)
#define pylith_meshio_datawriter_hh
-#include "pylith/utils/sievetypes.hh" // USES ALE::Obj, PETSc Mesh, real_section_type
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
-namespace pylith {
- namespace meshio {
- class DataWriter;
- } // meshio
-} // pylith
+#include "pylith/topology/topologyfwd.hh" // USES Field
-namespace spatialdata {
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-
+// DataWriter -----------------------------------------------------------
+template<typename mesh_type, typename field_type>
class pylith::meshio::DataWriter
{ // DataWriter
@@ -56,16 +48,14 @@
/** Prepare for writing files.
*
- * @param mesh PETSc mesh object
- * @param csMesh Coordinate system of mesh geometry
+ * @param mesh Finite-element mesh.
* @param numTimeSteps Expected number of time steps for fields.
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
virtual
- void open(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
+ void open(const mesh_type& mesh,
const int numTimeSteps,
const char* label =0,
const int labelId =0);
@@ -78,15 +68,13 @@
*
* @param t Time stamp for new data
* @param mesh PETSc mesh object
- * @param csMesh Coordinate system of mesh geometry
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
virtual
void openTimeStep(const double t,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
+ const mesh_type& mesh,
const char* label =0,
const int labelId =0);
@@ -97,35 +85,23 @@
/** Write field over vertices to file.
*
* @param t Time associated with field.
- * @param name Name of field.
- * @param field PETSc field over vertices.
- * @param fieldType Type of field.
- * @param mesh Finite-element mesh
+ * @param field Field over vertices.
*/
virtual
void writeVertexField(const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh) = 0;
+ const field_type& field) = 0;
/** Write field over cells to file.
*
* @param t Time associated with field.
- * @param name Name of field.
- * @param field PETSc field over cells.
- * @param fieldType Type of field.
- * @param mesh PETSc mesh object.
+ * @param field Field over cells.
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
virtual
void writeCellField(const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh,
+ const field_type& field,
const char* label =0,
const int labelId =0) = 0;
@@ -150,6 +126,8 @@
}; // DataWriter
+#include "DataWriter.cc" // template methods
+
#endif // pylith_meshio_datawriter_hh
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,8 +12,6 @@
#include <portinfo>
-#include "DataWriterVTK.hh" // implementation of class methods
-
#include <petscmesh_viewers.hh> // USES VTKViewer
#include <cassert> // USES assert()
@@ -22,7 +20,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::DataWriterVTK::DataWriterVTK(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::DataWriterVTK(void) :
_timeConstant(1.0),
_filename("output.vtk"),
_timeFormat("%f"),
@@ -34,7 +33,8 @@
// ----------------------------------------------------------------------
// Destructor
-pylith::meshio::DataWriterVTK::~DataWriterVTK(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::~DataWriterVTK(void)
{ // destructor
if (0 != _viewer)
PetscViewerDestroy(_viewer);
@@ -43,8 +43,9 @@
// ----------------------------------------------------------------------
// Copy constructor.
-pylith::meshio::DataWriterVTK::DataWriterVTK(const DataWriterVTK& w) :
- DataWriter(w),
+template<typename mesh_type, typename field_type>
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::DataWriterVTK(const DataWriterVTK<mesh_type, field_type>& w) :
+ DataWriter<mesh_type, field_type>(w),
_timeConstant(w._timeConstant),
_filename(w._filename),
_timeFormat(w._timeFormat),
@@ -56,8 +57,9 @@
// ----------------------------------------------------------------------
// Set value used to normalize time stamp in name of VTK file.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK::timeConstant(const double value)
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::timeConstant(const double value)
{ // timeConstant
if (value <= 0.0) {
std::ostringstream msg;
@@ -70,42 +72,46 @@
// ----------------------------------------------------------------------
// Prepare file for data at a new time step.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK::openTimeStep(
- const double t,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
- const char* label,
- const int labelId)
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::openTimeStep(const double t,
+ const mesh_type& mesh,
+ const char* label,
+ const int labelId)
{ // openTimeStep
- assert(!mesh.isNull());
- assert(0 != csMesh);
try {
- PetscErrorCode err;
-
+ PetscErrorCode err = 0;
+
const std::string& filename = _vtkFilename(t);
- err = PetscViewerCreate(mesh->comm(), &_viewer);
+ err = PetscViewerCreate(mesh.comm(), &_viewer);
+ CHECK_PETSC_ERROR(err);
err = PetscViewerSetType(_viewer, PETSC_VIEWER_ASCII);
+ CHECK_PETSC_ERROR(err);
err = PetscViewerSetFormat(_viewer, PETSC_VIEWER_ASCII_VTK);
+ CHECK_PETSC_ERROR(err);
err = PetscViewerFileSetName(_viewer, filename.c_str());
- if (err)
- throw std::runtime_error("Could not open VTK file.");
+ CHECK_PETSC_ERROR(err);
+
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = mesh.sieveMesh();
err = VTKViewer::writeHeader(_viewer);
+ CHECK_PETSC_ERROR(err);
//std::cout << "Wrote header for " << filename << std::endl;
- err = VTKViewer::writeVertices(mesh, _viewer);
+ err = VTKViewer::writeVertices(sieveMesh, _viewer);
+ CHECK_PETSC_ERROR(err);
//std::cout << "Wrote vertices for " << filename << std::endl;
- if (0 == label)
- err = VTKViewer::writeElements(mesh, _viewer);
- else {
+ if (0 == label) {
+ err = VTKViewer::writeElements(sieveMesh, _viewer);
+ CHECK_PETSC_ERROR(err);
+ } else {
const std::string labelName =
- (mesh->hasLabel("censored depth")) ? "censored depth" : "depth";
- err = VTKViewer::writeElements(mesh, label, labelId, labelName, 0, _viewer);
+ (sieveMesh->hasLabel("censored depth")) ? "censored depth" : "depth";
+ err = VTKViewer::writeElements(sieveMesh, label, labelId, labelName,
+ 0, _viewer);
+ CHECK_PETSC_ERROR(err);
} // if
- if (err)
- throw std::runtime_error("Could not write topology.");
//std::cout << "Wrote elements for " << filename << std::endl;
_wroteVertexHeader = false;
@@ -130,8 +136,9 @@
// ----------------------------------------------------------------------
/// Cleanup after writing data for a time step.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK::closeTimeStep(void)
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::closeTimeStep(void)
{ // closeTimeStep
PetscViewerDestroy(_viewer); _viewer = 0;
_wroteVertexHeader = false;
@@ -140,61 +147,58 @@
// ----------------------------------------------------------------------
// Write field over vertices to file.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK::writeVertexField(
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::writeVertexField(
const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh)
+ const field_type& field)
{ // writeVertexField
- assert(0 != name);
- assert(!mesh.isNull());
- assert(!field.isNull());
+ typedef typename field_type::Mesh::SieveMesh SieveMesh;
+ typedef typename field_type::Mesh::RealSection RealSection;
try {
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- assert(!vertices.isNull());
int rank = 0;
- MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
+ MPI_Comm_rank(field.mesh().comm(), &rank);
+ const ALE::Obj<SieveMesh>& sieveMesh = field.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
const std::string labelName =
- (mesh->hasLabel("censored depth")) ? "censored depth" : "depth";
- const ALE::Obj<Mesh::numbering_type>& numbering =
- mesh->getFactory()->getNumbering(mesh, labelName, 0);
+ (sieveMesh->hasLabel("censored depth")) ? "censored depth" : "depth";
+ const ALE::Obj<typename SieveMesh::numbering_type>& numbering =
+ sieveMesh->getFactory()->getNumbering(sieveMesh, labelName, 0);
assert(!numbering.isNull());
+ const ALE::Obj<RealSection>& section = field.section();
+ assert(!section.isNull());
+ assert(!sieveMesh->getLabelStratum(labelName, 0).isNull());
const int localFiberDim =
- field->getFiberDimension(*mesh->getLabelStratum(labelName, 0)->begin());
- int fiberDim;
- MPI_Allreduce((void *) &localFiberDim, (void *) &fiberDim, 1, MPI_INT, MPI_MAX,
- mesh->comm());
+ section->getFiberDimension(*sieveMesh->getLabelStratum(labelName, 0)->begin());
+ int fiberDim = 0;
+ MPI_Allreduce((void *) &localFiberDim, (void *) &fiberDim, 1,
+ MPI_INT, MPI_MAX, field.mesh().comm());
assert(fiberDim > 0);
- const int enforceDim = (fieldType != VECTOR_FIELD) ? fiberDim : 3;
+ const int enforceDim =
+ (field.vectorFieldType() != topology::FieldBase::VECTOR) ? fiberDim : 3;
PetscErrorCode err = 0;
-
if (!_wroteVertexHeader) {
err = PetscViewerASCIIPrintf(_viewer, "POINT_DATA %d\n",
- numbering->getGlobalSize());
- if (err)
- throw std::runtime_error("Could not write VTK point data header.");
+ numbering->getGlobalSize());
+ CHECK_PETSC_ERROR(err);
_wroteVertexHeader = true;
} // if
- err = VTKViewer::writeField(field, name, fiberDim, numbering, _viewer,
- enforceDim);
- if (err)
- throw std::runtime_error("Coult not write vertex field.");
-
+ err = VTKViewer::writeField(section, field.label(), fiberDim, numbering,
+ _viewer, enforceDim);
+ CHECK_PETSC_ERROR(err);
} catch (const std::exception& err) {
std::ostringstream msg;
- msg << "Error while writing field '" << name << "' at time "
+ msg << "Error while writing field '" << field.label() << "' at time "
<< t << " to VTK file '" << _filename << "'.\n" << err.what();
throw std::runtime_error(msg.str());
} catch (...) {
std::ostringstream msg;
- msg << "Error while writing field '" << name << "' at time "
+ msg << "Error while writing field '" << field.label() << "' at time "
<< t << " to VTK file '" << _filename << "'.\n";
throw std::runtime_error(msg.str());
} // try/catch
@@ -202,66 +206,64 @@
// ----------------------------------------------------------------------
// Write field over cells to file.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::DataWriterVTK::writeCellField(
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::writeCellField(
const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh,
+ const field_type& field,
const char* label,
const int labelId)
{ // writeCellField
- assert(0 != name);
- assert(!mesh.isNull());
- assert(!field.isNull());
+ typedef typename field_type::Mesh::SieveMesh SieveMesh;
+ typedef typename field_type::Mesh::RealSection RealSection;
try {
- const ALE::Obj<Mesh::label_sequence>& cells = (0 == label) ?
- mesh->heightStratum(0) :
- mesh->getLabelStratum(label, labelId);
- assert(!cells.isNull());
int rank = 0;
- MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
+ MPI_Comm_rank(field.mesh().comm(), &rank);
// Correctly handle boundary and fault meshes
// Cannot just use mesh->depth() because boundaries report the wrong thing
- const int cellDepth = (mesh->depth() == -1) ? -1 : 1;
+ const ALE::Obj<SieveMesh>& sieveMesh = field.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+ const int cellDepth = (sieveMesh->depth() == -1) ? -1 : 1;
const int depth = (0 == label) ? cellDepth : labelId;
const std::string labelName = (0 == label) ?
- ((mesh->hasLabel("censored depth")) ? "censored depth" : "depth") : label;
- const ALE::Obj<Mesh::numbering_type>& numbering =
- mesh->getFactory()->getNumbering(mesh, labelName, depth);
+ ((sieveMesh->hasLabel("censored depth")) ?
+ "censored depth" : "depth") : label;
+ assert(!sieveMesh->getFactory().isNull());
+ const ALE::Obj<typename SieveMesh::numbering_type>& numbering =
+ sieveMesh->getFactory()->getNumbering(sieveMesh, labelName, depth);
assert(!numbering.isNull());
+ assert(!sieveMesh->getLabelStratum(labelName, depth).isNull());
+ const ALE::Obj<RealSection>& section = field.section();
+ assert(!section.isNull());
const int localFiberDim =
- field->getFiberDimension(*mesh->getLabelStratum(labelName, depth)->begin());
- int fiberDim;
- MPI_Allreduce((void *) &localFiberDim, (void *) &fiberDim, 1, MPI_INT, MPI_MAX,
- mesh->comm());
+ section->getFiberDimension(*sieveMesh->getLabelStratum(labelName, depth)->begin());
+ int fiberDim = 0;
+ MPI_Allreduce((void *) &localFiberDim, (void *) &fiberDim, 1,
+ MPI_INT, MPI_MAX, field.mesh().comm());
assert(fiberDim > 0);
- const int enforceDim = (fieldType != VECTOR_FIELD) ? fiberDim : 3;
+ const int enforceDim =
+ (field.vectorFieldType() != topology::FieldBase::VECTOR) ? fiberDim : 3;
PetscErrorCode err = 0;
-
if (!_wroteCellHeader) {
err = PetscViewerASCIIPrintf(_viewer, "CELL_DATA %d\n",
- numbering->getGlobalSize());
- if (err)
- throw std::runtime_error("Could not write VTK point data header.");
+ numbering->getGlobalSize());
+ CHECK_PETSC_ERROR(err);
_wroteCellHeader = true;
} // if
- VTKViewer::writeField(field, name, fiberDim, numbering, _viewer,
- enforceDim);
-
+ VTKViewer::writeField(section, field.label(), fiberDim, numbering,
+ _viewer, enforceDim);
} catch (const std::exception& err) {
std::ostringstream msg;
- msg << "Error while writing field '" << name << "' at time "
+ msg << "Error while writing field '" << field.label() << "' at time "
<< t << " to VTK file '" << _filename << "'.\n" << err.what();
throw std::runtime_error(msg.str());
} catch (...) {
std::ostringstream msg;
- msg << "Error while writing field '" << name << "' at time "
+ msg << "Error while writing field '" << field.label() << "' at time "
<< t << " to VTK file '" << _filename << "'.\n";
throw std::runtime_error(msg.str());
} // try/catch
@@ -269,12 +271,14 @@
// ----------------------------------------------------------------------
// Generate filename for VTK file.
+template<typename mesh_type, typename field_type>
std::string
-pylith::meshio::DataWriterVTK::_vtkFilename(const double t) const
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::_vtkFilename(const double t) const
{ // _vtkFilename
std::ostringstream filename;
const int indexExt = _filename.find(".vtk");
- if (_numTimeSteps > 0) {
+ const int numTimeSteps = DataWriter<mesh_type, field_type>::_numTimeSteps;
+ if (numTimeSteps > 0) {
// If data with multiple time steps, then add time stamp to filename
char sbuffer[256];
sprintf(sbuffer, _timeFormat.c_str(), t/_timeConstant);
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,21 +19,17 @@
#if !defined(pylith_meshio_datawritervtk_hh)
#define pylith_meshio_datawritervtk_hh
+// Include directives ---------------------------------------------------
#include "DataWriter.hh" // ISA DataWriter
-#include <string> // USES std::string
-
-namespace pylith {
- namespace meshio {
- class DataWriterVTK;
-
- class TestDataWriterVTK; // unit testing
- } // meshio
-} // pylith
-
-class pylith::meshio::DataWriterVTK : public DataWriter
+// DataWriterVTK --------------------------------------------------------
+template<typename mesh_type, typename field_type>
+class pylith::meshio::DataWriterVTK : public DataWriter<mesh_type,field_type>
{ // DataWriterVTK
- friend class TestDataWriterVTK; // unit testing
+ friend class TestDataWriterVTKMesh; // unit testing
+ friend class TestDataWriterVTKSubMesh; // unit testing
+ friend class TestDataWriterVTKBCMesh; // unit testing
+ friend class TestDataWriterVTKFaultMesh; // unit testing
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
@@ -48,7 +44,7 @@
*
* @returns Copy of this.
*/
- DataWriter* clone(void) const;
+ DataWriter<mesh_type, field_type>* clone(void) const;
/** Set filename for VTK file.
*
@@ -74,15 +70,13 @@
/** Prepare file for data at a new time step.
*
* @param t Time stamp for new data
- * @param mesh PETSc mesh object
- * @param csMesh Coordinate system of mesh geometry
+ * @param mesh Finite-element mesh.
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
void openTimeStep(const double t,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
+ const mesh_type& mesh,
const char* label =0,
const int labelId =0);
@@ -92,33 +86,21 @@
/** Write field over vertices to file.
*
* @param t Time associated with field.
- * @param name Name of field.
- * @param field PETSc field over vertices.
- * @param fieldType Type of field.
- * @param mesh Finite-element mesh
+ * @param field Field over vertices.
*/
void writeVertexField(const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh);
+ const field_type& field);
/** Write field over cells to file.
*
* @param t Time associated with field.
- * @param name Name of field.
- * @param field PETSc field over cells.
- * @param fieldType Type of field.
- * @param mesh PETSc mesh object.
+ * @param field Field over cells.
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
void writeCellField(const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh,
+ const field_type& field,
const char* label =0,
const int labelId =0);
@@ -159,6 +141,7 @@
}; // DataWriterVTK
#include "DataWriterVTK.icc" // inline methods
+#include "DataWriterVTK.cc" // template definitions
#endif // pylith_meshio_datawritervtk_hh
Modified: short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/DataWriterVTK.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,23 +15,26 @@
#else
// Make copy of this object.
+template<typename mesh_type, typename field_type>
inline
-pylith::meshio::DataWriter*
-pylith::meshio::DataWriterVTK::clone(void) const {
+pylith::meshio::DataWriter<mesh_type, field_type>*
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::clone(void) const {
return new DataWriterVTK(*this);
}
// Set filename for VTK file.
+template<typename mesh_type, typename field_type>
inline
void
-pylith::meshio::DataWriterVTK::filename(const char* filename) {
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::filename(const char* filename) {
_filename = filename;
}
// Set time format for time stamp in name of VTK file.
+template<typename mesh_type, typename field_type>
inline
void
-pylith::meshio::DataWriterVTK::timeFormat(const char* format) {
+pylith::meshio::DataWriterVTK<mesh_type,field_type>::timeFormat(const char* format) {
_timeFormat = format;
}
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFile.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFile.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFile.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,17 +10,21 @@
// ======================================================================
//
+/**
+ * @file libsrc/topology/GMVFile.hh
+ *
+ * @brief C++ base class for input/output of LaGriT GMV files.
+ */
+
#if !defined(pylith_meshio_gmvfile_hh)
#define pylith_meshio_gmvfile_hh
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
+
#include <string> // HASA std::string
-namespace pylith {
- namespace meshio {
- class GMVFile;
- } // meshio
-} // pylith
-
+// GMVFile --------------------------------------------------------------
class pylith::meshio::GMVFile
{ // GMVFile
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -113,7 +113,7 @@
assert(cells.size() == numCells * numCorners);
assert(materialIds.size() == numCells);
-#if 0
+#if 0 // NOT YET IMPLEMENTED
_writeHeader();
_writeVertices(coordinates);
_writeCells(cells);
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFileAscii.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,20 +10,22 @@
// ======================================================================
//
+/**
+ * @file libsrc/topology/GMVFileAscii.hh
+ *
+ * @brief C++ object for input/output of LaGriT ASCII GMV files.
+ */
+
#if !defined(pylith_meshio_gmvfileascii_hh)
#define pylith_meshio_gmvfileascii_hh
+// Include directives ---------------------------------------------------
#include "GMVFile.hh" // ISA GMVFile
#include "pylith/utils/arrayfwd.hh" // USES int_array, double_array
#include <iosfwd>
-namespace pylith {
- namespace meshio {
- class GMVFileAscii;
- } // meshio
-} // pylith
-
+// GMVFileAscii ---------------------------------------------------------
class pylith::meshio::GMVFileAscii : public GMVFile
{ // GMVFileAscii
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -118,7 +118,7 @@
assert(cells.size() == numCells * numCorners);
assert(materialIds.size() == numCells);
-#if 0
+#if 0 // NOT YET IMPLEMENTED
_writeHeader();
_writeVertices(coordinates);
_writeCells(cells);
Modified: short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/GMVFileBinary.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,20 +10,22 @@
// ======================================================================
//
+/**
+ * @file libsrc/topology/GMVFileAscii.hh
+ *
+ * @brief C++ object for input/output of LaGriT ASCII GMV files.
+ */
+
#if !defined(pylith_meshio_gmvfilebinary_hh)
#define pylith_meshio_gmvfilebinary_hh
+// Include directives ---------------------------------------------------
#include "GMVFile.hh" // ISA GMVFile
#include "pylith/utils/arrayfwd.hh" // USES int_array, double_array
#include <iosfwd>
-namespace pylith {
- namespace meshio {
- class GMVFileBinary;
- } // meshio
-} // pylith
-
+// GMVFileBinary --------------------------------------------------------
class pylith::meshio::GMVFileBinary : public GMVFile
{ // GMVFileBinary
Modified: short/3D/PyLith/trunk/libsrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,10 +15,15 @@
subpkginclude_HEADERS = \
CellFilter.hh \
+ CellFilter.cc \
CellFilterAvg.hh \
+ CellFilterAvg.cc \
DataWriter.hh \
+ DataWriter.cc \
DataWriterVTK.hh \
DataWriterVTK.icc \
+ DataWriterVTK.cc \
+ MeshBuilder.hh \
MeshIO.hh \
MeshIO.icc \
MeshIOAscii.hh \
@@ -26,9 +31,14 @@
MeshIOLagrit.hh \
MeshIOLagrit.icc \
OutputManager.hh \
+ OutputManager.cc \
OutputSolnSubset.hh \
+ UCDFaultFile.hh \
VertexFilter.hh \
- VertexFilterVecNorm.hh
+ VertexFilter.cc \
+ VertexFilterVecNorm.hh \
+ VertexFilterVecNorm.cc \
+ meshiofwd.hh
if ENABLE_CUBIT
subpkginclude_HEADERS += \
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/meshio/MeshBuilder.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,305 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "MeshBuilder.hh" // implementation of class methods
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/utils/array.hh" // USES double_array, int_array
+
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+
+#include "Selection.hh" // USES boundary()
+
+#include <cassert> // USES assert()
+#include <sstream> // USES std::ostringstream
+#include <stdexcept> // USES std::runtime_error
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
+// Set vertices and cells in mesh.
+void
+pylith::meshio::MeshBuilder::buildMesh(topology::Mesh* mesh,
+ double_array* coordinates,
+ const int numVertices,
+ const int spaceDim,
+ const int_array& cells,
+ const int numCells,
+ const int numCorners,
+ const int meshDim,
+ const bool interpolate,
+ const spatialdata::units::Nondimensional& normalizer)
+{ // buildMesh
+ assert(0 != mesh);
+
+ assert(0 != coordinates);
+ MPI_Comm comm = mesh->comm();
+ int dim = meshDim;
+ int rank = 0;
+
+ { // Check to make sure every vertex is in at least one cell.
+ // This is required by Sieve
+ std::vector<bool> vertexInCell(numVertices, false);
+ const int size = cells.size();
+ for (int i=0; i < size; ++i)
+ vertexInCell[cells[i]] = true;
+ int count = 0;
+ for (int i=0; i < numVertices; ++i)
+ if (!vertexInCell[i])
+ ++count;
+ if (count > 0) {
+ std::ostringstream msg;
+ msg << "Mesh contains " << count
+ << " vertices that are not in any cells.";
+ throw std::runtime_error(msg.str());
+ } // if
+ } // check
+
+ MPI_Bcast(&dim, 1, MPI_INT, 0, comm);
+ mesh->createSieveMesh(dim);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ ALE::Obj<SieveMesh::sieve_type> sieve =
+ new SieveMesh::sieve_type(mesh->comm());
+ sieveMesh->setSieve(sieve);
+
+ MPI_Comm_rank(comm, &rank);
+ // Memory debugging
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.setDebug(mesh->debug()/2);
+
+ logger.stagePush("MeshCreation");
+ if (0 == rank) {
+ assert(coordinates->size() == numVertices*spaceDim);
+ assert(cells.size() == numCells*numCorners);
+ if (!interpolate) {
+ // Create the ISieve
+ sieve->setChart(SieveMesh::sieve_type::chart_type(0,
+ numCells+numVertices));
+ // Set cone and support sizes
+ for (int c = 0; c < numCells; ++c)
+ sieve->setConeSize(c, numCorners);
+ sieve->symmetrizeSizes(numCells, numCorners,
+ const_cast<int*>(&cells[0]), numCells);
+ // Allocate point storage
+ sieve->allocate();
+ // Fill up cones
+ int *cone = new int[numCorners];
+ int *coneO = new int[numCorners];
+ for (int v = 0; v < numCorners; ++v)
+ coneO[v] = 1;
+ for (int c = 0; c < numCells; ++c) {
+ for (int v = 0; v < numCorners; ++v)
+ cone[v] = cells[c*numCorners+v]+numCells;
+ sieve->setCone(cone, c);
+ sieve->setConeOrientation(coneO, c);
+ } // for
+ delete[] cone; cone = 0;
+ delete[] coneO; coneO = 0;
+ // Symmetrize to fill up supports
+ sieve->symmetrize();
+ } else {
+ // Same old thing
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
+ ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, meshDim,
+ numCells,
+ const_cast<int*>(&cells[0]),
+ numVertices,
+ interpolate,
+ numCorners);
+ std::map<ALE::Mesh::point_type,ALE::Mesh::point_type> renumbering;
+ ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
+ } // if/else
+ logger.stagePop();
+ logger.stagePush("MeshStratification");
+ if (!interpolate) {
+ // Optimized stratification
+ const ALE::Obj<SieveMesh::label_type>& height =
+ sieveMesh->createLabel("height");
+ const ALE::Obj<SieveMesh::label_type>& depth =
+ sieveMesh->createLabel("depth");
+
+#ifdef IMESH_NEW_LABELS
+ height->setChart(sieveMesh->getSieve()->getChart());
+ depth->setChart(sieveMesh->getSieve()->getChart());
+ for(int c = 0; c < numCells+numVertices; ++c) {
+ height->setConeSize(c, 1);
+ depth->setConeSize(c, 1);
+ }
+ if (numCells+numVertices)
+ height->setSupportSize(0, numCells+numVertices);
+ if (numCells+numVertices)
+ depth->setSupportSize(0, numCells+numVertices);
+ height->allocate();
+ depth->allocate();
+#endif
+ for(int c = 0; c < numCells; ++c) {
+ height->setCone(0, c);
+ depth->setCone(1, c);
+ } // for
+ for(int v = numCells; v < numCells+numVertices; ++v) {
+ height->setCone(1, v);
+ depth->setCone(0, v);
+ } // for
+#ifdef IMESH_NEW_LABELS
+ height->recalculateLabel();
+ depth->recalculateLabel();
+#endif
+ sieveMesh->setHeight(1);
+ sieveMesh->setDepth(1);
+ } else {
+ sieveMesh->stratify();
+ } // if/else
+ logger.stagePop();
+ } else {
+ logger.stagePush("MeshStratification");
+ sieveMesh->getSieve()->setChart(SieveMesh::sieve_type::chart_type());
+ sieveMesh->getSieve()->allocate();
+ sieveMesh->stratify();
+ logger.stagePop();
+ } // if/else
+
+#if defined(ALE_MEM_LOGGING)
+ std::cout
+ << std::endl
+ << "MeshCreation " << logger.getNumAllocations("MeshCreation")
+ << " allocations " << logger.getAllocationTotal("MeshCreation")
+ << " bytes" << std::endl
+
+ << "MeshCreation " << logger.getNumDeallocations("MeshCreation")
+ << " deallocations " << logger.getDeallocationTotal("MeshCreation")
+ << " bytes" << std::endl
+
+ << "MeshStratification " << logger.getNumAllocations("MeshStratification")
+ << " allocations " << logger.getAllocationTotal("MeshStratification")
+ << " bytes" << std::endl
+
+ << "MeshStratification " << logger.getNumDeallocations("MeshStratification")
+ << " deallocations " << logger.getDeallocationTotal("MeshStratification")
+ << " bytes" << std::endl << std::endl;
+#endif
+
+ const double lengthScale = normalizer.lengthScale();
+ normalizer.nondimensionalize(&(*coordinates)[0], coordinates->size(),
+ lengthScale);
+
+ ALE::SieveBuilder<SieveMesh>::buildCoordinates(sieveMesh, spaceDim,
+ &(*coordinates)[0]);
+
+ sieveMesh->getFactory()->clear();
+} // buildMesh
+
+// ----------------------------------------------------------------------
+// Set vertices and cells for fault mesh.
+void
+pylith::meshio::MeshBuilder::buildFaultMesh(const ALE::Obj<SieveMesh>& fault,
+ ALE::Obj<ALE::Mesh>& faultBd,
+ const double_array& coordinates,
+ const int numVertices,
+ const int spaceDim,
+ const int_array& cells,
+ const int numCells,
+ const int numCorners,
+ const int firstCell,
+ const int_array& faceCells,
+ const int meshDim)
+{ // buildFaultMesh
+ MPI_Comm comm = PETSC_COMM_WORLD;
+ int dim = meshDim;
+ int rank = 0;
+
+ assert(!fault.isNull());
+
+ ALE::Obj<SieveMesh::sieve_type> sieve =
+ new SieveMesh::sieve_type(fault->comm());
+ fault->setDebug(fault->debug());
+ fault->setSieve(sieve);
+
+ MPI_Comm_rank(comm, &rank);
+ // Memory debugging
+ ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
+ logger.setDebug(fault->debug()/2);
+
+ logger.stagePush("FaultCreation");
+ if (0 == rank) {
+ assert(coordinates.size() == numVertices*spaceDim);
+ assert(cells.size() == numCells*numCorners);
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
+ ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, meshDim,
+ numCells,
+ const_cast<int*>(&cells[0]),
+ numVertices,
+ true,
+ numCorners,
+ 0,
+ fault->getArrowSection("orientation"),
+ firstCell);
+
+ // Add in cells
+ for(int c = 0; c < numCells; ++c) {
+ s->addArrow(c+firstCell, faceCells[c*2+0]);
+ s->addArrow(c+firstCell, faceCells[c*2+1]);
+ } // for
+
+ ALE::Mesh::renumbering_type& renumbering = fault->getRenumbering();
+ ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering, false);
+ ALE::ISieveConverter::convertOrientation(*s, *sieve, renumbering,
+ fault->getArrowSection("orientation").ptr());
+
+ Obj<ALE::Mesh> tmpMesh =
+ new ALE::Mesh(fault->comm(), dim, fault->debug());
+ faultBd = ALE::Selection<ALE::Mesh>::boundary(tmpMesh);
+
+ logger.stagePop();
+ logger.stagePush("FaultStratification");
+ fault->stratify();
+ logger.stagePop();
+ } else {
+ logger.stagePush("FaultStratification");
+ fault->getSieve()->setChart(SieveMesh::sieve_type::chart_type());
+ fault->getSieve()->allocate();
+ fault->stratify();
+ logger.stagePop();
+ } // if/else
+
+#if defined(ALE_MEM_LOGGING)
+ std::cout
+ << std::endl
+ << "FaultCreation " << logger.getNumAllocations("FaultCreation")
+ << " allocations " << logger.getAllocationTotal("FaultCreation")
+ << " bytes" << std::endl
+
+ << "FaultCreation " << logger.getNumDeallocations("FaultCreation")
+ << " deallocations " << logger.getDeallocationTotal("FaultCreation")
+ << " bytes" << std::endl
+
+ << "FaultStratification " << logger.getNumAllocations("FaultStratification")
+ << " allocations " << logger.getAllocationTotal("FaultStratification")
+ << " bytes" << std::endl
+
+ << "FaultStratification " << logger.getNumDeallocations("FaultStratification")
+ << " deallocations " << logger.getDeallocationTotal("FaultStratification")
+ << " bytes" << std::endl << std::endl;
+#endif
+
+} // buildFaultMesh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/meshio/MeshBuilder.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshBuilder.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_meshbuilder_hh)
+#define pylith_meshio_meshbuilder_hh
+
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
+
+#include "pylith/topology/topologyfwd.hh" // USES Mesh
+#include "pylith/utils/arrayfwd.hh" // USES double_array, int_array,
+ // string_vector
+#include "spatialdata/units/unitsfwd.hh" // USES Nondimensional
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+
+// MeshBuilder ----------------------------------------------------------
+class pylith::meshio::MeshBuilder
+{ // MeshBuilder
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Build mesh topology and set vertex coordinates.
+ *
+ * All mesh information must use zero based indices. In other words,
+ * the lowest index MUST be 0 not 1.
+ *
+ * @param mesh PyLith finite-element mesh.
+ * @param coordinates Array of coordinates of vertices.
+ * @param numVertices Number of vertices.
+ * @param spaceDim Dimension of vector space for vertex coordinates.
+ * @param cells Array of indices of vertices in cells (first index is 0).
+ * @param numCells Number of cells.
+ * @param numCorners Number of vertices per cell.
+ * @param meshDim Dimension of cells in mesh.
+ */
+ static
+ void buildMesh(topology::Mesh* mesh,
+ double_array* coordinates,
+ const int numVertices,
+ const int spaceDim,
+ const int_array& cells,
+ const int numCells,
+ const int numCorners,
+ const int meshDim,
+ const bool interpolate,
+ const spatialdata::units::Nondimensional& normalizer);
+
+ /** Build fault mesh topology.
+ *
+ * All mesh information must use zero based indices. In other words,
+ * the lowest index MUST be 0 not 1.
+ *
+ * @param fault PETSc mesh for fault.
+ * @param faultBd PETSc mesh for fault boundary.
+ * @param coordinates Array of coordinates of vertices.
+ * @param numVertices Number of vertices.
+ * @param spaceDim Dimension of vector space for vertex coordinates.
+ * @param cells Array of indices of vertices in cells (first index is 0).
+ * @param numCells Number of cells.
+ * @param numCorners Number of vertices per cell.
+ * @param firstCell Label of first cell.
+ * @param cells Array of indices of vertices for fault surface cells
+ * (first index is 0).
+ * @param meshDim Dimension of cells in mesh.
+ */
+ static
+ void buildFaultMesh(const ALE::Obj<topology::Mesh::SieveMesh>& fault,
+ ALE::Obj<ALE::Mesh>& faultBd,
+ const double_array& coordinates,
+ const int numVertices,
+ const int spaceDim,
+ const int_array& cells,
+ const int numCells,
+ const int numCorners,
+ const int firstCell,
+ const int_array& faceCells,
+ const int meshDim);
+
+
+}; // MeshBuilder
+
+#endif // pylith_meshio_meshbuilder_hh
+
+// End of file
+
+
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,7 @@
#include "MeshIO.hh" // implementation of class methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/utils/array.hh" // USES double_array, int_array
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
@@ -25,6 +26,11 @@
#include <stdexcept> // USES std::runtime_error
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::Mesh::IntSection IntSection;
+
+// ----------------------------------------------------------------------
// Constructor
pylith::meshio::MeshIO::MeshIO(void) :
_mesh(0),
@@ -46,39 +52,38 @@
int
pylith::meshio::MeshIO::getMeshDim(void) const
{ // getMeshDim
- assert(0 != _mesh);
- assert(!_mesh->isNull());
- return (*_mesh)->getDimension();
+ return (0 != _mesh) ? _mesh->dimension() : 0;
} // getMeshDim
// ----------------------------------------------------------------------
+// Set scales used to nondimensionalize mesh.
+void
+pylith::meshio::MeshIO::normalizer(
+ const spatialdata::units::Nondimensional& dim)
+{ // normalizer
+ if (0 == _normalizer)
+ _normalizer = new spatialdata::units::Nondimensional(dim);
+ else
+ *_normalizer = dim;
+} // normalizer
+
+// ----------------------------------------------------------------------
// Read mesh from file.
void
-pylith::meshio::MeshIO::read(ALE::Obj<Mesh>* mesh)
+pylith::meshio::MeshIO::read(topology::Mesh* mesh)
{ // read
assert(0 == _mesh);
_mesh = mesh;
+ _mesh->debug(_debug);
_read();
_mesh = 0;
- (*mesh)->getFactory()->clear();
} // read
// ----------------------------------------------------------------------
-// Set scales used to nondimensionalize mesh.
-void
-pylith::meshio::MeshIO::normalizer(const spatialdata::units::Nondimensional& dim)
-{ // normalizer
- if (0 == _normalizer)
- _normalizer = new spatialdata::units::Nondimensional(dim);
- else
- *_normalizer = dim;
-} // normalizer
-
-// ----------------------------------------------------------------------
// Write mesh to file.
void
-pylith::meshio::MeshIO::write(ALE::Obj<Mesh>* mesh)
+pylith::meshio::MeshIO::write(topology::Mesh* const mesh)
{ // write
assert(0 == _mesh);
@@ -88,261 +93,6 @@
} // write
// ----------------------------------------------------------------------
-// Set vertices and cells in mesh.
-void
-pylith::meshio::MeshIO::_buildMesh(double_array* coordinates,
- const int numVertices,
- const int spaceDim,
- const int_array& cells,
- const int numCells,
- const int numCorners,
- const int meshDim)
-{ // _buildMesh
- assert(0 != _mesh);
- assert(0 != coordinates);
- MPI_Comm comm = PETSC_COMM_WORLD;
- int dim = meshDim;
- int rank;
-
- { // Check to make sure every vertex is in at least one cell.
- // This is required by Sieve
- std::vector<bool> vertexInCell(numVertices, false);
- const int size = cells.size();
- for (int i=0; i < size; ++i)
- vertexInCell[cells[i]] = true;
- int count = 0;
- for (int i=0; i < numVertices; ++i)
- if (!vertexInCell[i])
- ++count;
- if (count > 0) {
- std::ostringstream msg;
- msg << "Mesh contains " << count
- << " vertices that are not in any cells.";
- throw std::runtime_error(msg.str());
- } // if
- } // check
-
- MPI_Bcast(&dim, 1, MPI_INT, 0, comm);
- // :BUG: This causes a memory leak.
- *_mesh = new Mesh(PETSC_COMM_WORLD, dim);
-
- assert(!_mesh->isNull());
- (*_mesh)->setDebug(_debug);
-
- ALE::Obj<sieve_type> sieve = new sieve_type((*_mesh)->comm());
- (*_mesh)->setSieve(sieve);
-
- MPI_Comm_rank(comm, &rank);
- // Memory debugging
- ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
- logger.setDebug(_debug/2);
-
- logger.stagePush("MeshCreation");
- if (!rank) {
- assert(coordinates->size() == numVertices*spaceDim);
- assert(cells.size() == numCells*numCorners);
- if (!_interpolate) {
- // Create the ISieve
- sieve->setChart(Mesh::sieve_type::chart_type(0, numCells+numVertices));
- // Set cone and support sizes
- for(int c = 0; c < numCells; ++c) {sieve->setConeSize(c, numCorners);}
- sieve->symmetrizeSizes(numCells, numCorners, const_cast<int*>(&cells[0]), numCells);
- // Allocate point storage
- sieve->allocate();
- // Fill up cones
- int *cone = new int[numCorners];
- int *coneO = new int[numCorners];
- for(int v = 0; v < numCorners; ++v) {coneO[v] = 1;}
- for(int c = 0; c < numCells; ++c) {
- for(int v = 0; v < numCorners; ++v) cone[v] = cells[c*numCorners+v]+numCells;
- sieve->setCone(cone, c);
- sieve->setConeOrientation(coneO, c);
- }
- delete [] cone;
- // Symmetrize to fill up supports
- sieve->symmetrize();
- } else {
- // Same old thing
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, meshDim,
- numCells,
- const_cast<int*>(&cells[0]),
- numVertices,
- _interpolate,
- numCorners);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- }
- logger.stagePop();
- logger.stagePush("MeshStratification");
- if (!_interpolate) {
- // Optimized stratification
- const ALE::Obj<Mesh::label_type>& height = (*_mesh)->createLabel("height");
- const ALE::Obj<Mesh::label_type>& depth = (*_mesh)->createLabel("depth");
-
-#ifdef IMESH_NEW_LABELS
- height->setChart((*_mesh)->getSieve()->getChart());
- depth->setChart((*_mesh)->getSieve()->getChart());
- for(int c = 0; c < numCells+numVertices; ++c) {
- height->setConeSize(c, 1);
- depth->setConeSize(c, 1);
- }
- if (numCells+numVertices) {height->setSupportSize(0, numCells+numVertices);}
- if (numCells+numVertices) {depth->setSupportSize(0, numCells+numVertices);}
- height->allocate();
- depth->allocate();
-#endif
- for(int c = 0; c < numCells; ++c) {
- height->setCone(0, c);
- depth->setCone(1, c);
- }
- for(int v = numCells; v < numCells+numVertices; ++v) {
- height->setCone(1, v);
- depth->setCone(0, v);
- }
-#ifdef IMESH_NEW_LABELS
- height->recalculateLabel();
- depth->recalculateLabel();
-#endif
- (*_mesh)->setHeight(1);
- (*_mesh)->setDepth(1);
- } else {
- (*_mesh)->stratify();
- }
- logger.stagePop();
- } else {
- logger.stagePush("MeshStratification");
- (*_mesh)->getSieve()->setChart(sieve_type::chart_type());
- (*_mesh)->getSieve()->allocate();
- (*_mesh)->stratify();
- logger.stagePop();
- }
-
-#if defined(ALE_MEM_LOGGING)
- std::cout
- << std::endl
- << "MeshCreation " << logger.getNumAllocations("MeshCreation")
- << " allocations " << logger.getAllocationTotal("MeshCreation")
- << " bytes" << std::endl
-
- << "MeshCreation " << logger.getNumDeallocations("MeshCreation")
- << " deallocations " << logger.getDeallocationTotal("MeshCreation")
- << " bytes" << std::endl
-
- << "MeshStratification " << logger.getNumAllocations("MeshStratification")
- << " allocations " << logger.getAllocationTotal("MeshStratification")
- << " bytes" << std::endl
-
- << "MeshStratification " << logger.getNumDeallocations("MeshStratification")
- << " deallocations " << logger.getDeallocationTotal("MeshStratification")
- << " bytes" << std::endl << std::endl;
-#endif
-
- assert(0 != _normalizer);
- const double lengthScale = _normalizer->lengthScale();
- _normalizer->nondimensionalize(&(*coordinates)[0], coordinates->size(),
- lengthScale);
-
- ALE::SieveBuilder<Mesh>::buildCoordinates(*_mesh, spaceDim,
- &(*coordinates)[0]);
-} // _buildMesh
-
-// ----------------------------------------------------------------------
-// Set vertices and cells for fault mesh.
-void
-pylith::meshio::MeshIO::_buildFaultMesh(const double_array& coordinates,
- const int numVertices,
- const int spaceDim,
- const int_array& cells,
- const int numCells,
- const int numCorners,
- const int firstCell,
- const int_array& faceCells,
- const int meshDim,
- const Obj<Mesh>& fault,
- Obj<ALE::Mesh>& faultBd)
-{ // _buildFaultMesh
- MPI_Comm comm = PETSC_COMM_WORLD;
- int dim = meshDim;
- int rank;
-
- assert(!fault.isNull());
-
- ALE::Obj<sieve_type> sieve = new sieve_type(fault->comm());
- fault->setDebug(fault->debug());
- fault->setSieve(sieve);
-
- MPI_Comm_rank(comm, &rank);
- // Memory debugging
- ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
- logger.setDebug(fault->debug()/2);
-
- logger.stagePush("FaultCreation");
- if (!rank) {
- assert(coordinates.size() == numVertices*spaceDim);
- assert(cells.size() == numCells*numCorners);
- {
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, meshDim,
- numCells,
- const_cast<int*>(&cells[0]),
- numVertices,
- true,
- numCorners,
- 0,
- fault->getArrowSection("orientation"),
- firstCell);
-
- // Add in cells
- for(int c = 0; c < numCells; ++c) {
- s->addArrow(c+firstCell, faceCells[c*2+0]);
- s->addArrow(c+firstCell, faceCells[c*2+1]);
- }
-
- Mesh::renumbering_type& renumbering = fault->getRenumbering();
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering, false);
- ALE::ISieveConverter::convertOrientation(*s, *sieve, renumbering, fault->getArrowSection("orientation").ptr());
-
- Obj<ALE::Mesh> tmpMesh = new ALE::Mesh(fault->comm(), dim, fault->debug());
- faultBd = ALE::Selection<ALE::Mesh>::boundary(tmpMesh);
- }
- logger.stagePop();
- logger.stagePush("FaultStratification");
- fault->stratify();
- logger.stagePop();
- } else {
- logger.stagePush("FaultStratification");
- fault->getSieve()->setChart(sieve_type::chart_type());
- fault->getSieve()->allocate();
- fault->stratify();
- logger.stagePop();
- }
-
-#if defined(ALE_MEM_LOGGING)
- std::cout
- << std::endl
- << "FaultCreation " << logger.getNumAllocations("FaultCreation")
- << " allocations " << logger.getAllocationTotal("FaultCreation")
- << " bytes" << std::endl
-
- << "FaultCreation " << logger.getNumDeallocations("FaultCreation")
- << " deallocations " << logger.getDeallocationTotal("FaultCreation")
- << " bytes" << std::endl
-
- << "FaultStratification " << logger.getNumAllocations("FaultStratification")
- << " allocations " << logger.getAllocationTotal("FaultStratification")
- << " bytes" << std::endl
-
- << "FaultStratification " << logger.getNumDeallocations("FaultStratification")
- << " deallocations " << logger.getDeallocationTotal("FaultStratification")
- << " bytes" << std::endl << std::endl;
-#endif
-
-} // _buildFaultMesh
-
-// ----------------------------------------------------------------------
// Get coordinates of vertices in mesh.
void
pylith::meshio::MeshIO::_getVertices(double_array* coordinates,
@@ -353,12 +103,15 @@
assert(0 != numVertices);
assert(0 != spaceDim);
assert(0 != _mesh);
- assert(!_mesh->isNull());
- const ALE::Obj<Mesh::label_sequence>& vertices = (*_mesh)->depthStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
assert(!vertices.isNull());
- const ALE::Obj<real_section_type>& coordsField =
- (*_mesh)->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordsField =
+ sieveMesh->getRealSection("coordinates");
assert(!coordsField.isNull());
*numVertices = vertices->size();
@@ -369,11 +122,13 @@
const int size = (*numVertices) * (*spaceDim);
coordinates->resize(size);
+ const SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
int i = 0;
- for(Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
+ for(SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type *vertexCoords =
+ const RealSection::value_type *vertexCoords =
coordsField->restrictPoint(*v_iter);
for (int iDim=0; iDim < *spaceDim; ++iDim)
(*coordinates)[i++] = vertexCoords[iDim];
@@ -393,34 +148,39 @@
int* numCorners,
int* meshDim) const
{ // _getCells
+
assert(0 != cells);
assert(0 != numCells);
assert(0 != meshDim);
assert(0 != _mesh);
- assert(!_mesh->isNull());
- const ALE::Obj<sieve_type>& sieve = (*_mesh)->getSieve();
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = sieveMesh->getSieve();
assert(!sieve.isNull());
- const ALE::Obj<Mesh::label_sequence>& meshCells = (*_mesh)->heightStratum(0);
+ const ALE::Obj<SieveMesh::label_sequence>& meshCells =
+ sieveMesh->heightStratum(0);
assert(!meshCells.isNull());
- *meshDim = (*_mesh)->getDimension();
+ *meshDim = _mesh->dimension();
*numCells = meshCells->size();
- *numCorners = (*_mesh)->getNumCellCorners();
+ *numCorners = sieveMesh->getNumCellCorners();
- const ALE::Obj<Mesh::numbering_type>& vNumbering =
- (*_mesh)->getFactory()->getLocalNumbering(*_mesh, 0);
+ const ALE::Obj<SieveMesh::numbering_type>& vNumbering =
+ sieveMesh->getFactory()->getLocalNumbering(sieveMesh, 0);
const int size = (*numCells) * (*numCorners);
cells->resize(size);
- ALE::ISieveVisitor::PointRetriever<Mesh::sieve_type> pV(sieve->getMaxConeSize());
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type>
+ pV(sieve->getMaxConeSize());
int i = 0;
- for(Mesh::label_sequence::iterator e_iter = meshCells->begin();
+ for(SieveMesh::label_sequence::iterator e_iter = meshCells->begin();
e_iter != meshCells->end();
++e_iter) {
sieve->cone(*e_iter, pV);
- const Mesh::point_type *cone = pV.getPoints();
+ const SieveMesh::point_type *cone = pV.getPoints();
for(int p = 0; p < pV.getSize(); ++p, ++i) {
(*cells)[i] = vNumbering->getIndex(cone[p]);
}
@@ -434,14 +194,17 @@
pylith::meshio::MeshIO::_setMaterials(const int_array& materialIds)
{ // _setMaterials
assert(0 != _mesh);
- assert(!_mesh->isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
logger.stagePush("MaterialsCreation");
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- (*_mesh)->createLabel("material-id");
- if (!(*_mesh)->commRank()) {
- const ALE::Obj<Mesh::label_sequence>& cells = (*_mesh)->heightStratum(0);
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->createLabel("material-id");
+ if (!sieveMesh->commRank()) {
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
assert(!cells.isNull());
const int numCells = materialIds.size();
@@ -453,18 +216,22 @@
throw std::runtime_error(msg.str());
} // if
int i = 0;
- const Mesh::label_sequence::iterator end = cells->end();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
#ifdef IMESH_NEW_LABELS
- labelMaterials->setChart((*_mesh)->getSieve()->getChart());
- for(Mesh::label_sequence::iterator e_iter = cells->begin(); e_iter != end; ++e_iter) {
+ labelMaterials->setChart(sieveMesh->getSieve()->getChart());
+ for(SieveMesh::label_sequence::iterator e_iter = cells->begin();
+ e_iter != cellsEnd;
+ ++e_iter) {
labelMaterials->setConeSize(*e_iter, 1);
}
if (cells->size()) {labelMaterials->setSupportSize(0, cells->size());}
labelMaterials->allocate();
#endif
- for(Mesh::label_sequence::iterator e_iter = cells->begin(); e_iter != end; ++e_iter) {
- (*_mesh)->setValue(labelMaterials, *e_iter, materialIds[i++]);
+ for(SieveMesh::label_sequence::iterator e_iter = cells->begin();
+ e_iter != cellsEnd;
+ ++e_iter) {
+ sieveMesh->setValue(labelMaterials, *e_iter, materialIds[i++]);
}
#ifdef IMESH_NEW_LABELS
labelMaterials->recalculateLabel();
@@ -473,8 +240,17 @@
logger.stagePop();
#if defined(ALE_MEM_LOGGING)
- std::cout << "MaterialsCreation " << logger.getNumAllocations("MaterialsCreation") << " allocations " << logger.getAllocationTotal("MaterialsCreation") << " bytes" << std::endl;
- std::cout << "MaterialsCreation " << logger.getNumDeallocations("MaterialsCreation") << " deallocations " << logger.getDeallocationTotal("MaterialsCreation") << " bytes" << std::endl;
+ std::cout
+ << "MaterialsCreation "
+ << logger.getNumAllocations("MaterialsCreation")
+ << " allocations " << logger.getAllocationTotal("MaterialsCreation")
+ << " bytes"
+ << std::endl
+ << "MaterialsCreation "
+ << logger.getNumDeallocations("MaterialsCreation")
+ << " deallocations " << logger.getDeallocationTotal("MaterialsCreation")
+ << " bytes"
+ << std::endl;
#endif
} // _setMaterials
@@ -485,25 +261,29 @@
{ // _getMaterials
assert(0 != materialIds);
assert(0 != _mesh);
- assert(!_mesh->isNull());
- const ALE::Obj<Mesh::label_sequence>& cells = (*_mesh)->heightStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
assert(!cells.isNull());
const int numCells = cells->size();
const int size = numCells;
materialIds->resize(size);
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- (*_mesh)->getLabel("material-id");
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->getLabel("material-id");
const int idDefault = 0;
-
+
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
int i = 0;
- for(Mesh::label_sequence::iterator e_iter = cells->begin();
- e_iter != cells->end();
+ for(SieveMesh::label_sequence::iterator e_iter = cells->begin();
+ e_iter != cellsEnd;
++e_iter)
(*materialIds)[i++] =
- (*_mesh)->getValue(labelMaterials, *e_iter, idDefault);
+ sieveMesh->getValue(labelMaterials, *e_iter, idDefault);
} // _getMaterials
// ----------------------------------------------------------------------
@@ -514,31 +294,41 @@
const int_array& points)
{ // _setGroup
assert(0 != _mesh);
- assert(!_mesh->isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
logger.stagePush("GroupCreation");
- const ALE::Obj<int_section_type>& groupField = (*_mesh)->getIntSection(name);
+ const ALE::Obj<IntSection>& groupField = sieveMesh->getIntSection(name);
assert(!groupField.isNull());
const int numPoints = points.size();
- const int numVertices = (*_mesh)->depthStratum(0)->size();
- const int numCells = (*_mesh)->heightStratum(0)->size();
+ const int numVertices = sieveMesh->depthStratum(0)->size();
+ const int numCells = sieveMesh->heightStratum(0)->size();
if (CELL == type) {
- groupField->setChart(int_section_type::chart_type(0,numCells));
+ groupField->setChart(IntSection::chart_type(0,numCells));
for(int i=0; i < numPoints; ++i)
groupField->setFiberDimension(points[i], 1);
} else if (VERTEX == type) {
- groupField->setChart(int_section_type::chart_type(numCells,numCells+numVertices));
+ groupField->setChart(IntSection::chart_type(numCells,
+ numCells+numVertices));
for(int i=0; i < numPoints; ++i)
groupField->setFiberDimension(numCells+points[i], 1);
} // if/else
- (*_mesh)->allocate(groupField);
+ sieveMesh->allocate(groupField);
logger.stagePop();
#if defined(ALE_MEM_LOGGING)
- std::cout << "GroupCreation " << logger.getNumAllocations("GroupCreation") << " allocations " << logger.getAllocationTotal("GroupCreation") << " bytes" << std::endl;
- std::cout << "GroupCreation " << logger.getNumDeallocations("GroupCreation") << " deallocations " << logger.getDeallocationTotal("GroupCreation") << " bytes" << std::endl;
+ std::cout
+ << "GroupCreation " << logger.getNumAllocations("GroupCreation")
+ << " allocations " << logger.getAllocationTotal("GroupCreation")
+ << " bytes"
+ << std::endl
+ << "GroupCreation " << logger.getNumDeallocations("GroupCreation")
+ << " deallocations " << logger.getDeallocationTotal("GroupCreation")
+ << " bytes"
+ << std::endl;
#endif
} // _setGroup
@@ -548,36 +338,41 @@
pylith::meshio::MeshIO::_distributeGroups()
{ // _distributeGroups
assert(0 != _mesh);
- assert(!_mesh->isNull());
- if (!(*_mesh)->commRank()) {
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ if (!sieveMesh->commRank()) {
const ALE::Obj<std::set<std::string> >& sectionNames =
- (*_mesh)->getIntSections();
+ sieveMesh->getIntSections();
int numGroups = sectionNames->size();
- MPI_Bcast(&numGroups, 1, MPI_INT, 0, (*_mesh)->comm());
+ MPI_Bcast(&numGroups, 1, MPI_INT, 0, sieveMesh->comm());
+
+ const std::set<std::string>::const_iterator namesEnd = sectionNames->end();
for (std::set<std::string>::const_iterator name=sectionNames->begin();
- name != sectionNames->end(); ++name) {
+ name != namesEnd;
+ ++name) {
int len = name->size();
- MPI_Bcast(&len, 1, MPI_INT, 0, (*_mesh)->comm());
- MPI_Bcast((void *) name->c_str(), len, MPI_CHAR, 0, (*_mesh)->comm());
+ MPI_Bcast(&len, 1, MPI_INT, 0, sieveMesh->comm());
+ MPI_Bcast((void *) name->c_str(), len, MPI_CHAR, 0, sieveMesh->comm());
}
} else {
int numGroups;
- MPI_Bcast(&numGroups, 1, MPI_INT, 0, (*_mesh)->comm());
+ MPI_Bcast(&numGroups, 1, MPI_INT, 0, sieveMesh->comm());
for(int g = 0; g < numGroups; ++g) {
char *name;
int len;
- MPI_Bcast(&len, 1, MPI_INT, 0, (*_mesh)->comm());
+ MPI_Bcast(&len, 1, MPI_INT, 0, sieveMesh->comm());
name = new char[len+1];
- MPI_Bcast(name, len, MPI_CHAR, 0, (*_mesh)->comm());
+ MPI_Bcast(name, len, MPI_CHAR, 0, sieveMesh->comm());
name[len] = 0;
- const ALE::Obj<int_section_type>& groupField = (*_mesh)->getIntSection(name);
+ const ALE::Obj<IntSection>& groupField = sieveMesh->getIntSection(name);
assert(!groupField.isNull());
- (*_mesh)->allocate(groupField);
+ sieveMesh->allocate(groupField);
delete [] name;
} // for
} // if/else
@@ -590,16 +385,19 @@
{ // _getGroups
assert(0 != names);
assert(0 != _mesh);
- assert(!_mesh->isNull());
-
+
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
const ALE::Obj<std::set<std::string> >& sectionNames =
- (*_mesh)->getIntSections();
+ sieveMesh->getIntSections();
const int numGroups = sectionNames->size();
names->resize(numGroups);
+ const std::set<std::string>::const_iterator namesEnd = sectionNames->end();
int i=0;
for (std::set<std::string>::const_iterator name=sectionNames->begin();
- name != sectionNames->end();
+ name != namesEnd;
++name)
(*names)[i++] = *name;
} // _getGroups
@@ -614,36 +412,45 @@
assert(0 != points);
assert(0 != type);
assert(0 != _mesh);
- assert(!_mesh->isNull());
- const ALE::Obj<int_section_type>& groupField = (*_mesh)->getIntSection(name);
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<IntSection>& groupField = sieveMesh->getIntSection(name);
assert(!groupField.isNull());
- const int_section_type::chart_type& chart = groupField->getChart();
- Mesh::point_type firstPoint;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
- if (groupField->getFiberDimension(*c_iter)) {firstPoint = *c_iter; break;}
+ const IntSection::chart_type& chart = groupField->getChart();
+ SieveMesh::point_type firstPoint;
+ IntSection::chart_type::const_iterator chartEnd = chart.end();
+ for(IntSection::chart_type::const_iterator c_iter=chart.begin();
+ c_iter != chartEnd;
+ ++c_iter) {
+ if (groupField->getFiberDimension(*c_iter)) {
+ firstPoint = *c_iter;
+ break;
+ } // if
}
- ALE::Obj<Mesh::numbering_type> numbering;
+ ALE::Obj<SieveMesh::numbering_type> numbering;
- if ((*_mesh)->height(firstPoint) == 0) {
+ if (sieveMesh->height(firstPoint) == 0) {
*type = CELL;
- numbering = (*_mesh)->getFactory()->getNumbering(*_mesh,
- (*_mesh)->depth());
+ numbering = sieveMesh->getFactory()->getNumbering(sieveMesh,
+ sieveMesh->depth());
} else {
*type = VERTEX;
- numbering = (*_mesh)->getFactory()->getNumbering(*_mesh, 0);
+ numbering = sieveMesh->getFactory()->getNumbering(sieveMesh, 0);
} // if/else
const int numPoints = groupField->size();
points->resize(numPoints);
int i = 0;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin();
- c_iter != chart.end();
+ for(IntSection::chart_type::const_iterator c_iter=chart.begin();
+ c_iter != chartEnd;
++c_iter) {
assert(!numbering.isNull());
- if (groupField->getFiberDimension(*c_iter)) (*points)[i++] = numbering->getIndex(*c_iter);
+ if (groupField->getFiberDimension(*c_iter)) (*points)[i++] =
+ numbering->getIndex(*c_iter);
} // for
} // _getGroup
-// End of file
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIO.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,35 +10,36 @@
// ======================================================================
//
+/**
+ * @file libsrc/topology/MeshIO.hh
+ *
+ * @brief C++ object for managing mesh input/output.
+ */
+
#if !defined(pylith_meshio_meshio_hh)
#define pylith_meshio_meshio_hh
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
+
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+#include "spatialdata/units/unitsfwd.hh" // forward declarations
+
#include "pylith/utils/arrayfwd.hh" // USES double_array, int_array,
// string_vector
-#include "pylith/utils/sievetypes.hh" // USES Obj, PETSc Mesh
-#include "Mesh.hh" // USES ALE::Mesh
-
-namespace pylith {
- namespace meshio {
- class MeshIO;
- } // meshio
-} // pylith
-
-namespace spatialdata {
- namespace units {
- class Nondimensional;
- } // units
-} // spatialdata
-
+// MeshIO ---------------------------------------------------------------
class pylith::meshio::MeshIO
{ // MeshIO
-// PUBLIC TYPEDEFS //////////////////////////////////////////////////////
+// PUBLIC ENUMS /////////////////////////////////////////////////////////
public :
/// Type of points in a group.
- typedef enum { VERTEX, CELL } GroupPtType;
+ enum GroupPtType {
+ VERTEX=0,
+ CELL=1,
+ }; // GroupPtType
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public :
@@ -46,7 +47,8 @@
MeshIO(void);
/// Destructor
- virtual ~MeshIO(void);
+ virtual
+ ~MeshIO(void);
/** Set debug flag for mesh.
*
@@ -82,15 +84,15 @@
/** Read mesh from file.
*
- * @param mesh Pointer to PETSc mesh object
+ * @param mesh PyLith finite-element mesh.
*/
- void read(ALE::Obj<Mesh>* mesh);
+ void read(pylith::topology::Mesh* mesh);
/** Write mesh to file.
*
- * @param mesh Pointer to PETSc mesh object.
+ * @param mesh PyLith finite-element mesh.
*/
- void write(ALE::Obj<Mesh>* mesh);
+ void write(pylith::topology::Mesh* const mesh);
// PROTECTED MEMBERS ////////////////////////////////////////////////////
protected :
@@ -109,40 +111,6 @@
*/
int getMeshDim(void) const;
- /** Build mesh topology and set vertex coordinates.
- *
- * All mesh information must use zero based indices. In other words,
- * the lowest index MUST be 0 not 1.
- *
- * @param coordinates Array of coordinates of vertices
- * @param numVertices Number of vertices
- * @param spaceDim Dimension of vector space for vertex coordinates
- * @param cells Array of indices of vertices in cells (first index is 0 or 1)
- * @param numCells Number of cells
- * @param numCorners Number of vertices per cell
- * @param meshDim Dimension of cells in mesh
- */
- void _buildMesh(double_array* coordinates,
- const int numVertices,
- const int spaceDim,
- const int_array& cells,
- const int numCells,
- const int numCorners,
- const int meshDim);
-
- static void
- _buildFaultMesh(const double_array& coordinates,
- const int numVertices,
- const int spaceDim,
- const int_array& cells,
- const int numCells,
- const int numCorners,
- const int firstCell,
- const int_array& faceCells,
- const int meshDim,
- const Obj<Mesh>& fault,
- Obj<ALE::Mesh>& faultBd);
-
/** Get information about vertices in mesh.
*
* Method caller is responsible for memory management.
@@ -218,18 +186,17 @@
GroupPtType* type,
const char *name) const;
- /** Create empty groups on other processes
- */
+ /// Create empty groups on other processes
void _distributeGroups();
-// PRIVATE MEMBERS //////////////////////////////////////////////////////
-private :
+// PROTECTED MEMBERS ////////////////////////////////////////////////////
+protected :
- ALE::Obj<Mesh>* _mesh; ///< Pointer to PETSc mesh object
- spatialdata::units::Nondimensional* _normalizer; ///< Nondimensionalizer
+ topology::Mesh* _mesh; ///< Pointer to finite-element mesh.
+ spatialdata::units::Nondimensional* _normalizer; ///< Nondimensionalizer.
- bool _debug; ///< True to turn of mesh debugging output
- bool _interpolate; ///< True if building intermediate topology elements
+ bool _debug; ///< True to turn of mesh debugging output.
+ bool _interpolate; ///< True if building intermediate topology elements.
}; // MeshIO
@@ -237,4 +204,5 @@
#endif // pylith_meshio_meshio_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,13 +14,14 @@
#include "MeshIOAscii.hh" // implementation of class methods
+#include "MeshBuilder.hh" // USES MeshBuilder
+#include "pylith/topology/Mesh.hh" // USES Mesh
+
#include "pylith/utils/array.hh" // USES double_array, int_array, string_vector
#include "spatialdata/utils/LineParser.hh" // USES LineParser
#include "journal/info.h" // USES journal::info_t
-#include <petsc.h> // USES MPI
-
#include <iomanip> // USES setw(), setiosflags(), resetiosflags()
#include <strings.h> // USES strcasecmp()
#include <cassert> // USES assert()
@@ -29,8 +30,10 @@
#include <sstream> // USES std::ostringstream
// ----------------------------------------------------------------------
-const char* pylith::meshio::MeshIOAscii::groupTypeNames[] =
- {"vertices", "cells"};
+const char* pylith::meshio::MeshIOAscii::groupTypeNames[] = {
+ "vertices",
+ "cells",
+};
// ----------------------------------------------------------------------
// Constructor
@@ -51,8 +54,10 @@
void
pylith::meshio::MeshIOAscii::_read(void)
{ // _read
- MPI_Comm comm = PETSC_COMM_WORLD;
- int rank;
+ assert(0 != _normalizer);
+
+ MPI_Comm comm = _mesh->comm();
+ int rank = 0;
int meshDim = 0;
int spaceDim = 0;
int numVertices = 0;
@@ -63,7 +68,7 @@
int_array materialIds;
MPI_Comm_rank(comm, &rank);
- if (!rank) {
+ if (0 == rank) {
std::ifstream filein(_filename.c_str());
if (!filein.is_open() || !filein.good()) {
std::ostringstream msg;
@@ -74,11 +79,11 @@
spatialdata::utils::LineParser parser(filein, "//");
parser.eatwhitespace(true);
-
+
std::string token;
std::istringstream buffer;
const int maxIgnore = 1024;
-
+
buffer.str(parser.next());
buffer >> token;
if (0 != strcasecmp(token.c_str(), "mesh")) {
@@ -134,8 +139,9 @@
if (readDim && readCells && readVertices && !builtMesh) {
// Can now build mesh
- _buildMesh(&coordinates, numVertices, spaceDim,
- cells, numCells, numCorners, meshDim);
+ MeshBuilder::buildMesh(_mesh, &coordinates, numVertices, spaceDim,
+ cells, numCells, numCorners, meshDim,
+ _interpolate, *_normalizer);
_setMaterials(materialIds);
builtMesh = true;
} // if
@@ -161,8 +167,9 @@
} // catch
filein.close();
} else {
- _buildMesh(&coordinates, numVertices, spaceDim,
- cells, numCells, numCorners, meshDim);
+ MeshBuilder::buildMesh(_mesh, &coordinates, numVertices, spaceDim,
+ cells, numCells, numCorners, meshDim,
+ _interpolate, *_normalizer);
_setMaterials(materialIds);
} // if/else
_distributeGroups();
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOAscii.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,32 +10,30 @@
// ======================================================================
//
+/**
+ * @file libsrc/meshio/MeshIOAscii.hh
+ *
+ * @brief C++ input/output manager for PyLith ASCII mesh files.
+ */
+
#if !defined(pylith_meshio_meshioascii_hh)
#define pylith_meshio_meshioascii_hh
+// Include directives ---------------------------------------------------
+#include "MeshIO.hh" // ISA MeshIO
+
+#include "spatialdata/utils/utilsfwd.hh" // USES LineParser
+
#include <iosfwd> // USES std::istream, std::ostream
#include <string> // HASA std::string
-#include "MeshIO.hh"
-
-namespace pylith {
- namespace meshio {
- class MeshIOAscii;
- } // meshio
-} // pylith
-
-namespace spatialdata {
- namespace utils {
- class LineParser;
- } // utils
-} // pylith
-
+// MeshIOAscii ----------------------------------------------------------
class pylith::meshio::MeshIOAscii : public MeshIO
{ // MeshIOAscii
+ friend class TestMeshIOAscii; // unit testing
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
- static const char *groupTypeNames[];
/// Constructor
MeshIOAscii(void);
@@ -132,6 +130,9 @@
std::string _filename; ///< Name of file
bool _useIndexZero; ///< Flag indicating if indicates start at 0 (T) or 1 (F)
+ static
+ const char *groupTypeNames[]; ///< Types of mesh groups.
+
}; // MeshIOAscii
#include "MeshIOAscii.icc" // inline methods
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,8 @@
#include "MeshIOCubit.hh" // implementation of class methods
+#include "MeshBuilder.hh" // USES MeshBuilder
+
#include "pylith/utils/array.hh" // USES double_array, int_array, string_vector
#include "journal/info.h" // USES journal::info_t
@@ -45,7 +47,7 @@
pylith::meshio::MeshIOCubit::_read(void)
{ // _read
MPI_Comm comm = PETSC_COMM_WORLD;
- int rank;
+ int rank = 0;
int meshDim = 0;
int spaceDim = 0;
int numVertices = 0;
@@ -56,7 +58,7 @@
int_array materialIds;
MPI_Comm_rank(comm, &rank);
- if (!rank) {
+ if (0 == rank) {
try {
NcFile ncfile(_filename.c_str());
if (!ncfile.is_valid()) {
@@ -75,10 +77,11 @@
_readVertices(ncfile, &coordinates, &numVertices, &spaceDim);
_readCells(ncfile, &cells, &materialIds, &numCells, &numCorners);
_orientCells(&cells, numCells, numCorners, meshDim);
- _buildMesh(&coordinates, numVertices, spaceDim,
- cells, numCells, numCorners, meshDim);
+ MeshBuilder::buildMesh(_mesh, &coordinates, numVertices, spaceDim,
+ cells, numCells, numCorners, meshDim,
+ _interpolate, *_normalizer);
_setMaterials(materialIds);
-
+
_readGroups(ncfile);
} catch (std::exception& err) {
std::ostringstream msg;
@@ -92,8 +95,9 @@
throw std::runtime_error(msg.str());
} // try/catch
} else {
- _buildMesh(&coordinates, numVertices, spaceDim,
- cells, numCells, numCorners, meshDim);
+ MeshBuilder::buildMesh(_mesh, &coordinates, numVertices, spaceDim,
+ cells, numCells, numCorners, meshDim,
+ _interpolate, *_normalizer);
_setMaterials(materialIds);
}
_distributeGroups();
@@ -219,7 +223,8 @@
std::ostringstream msg;
msg << "All materials must have the same number of vertices per cell.\n"
<< "Expected " << *numCorners << " vertices per cell, but block "
- << blockIds[iMaterial] << " has " << num_nod_per_el->size() << " vertices.";
+ << blockIds[iMaterial] << " has " << num_nod_per_el->size()
+ << " vertices.";
throw std::runtime_error(msg.str());
} // if
@@ -342,7 +347,7 @@
assert(cells->size() == numCells*numCorners);
if (2 == meshDim && 4 == numCorners) // QUAD
-#if 0
+#if 0 // OLD
// 0 1 2 3 -> 0 1 3 2
for (int iCell=0; iCell < numCells; ++iCell) {
const int i2 = iCell*numCorners+2;
@@ -355,7 +360,7 @@
; // do nothing
#endif
else if (3 == meshDim && 8 == numCorners) // HEX
-#if 0
+#if 0 // OLD
// 0 1 2 3 4 5 6 7 -> 0 1 3 2 4 5 7 6
for (int iCell=0; iCell < numCells; ++iCell) {
const int i2 = iCell*numCorners+2;
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOCubit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,26 +10,27 @@
// ======================================================================
//
+/**
+ * @file pylith/meshio/MeshIOCubit.hh
+ *
+ * @brief C++ input/output manager for CUBIT Exodus II files.
+ */
+
#if !defined(pylith_meshio_meshiocubit_hh)
#define pylith_meshio_meshiocubit_hh
+// Include directives ---------------------------------------------------
+#include "MeshIO.hh" // ISA MeshIO
+
#include <string> // HASA std::string
-#include "MeshIO.hh"
-
-namespace pylith {
- namespace meshio {
- class MeshIOCubit;
-
- class TestMeshIOCubit; // unit testing
- } // meshio
-} // pylith
-
+// Forward declarations -------------------------------------------------
class NcFile; // netcdf file
+// MeshIOCubit ----------------------------------------------------------
class pylith::meshio::MeshIOCubit : public MeshIO
{ // MeshIOCubit
- friend class TestMeshIOCubit;
+ friend class TestMeshIOCubit; // unit testing
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,13 +18,13 @@
#include "GMVFileBinary.hh" // USES GMVFileBinary
#include "PsetFileAscii.hh" // USES PsetFileAscii
#include "PsetFileBinary.hh" // USES PsetFileBinary
+#include "MeshBuilder.hh" // USES MeshBuilder
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/utils/array.hh" // USES double_array, int_array
-#include <petsc.h> // USES MPI_Comm
-
#include <cassert> // USES assert()
-#include <stdexcept> // TEMPORARY
+#include <stdexcept> // USES std::runtime_error()
// ----------------------------------------------------------------------
// Constructor
@@ -43,151 +43,12 @@
{ // destructor
} // destructor
-void
-pylith::meshio::MeshIOLagrit::readFault(const std::string filename, const Obj<Mesh>& mesh, const Obj<Mesh>& fault, Obj<ALE::Mesh>& faultBd) {
- int faultDim = 2;
- int fSpaceDim = 0;
- int numFVertices = 0;
- int numFCells = 0;
- int numFCorners = 0;
- double_array fCoordinates;
- int_array fCells;
- int_array fMaterialIds;
- int_array faceCells;
- int_array vertexIDs;
-
- if (!fault->commRank()) {
- std::ifstream fin(filename.c_str(), std::ios::in);
- if (!(fin.is_open() && fin.good())) {
- std::ostringstream msg;
- msg << "Could not open ASCII INP file '" << filename << "' for reading.";
- throw std::runtime_error(msg.str());
- } // if
- int numNodeData, numCellData, numModelData;
-
- fSpaceDim = 3;
- // Section 1: <num_nodes> <num_cells> <num_ndata> <num_cdata> <num_mdata>
- fin >> numFVertices;
- fin >> numFCells;
- fin >> numNodeData;
- fin >> numCellData;
- fin >> numModelData;
- // Section 2: <node_id 1> <x> <y> <z>
- fCoordinates.resize(numFVertices * fSpaceDim);
- for(int v = 0; v < numFVertices; ++v) {
- int id;
-
- fin >> id;
- for(int d = 0; d < fSpaceDim; ++d) {
- fin >> fCoordinates[v*fSpaceDim + d];
- }
- }
- // Section 3: <cell_id 1> <mat_id> <cell_type> <cell_vert 1> ... <cell_vert n>
- fMaterialIds.resize(numFCells);
- for(int c = 0; c < numFCells; ++c) {
- std::string cellType;
- int cellID;
-
- fin >> cellID;
- fin >> fMaterialIds[c];
- fin >> cellType;
- if (cellType == "tri") {
- numFCorners = 3;
- } else if (cellType == "quad") {
- numFCorners = 4;
- } else {
- std::ostringstream msg;
- msg << "Unknown cell type " << cellType << "while reading INP file.";
- throw std::runtime_error(msg.str());
- }
- if (c == 0) fCells.resize(numFCells*numFCorners);
- for(int i = 0; i < numFCorners; ++i) fin >> fCells[c*numFCorners+i];
- }
- // Section 4: <num_comp for node data> <size comp 1> <size comp 2>...<size comp n>
- int numComponents, totalSize;
-
- fin >> numComponents;
- totalSize = 0;
- for(int i = 0; i < numComponents; ++i) {
- int compSize;
- fin >> compSize;
- totalSize += compSize;
- }
- // Section 5: <node_comp_label 1> , <units_label 1>
- for(int c = 0; c < numComponents; ++c) {
- std::string label, typeName;
-
- fin >> label;
- fin >> typeName;
- }
- // Section 6: <node_id 1> <node_data 1> ... <node_data num_ndata>
- vertexIDs.resize(numFVertices);
- for(int v = 0; v < numFVertices; ++v) {
- int id;
- double dummy;
-
- fin >> id;
- fin >> vertexIDs[v]; // global node number
- fin >> dummy; // components of normal at vertices
- fin >> dummy;
- fin >> dummy;
- }
- // Section 7: <num_comp for cell's data> <size comp 1> <size comp 2>...<size comp n>
- fin >> numComponents;
- totalSize = 0;
- for(int i = 0; i < numComponents; ++i) {
- int compSize;
- fin >> compSize;
- totalSize += compSize;
- }
- // Section 8: <cell_component_label 1> , <units_label 1>
- for(int c = 0; c < numComponents; ++c) {
- std::string label, typeName;
-
- fin >> label;
- fin >> typeName;
- }
- // Section 9: <cell_id 1> <cell_data 1> ... <cell_data num_cdata>
- faceCells.resize(numFCells*2);
- for(int c = 0; c < numFCells; ++c) {
- int id, faultId;
-
- fin >> id;
- fin >> faceCells[c*2+0]; // Cell numbers in global mesh on either side of fault
- fin >> faceCells[c*2+1];
- fin >> faultId;
- }
-
- // Determine the number of cells
- // Only do this once since we add cohesive cells after that
- static int numCells = -1;
-
- if (numCells == -1) {numCells = mesh->heightStratum(0)->size();}
-
- // Renumber vertices and use zero based indices
- // UCD file has one-based indices for both vertexIDs and fCells
- // Also, vertex numbers are offset by the number of cells
- for(int c = 0; c < numFCells; ++c)
- for(int corner = 0; corner < numFCorners; ++corner)
- fCells[c*numFCorners+corner] =
- vertexIDs[fCells[c*numFCorners+corner]-1] - 1 + numCells;
-
- // Switch to zero based index for global cell numbering
- for (int c=0; c < numFCells; ++c)
- for (int i=0; i < 2; ++i)
- faceCells[c*2+i] -= 1;
- }
-
- const int firstFaultCell = mesh->getSieve()->getBaseSize() + mesh->getSieve()->getCapSize();
- _buildFaultMesh(fCoordinates, numFVertices, fSpaceDim, fCells, numFCells, numFCorners, firstFaultCell, faceCells, faultDim, fault, faultBd);
-}
-
// ----------------------------------------------------------------------
// Unpickle mesh
void
pylith::meshio::MeshIOLagrit::_read(void)
{ // _read
- MPI_Comm comm = PETSC_COMM_WORLD;
+ MPI_Comm comm = _mesh->comm();
int rank;
int meshDim = 0;
int spaceDim = 0;
@@ -212,11 +73,12 @@
_orientCellsBinary(&cells, numCells, numCorners, meshDim);
} // if/else
}
- _buildMesh(&coordinates, numVertices, spaceDim,
- cells, numCells, numCorners, meshDim);
+ MeshBuilder::buildMesh(_mesh, &coordinates, numVertices, spaceDim,
+ cells, numCells, numCorners, meshDim,
+ _interpolate, *_normalizer);
_setMaterials(materialIds);
- if (!rank) {
+ if (0 == rank) {
std::vector<PsetFile::Pset> groups;
if (PsetFile::isAscii(_filenamePset.c_str())) {
PsetFileAscii filein(_filenamePset.c_str());
Modified: short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/MeshIOLagrit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,21 +10,21 @@
// ======================================================================
//
+/**
+ * @file libsrc/meshio/MeshIOLagrit.hh
+ *
+ * @brief Input/output manager for LaGriT GMV and Pset files.
+ */
+
#if !defined(pylith_meshio_meshiolagrit_hh)
#define pylith_meshio_meshiolagrit_hh
+// Include directives ---------------------------------------------------
#include "MeshIO.hh" // ISA MeshIO
#include <string> // HASA std::string
-namespace pylith {
- namespace meshio {
- class MeshIOLagrit;
-
- class TestMeshIOLagrit; // unit testing
- } // meshio
-} // pylith
-
+// MeshIOLagrit ---------------------------------------------------------
class pylith::meshio::MeshIOLagrit : public MeshIO
{ // MeshIOLagrit
friend class TestMeshIOLagrit; // unit testing
@@ -111,13 +111,6 @@
*/
bool isRecordHeader32Bit(void) const;
- // TEMPORARY
- static
- void readFault(const std::string filename,
- const Obj<Mesh>& mesh,
- const Obj<Mesh>& fault,
- Obj<ALE::Mesh>& faultBd);
-
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,8 +12,6 @@
#include <portinfo>
-#include "OutputManager.hh" // implementation of class methods
-
#include "DataWriter.hh" // USES DataWriter
#include "VertexFilter.hh" // USES VertexFilter
#include "CellFilter.hh" // USES CellFilter
@@ -22,7 +20,8 @@
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::OutputManager::OutputManager(void) :
+template<typename mesh_type, typename field_type>
+pylith::meshio::OutputManager<mesh_type, field_type>::OutputManager(void) :
_coordsys(0),
_writer(0),
_vertexFilter(0),
@@ -32,65 +31,75 @@
// ----------------------------------------------------------------------
// Destructor
-pylith::meshio::OutputManager::~OutputManager(void)
+template<typename mesh_type, typename field_type>
+pylith::meshio::OutputManager<mesh_type, field_type>::~OutputManager(void)
{ // destructor
- delete _writer; _writer = 0;
- delete _vertexFilter; _vertexFilter = 0;
- delete _cellFilter; _cellFilter = 0;
+ _writer = 0; // :TODO: Use shared pointer
+ _vertexFilter = 0; // :TODO: Use shared pointer
+ _cellFilter = 0; // :TODO: Use shared pointer
delete _coordsys; _coordsys = 0;
} // destructor
// ----------------------------------------------------------------------
// Set coordinate system in output. The vertex fields in the output
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::coordsys(const spatialdata::geocoords::CoordSys* cs)
+pylith::meshio::OutputManager<mesh_type, field_type>::coordsys(
+ const spatialdata::geocoords::CoordSys* cs)
{ // coordsys
delete _coordsys; _coordsys = (0 != cs) ? cs->clone() : 0;
} // coordsys
// ----------------------------------------------------------------------
// Set writer to write data to file.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::writer(const DataWriter* datawriter)
+pylith::meshio::OutputManager<mesh_type, field_type>::writer(
+ DataWriter<mesh_type, field_type>* const datawriter)
{ // writer
- delete _writer; _writer = (0 != datawriter) ? datawriter->clone() : 0;
+ _writer = datawriter; // :TODO: Use shared pointer
} // writer
// ----------------------------------------------------------------------
// Set filter for vertex data.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::vertexFilter(const VertexFilter* filter)
+pylith::meshio::OutputManager<mesh_type, field_type>::vertexFilter(
+ VertexFilter<field_type>* const filter)
{ // vertexFilter
- delete _vertexFilter; _vertexFilter = (0 != filter) ? filter->clone() : 0;
+ _vertexFilter = filter; // :TODO: Use shared pointer
} // vertexFilter
// ----------------------------------------------------------------------
// Set filter for cell data.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::cellFilter(const CellFilter* filter)
+pylith::meshio::OutputManager<mesh_type, field_type>::cellFilter(
+ CellFilter<mesh_type, field_type>* const filter)
{ // cellFilter
- delete _cellFilter; _cellFilter = (0 != filter) ? filter->clone() : 0;
+ _cellFilter = filter; // :TODO: Use shared pointer
} // cellFilter
// ----------------------------------------------------------------------
// Prepare for output.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::open(
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
- const int numTimeSteps,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::open(
+ const mesh_type& mesh,
+ const int numTimeSteps,
+ const char* label,
+ const int labelId)
{ // open
assert(0 != _writer);
- _writer->open(mesh, csMesh, numTimeSteps, label, labelId);
+ _writer->open(mesh, numTimeSteps, label, labelId);
} // open
// ----------------------------------------------------------------------
/// Close output files.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::close(void)
+pylith::meshio::OutputManager<mesh_type, field_type>::close(void)
{ // close
assert(0 != _writer);
_writer->close();
@@ -98,22 +107,23 @@
// ----------------------------------------------------------------------
// Setup file for writing fields at time step.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::openTimeStep(
- const double t,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::openTimeStep(
+ const double t,
+ const mesh_type& mesh,
+ const char* label,
+ const int labelId)
{ // openTimeStep
assert(0 != _writer);
- _writer->openTimeStep(t, mesh, csMesh, label, labelId);
+ _writer->openTimeStep(t, mesh, label, labelId);
} // openTimeStep
// ----------------------------------------------------------------------
// End writing fields at time step.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::closeTimeStep(void)
+pylith::meshio::OutputManager<mesh_type, field_type>::closeTimeStep(void)
{ // closeTimeStep
assert(0 != _writer);
_writer->closeTimeStep();
@@ -121,46 +131,32 @@
// ----------------------------------------------------------------------
// Append finite-element vertex field to file.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::appendVertexField(
- const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh)
+pylith::meshio::OutputManager<mesh_type, field_type>::appendVertexField(
+ const double t,
+ const field_type& field)
{ // appendVertexField
- assert(0 != name);
+ const field_type& fieldFiltered =
+ (0 == _vertexFilter) ? field : _vertexFilter->filter(field);
- VectorFieldEnum fieldTypeFiltered = fieldType;
- const ALE::Obj<real_section_type>& fieldFiltered =
- (0 == _vertexFilter) ?
- field : _vertexFilter->filter(&fieldTypeFiltered, field, mesh);
-
- _writer->writeVertexField(t, name, fieldFiltered, fieldTypeFiltered, mesh);
+ _writer->writeVertexField(t, fieldFiltered);
} // appendVertexField
// ----------------------------------------------------------------------
// Append finite-element cell field to file.
+template<typename mesh_type, typename field_type>
void
-pylith::meshio::OutputManager::appendCellField(
- const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh,
- const char* label,
- const int labelId)
+pylith::meshio::OutputManager<mesh_type, field_type>::appendCellField(
+ const double t,
+ const field_type& field,
+ const char* label,
+ const int labelId)
{ // appendCellField
- assert(0 != name);
+ const field_type& fieldFiltered =
+ (0 == _cellFilter) ? field : _cellFilter->filter(field, label, labelId);
- VectorFieldEnum fieldTypeFiltered = fieldType;
- const ALE::Obj<real_section_type>& fieldFiltered =
- (0 == _cellFilter) ?
- field : _cellFilter->filter(&fieldTypeFiltered, field,
- mesh, label, labelId);
-
- _writer->writeCellField(t, name, fieldFiltered, fieldTypeFiltered,
- mesh, label, labelId);
+ _writer->writeCellField(t, fieldFiltered, label, labelId);
} // appendCellField
Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputManager.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,26 +19,14 @@
#if !defined(pylith_meshio_outputmanager_hh)
#define pylith_meshio_outputmanager_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh, real_section_type
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
-namespace pylith {
- namespace meshio {
- class OutputManager;
- class TestOutputManager; // unit testing
+#include "pylith/topology/topologyfwd.hh" // USES Field
+#include "spatialdata/geocoords/geocoordsfwd.hh" // USES CoordSys
- class DataWriter; // HOLDS DataWriter
- class CellFilter; // HOLDSA CellFilter
- class VertexFilter; // HOLDSA VertexFilter
- } // meshio
-} // pylith
-
-namespace spatialdata {
- namespace geocoords {
- class CoordSys; // USES CoordSys
- } // geocoords
-} // spatialdata
-
+// OutputManager --------------------------------------------------------
+template<typename mesh_type, typename field_type>
class pylith::meshio::OutputManager
{ // OutputManager
friend class TestOutputManager; // unit testing
@@ -64,31 +52,29 @@
*
* @param datawriter Writer for data.
*/
- void writer(const DataWriter* datawriter);
+ void writer(DataWriter<mesh_type, field_type>* const datawriter);
/** Set filter for vertex data.
*
* @param filter Filter to apply to vertex data before writing.
*/
- void vertexFilter(const VertexFilter* filter);
+ void vertexFilter(VertexFilter<field_type>* const filter);
/** Set filter for cell data.
*
* @param filter Filter to apply to cell data before writing.
*/
- void cellFilter(const CellFilter* filter);
+ void cellFilter(CellFilter<mesh_type, field_type>* const filter);
/** Prepare for output.
*
- * @param mesh PETSc mesh object.
- * @param csMesh Coordinate system of mesh geometry.
+ * @param mesh Finite-element mesh object.
* @param numTimeSteps Expected number of time steps.
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
- void open(const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
+ void open(const mesh_type& mesh,
const int numTimeSteps,
const char* label =0,
const int labelId =0);
@@ -99,15 +85,13 @@
/** Setup file for writing fields at time step.
*
* @param t Time of time step.
- * @param mesh PETSc mesh object.
- * @param csMesh Coordinate system of mesh geometry
+ * @param mesh Finite-element mesh object.
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
void openTimeStep(const double t,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* csMesh,
+ const mesh_type& mesh,
const char* label =0,
const int labelId =0);
@@ -117,33 +101,21 @@
/** Append finite-element vertex field to file.
*
* @param t Time associated with field.
- * @param name Name of field.
* @param field Vertex field.
- * @param fieldType Type of field.
- * @param mesh PETSc mesh object.
*/
void appendVertexField(const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh);
+ const field_type& field);
/** Append finite-element cell field to file.
*
* @param t Time associated with field.
- * @param name Name of field.
* @param field Cell field.
- * @param fieldType Type of field.
- * @param mesh PETSc mesh object.
* @param label Name of label defining cells to include in output
* (=0 means use all cells in mesh).
* @param labelId Value of label defining which cells to include.
*/
void appendCellField(const double t,
- const char* name,
- const ALE::Obj<real_section_type>& field,
- const VectorFieldEnum fieldType,
- const ALE::Obj<Mesh>& mesh,
+ const field_type& field,
const char* label =0,
const int labelId =0);
@@ -156,13 +128,18 @@
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system for output.
- DataWriter* _writer; ///< Writer for data.
- VertexFilter* _vertexFilter; ///< Filter applied to vertex data.
- CellFilter* _cellFilter; ///< Filter applied to cell data.
+ /// Coordinate system for output.
+ spatialdata::geocoords::CoordSys* _coordsys;
+ DataWriter<mesh_type, field_type>* _writer; ///< Writer for data.
+ VertexFilter<field_type>* _vertexFilter; ///< Filter applied to vertex data.
+ CellFilter<mesh_type, field_type>* _cellFilter; ///< Filter applied to cell data.
+
}; // OutputManager
+#include "OutputManager.cc" // template methods
+
#endif // pylith_meshio_outputmanager_hh
+
// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,12 +14,13 @@
#include "OutputSolnSubset.hh" // implementation of class methods
-#include <Selection.hh> // USES submesh algorithms
+#include "pylith/topology/Mesh.hh" // USES Mesh
// ----------------------------------------------------------------------
// Constructor
pylith::meshio::OutputSolnSubset::OutputSolnSubset(void) :
- _label("")
+ _label(""),
+ _submesh(0)
{ // constructor
} // constructor
@@ -27,6 +28,7 @@
// Destructor
pylith::meshio::OutputSolnSubset::~OutputSolnSubset(void)
{ // destructor
+ delete _submesh; _submesh = 0;
} // destructor
// ----------------------------------------------------------------------
@@ -40,11 +42,12 @@
// ----------------------------------------------------------------------
// Verify configuration is acceptable.
void
-pylith::meshio::OutputSolnSubset::verifyConfiguration(const ALE::Obj<Mesh>& mesh) const
+pylith::meshio::OutputSolnSubset::verifyConfiguration(const topology::Mesh& mesh) const
{ // verifyConfiguration
- assert(!mesh.isNull());
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
- if (!mesh->hasIntSection(_label)) {
+ if (!sieveMesh->hasIntSection(_label)) {
std::ostringstream msg;
msg << "Mesh missing group of vertices '" << _label
<< " for subdomain output.";
@@ -54,36 +57,12 @@
// ----------------------------------------------------------------------
// Get mesh associated with subdomain.
-const ALE::Obj<pylith::Mesh>&
-pylith::meshio::OutputSolnSubset::subdomainMesh(const ALE::Obj<Mesh>& mesh)
+const pylith::topology::SubMesh&
+pylith::meshio::OutputSolnSubset::subdomainMesh(const topology::Mesh& mesh)
{ // subdomainMesh
- _mesh =
- ALE::Selection<Mesh>::submeshV<SubMesh>(mesh, mesh->getIntSection(_label));
- if (_mesh.isNull()) {
- std::ostringstream msg;
- msg << "Could not construct mesh of subdomain " << _label << "'.";
- throw std::runtime_error(msg.str());
- } // if
- _mesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
- // Create the parallel overlap
- const Obj<Mesh::sieve_type>& sieve = _mesh->getSieve();
- Obj<Mesh::send_overlap_type> sendParallelMeshOverlap = _mesh->getSendOverlap();
- Obj<Mesh::recv_overlap_type> recvParallelMeshOverlap = _mesh->getRecvOverlap();
- Mesh::renumbering_type& renumbering = _mesh->getRenumbering();
- Mesh::renumbering_type& oldRenumbering = mesh->getRenumbering();
- for(Mesh::renumbering_type::const_iterator r_iter = oldRenumbering.begin(); r_iter != oldRenumbering.end(); ++r_iter) {
- if (sieve->getChart().hasPoint(r_iter->second) && (sieve->getConeSize(r_iter->second) || sieve->getSupportSize(r_iter->second))) {
- renumbering[r_iter->first] = r_iter->second;
- }
- }
- // Can I figure this out in a nicer way?
- ALE::SetFromMap<std::map<Mesh::point_type,Mesh::point_type> > globalPoints(renumbering);
-
- ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering, sendParallelMeshOverlap, recvParallelMeshOverlap);
- _mesh->setCalculatedOverlap(true);
-
- return _mesh;
+ delete _submesh; _submesh = new topology::SubMesh(mesh, _label.c_str());
+ assert(0 != _submesh);
+ return *_submesh;
} // subdomainMesh
Modified: short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/OutputSolnSubset.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,20 +20,19 @@
#if !defined(pylith_meshio_outputsolnsubset_hh)
#define pylith_meshio_outputsolnsubset_hh
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
+
+#include "pylith/topology/SubMesh.hh" // ISA OutputManager<SubMesh>
+#include "pylith/topology/Mesh.hh" // ISA OutputManager<Field<Mesh>>
+#include "pylith/topology/Field.hh" // ISA OutputManager<Field<Mesh>>
#include "OutputManager.hh" // ISA OutputManager
-#include "pylith/utils/sievetypes.hh" // HASA PETSc Mesh
#include <string> // HASA std::string
-namespace pylith {
- namespace meshio {
- class OutputSolnSubset;
-
- class TestOutputSolnSubset; // unit testing
- } // meshio
-} // pylith
-
-class pylith::meshio::OutputSolnSubset : public OutputManager
+// OutputSolnSubset -----------------------------------------------------
+class pylith::meshio::OutputSolnSubset :
+ public OutputManager<topology::SubMesh, topology::Field<topology::Mesh> >
{ // OutputSolnSubset
friend class TestOutputSolnSubset; // unit testing
@@ -56,15 +55,14 @@
*
* @param mesh PETSc mesh
*/
- void verifyConfiguration(const ALE::Obj<Mesh>& mesh) const;
+ void verifyConfiguration(const topology::Mesh& mesh) const;
/** Get mesh associated with subdomain.
*
* @returns Mesh associated with subdomain.
*/
- const ALE::Obj<Mesh>& subdomainMesh(const ALE::Obj<Mesh>& mesh);
+ const topology::SubMesh& subdomainMesh(const topology::Mesh& mesh);
-
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
@@ -75,7 +73,7 @@
private :
std::string _label; ///< Label of subdomain.
- ALE::Obj<SubMesh> _mesh; ///< Mesh of subdomain.
+ topology::SubMesh* _submesh; ///< Mesh of subdomain.
}; // OutputSolnSubset
Modified: short/3D/PyLith/trunk/libsrc/meshio/PsetFile.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/PsetFile.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/PsetFile.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,18 +10,22 @@
// ======================================================================
//
+/**
+ * @file libsrc/topology/PsetFile.hh
+ *
+ * @brief C++ base class for input/output of LaGriT Pset files.
+ */
+
#if !defined(pylith_meshio_psetfile_hh)
#define pylith_meshio_psetfile_hh
-#include "pylith/utils/array.hh" // USES int_array
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
+
+#include "pylith/utils/array.hh" // HASA int_array
#include <string> // HASA std::string
-namespace pylith {
- namespace meshio {
- class PsetFile;
- } // meshio
-} // pylith
-
+// PsetFile -------------------------------------------------------------
class pylith::meshio::PsetFile
{ // PsetFile
Modified: short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/PsetFileAscii.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,20 +10,21 @@
// ======================================================================
//
+/**
+ * @file libsrc/topology/PsetFile.hh
+ *
+ * @brief C++ object for input/output of LaGriT binary Pset files.
+ */
+
#if !defined(pylith_meshio_psetfileascii_hh)
#define pylith_meshio_psetfileascii_hh
+// Include directives ---------------------------------------------------
#include "PsetFile.hh" // ISA PsetFile
-#include "pylith/utils/array.hh" // USES int_array, string_array, std::vector
#include <iosfwd>
-namespace pylith {
- namespace meshio {
- class PsetFileAscii;
- } // meshio
-} // pylith
-
+// PsetFileAscii --------------------------------------------------------
class pylith::meshio::PsetFileAscii : public PsetFile
{ // PsetFileAscii
Modified: short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/PsetFileBinary.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,20 +10,21 @@
// ======================================================================
//
+/**
+ * @file libsrc/topology/PsetFile.hh
+ *
+ * @brief C++ object for input/output of LaGriT binary Pset files.
+ */
+
#if !defined(pylith_meshio_psetfilebinary_hh)
#define pylith_meshio_psetfilebinary_hh
+// Include directives ---------------------------------------------------
#include "PsetFile.hh" // ISA PsetFile
-#include "pylith/utils/array.hh" // USES int_array, string_array, std::vector
#include <iosfwd>
-namespace pylith {
- namespace meshio {
- class PsetFileBinary;
- } // meshio
-} // pylith
-
+// PsetFileBinary -------------------------------------------------------
class pylith::meshio::PsetFileBinary : public PsetFile
{ // PsetFileBinary
Copied: short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/meshio/UCDFaultFile.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,195 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "UCDFaultFile.hh" // implementation of class methods
+
+#include "MeshBuilder.hh" // USES MeshBuilder
+
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/utils/array.hh" // USES double_array, int_array
+
+#include <petsc.h> // USES MPI_Comm
+
+#include <cassert> // USES assert()
+#include <stdexcept> // USES std::runtime_error
+
+// ----------------------------------------------------------------------
+void
+pylith::meshio::UCDFaultFile::read(const char* filename,
+ topology::SubMesh* faultMesh,
+ ALE::Obj<ALE::Mesh>& faultBoundary,
+ const topology::Mesh& mesh)
+{ // read
+ assert(0 != faultMesh);
+
+ int faultDim = 2;
+ int fSpaceDim = 0;
+ int numFVertices = 0;
+ int numFCells = 0;
+ int numFCorners = 0;
+ double_array fCoordinates;
+ int_array fCells;
+ int_array fMaterialIds;
+ int_array faceCells;
+ int_array vertexIDs;
+
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ int rank = 0;
+ MPI_Comm_rank(mesh.comm(), &rank);
+ if (0 == rank) {
+ std::ifstream fin(filename, std::ios::in);
+ if (!(fin.is_open() && fin.good())) {
+ std::ostringstream msg;
+ msg << "Could not open ASCII INP file '" << filename << "' for reading.";
+ throw std::runtime_error(msg.str());
+ } // if
+ int numNodeData = 0;
+ int numCellData = 0;
+ int numModelData = 0;
+
+ fSpaceDim = 3;
+
+ // Section 1: <num_nodes> <num_cells> <num_ndata> <num_cdata> <num_mdata>
+ fin >> numFVertices;
+ fin >> numFCells;
+ fin >> numNodeData;
+ fin >> numCellData;
+ fin >> numModelData;
+ // Section 2: <node_id 1> <x> <y> <z>
+ fCoordinates.resize(numFVertices * fSpaceDim);
+ for(int v = 0; v < numFVertices; ++v) {
+ int id;
+ fin >> id;
+ for(int d = 0; d < fSpaceDim; ++d)
+ fin >> fCoordinates[v*fSpaceDim + d];
+ } // for
+
+ // Section 3: <cell_id 1> <mat_id> <cell_type> <cell_vert 1> ... <cell_vert n>
+ fMaterialIds.resize(numFCells);
+ for(int c = 0; c < numFCells; ++c) {
+ std::string cellType = "";
+ int cellID = 0;
+
+ fin >> cellID;
+ fin >> fMaterialIds[c];
+ fin >> cellType;
+ if (cellType == "tri") {
+ numFCorners = 3;
+ } else if (cellType == "quad") {
+ numFCorners = 4;
+ } else {
+ std::ostringstream msg;
+ msg << "Unknown cell type " << cellType << "while reading INP file.";
+ throw std::runtime_error(msg.str());
+ } // if/else
+ if (c == 0) fCells.resize(numFCells*numFCorners);
+ for(int i = 0; i < numFCorners; ++i)
+ fin >> fCells[c*numFCorners+i];
+ } // for
+
+ // Section 4: <num_comp for node data> <size comp 1> <size comp 2>...<size comp n>
+ int numComponents = 0;
+ int totalSize = 0;
+
+ fin >> numComponents;
+ totalSize = 0;
+ for(int i = 0; i < numComponents; ++i) {
+ int compSize;
+ fin >> compSize;
+ totalSize += compSize;
+ } // for
+ // Section 5: <node_comp_label 1> , <units_label 1>
+ for(int c = 0; c < numComponents; ++c) {
+ std::string label, typeName;
+
+ fin >> label;
+ fin >> typeName;
+ } // for
+
+ // Section 6: <node_id 1> <node_data 1> ... <node_data num_ndata>
+ vertexIDs.resize(numFVertices);
+ for(int v = 0; v < numFVertices; ++v) {
+ int id;
+ double dummy;
+
+ fin >> id;
+ fin >> vertexIDs[v]; // global node number
+ fin >> dummy; // components of normal at vertices
+ fin >> dummy;
+ fin >> dummy;
+ } // for
+
+ // Section 7: <num_comp for cell's data> <size comp 1> <size comp 2>...<size comp n>
+ fin >> numComponents;
+ totalSize = 0;
+ for(int i = 0; i < numComponents; ++i) {
+ int compSize;
+ fin >> compSize;
+ totalSize += compSize;
+ }
+
+ // Section 8: <cell_component_label 1> , <units_label 1>
+ for(int c = 0; c < numComponents; ++c) {
+ std::string label, typeName;
+
+ fin >> label;
+ fin >> typeName;
+ } // for
+
+ // Section 9: <cell_id 1> <cell_data 1> ... <cell_data num_cdata>
+ faceCells.resize(numFCells*2);
+ for(int c = 0; c < numFCells; ++c) {
+ int id, faultId;
+
+ fin >> id;
+ fin >> faceCells[c*2+0]; // Cell numbers in global mesh on either side of fault
+ fin >> faceCells[c*2+1];
+ fin >> faultId;
+ } // for
+
+ // Determine the number of cells
+ // Only do this once since we add cohesive cells after that
+ static int numCells = -1;
+
+ assert(!sieveMesh->heightStratum(0).isNull());
+ if (numCells == -1) {numCells = sieveMesh->heightStratum(0)->size();}
+
+ // Renumber vertices and use zero based indices
+ // UCD file has one-based indices for both vertexIDs and fCells
+ // Also, vertex numbers are offset by the number of cells
+ for(int c = 0; c < numFCells; ++c)
+ for(int corner = 0; corner < numFCorners; ++corner)
+ fCells[c*numFCorners+corner] =
+ vertexIDs[fCells[c*numFCorners+corner]-1] - 1 + numCells;
+
+ // Switch to zero based index for global cell numbering
+ for (int c=0; c < numFCells; ++c)
+ for (int i=0; i < 2; ++i)
+ faceCells[c*2+i] -= 1;
+ } // if
+
+ assert(!sieveMesh->getSieve().isNull());
+ const int firstFaultCell =
+ sieveMesh->getSieve()->getBaseSize() + sieveMesh->getSieve()->getCapSize();
+ MeshBuilder::buildFaultMesh(faultMesh->sieveMesh(), faultBoundary,
+ fCoordinates, numFVertices, fSpaceDim, fCells,
+ numFCells, numFCorners, firstFaultCell,
+ faceCells, faultDim);
+} // read
+
+
+// End of file
+
Copied: short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/meshio/UCDFaultFile.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/UCDFaultFile.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/meshio/UCDFaultFile.hh
+ *
+ * @brief C++ object for reading a fault mesh from a UCD file.
+ *
+ * Temporary fix for getting a fault mesh information into
+ * PyLith. Using a fault mesh permits cells to have more than one face
+ * on the fault surface. Supporting information also provides the
+ * orientation of the fault surface, eliminating the need to determine
+ * it from the faces/vertices alone.
+ */
+
+#if !defined(pylith_meshio_ucdfaultfile_hh)
+#define pylith_meshio_ucdfaultfile_hh
+
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
+
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
+
+#include "pylith/utils/sievetypes.hh" // USES ALE::Obj, ALE::Mesh
+
+// UCDFaultFile ---------------------------------------------------------
+class pylith::meshio::UCDFaultFile
+{ // UCDFaultFile
+ friend class TestUCDFaultFile; // unit testing
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ static
+ void read(const char* filename,
+ topology::SubMesh* faultMesh,
+ ALE::Obj<ALE::Mesh>& faultBoundary,
+ const topology::Mesh& mesh);
+
+}; // UCDFaultFile
+
+#endif // pylith_meshio_ucdfaultfile_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,30 +12,32 @@
#include <portinfo>
-#include "VertexFilter.hh" // implementation of class methods
-
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::VertexFilter::VertexFilter(void)
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>::VertexFilter(void)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-pylith::meshio::VertexFilter::~VertexFilter(void)
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>::~VertexFilter(void)
{ // destructor
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-pylith::meshio::VertexFilter::VertexFilter(const VertexFilter& f)
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>::VertexFilter(const VertexFilter& f)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// operator=.
-const pylith::meshio::VertexFilter&
-pylith::meshio::VertexFilter::operator=(const VertexFilter& f)
+template<typename field_type>
+const pylith::meshio::VertexFilter<field_type>&
+pylith::meshio::VertexFilter<field_type>::operator=(const VertexFilter& f)
{ // operator=
} // operator=
Modified: short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/VertexFilter.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,16 +20,13 @@
#if !defined(pylith_meshio_vertexfilter_hh)
#define pylith_meshio_vertexfilter_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh, real_section_type
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+// Include directives ---------------------------------------------------
+#include "meshiofwd.hh" // forward declarations
-namespace pylith {
- namespace meshio {
- class VertexFilter;
- } // meshio
+#include "pylith/topology/topologyfwd.hh" // USES Field
-} // pylith
-
+// VertexFilter ---------------------------------------------------------
+template<typename field_type>
class pylith::meshio::VertexFilter
{ // VertexFilter
@@ -49,17 +46,13 @@
virtual
VertexFilter* clone(void) const = 0;
- /** Filter field. Field type of filtered field is returned via an argument.
+ /** Filter field over vertices of a mesh.
*
- * @param fieldType Field type of filtered field.
* @param fieldIn Field to filter.
- * @param mesh PETSc mesh.
*/
virtual
- const ALE::Obj<real_section_type>&
- filter(VectorFieldEnum* fieldType,
- const ALE::Obj<real_section_type>& fieldIn,
- const ALE::Obj<Mesh>& mesh) = 0;
+ const field_type&
+ filter(const field_type& fieldIn) = 0;
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -71,6 +64,7 @@
*/
VertexFilter(const VertexFilter& f);
+private :
/** operator=.
*
* @param f Filter to copy.
@@ -80,6 +74,8 @@
}; // VertexFilter
+#include "VertexFilter.cc" // template definitions
+
#endif // pylith_meshio_vertexfilter_hh
Modified: short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,80 +12,111 @@
#include <portinfo>
-#include "VertexFilterVecNorm.hh" // implementation of class methods
+#include "pylith/topology/Field.hh" // USES Field
// ----------------------------------------------------------------------
// Constructor
-pylith::meshio::VertexFilterVecNorm::VertexFilterVecNorm(void)
+template<typename field_type>
+pylith::meshio::VertexFilterVecNorm<field_type>::VertexFilterVecNorm(void) :
+ _fieldVecNorm(0)
{ // constructor
} // constructor
// ----------------------------------------------------------------------
// Destructor
-pylith::meshio::VertexFilterVecNorm::~VertexFilterVecNorm(void)
+template<typename field_type>
+pylith::meshio::VertexFilterVecNorm<field_type>::~VertexFilterVecNorm(void)
{ // destructor
+ delete _fieldVecNorm; _fieldVecNorm = 0;
} // destructor
// ----------------------------------------------------------------------
// Copy constructor.
-pylith::meshio::VertexFilterVecNorm::VertexFilterVecNorm(const VertexFilterVecNorm& f) :
- VertexFilter(f)
+template<typename field_type>
+pylith::meshio::VertexFilterVecNorm<field_type>::VertexFilterVecNorm(const VertexFilterVecNorm& f) :
+ VertexFilter<field_type>(f),
+ _fieldVecNorm(0)
{ // copy constructor
} // copy constructor
// ----------------------------------------------------------------------
// Create copy of filter.
-pylith::meshio::VertexFilter*
-pylith::meshio::VertexFilterVecNorm::clone(void) const
+template<typename field_type>
+pylith::meshio::VertexFilter<field_type>*
+pylith::meshio::VertexFilterVecNorm<field_type>::clone(void) const
{ // clone
return new VertexFilterVecNorm(*this);
} // clone
// ----------------------------------------------------------------------
// Filter field.
-const ALE::Obj<pylith::real_section_type>&
-pylith::meshio::VertexFilterVecNorm::filter(
- VectorFieldEnum* fieldType,
- const ALE::Obj<real_section_type>& fieldIn,
- const ALE::Obj<Mesh>& mesh)
+template<typename field_type>
+const field_type&
+pylith::meshio::VertexFilterVecNorm<field_type>::filter(
+ const field_type& fieldIn)
{ // filter
- assert(0 != fieldType);
- *fieldType = SCALAR_FIELD;
+ typedef typename field_type::Mesh::RealSection RealSection;
+ typedef typename field_type::Mesh::SieveMesh SieveMesh;
+ typedef typename SieveMesh::label_sequence label_sequence;
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = fieldIn.mesh().sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ const ALE::Obj<label_sequence>& vertices = sieveMesh->depthStratum(0);
assert(!vertices.isNull());
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const typename label_sequence::iterator verticesEnd = vertices->end();
- const int fiberDim = fieldIn->getFiberDimension(*vertices->begin());
+ const ALE::Obj<RealSection>& sectionIn = fieldIn.section();
+ assert(!sectionIn.isNull());
+ const int fiberDimIn = sectionIn->getFiberDimension(*vertices->begin());
+ const int fiberDimNorm = 1;
// Allocation field if necessary
- if (_fieldVecNorm.isNull() ||
- 1 != _fieldVecNorm->getFiberDimension(*vertices->begin())) {
- _fieldVecNorm = new real_section_type(mesh->comm(), mesh->debug());
- _fieldVecNorm->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(), vertices->end()), *std::max_element(vertices->begin(), vertices->end())+1));
- _fieldVecNorm->setFiberDimension(vertices, 1);
- mesh->allocate(_fieldVecNorm);
+ if (0 == _fieldVecNorm) {
+ _fieldVecNorm = new field_type(fieldIn.mesh());
+ _fieldVecNorm->newSection(sectionIn->getChart(), fiberDimNorm);
+ _fieldVecNorm->allocate();
+
+ _fieldVecNorm->label(fieldIn.label());
+ switch (fieldIn.vectorFieldType())
+ { // switch
+ case topology::FieldBase::SCALAR:
+ case topology::FieldBase::VECTOR:
+ _fieldVecNorm->vectorFieldType(topology::FieldBase::SCALAR);
+ break;
+ case topology::FieldBase::MULTI_SCALAR:
+ case topology::FieldBase::MULTI_VECTOR:
+ case topology::FieldBase::MULTI_TENSOR:
+ case topology::FieldBase::MULTI_OTHER:
+ case topology::FieldBase::TENSOR:
+ case topology::FieldBase::OTHER:
+ default :
+ std::cerr << "Bad vector field type for VertexFilterVecNorm." << std::endl;
+ assert(0);
+ } // switch
} // if
+ const ALE::Obj<RealSection>& sectionNorm =
+ _fieldVecNorm->section();
+ assert(!sectionNorm.isNull());
+
double norm = 0.0;
-
// Loop over vertices
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (typename label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter) {
- const real_section_type::value_type* values =
- fieldIn->restrictPoint(*v_iter);
+ const double* values = sectionIn->restrictPoint(*v_iter);
norm = 0.0;
- for (int i=0; i < fiberDim; ++i)
+ for (int i=0; i < fiberDimIn; ++i)
norm += values[i]*values[i];
norm = sqrt(norm);
- _fieldVecNorm->updatePoint(*v_iter, &norm);
- PetscLogFlops( 1 + fiberDim*2 );
+ sectionNorm->updatePoint(*v_iter, &norm);
} // for
+ PetscLogFlops(vertices->size() * (1 + 2*fiberDimIn) );
- return _fieldVecNorm;
+ return *_fieldVecNorm;
} // filter
Modified: short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/meshio/VertexFilterVecNorm.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,15 +20,12 @@
#if !defined(pylith_meshio_cellfiltervecnorm_hh)
#define pylith_meshio_cellfiltervecnorm_hh
+// Include directives ---------------------------------------------------
#include "VertexFilter.hh" // ISA VertexFilter
-namespace pylith {
- namespace meshio {
- class VertexFilterVecNorm;
- } // meshio
-} // pylith
-
-class pylith::meshio::VertexFilterVecNorm : public VertexFilter
+// VertexFilterVecNorm --------------------------------------------------
+template<typename field_type>
+class pylith::meshio::VertexFilterVecNorm : public VertexFilter<field_type>
{ // VertexFilterVecNorm
// PUBLIC METHODS ///////////////////////////////////////////////////////
@@ -44,18 +41,14 @@
*
* @returns Copy of filter.
*/
- VertexFilter* clone(void) const;
+ VertexFilter<field_type>* clone(void) const;
- /** Filter field. Field type of filtered field is returned via an argument.
+ /** Filter vertex field.
*
- * @param fieldType Field type of filtered field.
* @param fieldIn Field to filter.
- * @param mesh PETSc mesh.
*/
- const ALE::Obj<real_section_type>&
- filter(VectorFieldEnum* fieldType,
- const ALE::Obj<real_section_type>& fieldIn,
- const ALE::Obj<Mesh>& mesh);
+ const field_type&
+ filter(const field_type& fieldIn);
// PROTECTED METHODS ////////////////////////////////////////////////////
protected :
@@ -71,15 +64,17 @@
private :
/// Not implemented.
- const VertexFilter& operator=(const VertexFilter&);
+ const VertexFilterVecNorm& operator=(const VertexFilterVecNorm&);
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- ALE::Obj<real_section_type> _fieldVecNorm; ///< Filtered vertex field
+ field_type* _fieldVecNorm; ///< Filtered vertex field
}; // VertexFilterVecNorm
+#include "VertexFilterVecNorm.cc" // template definitions
+
#endif // pylith_meshio_cellfiltervecnorm_hh
Copied: short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/meshio/meshiofwd.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/meshio/meshiofwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/meshio/meshiofwd.hh
+ *
+ * @brief Forward declarations for PyLith meshio objects.
+ *
+ * Including this header file eliminates the need to use separate
+ * forward declarations.
+ */
+
+#if !defined(pylith_meshio_meshiofwd_hh)
+#define pylith_meshio_meshiofwd_hh
+
+namespace pylith {
+ namespace meshio {
+
+ class BinaryIO;
+
+ class MeshIO;
+ class MeshBuilder;
+ class MeshIOAscii;
+ class MeshIOCubit;
+ class MeshIOLagrit;
+ class GMVFile;
+ class GMVFileAscii;
+ class GMVFileBinary;
+ class PsetFile;
+ class PsetFileAscii;
+ class PsetFileBinary;
+
+ template<typename mesh_type, typename field_type> class OutputManager;
+ template<typename mesh_type, typename field_type> class DataWriter;
+ template<typename mesh_type, typename field_type> class DataWriterVTK;
+ template<typename mesh_type, typename field_type> class CellFilter;
+ template<typename mesh_type, typename field_type> class CellFilterAvg;
+ template<typename field_type> class VertexFilter;
+ template<typename field_type> class VertexFilterVecNorm;
+ class OutputSolnSubset;
+
+ class UCDFaultFile;
+
+ } // meshio
+} // pylith
+
+
+#endif // pylith_meshio_meshiofwd_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/problems (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/problems)
Modified: short/3D/PyLith/trunk/libsrc/topology/Distributor.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Distributor.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Distributor.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,8 @@
#include "Distributor.hh" // implementation of class methods
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-#include "pylith/utils/vectorfields.hh" // USES SCALAR_FIELD
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field<Mesh>
#include "pylith/meshio/DataWriter.hh" // USES DataWriter
#include <cstring> // USES strlen()
@@ -25,6 +25,11 @@
#include <cassert> // USES assert()
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::Mesh::IntSection IntSection;
+
+// ----------------------------------------------------------------------
// Constructor
pylith::topology::Distributor::Distributor(void)
{ // constructor
@@ -39,99 +44,199 @@
// ----------------------------------------------------------------------
// Distribute mesh among processors.
void
-pylith::topology::Distributor::distribute(ALE::Obj<Mesh>* const newMesh,
- const ALE::Obj<Mesh>& origMesh,
+pylith::topology::Distributor::distribute(topology::Mesh* const newMesh,
+ const topology::Mesh& origMesh,
const char* partitioner)
{ // distribute
- if (0 == strcasecmp(partitioner, "")) {
- distribute_private<ALE::DistributionNew<Mesh> >(newMesh, origMesh);
+ assert(0 != newMesh);
+
+ newMesh->coordsys(origMesh.coordsys());
+
+ if (0 == strcasecmp(partitioner, ""))
+ _distribute<ALE::DistributionNew<SieveMesh> >(newMesh, origMesh);
#if defined(PETSC_HAVE_CHACO)
- } else if (0 == strcasecmp(partitioner, "chaco")) {
- distribute_private<ALE::DistributionNew<Mesh, ALE::Partitioner<ALE::Chaco::Partitioner<> > > >(newMesh, origMesh);
+ else if (0 == strcasecmp(partitioner, "chaco"))
+ _distribute<ALE::DistributionNew<SieveMesh, ALE::Partitioner<ALE::Chaco::Partitioner<> > > >(newMesh, origMesh);
#endif
#if defined(PETSC_HAVE_PARMETIS)
- } else if (0 == strcasecmp(partitioner, "parmetis")) {
- distribute_private<ALE::DistributionNew<Mesh, ALE::Partitioner<ALE::ParMetis::Partitioner<> > > >(newMesh, origMesh);
+ else if (0 == strcasecmp(partitioner, "parmetis"))
+ _distribute<ALE::DistributionNew<SieveMesh, ALE::Partitioner<ALE::ParMetis::Partitioner<> > > >(newMesh, origMesh);
#endif
- } else {
- std::cout << "ERROR: Using default partitioner instead of unknown partitioner " << partitioner << std::endl;
- distribute_private<ALE::DistributionNew<Mesh> >(newMesh, origMesh);
- }
-}
+ else {
+ std::cerr << "ERROR: Using default partitioner instead of unknown "
+ "partitioner '" << partitioner << "'." << std::endl;
+ _distribute<ALE::DistributionNew<SieveMesh> >(newMesh, origMesh);
+ } // else
+} // distribute
+// ----------------------------------------------------------------------
+// Write partitioning info for distributed mesh.
+void
+pylith::topology::Distributor::write(meshio::DataWriter<topology::Mesh, topology::Field<topology::Mesh> >* const writer,
+ const topology::Mesh& mesh)
+{ // write
+
+ // Setup and allocate field
+ const int fiberDim = 1;
+ topology::Field<topology::Mesh> partition(mesh);
+ partition.scale(1.0);
+ partition.label("partition");
+ partition.vectorFieldType(topology::FieldBase::SCALAR);
+ partition.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
+ partition.allocate();
+ const ALE::Obj<RealSection>& partitionSection = partition.section();
+ assert(!partitionSection.isNull());
+
+ const ALE::Obj<SieveMesh> sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ double rankReal = double(sieveMesh->commRank());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
+ assert(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsBegin = cells->begin();
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ for (SieveMesh::label_sequence::iterator c_iter=cellsBegin;
+ c_iter != cellsEnd;
+ ++c_iter) {
+ partitionSection->updatePoint(*c_iter, &rankReal);
+ } // for
+
+ //partition->view("PARTITION");
+ const double t = 0.0;
+ const int numTimeSteps = 0;
+ writer->open(mesh, numTimeSteps);
+ writer->openTimeStep(t, mesh);
+ writer->writeCellField(t, partition);
+ writer->closeTimeStep();
+ writer->close();
+} // write
+
+// ----------------------------------------------------------------------
template<typename DistributionType>
void
-pylith::topology::Distributor::distribute_private(ALE::Obj<Mesh>* const newMesh,
- const ALE::Obj<Mesh>& origMesh)
+pylith::topology::Distributor::_distribute(topology::Mesh* const newMesh,
+ const topology::Mesh& origMesh)
{ // distribute
- typedef typename Mesh::point_type point_type;
+ typedef typename SieveMesh::point_type point_type;
typedef typename DistributionType::partitioner_type partitioner_type;
typedef typename DistributionType::partition_type partition_type;
- const Obj<Mesh::sieve_type> newSieve = new Mesh::sieve_type(origMesh->comm(), origMesh->debug());
- const Obj<Mesh::send_overlap_type> sendMeshOverlap = new Mesh::send_overlap_type(origMesh->comm(), origMesh->debug());
- const Obj<Mesh::recv_overlap_type> recvMeshOverlap = new Mesh::recv_overlap_type(origMesh->comm(), origMesh->debug());
+ ALE::Obj<SieveMesh>& newSieveMesh = newMesh->sieveMesh();
+ assert(!newSieveMesh.isNull());
+ const ALE::Obj<SieveMesh>& origSieveMesh = origMesh.sieveMesh();
+ assert(!origSieveMesh.isNull());
- *newMesh = new Mesh(origMesh->comm(), origMesh->getDimension(), origMesh->debug());
- (*newMesh)->setSieve(newSieve);
- // IMESH_TODO
- // This might be unnecessary, since the overlap for submeshes is just the restriction of the overlaps
- // std::map<point_type,point_type> renumbering;
- Mesh::renumbering_type& renumbering = (*newMesh)->getRenumbering();
+ const ALE::Obj<SieveMesh::sieve_type> newSieve =
+ new SieveMesh::sieve_type(origSieveMesh->comm(), origSieveMesh->debug());
+ assert(!newSieve.isNull());
+ const ALE::Obj<SieveMesh::send_overlap_type> sendMeshOverlap =
+ new SieveMesh::send_overlap_type(origSieveMesh->comm(),
+ origSieveMesh->debug());
+ assert(!sendMeshOverlap.isNull());
+ const ALE::Obj<SieveMesh::recv_overlap_type> recvMeshOverlap =
+ new SieveMesh::recv_overlap_type(origSieveMesh->comm(),
+ origSieveMesh->debug());
+ assert(!recvMeshOverlap.isNull());
+
+ newSieveMesh = new SieveMesh(origSieveMesh->comm(),
+ origSieveMesh->getDimension(),
+ origSieveMesh->debug());
+ assert(!newSieveMesh.isNull());
+ newSieveMesh->setSieve(newSieve);
+ // IMESH_TODO This might be unnecessary, since the overlap for
+ // submeshes is just the restriction of the overlaps
+ // std::map<point_type,point_type> renumbering;
+ SieveMesh::renumbering_type& renumbering = newSieveMesh->getRenumbering();
// Distribute the mesh
- Obj<partition_type> partition = DistributionType::distributeMeshV(origMesh, (*newMesh), renumbering, sendMeshOverlap, recvMeshOverlap);
- if (origMesh->debug()) {
- std::cout << "["<<origMesh->commRank()<<"]: Mesh Renumbering:" << std::endl;
- for(Mesh::renumbering_type::const_iterator r_iter = renumbering.begin(); r_iter != renumbering.end(); ++r_iter) {
- std::cout << "["<<origMesh->commRank()<<"]: global point " << r_iter->first << " --> " << " local point " << r_iter->second << std::endl;
- }
- }
+ ALE::Obj<partition_type> partition =
+ DistributionType::distributeMeshV(origSieveMesh, newSieveMesh,
+ renumbering,
+ sendMeshOverlap, recvMeshOverlap);
+ if (origSieveMesh->debug()) {
+ std::cout << "["<<origSieveMesh->commRank()<<"]: Mesh Renumbering:"
+ << std::endl;
+ for (SieveMesh::renumbering_type::const_iterator r_iter = renumbering.begin();
+ r_iter != renumbering.end();
+ ++r_iter) {
+ std::cout << "["<<origSieveMesh->commRank()<<"]: global point "
+ << r_iter->first << " --> " << " local point "
+ << r_iter->second << std::endl;
+ } // for
+ } // if
// Check overlap
int localSendOverlapSize = 0, sendOverlapSize;
int localRecvOverlapSize = 0, recvOverlapSize;
- for(int p = 0; p < sendMeshOverlap->commSize(); ++p) {
+ const int commSize = sendMeshOverlap->commSize();
+ for (int p = 0; p < commSize; ++p) {
localSendOverlapSize += sendMeshOverlap->cone(p)->size();
localRecvOverlapSize += recvMeshOverlap->support(p)->size();
- }
- MPI_Allreduce(&localSendOverlapSize, &sendOverlapSize, 1, MPI_INT, MPI_SUM, sendMeshOverlap->comm());
- MPI_Allreduce(&localRecvOverlapSize, &recvOverlapSize, 1, MPI_INT, MPI_SUM, recvMeshOverlap->comm());
- if(sendOverlapSize != recvOverlapSize) {
- std::cout <<"["<<sendMeshOverlap->commRank()<<"]: Size mismatch " << sendOverlapSize << " != " << recvOverlapSize << std::endl;
+ } // for
+ MPI_Allreduce(&localSendOverlapSize, &sendOverlapSize, 1, MPI_INT, MPI_SUM,
+ sendMeshOverlap->comm());
+ MPI_Allreduce(&localRecvOverlapSize, &recvOverlapSize, 1, MPI_INT, MPI_SUM,
+ recvMeshOverlap->comm());
+ if (sendOverlapSize != recvOverlapSize) {
+ std::cout <<"["<<sendMeshOverlap->commRank()<<"]: Size mismatch " <<
+ sendOverlapSize << " != " << recvOverlapSize << std::endl;
sendMeshOverlap->view("Send Overlap");
recvMeshOverlap->view("Recv Overlap");
throw ALE::Exception("Invalid Overlap");
- }
+ } // if
// Distribute the coordinates
- const Obj<real_section_type>& coordinates = origMesh->getRealSection("coordinates");
- const Obj<real_section_type>& parallelCoordinates = (*newMesh)->getRealSection("coordinates");
+ const ALE::Obj<RealSection>& coordinates =
+ origSieveMesh->getRealSection("coordinates");
+ assert(!coordinates.isNull());
+ const ALE::Obj<RealSection>& parallelCoordinates =
+ newSieveMesh->getRealSection("coordinates");
+ assert(!parallelCoordinates.isNull());
- (*newMesh)->setupCoordinates(parallelCoordinates);
- DistributionType::distributeSection(coordinates, partition, renumbering, sendMeshOverlap, recvMeshOverlap, parallelCoordinates);
+ newSieveMesh->setupCoordinates(parallelCoordinates);
+ DistributionType::distributeSection(coordinates, partition, renumbering,
+ sendMeshOverlap, recvMeshOverlap,
+ parallelCoordinates);
// Distribute other sections
- if (origMesh->getRealSections()->size() > 1) {
- Obj<std::set<std::string> > names = origMesh->getRealSections();
- int n = 0;
+ if (origSieveMesh->getRealSections()->size() > 1) {
+ ALE::Obj<std::set<std::string> > names = origSieveMesh->getRealSections();
+ assert(!names.isNull());
+ int n = 0;
- for(std::set<std::string>::const_iterator n_iter = names->begin(); n_iter != names->end(); ++n_iter) {
- if (*n_iter == "coordinates") continue;
- if (*n_iter == "replaced_cells") continue;
- std::cout << "ERROR: Did not distribute real section " << *n_iter << std::endl;
+ const std::set<std::string>::const_iterator namesBegin = names->begin();
+ const std::set<std::string>::const_iterator namesEnd = names->end();
+ for (std::set<std::string>::const_iterator n_iter = namesBegin;
+ n_iter != namesEnd;
+ ++n_iter) {
+ if (*n_iter == "coordinates") continue; // already copied
+ if (*n_iter == "replaced_cells") continue; // ignore
+ std::cerr << "ERROR: Did not distribute real section '" << *n_iter
+ << "'." << std::endl;
++n;
- }
- if (n) {throw ALE::Exception("Need to distribute more real sections");}
+ } // if
+ if (n)
+ throw std::logic_error("Need to distribute more real sections");
}
- if (origMesh->getIntSections()->size() > 0) {
- Obj<std::set<std::string> > names = origMesh->getIntSections();
+ if (origSieveMesh->getIntSections()->size() > 0) {
+ ALE::Obj<std::set<std::string> > names = origSieveMesh->getIntSections();
+ assert(!names.isNull());
- for(std::set<std::string>::const_iterator n_iter = names->begin(); n_iter != names->end(); ++n_iter) {
- const Obj<Mesh::int_section_type>& origSection = origMesh->getIntSection(*n_iter);
- const Obj<Mesh::int_section_type>& newSection = (*newMesh)->getIntSection(*n_iter);
+ std::set<std::string>::const_iterator namesBegin = names->begin();
+ std::set<std::string>::const_iterator namesEnd = names->end();
+ for (std::set<std::string>::const_iterator n_iter = namesBegin;
+ n_iter != namesEnd;
+ ++n_iter) {
+ const ALE::Obj<IntSection>& origSection =
+ origSieveMesh->getIntSection(*n_iter);
+ assert(!origSection.isNull());
+ const ALE::Obj<IntSection>& newSection =
+ newSieveMesh->getIntSection(*n_iter);
+ assert(!newSection.isNull());
// We assume all integer sections are complete sections
- newSection->setChart((*newMesh)->getSieve()->getChart());
- DistributionType::distributeSection(origSection, partition, renumbering, sendMeshOverlap, recvMeshOverlap, newSection);
-#if 0
+ newSection->setChart(newSieveMesh->getSieve()->getChart());
+ DistributionType::distributeSection(origSection, partition, renumbering,
+ sendMeshOverlap, recvMeshOverlap,
+ newSection);
+#if 0 // DEBUGGING
std::string serialName("Serial ");
std::string parallelName("Parallel ");
serialName += *n_iter;
@@ -139,36 +244,44 @@
origSection->view(serialName.c_str());
newSection->view(parallelName.c_str());
#endif
- }
- }
- if (origMesh->getArrowSections()->size() > 1) {
- throw ALE::Exception("Need to distribute more arrow sections");
- }
+ } // for
+ } // if
+ if (origSieveMesh->getArrowSections()->size() > 1)
+ throw std::logic_error("Need to distribute more arrow sections");
+
// Distribute labels
- const Mesh::labels_type& labels = origMesh->getLabels();
+ const SieveMesh::labels_type& labels = origSieveMesh->getLabels();
+ const SieveMesh::labels_type::const_iterator labelsBegin = labels.begin();
+ const SieveMesh::labels_type::const_iterator labelsEnd = labels.end();
- for(Mesh::labels_type::const_iterator l_iter = labels.begin(); l_iter != labels.end(); ++l_iter) {
- if ((*newMesh)->hasLabel(l_iter->first)) continue;
+ for (SieveMesh::labels_type::const_iterator l_iter = labelsBegin;
+ l_iter != labelsEnd;
+ ++l_iter) {
+ if (newSieveMesh->hasLabel(l_iter->first)) continue;
+ const ALE::Obj<SieveMesh::label_type>& origLabel = l_iter->second;
+ assert(!origLabel.isNull());
+ const ALE::Obj<SieveMesh::label_type>& newLabel =
+ newSieveMesh->createLabel(l_iter->first);
+ assert(!newLabel.isNull());
+
#ifdef IMESH_NEW_LABELS
- const Obj<Mesh::label_type>& origLabel = l_iter->second;
- const Obj<Mesh::label_type>& newLabel = (*newMesh)->createLabel(l_iter->first);
-
newLabel->setChart(newSieve->getChart());
// Size the local mesh
- partitioner_type::sizeLocalSieveV(origLabel, partition, renumbering, newLabel);
+ partitioner_type::sizeLocalSieveV(origLabel, partition, renumbering,
+ newLabel);
// Create the remote meshes
- DistributionType::completeConesV(origLabel, newLabel, renumbering, sendMeshOverlap, recvMeshOverlap);
+ DistributionType::completeConesV(origLabel, newLabel, renumbering,
+ sendMeshOverlap, recvMeshOverlap);
// Create the local mesh
- partitioner_type::createLocalSieveV(origLabel, partition, renumbering, newLabel);
+ partitioner_type::createLocalSieveV(origLabel, partition, renumbering,
+ newLabel);
newLabel->symmetrize();
#else
- const Obj<Mesh::label_type>& origLabel = l_iter->second;
- const Obj<Mesh::label_type>& newLabel = (*newMesh)->createLabel(l_iter->first);
// Get remote labels
- ALE::New::Completion<Mesh,Mesh::point_type>::scatterCones(origLabel, newLabel, sendMeshOverlap, recvMeshOverlap, renumbering);
+ ALE::New::Completion<SieveMesh,SieveMesh::point_type>::scatterCones(origLabel, newLabel, sendMeshOverlap, recvMeshOverlap, renumbering);
// Create local label
- newLabel->add(origLabel, (*newMesh)->getSieve(), renumbering);
-#if 0
+ newLabel->add(origLabel, newSieveMesh->getSieve(), renumbering);
+#if 0 // DEBUGGING
std::string serialName("Serial ");
std::string parallelName("Parallel ");
serialName += l_iter->first;
@@ -177,54 +290,23 @@
newLabel->view(parallelName.c_str());
#endif
#endif
- }
+ } // for
+
// Create the parallel overlap
- Obj<Mesh::send_overlap_type> sendParallelMeshOverlap = (*newMesh)->getSendOverlap();
- Obj<Mesh::recv_overlap_type> recvParallelMeshOverlap = (*newMesh)->getRecvOverlap();
+ ALE::Obj<SieveMesh::send_overlap_type> sendParallelMeshOverlap =
+ newSieveMesh->getSendOverlap();
+ assert(!sendParallelMeshOverlap.isNull());
+ ALE::Obj<SieveMesh::recv_overlap_type> recvParallelMeshOverlap =
+ newSieveMesh->getRecvOverlap();
+ assert(!recvParallelMeshOverlap.isNull());
+
// Can I figure this out in a nicer way?
ALE::SetFromMap<std::map<point_type,point_type> > globalPoints(renumbering);
-
- ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering, sendParallelMeshOverlap, recvParallelMeshOverlap);
- (*newMesh)->setCalculatedOverlap(true);
+ ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering,
+ sendParallelMeshOverlap,
+ recvParallelMeshOverlap);
+ newSieveMesh->setCalculatedOverlap(true);
} // distribute
-// ----------------------------------------------------------------------
-// Write partitioning info for distributed mesh.
-void
-pylith::topology::Distributor::write(meshio::DataWriter* const writer,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs)
-{ // write
-
- // Setup and allocate field
- const int fiberDim = 1;
- ALE::Obj<real_section_type> partition =
- new real_section_type(mesh->comm(), mesh->debug());
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
- assert(!cells.isNull());
- partition->setChart(real_section_type::chart_type(*std::min_element(cells->begin(), cells->end()),
- *std::max_element(cells->begin(), cells->end())+1));
- partition->setFiberDimension(cells, fiberDim);
- mesh->allocate(partition);
- const int rank = mesh->commRank();
- double rankReal = double(rank);
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
- c_iter != cellsEnd;
- ++c_iter) {
- partition->updatePoint(*c_iter, &rankReal);
- } // for
-
- //partition->view("PARTITION");
- const double t = 0.0;
- const int numTimeSteps = 0;
- writer->open(mesh, cs, numTimeSteps);
- writer->openTimeStep(t, mesh, cs);
- writer->writeCellField(t, "partition", partition, SCALAR_FIELD, mesh);
- writer->closeTimeStep();
- writer->close();
-} // write
-
-
// End of file
Modified: short/3D/PyLith/trunk/libsrc/topology/Distributor.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Distributor.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Distributor.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,25 +19,11 @@
#if !defined(pylith_topology_distributor_hh)
#define pylith_topology_distributor_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
-namespace pylith {
- namespace topology {
- class Distributor;
- class TestDistributor;
- } // topology
+#include "pylith/meshio/meshiofwd.hh" // USES DataWriter<Mesh>
- namespace meshio {
- class DataWriter;
- } // meshio
-} // pylith
-
-namespace spatialdata {
- namespace geocoords {
- class CoordSys;
- } // geocoords
-} // spatialdata
-
class pylith::topology::Distributor
{ // Distributor
friend class TestDistributor; // unit testing
@@ -54,12 +40,12 @@
/** Distribute mesh among processors.
*
* @param newMesh Distributed mesh (result).
- * @param mesh Mesh to distribute.
+ * @param origMesh Mesh to distribute.
* @param partitioner Name of partitioner to use in distributing mesh.
*/
static
- void distribute(ALE::Obj<Mesh>* const newMesh,
- const ALE::Obj<Mesh>& mesh,
+ void distribute(topology::Mesh* const newMesh,
+ const topology::Mesh& origMesh,
const char* partitioner);
/** Write partitioning info for distributed mesh.
@@ -69,25 +55,29 @@
* @param cs Coordinate system for mesh.
*/
static
- void write(meshio::DataWriter* const writer,
- const ALE::Obj<Mesh>& mesh,
- const spatialdata::geocoords::CoordSys* cs);
+ void write(meshio::DataWriter<topology::Mesh, topology::Field<topology::Mesh> >* const writer,
+ const topology::Mesh& mesh);
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
+// PRIVATE //////////////////////////////////////////////////////////////
private :
- /// Not implemented
- Distributor(const Distributor&);
-
- /// Not implemented
- const Distributor& operator=(const Distributor&);
-
+ /** Distribute mesh among processors.
+ *
+ * @param newMesh Distributed mesh (result).
+ * @param origMesh Mesh to distribute.
+ */
template<typename DistributionType>
static
void
- distribute_private(ALE::Obj<Mesh>* const newMesh,
- const ALE::Obj<Mesh>& origMesh);
+ _distribute(topology::Mesh* const newMesh,
+ const topology::Mesh& origMesh);
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ Distributor(const Distributor&); ///< Not implemented
+ const Distributor& operator=(const Distributor&); ///< Not implemented
+
}; // Distributor
#endif // pylith_topology_distributor_hh
Deleted: short/3D/PyLith/trunk/libsrc/topology/Field.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,291 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <portinfo>
-
-#include "Field.hh" // implementation of class methods
-
-#include "pylith/utils/array.hh" // USES double_array
-
-#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
-#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-
-#include <stdexcept> // USES std::runtime_error
-#include <sstream> // USES std::ostringstream
-#include <cassert> // USES assert()
-
-// ----------------------------------------------------------------------
-// Default constructor.
-pylith::topology::Field::Field(const ALE::Obj<SieveMesh>& mesh) :
- _mesh(mesh),
- _scale(1.0),
- _name("unknown"),
- _vecFieldType(OTHER),
- _dimensionsOkay(false)
-{ // constructor
- assert(!mesh.isNull());
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor.
-pylith::topology::Field::~Field(void)
-{ // destructor
-} // destructor
-
-// ----------------------------------------------------------------------
-// Get spatial dimension of domain.
-int
-pylith::topology::Field::spaceDim(void) const
-{ // spaceDim
- assert(!_mesh.isNull());
- return _mesh->getDimension();
-} // spaceDim
-
-// ----------------------------------------------------------------------
-// Create seive section.
-void
-pylith::topology::Field::newSection(void)
-{ // newSection
- assert(!_mesh.isNull());
- _section = new SieveRealSection(_mesh->comm(), _mesh->debug());
-} // newSection
-
-// ----------------------------------------------------------------------
-// Create section given atlas.
-void
-pylith::topology::Field::copyLayout(const Field& src)
-{ // createSection
- _vecFieldType = src._vecFieldType;
-
- const ALE::Obj<SieveRealSection>& srcSection = src.section();
- if (!srcSection.isNull() && _section.isNull())
- newSection();
-
- if (!_section.isNull()) {
- _section->setAtlas(srcSection->getAtlas());
- _section->allocateStorage();
- _section->setBC(srcSection->getBC());
- } // if
-} // createSection
-
-// ----------------------------------------------------------------------
-// Clear variables associated with section.
-void
-pylith::topology::Field::clear(void)
-{ // clear
- if (!_section.isNull())
- _section->clear();
-
- _scale = 1.0;
- _vecFieldType = OTHER;
- _dimensionsOkay = false;
-} // clear
-
-// ----------------------------------------------------------------------
-// Zero section values.
-void
-pylith::topology::Field::zero(void)
-{ // zero
- if (!_section.isNull())
- _section->zero();
-} // zero
-
-// ----------------------------------------------------------------------
-// Complete section by assembling across processors.
-void
-pylith::topology::Field::complete(void)
-{ // complete
- if (!_section.isNull())
- ALE::Completion::completeSectionAdd(_mesh->getSendOverlap(),
- _mesh->getRecvOverlap(),
- _section, _section);
-} // complete
-
-// ----------------------------------------------------------------------
-// Copy field values and metadata.
-void
-pylith::topology::Field::copy(const Field& field)
-{ // copy
- // Check compatibility of sections
- const int srcSize = (!field._section.isNull()) ? field._section->size() : 0;
- const int dstSize = (!_section.isNull()) ? _section->size() : 0;
- if (field.spaceDim() != spaceDim() ||
- field._vecFieldType != _vecFieldType ||
- field._scale != _scale ||
- srcSize != dstSize) {
- std::ostringstream msg;
-
- msg << "Cannot copy values from section '" << field._name
- << "' to section '" << _name << "'. Sections are incompatible.\n"
- << " Source section:\n"
- << " space dim: " << field.spaceDim() << "\n"
- << " vector field type: " << field._vecFieldType << "\n"
- << " scale: " << field._scale << "\n"
- << " size: " << srcSize
- << " Destination section:\n"
- << " space dim: " << spaceDim() << "\n"
- << " vector field type: " << _vecFieldType << "\n"
- << " scale: " << _scale << "\n"
- << " size: " << dstSize;
- throw std::runtime_error(msg.str());
- } // if
- assert( (_section.isNull() && field._section.isNull()) ||
- (!_section.isNull() && !field._section.isNull()) );
-
- if (!_section.isNull()) {
- // Copy values from field
- const SieveRealSection::chart_type& chart = _section->getChart();
- const SieveRealSection::chart_type::const_iterator chartEnd = chart.end();
-
- for (SieveRealSection::chart_type::const_iterator c_iter = chart.begin();
- c_iter != chartEnd;
- ++c_iter) {
- assert(field._section->getFiberDimension(*c_iter) ==
- _section->getFiberDimension(*c_iter));
- _section->updatePoint(*c_iter, field._section->restrictPoint(*c_iter));
- } // for
- } // if
-} // copy
-
-// ----------------------------------------------------------------------
-// Add two fields, storing the result in one of the fields.
-void
-pylith::topology::Field::operator+=(const Field& field)
-{ // operator+=
- // Check compatibility of sections
- const int srcSize = (!field._section.isNull()) ? field._section->size() : 0;
- const int dstSize = (!_section.isNull()) ? _section->size() : 0;
- if (field.spaceDim() != spaceDim() ||
- field._vecFieldType != _vecFieldType ||
- field._scale != _scale ||
- srcSize != dstSize) {
- std::ostringstream msg;
-
- msg << "Cannot add values from section '" << field._name
- << "' to section '" << _name << "'. Sections are incompatible.\n"
- << " Source section:\n"
- << " space dim: " << field.spaceDim() << "\n"
- << " vector field type: " << field._vecFieldType << "\n"
- << " scale: " << field._scale << "\n"
- << " size: " << srcSize
- << " Destination section:\n"
- << " space dim: " << spaceDim() << "\n"
- << " vector field type: " << _vecFieldType << "\n"
- << " scale: " << _scale << "\n"
- << " size: " << dstSize;
- throw std::runtime_error(msg.str());
- } // if
- assert( (_section.isNull() && field._section.isNull()) ||
- (!_section.isNull() && !field._section.isNull()) );
-
- if (!_section.isNull()) {
- // Add values from field
- const SieveRealSection::chart_type& chart = _section->getChart();
- const SieveRealSection::chart_type::const_iterator chartEnd = chart.end();
-
- // Assume fiber dimension is uniform
- const int fiberDim = _section->getFiberDimension(*chart.begin());
- double_array values(fiberDim);
-
- for (SieveRealSection::chart_type::const_iterator c_iter = chart.begin();
- c_iter != chartEnd;
- ++c_iter) {
- assert(fiberDim == field._section->getFiberDimension(*c_iter));
- assert(fiberDim == _section->getFiberDimension(*c_iter));
- field._section->restrictPoint(*c_iter, &values[0], values.size());
- _section->updateAddPoint(*c_iter, &values[0]);
- } // for
- } // if
-} // operator+=
-
-// ----------------------------------------------------------------------
-// Dimensionalize field.
-void
-pylith::topology::Field::dimensionalize(void)
-{ // dimensionalize
- if (!_dimensionsOkay) {
- std::ostringstream msg;
- msg << "Cannot dimensionalize field '" << _name << "' because the flag "
- << "has been set to keep field nondimensional.";
- throw std::runtime_error(msg.str());
- } // if
-
- if (!_section.isNull()) {
- const SieveRealSection::chart_type& chart = _section->getChart();
- const SieveRealSection::chart_type::const_iterator chartEnd = chart.end();
-
- // Assume fiber dimension is uniform
- const int fiberDim = _section->getFiberDimension(*chart.begin());
- double_array values(fiberDim);
-
- spatialdata::units::Nondimensional normalizer;
-
- for (SieveRealSection::chart_type::const_iterator c_iter = chart.begin();
- c_iter != chartEnd;
- ++c_iter) {
- assert(fiberDim == _section->getFiberDimension(*c_iter));
-
- _section->restrictPoint(*c_iter, &values[0], values.size());
- normalizer.dimensionalize(&values[0], values.size(), _scale);
- _section->updatePoint(*c_iter, &values[0]);
- } // for
- } // if
-} // dimensionalize
-
-// ----------------------------------------------------------------------
-// Print field to standard out.
-void
-pylith::topology::Field::view(const char* label)
-{ // view
- std::string vecFieldString;
- switch(_vecFieldType)
- { // switch
- case SCALAR:
- vecFieldString = "scalar";
- break;
- case VECTOR:
- vecFieldString = "vector";
- break;
- case TENSOR:
- vecFieldString = "tensor";
- break;
- case OTHER:
- vecFieldString = "other";
- break;
- case MULTI_SCALAR:
- vecFieldString = "multiple scalars";
- break;
- case MULTI_VECTOR:
- vecFieldString = "multiple vectors";
- break;
- case MULTI_TENSOR:
- vecFieldString = "multiple tensors";
- break;
- case MULTI_OTHER:
- vecFieldString = "multiple other values";
- break;
- default :
- std::cerr << "Unknown vector field value '" << _vecFieldType
- << "'." << std::endl;
- assert(0);
- } // switch
-
- std::cout << "Viewing field '" << _name << "' "<< label << ".\n"
- << " vector field type: " << vecFieldString << "\n"
- << " scale: " << _scale << "\n"
- << " dimensionalize flag: " << _dimensionsOkay << std::endl;
- if (!_section.isNull())
- _section->view(label);
-} // view
-
-
-// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/Field.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,584 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "Field.hh" // implementation of class methods
+
+#include "pylith/utils/array.hh" // USES double_array
+
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+#include <stdexcept> // USES std::runtime_error
+#include <sstream> // USES std::ostringstream
+#include <cassert> // USES assert()
+
+// ----------------------------------------------------------------------
+// Default constructor.
+template<typename mesh_type>
+pylith::topology::Field<mesh_type>::Field(const mesh_type& mesh) :
+ _scale(1.0),
+ _label("unknown"),
+ _mesh(mesh),
+ _vector(0),
+ _scatter(0),
+ _vecFieldType(OTHER),
+ _dimensionsOkay(false)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+template<typename mesh_type>
+pylith::topology::Field<mesh_type>::~Field(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate PETSc and local data structures.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::deallocate(void)
+{ // deallocate
+ PetscErrorCode err = 0;
+ if (0 != _vector) {
+ err = VecDestroy(_vector); _vector = 0;
+ CHECK_PETSC_ERROR(err);
+ } // if
+
+ if (0 != _scatter) {
+ err = VecScatterDestroy(_scatter); _scatter = 0;
+ CHECK_PETSC_ERROR(err);
+ } // if
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Get spatial dimension of domain.
+template<typename mesh_type>
+int
+pylith::topology::Field<mesh_type>::spaceDim(void) const
+{ // spaceDim
+ const spatialdata::geocoords::CoordSys* cs = _mesh.coordsys();
+ return (0 != cs) ? cs->spaceDim() : 0;
+} // spaceDim
+
+// ----------------------------------------------------------------------
+// Create seive section.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::newSection(void)
+{ // newSection
+ _section = new RealSection(_mesh.comm(), _mesh.debug());
+} // newSection
+
+// ----------------------------------------------------------------------
+// Create sieve section and set chart and fiber dimesion.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::newSection(
+ const ALE::Obj<label_sequence>& points,
+ const int fiberDim)
+{ // newSection
+ typedef typename mesh_type::SieveMesh::point_type point_type;
+
+ if (fiberDim < 0) {
+ std::ostringstream msg;
+ msg
+ << "Fiber dimension (" << fiberDim << ") for field '" << _label
+ << "' must be nonnegative.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ _section = new RealSection(_mesh.comm(), _mesh.debug());
+
+ if (points->size() > 0) {
+ const point_type pointMin =
+ *std::min_element(points->begin(), points->end());
+ const point_type pointMax =
+ *std::max_element(points->begin(), points->end());
+ _section->setChart(chart_type(pointMin, pointMax+1));
+ _section->setFiberDimension(points, fiberDim);
+ } else {
+ // Create empty chart
+ _section->setChart(chart_type(0, 0));
+ _section->setFiberDimension(points, fiberDim);
+ } // if/else
+} // newSection
+
+// ----------------------------------------------------------------------
+// Create sieve section and set chart and fiber dimesion.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::newSection(const DomainEnum domain,
+ const int fiberDim,
+ const int stratum)
+{ // newSection
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ ALE::Obj<label_sequence> points;
+ if (VERTICES_FIELD == domain)
+ points = sieveMesh->depthStratum(stratum);
+ else if (CELLS_FIELD == domain)
+ points = sieveMesh->heightStratum(stratum);
+ else {
+ std::cerr << "Unknown value for DomainEnum: " << domain << std::endl;
+ assert(0);
+ } // else
+
+ newSection(points, fiberDim);
+} // newSection
+
+// ----------------------------------------------------------------------
+// Create section given chart.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::newSection(const chart_type& chart,
+ const int fiberDim)
+{ // newSection
+ if (_section.isNull())
+ newSection();
+
+ _section->setChart(chart);
+
+ const typename chart_type::const_iterator chartEnd = chart.end();
+ for (typename chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chartEnd;
+ ++c_iter)
+ _section->setFiberDimension(*c_iter, fiberDim);
+ allocate();
+} // newSection
+
+// ----------------------------------------------------------------------
+// Create section with same layout as another section.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::newSection(const Field& src)
+{ // newSection
+ _vecFieldType = src._vecFieldType;
+
+ const ALE::Obj<RealSection>& srcSection = src.section();
+ if (!srcSection.isNull() && _section.isNull())
+ newSection();
+
+ if (!_section.isNull()) {
+ _section->setAtlas(srcSection->getAtlas());
+ _section->allocateStorage();
+ _section->setBC(srcSection->getBC());
+
+ if (0 != src._scatter) {
+ _scatter = src._scatter;
+ PetscErrorCode err = PetscObjectReference((PetscObject) _scatter);
+ CHECK_PETSC_ERROR(err);
+ } // if
+ } // if
+} // newSection
+
+// ----------------------------------------------------------------------
+// Clear variables associated with section.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::clear(void)
+{ // clear
+ if (!_section.isNull())
+ _section->clear();
+
+ _scale = 1.0;
+ _vecFieldType = OTHER;
+ _dimensionsOkay = false;
+} // clear
+
+// ----------------------------------------------------------------------
+// Allocate Sieve section.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::allocate(void)
+{ // allocate
+ assert(!_section.isNull());
+
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ sieveMesh->allocate(_section);
+} // allocate
+
+// ----------------------------------------------------------------------
+// Zero section values.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::zero(void)
+{ // zero
+ if (!_section.isNull())
+ _section->zero();
+} // zero
+
+// ----------------------------------------------------------------------
+// Complete section by assembling across processors.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::complete(void)
+{ // complete
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+
+ if (!_section.isNull())
+ ALE::Completion::completeSectionAdd(sieveMesh->getSendOverlap(),
+ sieveMesh->getRecvOverlap(),
+ _section, _section);
+} // complete
+
+// ----------------------------------------------------------------------
+// Copy field values and metadata.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::copy(const Field& field)
+{ // copy
+ // Check compatibility of sections
+ const int srcSize = (!field._section.isNull()) ? field._section->size() : 0;
+ const int dstSize = (!_section.isNull()) ? _section->size() : 0;
+ if (field.spaceDim() != spaceDim() ||
+ field._vecFieldType != _vecFieldType ||
+ field._scale != _scale ||
+ srcSize != dstSize) {
+ std::ostringstream msg;
+
+ msg << "Cannot copy values from section '" << field._label
+ << "' to section '" << _label << "'. Sections are incompatible.\n"
+ << " Source section:\n"
+ << " space dim: " << field.spaceDim() << "\n"
+ << " vector field type: " << field._vecFieldType << "\n"
+ << " scale: " << field._scale << "\n"
+ << " size: " << srcSize
+ << " Destination section:\n"
+ << " space dim: " << spaceDim() << "\n"
+ << " vector field type: " << _vecFieldType << "\n"
+ << " scale: " << _scale << "\n"
+ << " size: " << dstSize;
+ throw std::runtime_error(msg.str());
+ } // if
+ assert( (_section.isNull() && field._section.isNull()) ||
+ (!_section.isNull() && !field._section.isNull()) );
+
+ if (!_section.isNull()) {
+ // Copy values from field
+ const chart_type& chart = _section->getChart();
+ const typename chart_type::const_iterator chartEnd = chart.end();
+
+ for (typename chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chartEnd;
+ ++c_iter) {
+ assert(field._section->getFiberDimension(*c_iter) ==
+ _section->getFiberDimension(*c_iter));
+ _section->updatePoint(*c_iter, field._section->restrictPoint(*c_iter));
+ } // for
+ } // if
+} // copy
+
+// ----------------------------------------------------------------------
+// Copy field values.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::copy(const ALE::Obj<typename mesh_type::RealSection>& osection)
+{ // copy
+ // Check compatibility of sections
+ const int srcSize = (!osection.isNull()) ? osection->size() : 0;
+ const int dstSize = (!_section.isNull()) ? _section->size() : 0;
+ if (srcSize != dstSize) {
+ std::ostringstream msg;
+
+ msg << "Cannot copy values from Sieve section "
+ << _label << "'. Sections are incompatible.\n"
+ << " Source section:\n"
+ << " size: " << srcSize
+ << " Destination section:\n"
+ << " space dim: " << spaceDim() << "\n"
+ << " vector field type: " << _vecFieldType << "\n"
+ << " scale: " << _scale << "\n"
+ << " size: " << dstSize;
+ throw std::runtime_error(msg.str());
+ } // if
+ assert( (_section.isNull() && osection.isNull()) ||
+ (!_section.isNull() && !osection.isNull()) );
+
+ if (!_section.isNull()) {
+ // Copy values from field
+ const chart_type& chart = _section->getChart();
+ const typename chart_type::const_iterator chartEnd = chart.end();
+
+ for (typename chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chartEnd;
+ ++c_iter) {
+ assert(osection->getFiberDimension(*c_iter) ==
+ _section->getFiberDimension(*c_iter));
+ _section->updatePoint(*c_iter, osection->restrictPoint(*c_iter));
+ } // for
+ } // if
+} // copy
+
+// ----------------------------------------------------------------------
+// Add two fields, storing the result in one of the fields.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::operator+=(const Field& field)
+{ // operator+=
+ // Check compatibility of sections
+ const int srcSize = (!field._section.isNull()) ? field._section->size() : 0;
+ const int dstSize = (!_section.isNull()) ? _section->size() : 0;
+ if (field.spaceDim() != spaceDim() ||
+ field._vecFieldType != _vecFieldType ||
+ field._scale != _scale ||
+ srcSize != dstSize) {
+ std::ostringstream msg;
+
+ msg << "Cannot add values from section '" << field._label
+ << "' to section '" << _label << "'. Sections are incompatible.\n"
+ << " Source section:\n"
+ << " space dim: " << field.spaceDim() << "\n"
+ << " vector field type: " << field._vecFieldType << "\n"
+ << " scale: " << field._scale << "\n"
+ << " size: " << srcSize
+ << " Destination section:\n"
+ << " space dim: " << spaceDim() << "\n"
+ << " vector field type: " << _vecFieldType << "\n"
+ << " scale: " << _scale << "\n"
+ << " size: " << dstSize;
+ throw std::runtime_error(msg.str());
+ } // if
+ assert( (_section.isNull() && field._section.isNull()) ||
+ (!_section.isNull() && !field._section.isNull()) );
+
+ if (!_section.isNull()) {
+ // Add values from field
+ const chart_type& chart = _section->getChart();
+ const typename chart_type::const_iterator chartEnd = chart.end();
+
+ // Assume fiber dimension is uniform
+ const int fiberDim = _section->getFiberDimension(*chart.begin());
+ double_array values(fiberDim);
+
+ for (typename chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chartEnd;
+ ++c_iter) {
+ assert(fiberDim == field._section->getFiberDimension(*c_iter));
+ assert(fiberDim == _section->getFiberDimension(*c_iter));
+ field._section->restrictPoint(*c_iter, &values[0], values.size());
+ _section->updateAddPoint(*c_iter, &values[0]);
+ } // for
+ } // if
+} // operator+=
+
+// ----------------------------------------------------------------------
+// Dimensionalize field.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::dimensionalize(void)
+{ // dimensionalize
+ if (!_dimensionsOkay) {
+ std::ostringstream msg;
+ msg << "Cannot dimensionalize field '" << _label << "' because the flag "
+ << "has been set to keep field nondimensional.";
+ throw std::runtime_error(msg.str());
+ } // if
+
+ if (!_section.isNull()) {
+ const chart_type& chart = _section->getChart();
+ const typename chart_type::const_iterator chartEnd = chart.end();
+
+ // Assume fiber dimension is uniform
+ const int fiberDim = _section->getFiberDimension(*chart.begin());
+ double_array values(fiberDim);
+
+ spatialdata::units::Nondimensional normalizer;
+
+ for (typename chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chartEnd;
+ ++c_iter) {
+ assert(fiberDim == _section->getFiberDimension(*c_iter));
+
+ _section->restrictPoint(*c_iter, &values[0], values.size());
+ normalizer.dimensionalize(&values[0], values.size(), _scale);
+ _section->updatePoint(*c_iter, &values[0]);
+ } // for
+ } // if
+} // dimensionalize
+
+// ----------------------------------------------------------------------
+// Print field to standard out.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::view(const char* label)
+{ // view
+ std::string vecFieldString;
+ switch(_vecFieldType)
+ { // switch
+ case SCALAR:
+ vecFieldString = "scalar";
+ break;
+ case VECTOR:
+ vecFieldString = "vector";
+ break;
+ case TENSOR:
+ vecFieldString = "tensor";
+ break;
+ case OTHER:
+ vecFieldString = "other";
+ break;
+ case MULTI_SCALAR:
+ vecFieldString = "multiple scalars";
+ break;
+ case MULTI_VECTOR:
+ vecFieldString = "multiple vectors";
+ break;
+ case MULTI_TENSOR:
+ vecFieldString = "multiple tensors";
+ break;
+ case MULTI_OTHER:
+ vecFieldString = "multiple other values";
+ break;
+ default :
+ std::cerr << "Unknown vector field value '" << _vecFieldType
+ << "'." << std::endl;
+ assert(0);
+ } // switch
+
+ std::cout << "Viewing field '" << _label << "' "<< label << ".\n"
+ << " vector field type: " << vecFieldString << "\n"
+ << " scale: " << _scale << "\n"
+ << " dimensionalize flag: " << _dimensionsOkay << std::endl;
+ if (!_section.isNull())
+ _section->view(label);
+} // view
+
+// ----------------------------------------------------------------------
+// Create PETSc vector for field.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::createVector(void)
+{ // createVector
+ PetscErrorCode err = 0;
+
+ if (0 != _vector) {
+ err = VecDestroy(_vector); _vector = 0;
+ CHECK_PETSC_ERROR(err);
+ } // if
+
+ const ALE::Obj<typename mesh_type::SieveMesh>& sieveMesh = _mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<typename mesh_type::SieveMesh::order_type>& order =
+ sieveMesh->getFactory()->getGlobalOrder(sieveMesh,
+ _section->getName(), _section);
+ assert(!order.isNull());
+
+ err = VecCreate(_mesh.comm(), &_vector);
+ CHECK_PETSC_ERROR(err);
+
+ err = VecSetSizes(_vector, order->getLocalSize(), order->getGlobalSize());
+ CHECK_PETSC_ERROR(err);
+
+ err = VecSetFromOptions(_vector); CHECK_PETSC_ERROR(err);
+} // createVector
+
+// ----------------------------------------------------------------------
+// Create PETSc vector scatter for field. This is used to transfer
+// information from the "global" PETSc vector view to the "local"
+// Sieve section view.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::createScatter(void)
+{ // createScatter
+ assert(!_section.isNull());
+ assert(!_mesh.sieveMesh().isNull());
+
+ PetscErrorCode err = 0;
+ if (0 != _scatter) {
+ err = VecScatterDestroy(_scatter); _scatter = 0;
+ CHECK_PETSC_ERROR(err);
+ } // if
+
+ err = MeshCreateGlobalScatter(_mesh.sieveMesh(), _section, &_scatter);
+ CHECK_PETSC_ERROR(err);
+} // createScatter
+
+// ----------------------------------------------------------------------
+// Scatter section information across processors to update the
+// PETSc vector view of the field.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::scatterSectionToVector(void) const
+{ // scatterSectionToVector
+ assert(0 != _vector);
+
+ scatterSectionToVector(_vector);
+} // scatterSectionToVector
+
+// ----------------------------------------------------------------------
+// Scatter section information across processors to update the
+// PETSc vector view of the field.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::scatterSectionToVector(const PetscVec vector) const
+{ // scatterSectionToVector
+ assert(!_section.isNull());
+ assert(0 != _scatter);
+ assert(0 != vector);
+
+ PetscErrorCode err = 0;
+ PetscVec localVec = 0;
+ err = VecCreateSeqWithArray(PETSC_COMM_SELF,
+ _section->sizeWithBC(), _section->restrictSpace(),
+ &localVec); CHECK_PETSC_ERROR(err);
+ err = VecScatterBegin(_scatter, localVec, vector,
+ INSERT_VALUES, SCATTER_FORWARD); CHECK_PETSC_ERROR(err);
+ err = VecScatterEnd(_scatter, localVec, vector,
+ INSERT_VALUES, SCATTER_FORWARD); CHECK_PETSC_ERROR(err);
+ err = VecDestroy(localVec); CHECK_PETSC_ERROR(err);
+} // scatterSectionToVector
+
+// ----------------------------------------------------------------------
+// Scatter PETSc vector information across processors to update the
+// section view of the field.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::scatterVectorToSection(void) const
+{ // scatterVectorToSection
+ assert(0 != _vector);
+
+ scatterVectorToSection(_vector);
+} // scatterVectorToSection
+
+// ----------------------------------------------------------------------
+// Scatter PETSc vector information across processors to update the
+// section view of the field.
+template<typename mesh_type>
+void
+pylith::topology::Field<mesh_type>::scatterVectorToSection(const PetscVec vector) const
+{ // scatterVectorToSection
+ assert(!_section.isNull());
+ assert(0 != _scatter);
+ assert(0 != vector);
+
+ PetscErrorCode err = 0;
+ PetscVec localVec = 0;
+ err = VecCreateSeqWithArray(PETSC_COMM_SELF,
+ _section->sizeWithBC(), _section->restrictSpace(),
+ &localVec); CHECK_PETSC_ERROR(err);
+ err = VecScatterBegin(_scatter, vector, localVec,
+ INSERT_VALUES, SCATTER_REVERSE); CHECK_PETSC_ERROR(err);
+ err = VecScatterEnd(_scatter, vector, localVec,
+ INSERT_VALUES, SCATTER_REVERSE); CHECK_PETSC_ERROR(err);
+ err = VecDestroy(localVec); CHECK_PETSC_ERROR(err);
+} // scatterVectorToSection
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/Field.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,200 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/**
- * @file pylith/topology/Field.hh
- *
- * @brief Vector field over the vertices or cells of a finite-element mesh.
- *
- * Extends Sieve real general section by adding metadata.
- */
-
-#if !defined(pylith_topology_field_hh)
-#define pylith_topology_field_hh
-
-// Include directives ---------------------------------------------------
-#define NEWPYLITHMESH 1
-#include "pylith/utils/sievetypes.hh" // HASA PETSc real_section_type
-
-#include <string> // HASA std::string
-
-// Forward declarations -------------------------------------------------
-namespace pylith {
- namespace topology {
- class Field;
- class TestField;
- } // topology
-} // pylith
-
-// Field ----------------------------------------------------------------
-class pylith::topology::Field
-{ // Field
- friend class TestField; // unit testing
-
-// PUBLIC ENUMS /////////////////////////////////////////////////////////
-public :
-
- enum VectorFieldEnum {
- SCALAR=0, ///< Scalar.
- VECTOR=1, ///< Vector.
- TENSOR=2, ///< Tensor.
- OTHER=3, ///< Not a scalar, vector, or tensor.
- MULTI_SCALAR=4, ///< Scalar at multiple points.
- MULTI_VECTOR=5, ///< Vector at multiple points.
- MULTI_TENSOR=6, ///< Tensor at multiple points.
- MULTI_OTHER=7, ///< Not a scalar, vector, or tensor at multiple points.
- }; // VectorFieldEnum
-
-// PUBLIC MEMBERS ///////////////////////////////////////////////////////
-public :
-
- /** Default constructor.
- *
- * @param mesh Sieve mesh.
- */
- Field(const ALE::Obj<SieveMesh>& mesh);
-
- /// Destructor.
- ~Field(void);
-
- /** Get Sieve section.
- *
- * @returns Sieve section.
- */
- const ALE::Obj<SieveRealSection>& section(void) const;
-
- /** Set name of field.
- *
- * @param value Name of field.
- */
- void name(const char* value);
-
- /** Get name of field.
- *
- * @returns Name of field.
- */
- const char* name(void) const;
-
- /** Set vector field type
- *
- * @param value Type of vector field.
- */
- void vectorFieldType(const VectorFieldEnum value);
-
- /** Get vector field type
- *
- * @returns Type of vector field.
- */
- VectorFieldEnum vectorFieldType(void) const;
-
- /** Get spatial dimension of domain.
- *
- * @returns Spatial dimension of domain.
- */
- int spaceDim(void) const;
-
- /** Set scale for dimensionalizing field.
- *
- * @param value Scale associated with field.
- */
- void scale(const double value);
-
- /** Get scale for dimensionalizing field.
- *
- * @returns Scale associated with field.
- */
- double scale(void) const;
-
- /** Set flag indicating whether it is okay to dimensionalize field.
- *
- * @param value True if it is okay to dimensionalize field.
- */
- void addDimensionOkay(const bool value);
-
- /** Set flag indicating whether it is okay to dimensionalize field.
- *
- * @param value True if it is okay to dimensionalize field.
- */
- bool addDimensionOkay(void) const;
-
- /// Create sieve section.
- void newSection(void);
-
- /** Create section with same layout (fiber dimension and
- * constraints) as another section. This allows the layout data
- * structures to be reused across multiple fields, reducing memory
- * usage.
- *
- * @param sec Section defining layout.
- */
- void copyLayout(const Field& src);
-
- /// Clear variables associated with section.
- void clear(void);
-
- /// Zero section values.
- void zero(void);
-
- /// Complete section by assembling across processors.
- void complete(void);
-
- /** Copy field values and metadata.
- *
- * @param field Field to copy.
- */
- void copy(const Field& field);
-
- /** Add two fields, storing the result in one of the fields.
- *
- * @param field Field to add.
- */
- void operator+=(const Field& field);
-
- /** Dimensionalize field. Throws runtime_error if field is not
- * allowed to be dimensionalized.
- */
- void dimensionalize(void);
-
- /** Print field to standard out.
- *
- * @param label Label for output.
- */
- void view(const char* label);
-
-// PROTECTED MEMBERS ////////////////////////////////////////////////////
-protected :
-
- const ALE::Obj<SieveMesh>& _mesh; ///< Mesh associated with section
- ALE::Obj<SieveRealSection> _section; ///< Real section with data
-
-// PRIVATE MEMBERS //////////////////////////////////////////////////////
-private :
-
- double _scale; ///< Dimensional scale associated with field
- std::string _name; ///< Name of field
- VectorFieldEnum _vecFieldType; ///< Type of vector field
- bool _dimensionsOkay; ///< Flag indicating it is okay to dimensionalize
-
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- Field(const Field&); ///< Not implemented
- const Field& operator=(const Field&); ///< Not implemented
-
-}; // Field
-
-#include "Field.icc"
-
-#endif // pylith_topology_field_hh
-
-
-// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/Field.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,284 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/Field.hh
+ *
+ * @brief Vector field over the vertices or cells of a finite-element
+ * mesh.
+ *
+ * Extends Sieve real general section by adding metadata.
+ */
+
+#if !defined(pylith_topology_field_hh)
+#define pylith_topology_field_hh
+
+// Include directives ---------------------------------------------------
+#include "FieldBase.hh" // ISA FieldBase
+
+#include "pylith/utils/petscfwd.h" // HASA PetscVec
+
+#include <petscmesh.hh>
+
+// Field ----------------------------------------------------------------
+template<typename mesh_type>
+class pylith::topology::Field : public FieldBase
+{ // Field
+ friend class TestFieldMesh; // unit testing
+ friend class TestFieldSubMesh; // unit testing
+
+// PUBLIC TYPEDEFS //////////////////////////////////////////////////////
+public:
+
+ // Convenience typedefs
+ typedef mesh_type Mesh;
+
+// PRIVATE TYPEDEFS /////////////////////////////////////////////////////
+private:
+
+ // Convenience typedefs
+ typedef typename mesh_type::RealSection RealSection;
+ typedef typename mesh_type::SieveMesh SieveMesh;
+ typedef typename SieveMesh::label_sequence label_sequence;
+ typedef typename RealSection::chart_type chart_type;
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ Field(const mesh_type& mesh);
+
+ /// Destructor.
+ ~Field(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Get Sieve section.
+ *
+ * @returns Sieve section.
+ */
+ const ALE::Obj<RealSection>& section(void) const;
+
+ /** Get mesh associated with field.
+ *
+ * @returns Finite-element mesh.
+ */
+ const mesh_type& mesh(void) const;
+
+ /** Set label for field.
+ *
+ * @param value Label for field.
+ */
+ void label(const char* value);
+
+ /** Get label for field.
+ *
+ * @returns Label for field.
+ */
+ const char* label(void) const;
+
+ /** Set vector field type
+ *
+ * @param value Type of vector field.
+ */
+ void vectorFieldType(const VectorFieldEnum value);
+
+ /** Get vector field type
+ *
+ * @returns Type of vector field.
+ */
+ VectorFieldEnum vectorFieldType(void) const;
+
+ /** Set scale for dimensionalizing field.
+ *
+ * @param value Scale associated with field.
+ */
+ void scale(const double value);
+
+ /** Get scale for dimensionalizing field.
+ *
+ * @returns Scale associated with field.
+ */
+ double scale(void) const;
+
+ /** Set flag indicating whether it is okay to dimensionalize field.
+ *
+ * @param value True if it is okay to dimensionalize field.
+ */
+ void addDimensionOkay(const bool value);
+
+ /** Set flag indicating whether it is okay to dimensionalize field.
+ *
+ * @param value True if it is okay to dimensionalize field.
+ */
+ bool addDimensionOkay(void) const;
+
+ /** Get spatial dimension of domain.
+ *
+ * @returns Spatial dimension of domain.
+ */
+ int spaceDim(void) const;
+
+ /// Create sieve section.
+ void newSection(void);
+
+ /** Create sieve section and set chart and fiber dimesion.
+ *
+ * @param points Points over which to define section.
+ * @param dim Fiber dimension for section.
+ */
+ void newSection(const ALE::Obj<label_sequence>& points,
+ const int fiberDim);
+
+ /** Create sieve section and set chart and fiber dimesion.
+ *
+ * @param domain Type of points over which to define section.
+ * @param dim Fiber dimension for section.
+ * @param stratum Stratum depth (for vertices) and height (for cells).
+ */
+ void newSection(const DomainEnum domain,
+ const int fiberDim,
+ const int stratum =0);
+
+ /** Create section given chart. This allows a chart to be reused
+ * across multiple fields, reducing memory usage.
+ *
+ * @param chart Chart defining points over which section is defined.
+ * @param fiberDim Fiber dimension.
+ */
+ void newSection(const chart_type& chart,
+ const int fiberDim);
+
+ /** Create section with same layout (fiber dimension and
+ * constraints) as another section. This allows the layout data
+ * structures to be reused across multiple fields, reducing memory
+ * usage.
+ *
+ * @param sec Section defining layout.
+ */
+ void newSection(const Field& src);
+
+ /// Clear variables associated with section.
+ void clear(void);
+
+ /// Allocate field.
+ void allocate(void);
+
+ /// Zero section values.
+ void zero(void);
+
+ /// Complete section by assembling across processors.
+ void complete(void);
+
+ /** Copy field values and metadata.
+ *
+ * @param field Field to copy.
+ */
+ void copy(const Field& field);
+
+ /** Copy field values.
+ *
+ * @param field Field to copy.
+ */
+ void copy(const ALE::Obj<typename mesh_type::RealSection>& field);
+
+ /** Add two fields, storing the result in one of the fields.
+ *
+ * @param field Field to add.
+ */
+ void operator+=(const Field& field);
+
+ /** Dimensionalize field. Throws runtime_error if field is not
+ * allowed to be dimensionalized.
+ */
+ void dimensionalize(void);
+
+ /** Print field to standard out.
+ *
+ * @param label Label for output.
+ */
+ void view(const char* label);
+
+ /// Create PETSc vector for field.
+ void createVector(void);
+
+ /** Get PETSc vector associated with field.
+ *
+ * @returns PETSc vector.
+ */
+ PetscVec vector(void);
+
+ /** Get PETSc vector associated with field.
+ *
+ * @returns PETSc vector.
+ */
+ const PetscVec vector(void) const;
+
+ /// Create PETSc vector scatter for field. This is used to transfer
+ /// information from the "global" PETSc vector view to the "local"
+ /// Sieve section view.
+ void createScatter(void);
+
+ /// Scatter section information across processors to update the
+ /// PETSc vector view of the field.
+ void scatterSectionToVector(void) const;
+
+ /** Scatter section information across processors to update the
+ * PETSc vector view of the field.
+ *
+ * @param vector PETSc vector to update.
+ */
+ void scatterSectionToVector(const PetscVec vector) const;
+
+ /// Scatter PETSc vector information across processors to update the
+ /// Sieve section view of the field.
+ void scatterVectorToSection(void) const;
+
+ /** Scatter section information across processors to update the
+ * PETSc vector view of the field.
+ *
+ * @param vector PETSc vector used in update.
+ */
+ void scatterVectorToSection(const PetscVec vector) const;
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ double _scale; ///< Dimensional scale associated with field.
+ std::string _label; ///< Label for field.
+ const mesh_type& _mesh; ///< Mesh associated with section.
+ ALE::Obj<RealSection> _section; ///< Real section with data.
+ PetscVec _vector; ///< PETSc vector associated with field.
+ PetscVecScatter _scatter; ///< PETSc scatter associated with field.
+ VectorFieldEnum _vecFieldType; ///< Type of vector field.
+ bool _dimensionsOkay; ///< Flag indicating it is okay to dimensionalize.
+
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ Field(const Field&); ///< Not implemented
+ const Field& operator=(const Field&); ///< Not implemented
+
+}; // Field
+
+#include "Field.icc"
+#include "Field.cc"
+
+#endif // pylith_topology_field_hh
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/Field.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,83 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_topology_field_hh)
-#error "Field.icc must be included only from Field.hh"
-#else
-
-// Get Sieve section.
-inline
-const ALE::Obj<pylith::SieveRealSection>&
-pylith::topology::Field::section(void) const {
- return _section;
-}
-
-// Set name of field.
-inline
-void
-pylith::topology::Field::name(const char* value) {
- _name = value;
-}
-
-// Get name of field.
-inline
-const char*
-pylith::topology::Field::name(void) const {
- return _name.c_str();
-}
-
-// Set vector field type
-inline
-void
-pylith::topology::Field::vectorFieldType(const VectorFieldEnum value) {
- _vecFieldType = value;
-}
-
-// Get vector field type
-inline
-pylith::topology::Field::VectorFieldEnum
-pylith::topology::Field::vectorFieldType(void) const {
- return _vecFieldType;
-}
-
-// Set scale for dimensionalizing field.
-inline
-void
-pylith::topology::Field::scale(const double value) {
- _scale = value;
-}
-
-// Get scale for dimensionalizing field.
-inline
-double
-pylith::topology::Field::scale(void) const {
- return _scale;
-}
-
-// Set flag indicating whether it is okay to dimensionalize field.
-inline
-void
-pylith::topology::Field::addDimensionOkay(const bool value) {
- _dimensionsOkay = value;
-}
-
-// Set flag indicating whether it is okay to dimensionalize field.
-inline
-bool
-pylith::topology::Field::addDimensionOkay(void) const {
- return _dimensionsOkay;
-}
-
-#endif
-
-
-// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/Field.icc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/Field.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Field.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/Field.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,117 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_field_hh)
+#error "Field.icc must be included only from Field.hh"
+#else
+
+// Get Sieve section.
+template<typename mesh_type>
+inline
+const ALE::Obj<typename mesh_type::RealSection>&
+pylith::topology::Field<mesh_type>::section(void) const {
+ return _section;
+}
+
+// Get mesh associated with field.
+template<typename mesh_type>
+inline
+const
+mesh_type&
+pylith::topology::Field<mesh_type>::mesh(void) const {
+ return _mesh;
+}
+
+// Set label for field.
+template<typename mesh_type>
+inline
+void
+pylith::topology::Field<mesh_type>::label(const char* value) {
+ _label = value;
+}
+
+// Get label for field.
+template<typename mesh_type>
+inline
+const char*
+pylith::topology::Field<mesh_type>::label(void) const {
+ return _label.c_str();
+}
+
+// Set vector field type
+template<typename mesh_type>
+inline
+void
+pylith::topology::Field<mesh_type>::vectorFieldType(const VectorFieldEnum value) {
+ _vecFieldType = value;
+}
+
+// Get vector field type
+template<typename mesh_type>
+inline
+typename pylith::topology::Field<mesh_type>::VectorFieldEnum
+pylith::topology::Field<mesh_type>::vectorFieldType(void) const {
+ return _vecFieldType;
+}
+
+// Set scale for dimensionalizing field.
+template<typename mesh_type>
+inline
+void
+pylith::topology::Field<mesh_type>::scale(const double value) {
+ _scale = value;
+}
+
+// Get scale for dimensionalizing field.
+template<typename mesh_type>
+inline
+double
+pylith::topology::Field<mesh_type>::scale(void) const {
+ return _scale;
+}
+
+// Set flag indicating whether it is okay to dimensionalize field.
+template<typename mesh_type>
+inline
+void
+pylith::topology::Field<mesh_type>::addDimensionOkay(const bool value) {
+ _dimensionsOkay = value;
+}
+
+// Set flag indicating whether it is okay to dimensionalize field.
+template<typename mesh_type>
+inline
+bool
+pylith::topology::Field<mesh_type>::addDimensionOkay(void) const {
+ return _dimensionsOkay;
+}
+
+// Get PETSc vector associated with field.
+template<typename mesh_type>
+inline
+PetscVec
+pylith::topology::Field<mesh_type>::vector(void) {
+ return _vector;
+}
+
+// Get PETSc vector associated with field.
+template<typename mesh_type>
+inline
+const PetscVec
+pylith::topology::Field<mesh_type>::vector(void) const {
+ return _vector;
+}
+
+#endif
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/FieldBase.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldBase.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldBase.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldBase.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,30 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "FieldBase.hh" // implementation of class methods
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::topology::FieldBase::FieldBase(void)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::topology::FieldBase::~FieldBase(void)
+{ // destructor
+} // destructor
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/FieldBase.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/FieldBase.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldBase.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldBase.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/FieldBase.hh
+ *
+ * @brief Basic information related to a vector field over the
+ * vertices or cells of a finite-element mesh.
+ */
+
+#if !defined(pylith_topology_fieldbase_hh)
+#define pylith_topology_fieldbase_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+// FieldBase ------------------------------------------------------------
+class pylith::topology::FieldBase
+{ // Field
+
+// PUBLIC ENUMS /////////////////////////////////////////////////////////
+public :
+
+ enum VectorFieldEnum {
+ SCALAR=0, ///< Scalar.
+ VECTOR=1, ///< Vector.
+ TENSOR=2, ///< Tensor.
+ OTHER=3, ///< Not a scalar, vector, or tensor.
+ MULTI_SCALAR=4, ///< Scalar at multiple points.
+ MULTI_VECTOR=5, ///< Vector at multiple points.
+ MULTI_TENSOR=6, ///< Tensor at multiple points.
+ MULTI_OTHER=7, ///< Not a scalar, vector, or tensor at multiple points.
+ }; // VectorFieldEnum
+
+ enum DomainEnum {
+ VERTICES_FIELD=0, ///< FieldBase over vertices.
+ CELLS_FIELD=1, ///< FieldBase over cells.
+ }; // DomainEnum
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ FieldBase(void); ///< Default constructor.
+ ~FieldBase(void); ///< Default destructor.
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ FieldBase(const FieldBase&); ///< Not implemented
+ const FieldBase& operator=(const FieldBase&); ///< Not implemented
+
+}; // FieldBase
+
+#endif // pylith_topology_fieldbase_hh
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/FieldOps.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldOps.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldOps.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,45 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <portinfo>
-
-#include "FieldOps.hh" // implementation of class methods
-
-#include <stdexcept> // USES std::runtime_error
-#include <sstream> // USES std::ostringstream
-#include <cassert> // USES assert()
-
-// ----------------------------------------------------------------------
-// Copy values from one section to another.
-void
-pylith::topology::FieldOps::copyValues(const ALE::Obj<real_section_type>& dest,
- const ALE::Obj<real_section_type>& src)
-{ // copyValues
- typedef real_section_type::chart_type chart_type;
-
- assert(!dest.isNull());
- assert(!src.isNull());
-
- const chart_type& chartSrc = src->getChart();
- const chart_type& chartDest = dest->getChart();
- const chart_type::const_iterator chartEnd = chartSrc.end();
- for (chart_type::const_iterator c_iter = chartSrc.begin();
- c_iter != chartEnd;
- ++c_iter) {
- assert(dest->getFiberDimension(*c_iter) ==
- src->getFiberDimension(*c_iter));
- dest->updatePoint(*c_iter, src->restrictPoint(*c_iter));
- } // for
-} // copyValues
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/FieldOps.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldOps.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldOps.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,66 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/**
- * @file pylith/topology/FieldOps.hh
- *
- * @brief Temporary object for doing operations on a PETSc
- * field. Object will be replaced by a PyLith Field object that inherits
- * or templates over the PETSc Field object.
- */
-
-#if !defined(pylith_topology_fieldops_hh)
-#define pylith_topology_fieldops_hh
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc real_section_type
-
-namespace pylith {
- namespace topology {
- class FieldOps;
- class TestFieldOps;
- } // topology
-} // pylith
-
-class pylith::topology::FieldOps
-{ // MeshOps
- friend class TestFieldOps; // unit testing
-
-// PUBLIC MEMBERS ///////////////////////////////////////////////////////
-public :
-
- /** Copy values from one section to another. Sections must be
- * compatible in size and shape.
- *
- * @param dest Section to copy values into.
- * @param src Section to copy values from.
- */
- static
- void copyValues(const ALE::Obj<real_section_type>& dest,
- const ALE::Obj<real_section_type>& src);
-
-
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- /// Not implemented
- FieldOps(const FieldOps&);
-
- /// Not implemented
- const FieldOps& operator=(const FieldOps&);
-
-
-}; // FieldOps
-
-#endif // pylith_topology_fieldops_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/FieldUniform.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldUniform.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldUniform.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,74 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <portinfo>
-
-#include "FieldUniform.hh" // implementation of class methods
-
-#include <stdexcept> // USES std::runtime_error
-#include <sstream> // USES std::ostringstream
-#include <cassert> // USES assert()
-
-// ----------------------------------------------------------------------
-// Default constructor.
-pylith::topology::FieldUniform::FieldUniform(const ALE::Obj<SieveMesh>& mesh,
- const int fiberDim) :
- Field(mesh),
- _fiberDim(fiberDim)
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor.
-pylith::topology::FieldUniform::~FieldUniform(void)
-{ // destructor
-} // destructor
-
-// ----------------------------------------------------------------------
-// Create section given points.
-void
-pylith::topology::FieldUniform::createSection(
- const ALE::Obj<SieveMesh::label_sequence>& points)
-{ // createSection
- if (_section.isNull())
- newSection();
-
- const SieveMesh::point_type pointMin =
- *std::min_element(points->begin(), points->end());
- const SieveMesh::point_type pointMax =
- *std::max_element(points->begin(), points->end());
- _section->setChart(SieveRealSection::chart_type(pointMin, pointMax+1));
- _section->setFiberDimension(points, _fiberDim);
- _mesh->allocate(_section);
-} // createSection
-
-// ----------------------------------------------------------------------
-// Create section given chart.
-void
-pylith::topology::FieldUniform::createSection(
- const SieveRealSection::chart_type& chart)
-{ // createSection
- if (_section.isNull())
- newSection();
-
- _section->setChart(chart);
-
- const SieveRealSection::chart_type::const_iterator chartEnd = chart.end();
- for (SieveRealSection::chart_type::const_iterator c_iter = chart.begin();
- c_iter != chartEnd;
- ++c_iter)
- _section->setFiberDimension(*c_iter, _fiberDim);
- _mesh->allocate(_section);
-} // createSection
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/FieldUniform.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldUniform.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldUniform.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,83 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/**
- * @file pylith/topology/FieldUniform.hh
- *
- * @brief Vector field with uniform fiber dimension (no constraints)
- * over the vertices or cells of a finite-element mesh.
- *
- * Special case of Field with a uniform fiber dimension and no constraints.
- */
-
-#if !defined(pylith_topology_fielduniform_hh)
-#define pylith_topology_fielduniform_hh
-
-// Include directives ---------------------------------------------------
-#include "Field.hh" // ISA Field
-
-// Forward declarations -------------------------------------------------
-namespace pylith {
- namespace topology {
- class FieldUniform;
- class TestFieldUniform;
- } // topology
-} // pylith
-
-// FieldUniform ---------------------------------------------------------
-class pylith::topology::FieldUniform : public Field
-{ // FieldUniform
- friend class TestFieldUniform; // unit testing
-
-// PUBLIC MEMBERS ///////////////////////////////////////////////////////
-public :
-
- /** Default constructor.
- *
- * @param mesh Sieve mesh.
- */
- FieldUniform(const ALE::Obj<SieveMesh>& mesh,
- const int fiberDim);
-
- /// Destructor.
- ~FieldUniform(void);
-
- /** Create section given points.
- *
- * @param points Mesh points over which to define section.
- */
- void createSection(const ALE::Obj<SieveMesh::label_sequence>& points);
-
- /** Create section given chart. This allows a chart to be reused
- * across multiple fields, reducing memory usage.
- *
- * @param chart Chart defining points over which section is defined.
- */
- void createSection(const SieveRealSection::chart_type& chart);
-
-// PRIVATE MEMBERS //////////////////////////////////////////////////////
-private :
-
- const int _fiberDim; ///< Fiber dimension
-
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- FieldUniform(const FieldUniform&); ///< Not implemented
- const FieldUniform& operator=(const FieldUniform&); ///< Not implemented
-
-}; // FieldUniform
-
-#endif // pylith_topology_fielduniform_hh
-
-
-// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/Fields.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Fields.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/Fields.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,131 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/Fields.hh
+ *
+ * @brief Object for managing fields over a finite-element mesh.
+ */
+
+#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 ---------------------------------------------------------------
+template<typename field_type>
+class pylith::topology::Fields
+{ // 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);
+
+ /// Destructor.
+ ~Fields(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field.
+ */
+ void add(const char* name,
+ const char* label);
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field.
+ * @param domain Type of points over which to define field.
+ * @param fiberDim Fiber dimension for field.
+ */
+ void add(const char* name,
+ const char* label,
+ const pylith::topology::FieldBase::DomainEnum domain,
+ const int fiberDim);
+
+ /** Delete field.
+ *
+ * @param name Name of field.
+ */
+ void del(const char* name);
+
+ /** Delete field (without conflict with Python del).
+ *
+ * @param name Name of field.
+ */
+ void delField(const char* name);
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ */
+ const field_type& get(const char* name) const;
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ */
+ field_type& get(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;
+
+// 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
Copied: short/3D/PyLith/trunk/libsrc/topology/Fields.icc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/Fields.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Fields.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/Fields.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,181 @@
+// -*- 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
+
+// ----------------------------------------------------------------------
+// Add field.
+template<typename field_type>
+void
+pylith::topology::Fields<field_type>::add(const char* name,
+ const char* label)
+{ // add
+ typename map_type::iterator iter = _fields.find(name);
+ if (iter != _fields.end()) {
+ 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
+ typename map_type::iterator iter = _fields.find(name);
+ if (iter != _fields.end()) {
+ 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->newSection(*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
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsManager.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,268 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include <portinfo>
-
-#include "FieldsManager.hh" // implementation of class methods
-
-#include <stdexcept> // USES std::runtime_error
-#include <sstream> // USES std::ostringstream
-#include <strings.h> // USES strcasecmp()
-#include <cassert> // USES assert()
-
-// ----------------------------------------------------------------------
-// Constructor
-pylith::topology::FieldsManager::FieldsManager(const ALE::Obj<Mesh>& mesh) :
- _mesh(mesh),
- _solutionName("")
-{ // constructor
-} // constructor
-
-// ----------------------------------------------------------------------
-// Destructor
-pylith::topology::FieldsManager::~FieldsManager(void)
-{ // destructor
-} // destructor
-
-// ----------------------------------------------------------------------
-// Add field.
-void
-pylith::topology::FieldsManager::addReal(const char* name)
-{ // addReal
- assert(!_mesh.isNull());
-
- map_real_type::iterator iter = _real.find(name);
- if (iter != _real.end()) {
- std::ostringstream msg;
- msg << "Could not add field '" << name
- << "', because it already exists.";
- throw std::runtime_error(msg.str());
- } // if
-
- _real[name] = new real_section_type(_mesh->comm(), _mesh->debug());
-} // addReal
-
-// ----------------------------------------------------------------------
-// Get field.
-const ALE::Obj<pylith::real_section_type>&
-pylith::topology::FieldsManager::getReal(const char* name)
-{ // getReal
- map_real_type::const_iterator iter = _real.find(name);
- if (iter == _real.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name << "'.";
- throw std::runtime_error(msg.str());
- } // if
- return iter->second;
-} // getReal
-
-// ----------------------------------------------------------------------
-// Remove field.
-void
-pylith::topology::FieldsManager::delReal(const char* name)
-{ // delReal
- map_real_type::const_iterator iter = _real.find(name);
- if (iter == _real.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name << "' to delete.";
- throw std::runtime_error(msg.str());
- } // if
- _real.erase(name);
-} // delReal
-
-// ----------------------------------------------------------------------
-// Set fiber dimension for field.
-void
-pylith::topology::FieldsManager::setFiberDimension(const char* name,
- const int fiberDim,
- const char* points)
-{ // setFiberDimension
- assert(!_mesh.isNull());
- assert(fiberDim >= 0);
-
- map_real_type::const_iterator iter = _real.find(name);
- if (iter == _real.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name << "' to delete.";
- throw std::runtime_error(msg.str());
- } // if
-
- assert(!_real[name].isNull());
- if (0 == strcasecmp(points, "vertices")) {
- const ALE::Obj<Mesh::label_sequence>& vertices = _mesh->depthStratum(0);
-
- if (vertices->size() > 0) {
- _real[name]->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),vertices->end()),*std::max_element(vertices->begin(),vertices->end())+1));
- } else {
- _real[name]->setChart(real_section_type::chart_type(0,0));
- }
- _real[name]->setFiberDimension(vertices, fiberDim);
- } else if (0 == strcasecmp(points, "cells")) {
- const ALE::Obj<Mesh::label_sequence>& cells = _mesh->heightStratum(0);
-
- if (cells->size() > 0) {
- _real[name]->setChart(real_section_type::chart_type(*std::min_element(cells->begin(),cells->end()),*std::max_element(cells->begin(),cells->end())+1));
- } else {
- _real[name]->setChart(real_section_type::chart_type(0,0));
- }
- _real[name]->setFiberDimension(cells, fiberDim);
- } else {
- std::ostringstream msg;
- msg << "Could not determine parse '" << points
- << "' into a known point type when setting fiber dimension to "
- << fiberDim << " for section '" << name << "'.\n"
- << "Known point types are 'vertices' and 'cells'.";
- throw std::runtime_error(msg.str());
- } // if/else
-} // setFiberDimension
-
-// ----------------------------------------------------------------------
-// Allocate field.
-void
-pylith::topology::FieldsManager::allocate(const char* name)
-{ // allocate
- assert(!_mesh.isNull());
-
- map_real_type::const_iterator iter = _real.find(name);
- if (iter == _real.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name << "' to delete.";
- throw std::runtime_error(msg.str());
- } // if
-
- assert(!_real[name].isNull());
- _mesh->allocate(_real[name]);
-} // allocate
-
-// ----------------------------------------------------------------------
-// Copy layout of field to all other fields.
-void
-pylith::topology::FieldsManager::copyLayout(const char* name)
-{ // copyLayout
- assert(!_mesh.isNull());
-
- map_real_type::const_iterator src = _real.find(name);
- if (src == _real.end()) {
- std::ostringstream msg;
- msg << "Could not find field '" << name << "'.";
- throw std::runtime_error(msg.str());
- } // if
-
- assert(!src->second.isNull());
- const map_real_type::iterator begin = _real.begin();
- const map_real_type::iterator end = _real.end();
- for (map_real_type::iterator iter=begin; iter != end; ++iter)
- if (iter != src) {
- // Make sure fields are same size
- assert(!iter->second.isNull());
- iter->second->setAtlas(src->second->getAtlas());
- iter->second->allocateStorage();
- iter->second->setBC(src->second->getBC());
- } // if
-} // copyLayout
-
-// ----------------------------------------------------------------------
-// Copy layout of field to managed fields.
-void
-pylith::topology::FieldsManager::copyLayout(
- const ALE::Obj<real_section_type>& field)
-{ // copyLayout
- assert(!_mesh.isNull());
- assert(!field.isNull());
-
- const map_real_type::iterator begin = _real.begin();
- const map_real_type::iterator end = _real.end();
- for (map_real_type::iterator iter=begin; iter != end; ++iter) {
- // Make sure fields are same size
- assert(!iter->second.isNull());
- iter->second->setAtlas(field->getAtlas());
- iter->second->allocateStorage();
- iter->second->setBC(field->getBC());
- } // for
-} // copyLayout
-
-// ----------------------------------------------------------------------
-// Set name of solution field.
-void
-pylith::topology::FieldsManager::solutionField(const char* name)
-{ // solutionField
- map_real_type::const_iterator iter = _real.find(name);
- if (iter == _real.end()) {
- std::ostringstream msg;
- msg << "Cannot use unknown field '" << name
- << "' when setting name of solution field.";
- throw std::runtime_error(msg.str());
- } // if
- _solutionName = name;
-} // solutionField
-
-// ----------------------------------------------------------------------
-// Get solution field.
-const ALE::Obj<pylith::real_section_type>&
-pylith::topology::FieldsManager::getSolution(void)
-{ // getSolution
- if (_solutionName == "")
- throw std::runtime_error("Cannot retrieve solution. Name of solution " \
- "field has not been specified.");
- return getReal(_solutionName.c_str());
-} // getSolution
-
-// ----------------------------------------------------------------------
-// Create history manager for a subset of the managed fields.
-void
-pylith::topology::FieldsManager::createHistory(const char** fields,
- const int size)
-{ // createHistory
- if (size > 0 && 0 != fields) {
- _history.resize(size);
- for (int i=0; i < size; ++i) {
- map_real_type::const_iterator iter = _real.find(fields[i]);
- if (iter == _real.end()) {
- std::ostringstream msg;
- msg << "Cannot use unknown field '" << fields[i]
- << "' when creating history.";
- throw std::runtime_error(msg.str());
- } // if
- _history[i] = fields[i];
- } // for
- } // if
-} // createHistory
-
-// ----------------------------------------------------------------------
-// Shift fields in history. Handles to fields are shifted so that the
-// most recent values become associated with the second most recent
-// item in the history, etc.
-void
-pylith::topology::FieldsManager::shiftHistory(void)
-{ // shiftHistory
-
- assert(_history.size() > 0);
- const int size = _history.size();
- ALE::Obj<real_section_type> tmp = _real[_history[size-1]];
- tmp.addRef();
- for (int i=size-1; i > 0; --i)
- _real[_history[i]] = _real[_history[i-1]];
- _real[_history[0]] = tmp;
-
-} // shiftHistory
-
-// ----------------------------------------------------------------------
-// Get field in history by position.
-const ALE::Obj<pylith::real_section_type>&
-pylith::topology::FieldsManager::getFieldByHistory(const int index)
-{ // getFieldByHistory
- assert(index < _history.size());
- return getReal(_history[index].c_str());
-} // getFieldByHistory
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/FieldsManager.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,163 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/**
- * @file pylith/topology/FieldsManager.hh
- *
- * @brief Object for managing fields associated with the fields
- * defined over a finite-element mesh.
- */
-
-#if !defined(pylith_topology_fieldsmanager_hh)
-#define pylith_topology_fieldsmanager_hh
-
-#include <map> // HASA std::map
-#include <string> // USES std::string
-#include <vector> // USES std::vector
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-namespace pylith {
- namespace topology {
- class FieldsManager;
- class TestFieldsManager;
- } // topology
-} // pylith
-
-class pylith::topology::FieldsManager
-{ // FieldsManager
- friend class TestFieldsManager; // unit testing
-
-// PUBLIC MEMBERS ///////////////////////////////////////////////////////
-public :
-
- /// Constructor
- FieldsManager(const ALE::Obj<Mesh>& mesh);
-
- /// Destructor
- ~FieldsManager(void);
-
- /** Add field.
- *
- * @param name Name of field.
- */
- void addReal(const char* name);
-
- /** Get field.
- *
- * @param name Name of field.
- */
- const ALE::Obj<real_section_type>& getReal(const char* name);
-
- /** Remove field.
- *
- * @param name Name of field.
- */
- void delReal(const char* name);
-
- /** Set fiber dimension for field.
- *
- * @param name Name of field.
- * @param fiberDim Fiber dimension
- * @param points Name of set of points in mesh over which section is defined
- * { "vertices", "cells" }
- */
- void setFiberDimension(const char* name,
- const int fiberDim,
- const char* points);
-
- /** Allocate field.
- *
- * @param name Name of field.
- */
- void allocate(const char* name);
-
- /** Copy layout of field to all other fields.
- *
- * @param name Name of field.
- */
- void copyLayout(const char* name);
-
- /** Copy layout of field to managed fields.
- *
- * @param field Field from which to copy layout.
- */
- void copyLayout(const ALE::Obj<real_section_type>& field);
-
- /** Set name of solution field.
- *
- * @param name Name of field that is the solution.
- */
- void solutionField(const char* name);
-
- /** Get solution field.
- *
- * @returns Solution field.
- */
- const ALE::Obj<real_section_type>& getSolution(void);
-
- /** Create history manager for a subset of the managed fields.
- *
- * @param fields Fields in history (first is most recent).
- * @param size Number of fields in history.
- */
- void createHistory(const char** fields,
- const int size);
-
- /** Shift fields in history. Handles to fields are shifted so that
- * the most recent values become associated with the second most
- * recent item in the history, etc.
- */
- void shiftHistory(void);
-
- /** Get field in history by position.
- *
- * @param index Index in history [0=most recent, 1=previous, etc]
- * @returns Field in history.
- */
- const ALE::Obj<real_section_type>& getFieldByHistory(const int index);
-
-// NOT IMPLEMENTED //////////////////////////////////////////////////////
-private :
-
- /// Not implemented
- FieldsManager(const FieldsManager&);
-
- /// Not implemented
- const FieldsManager& operator=(const FieldsManager&);
-
-// PRIVATE TYPEDEFS /////////////////////////////////////////////////////
-private :
-
- typedef std::map< std::string, ALE::Obj<real_section_type> > map_real_type;
-
-// PRIVATE MEMBERS //////////////////////////////////////////////////////
-private :
-
- /// PETSc mesh associated with fields
- const ALE::Obj<Mesh>& _mesh;
-
- /// Map for fieldss stored as real fields
- map_real_type _real;
-
- /// Name of field that corresponds to the solution.
- std::string _solutionName;
-
- /// History manager for a subset of the fields
- std::vector<std::string> _history;
-
-}; // FieldsManager
-
-#endif // pylith_topology_fieldsmanager_hh
-
-
-// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/Jacobian.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "Jacobian.hh" // implementation of class methods
+
+#include "Mesh.hh" // USES Mesh
+#include "SolutionFields.hh" // USES SolutionFields
+#include "Field.hh" // USES Field
+
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::topology::Jacobian::Jacobian(const SolutionFields& fields) :
+ _fields(fields),
+ _matrix(0)
+{ // constructor
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = fields.mesh().sieveMesh();
+ const ALE::Obj<Mesh::RealSection>& solnSection = fields.solution().section();
+
+ PetscErrorCode err = MeshCreateMatrix(sieveMesh, solnSection,
+ MATAIJ, &_matrix);
+ CHECK_PETSC_ERROR_MSG(err, "Could not create PETSc sparse matrix "
+ "associated with system Jacobian.");
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::topology::Jacobian::~Jacobian(void)
+{ // destructor
+ deallocate();
+} // destructor
+
+// ----------------------------------------------------------------------
+// Deallocate PETSc and local data structures.
+void
+pylith::topology::Jacobian::deallocate(void)
+{ // deallocate
+ if (0 != _matrix) {
+ PetscErrorCode err = MatDestroy(_matrix); _matrix = 0;
+ CHECK_PETSC_ERROR(err);
+ } // if
+} // deallocate
+
+// ----------------------------------------------------------------------
+// Get PETSc matrix.
+const PetscMat
+pylith::topology::Jacobian::matrix(void) const
+{ // matrix
+ return _matrix;
+} // matrix
+
+// ----------------------------------------------------------------------
+// Get PETSc matrix.
+PetscMat
+pylith::topology::Jacobian::matrix(void)
+{ // matrix
+ return _matrix;
+} // matrix
+
+// ----------------------------------------------------------------------
+// Assemble matrix.
+void
+pylith::topology::Jacobian::assemble(const char* mode)
+{ // assemble
+ PetscErrorCode err = 0;
+ if (0 == strcmp(mode, "final_assembly")) {
+ err = MatAssemblyBegin(_matrix, MAT_FINAL_ASSEMBLY);
+ CHECK_PETSC_ERROR(err);
+ err = MatAssemblyEnd(_matrix, MAT_FINAL_ASSEMBLY);
+ CHECK_PETSC_ERROR(err);
+ } else if (0 == strcmp(mode, "flush_assembly")) {
+ err = MatAssemblyBegin(_matrix, MAT_FLUSH_ASSEMBLY);
+ CHECK_PETSC_ERROR(err);
+ err = MatAssemblyEnd(_matrix, MAT_FLUSH_ASSEMBLY);
+ CHECK_PETSC_ERROR(err);
+ } else
+ throw std::runtime_error("Unknown mode for assembly of sparse matrix "
+ "associated with system Jacobian.");
+} // assemble
+
+// ----------------------------------------------------------------------
+// Set entries in matrix to zero (retain structure).
+void
+pylith::topology::Jacobian::zero(void)
+{ // zero
+ PetscErrorCode err = MatZeroEntries(_matrix);
+ CHECK_PETSC_ERROR(err);
+} // zero
+
+// ----------------------------------------------------------------------
+// View matrix to stdout.
+void
+pylith::topology::Jacobian::view(void)
+{ // view
+ PetscErrorCode err = MatView(_matrix, PETSC_VIEWER_STDOUT_WORLD);
+ CHECK_PETSC_ERROR(err);
+} // view
+
+// ----------------------------------------------------------------------
+// Write matrix to binary file.
+void
+pylith::topology::Jacobian::write(const char* filename)
+{ // write
+ PetscViewer viewer;
+
+ const MPI_Comm comm = _fields.mesh().comm();
+
+ PetscErrorCode err =
+ PetscViewerBinaryOpen(comm, filename, FILE_MODE_WRITE, &viewer);
+ CHECK_PETSC_ERROR(err);
+
+ err = MatView(_matrix, viewer); CHECK_PETSC_ERROR(err);
+ err = PetscViewerDestroy(viewer); CHECK_PETSC_ERROR(err);
+} // write
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/Jacobian.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/Jacobian.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/Jacobian.hh
+ *
+ * @brief Jacobian of the system as a PETSc sparse matrix.
+ */
+
+#if !defined(pylith_topology_jacobian_hh)
+#define pylith_topology_jacobian_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include "pylith/utils/petscfwd.h" // HOLDSA PetscMat
+
+// Jacobian -------------------------------------------------------------
+class pylith::topology::Jacobian
+{ // Jacobian
+ friend class TestJacobian; // unit testing
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param fields Fields associated with mesh and solution of the problem.
+ */
+ Jacobian(const SolutionFields& fields);
+
+ /// Destructor.
+ ~Jacobian(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Get PETSc matrix.
+ *
+ * @returns PETSc sparse matrix.
+ */
+ const PetscMat matrix(void) const;
+
+ /** Get PETSc matrix.
+ *
+ * @returns PETSc sparse matrix.
+ */
+ PetscMat matrix(void);
+
+ /** Assemble matrix.
+ *
+ * @param mode Assembly mode.
+ */
+ void assemble(const char* mode);
+
+ /// Set entries in matrix to zero (retain structure).
+ void zero(void);
+
+ /// View matrix to stdout.
+ void view(void);
+
+ /** Write matrix to binary file.
+ *
+ * @param filename Name of file.
+ */
+ void write(const char* filename);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ const SolutionFields& _fields; ///< Solution fields associated with problem.
+ PetscMat _matrix; ///< Sparse matrix for Jacobian of problem.
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ Jacobian(const Jacobian&); ///< Not implemented
+ const Jacobian& operator=(const Jacobian&); ///< Not implemented
+
+}; // Jacobian
+
+#endif // pylith_topology_jacobian_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,16 +15,23 @@
subpkginclude_HEADERS = \
Distributor.hh \
+ FieldBase.hh \
Field.hh \
Field.icc \
- FieldUniform.hh \
- FieldsManager.hh \
- FieldOps.hh \
+ Field.cc \
+ Fields.hh \
+ Fields.icc \
+ Jacobian.hh \
Mesh.hh \
Mesh.icc \
MeshOps.hh \
MeshRefiner.hh \
- RefineUniform.hh
+ RefineUniform.hh \
+ SolutionFields.hh \
+ SubMesh.hh \
+ SubMesh.icc \
+ SubMesh.cc \
+ topologyfwd.hh
noinst_HEADERS =
Modified: short/3D/PyLith/trunk/libsrc/topology/Mesh.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Mesh.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Mesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,11 +18,24 @@
// ----------------------------------------------------------------------
// Default constructor
-pylith::topology::Mesh::Mesh(const MPI_Comm& comm,
- const int dim) :
+pylith::topology::Mesh::Mesh(void) :
+ _coordsys(0),
+ _comm(PETSC_COMM_WORLD),
+ _debug(false)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default constructor
+pylith::topology::Mesh::Mesh(const int dim,
+ const MPI_Comm& comm) :
_mesh(new SieveMesh(comm, dim)),
- _coordsys(0)
+ _coordsys(0),
+ _comm(comm),
+ _debug(false)
{ // constructor
+ assert(!_mesh->getFactory().isNull());
+ _mesh->getFactory()->clear();
} // constructor
// ----------------------------------------------------------------------
@@ -33,11 +46,25 @@
} // destructor
// ----------------------------------------------------------------------
+// Create Sieve mesh.
+void
+pylith::topology::Mesh::createSieveMesh(const int dim)
+{ // createSieveMesh
+ _mesh.destroy();
+ _mesh = new SieveMesh(_comm, dim);
+ _mesh->setDebug(_debug);
+ assert(!_mesh->getFactory().isNull());
+ _mesh->getFactory()->clear();
+} // createSieveMesh
+
+// ----------------------------------------------------------------------
// Set coordinate system.
void
pylith::topology::Mesh::coordsys(const spatialdata::geocoords::CoordSys* cs)
{ // coordsys
delete _coordsys; _coordsys = (0 != cs) ? cs->clone() : 0;
+ if (0 != _coordsys)
+ _coordsys->initialize();
} // coordsys
// ----------------------------------------------------------------------
@@ -45,8 +72,6 @@
void
pylith::topology::Mesh::initialize(void)
{ // initialize
- if (0 != _coordsys)
- _coordsys->initialize();
} // initialize
Modified: short/3D/PyLith/trunk/libsrc/topology/Mesh.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Mesh.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Mesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,9 +11,9 @@
//
/**
- * @file pylith/topology/Mesh.hh
+ * @file libsrc/topology/Mesh.hh
*
- * @brief PyLith finite-element mesh.
+ * @brief C++ PyLith finite-element mesh.
*
* Extends Sieve mesh to include coordinate system associated with
* domain.
@@ -23,40 +23,60 @@
#define pylith_topology_mesh_hh
// Include directives ---------------------------------------------------
-#define NEWPYLITHMESH 1
-#include "pylith/utils/sievetypes.hh"
+#include "topologyfwd.hh" // forward declarations
+#include "spatialdata/geocoords/geocoordsfwd.hh" // forward declarations
-// Forward declarations -------------------------------------------------
-namespace pylith {
- namespace topology {
- class Mesh;
- } // topology
-} // pylith
+#include <petscmesh.hh> // HASA ALE::IMesh
-namespace spatialdata {
- namespace geocoords {
- class CoordSys;
- } // geocoords
-} // spatialdata
-
// Mesh -----------------------------------------------------------------
class pylith::topology::Mesh
{ // Mesh
+ friend class TestMesh; // unit testing
+// PUBLIC TYPEDEFS //////////////////////////////////////////////////////
+public :
+
+ // Typedefs for basic types associated with Sieve mesh.
+ // All other PyLith mesh and submesh objects should define:
+ // (1) SieveMesh - Sieve mesh
+ // (2) RealSection - Section of doubles
+ // (3) IntSection - Section of ints
+ // because these are used in templated code.
+ //
+ // All other mesh objects for the domain should also define
+ // (1) SieveSubMesh - SubMesh object
+ typedef ALE::IMesh<> SieveMesh;
+ typedef SieveMesh::real_section_type RealSection;
+ typedef SieveMesh::int_section_type IntSection;
+ typedef ALE::IMesh<ALE::LabelSifter<int, SieveMesh::point_type> > SieveSubMesh;
+ typedef ALE::ISieveVisitor::RestrictVisitor<RealSection> RestrictVisitor;
+ typedef ALE::ISieveVisitor::UpdateAddVisitor<RealSection> UpdateAddVisitor;
+ typedef ALE::ISieveVisitor::IndicesVisitor<RealSection,SieveMesh::order_type,PetscInt> IndicesVisitor;
+
+
// PUBLIC METHODS ///////////////////////////////////////////////////////
public :
- /** Default constructor.
+ /// Default constructor.
+ Mesh(void);
+
+ /** Constructor with dimension and communicator.
*
+ * @param dim Dimension associated with mesh cells.
* @param comm MPI communicator for mesh.
- * @param dim Dimension associated with mesh cells.
*/
- Mesh(const MPI_Comm& comm =PETSC_COMM_WORLD,
- const int dim =3);
+ Mesh(const int dim,
+ const MPI_Comm& comm =PETSC_COMM_WORLD);
/// Default destructor
~Mesh(void);
+ /** Create Sieve mesh.
+ *
+ * @param dim Dimension associated with mesh cells.
+ */
+ void createSieveMesh(const int dim=3);
+
/** Get Sieve mesh.
*
* @returns Sieve mesh.
@@ -81,15 +101,53 @@
*/
const spatialdata::geocoords::CoordSys* coordsys(void) const;
+ /** Set debug flag.
+ *
+ * @param value Turn on debugging if true.
+ */
+ void debug(const bool value);
+
+ /** Get debug flag.
+ *
+ * @param Get debugging flag.
+ */
+ bool debug(void) const;
+
+ /** Get dimension of mesh.
+ *
+ * @returns Dimension of mesh.
+ */
+ int dimension(void) const;
+
+ /** Set MPI communicator associated with mesh.
+ *
+ * @param value MPI communicator.
+ */
+ void comm(const MPI_Comm value);
+
+ /** Get MPI communicator associated with mesh.
+ *
+ * @returns MPI communicator.
+ */
+ const MPI_Comm comm(void) const;
+
/// Initialize the finite-element mesh.
void initialize(void);
+ /** Print mesh to stdout.
+ *
+ * @param label Label for mesh.
+ */
+ void view(const char* label);
+
// PRIVATE MEMBERS //////////////////////////////////////////////////////
private :
- ALE::Obj<SieveMesh> _mesh; ///< Sieve mesh
- spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system
-
+ ALE::Obj<SieveMesh> _mesh; ///< Sieve mesh.
+ spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system.
+ MPI_Comm _comm; ///< MPI communicator for mesh.
+ bool _debug; ///< Debugging flag for mesh.
+
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
Modified: short/3D/PyLith/trunk/libsrc/topology/Mesh.icc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/Mesh.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/Mesh.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,14 +16,14 @@
// Get Sieve mesh.
inline
-const ALE::Obj<pylith::SieveMesh>&
+const ALE::Obj<pylith::topology::Mesh::SieveMesh>&
pylith::topology::Mesh::sieveMesh(void) const {
return _mesh;
}
// Get Sieve mesh.
inline
-ALE::Obj<pylith::SieveMesh>&
+ALE::Obj<pylith::topology::Mesh::SieveMesh>&
pylith::topology::Mesh::sieveMesh(void) {
return _mesh;
}
@@ -35,7 +35,51 @@
return _coordsys;
}
+// Set debug flag.
+inline
+void
+pylith::topology::Mesh::debug(const bool value) {
+ _debug = value;
+ if (!_mesh.isNull())
+ _mesh->setDebug(value);
+}
+// Get debug flag.
+inline
+bool
+pylith::topology::Mesh::debug(void) const {
+ return _debug;
+}
+
+// Get dimension of mesh.
+inline
+int
+pylith::topology::Mesh::dimension(void) const {
+ return (!_mesh.isNull()) ? _mesh->getDimension() : 0;
+}
+
+// Set MPI communicator associated with mesh.
+inline
+void
+pylith::topology::Mesh::comm(const MPI_Comm value) {
+ _comm = value;
+}
+
+// Get MPI communicator associated with mesh.
+inline
+const MPI_Comm
+pylith::topology::Mesh::comm(void) const {
+ return _comm;
+}
+
+// Print mesh to stdout.
+inline
+void
+pylith::topology::Mesh::view(const char* label) {
+ _mesh->view(label);
+}
+
+
#endif
Modified: short/3D/PyLith/trunk/libsrc/topology/MeshOps.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/MeshOps.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/MeshOps.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,7 @@
#include "MeshOps.hh" // implementation of class methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/utils/array.hh" // USES int_array
#include <stdexcept> // USES std::runtime_error
@@ -26,10 +27,12 @@
// ----------------------------------------------------------------------
void
-pylith::topology::MeshOps::checkMaterialIds(const ALE::Obj<Mesh>& mesh,
- int* materialIds,
+pylith::topology::MeshOps::checkMaterialIds(const Mesh& mesh,
+ int* const materialIds,
const int numMaterials)
{ // checkMaterialIds
+ typedef Mesh::SieveMesh SieveMesh;
+
assert( (0 == numMaterials && 0 == materialIds) ||
(0 < numMaterials && 0 != materialIds) );
@@ -41,19 +44,22 @@
int_array matCellCounts(numMaterials);
matCellCounts = 0;
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
assert(!cells.isNull());
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
- const ALE::Obj<Mesh::label_type>& materialsLabel = mesh->getLabel("material-id");
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ const ALE::Obj<SieveMesh::label_type>& materialsLabel =
+ sieveMesh->getLabel("material-id");
int* matBegin = materialIds;
int* matEnd = materialIds + numMaterials;
std::sort(matBegin, matEnd);
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter) {
- const int cellId = mesh->getValue(materialsLabel, *c_iter);
+ const int cellId = sieveMesh->getValue(materialsLabel, *c_iter);
const int* result = std::find(matBegin, matEnd, cellId);
if (result == matEnd) {
std::ostringstream msg;
@@ -70,7 +76,7 @@
// Make sure each material has
int_array matCellCountsAll(matCellCounts.size());
MPI_Allreduce(&matCellCounts[0], &matCellCountsAll[0],
- matCellCounts.size(), MPI_INT, MPI_SUM, mesh->comm());
+ matCellCounts.size(), MPI_INT, MPI_SUM, mesh.comm());
for (int i=0; i < numMaterials; ++i) {
const int matId = materialIds[i];
const int matIndex = materialIndex[matId];
Modified: short/3D/PyLith/trunk/libsrc/topology/MeshOps.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/MeshOps.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/topology/MeshOps.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,23 +13,16 @@
/**
* @file pylith/topology/MeshOps.hh
*
- * @brief Temporary object for doing operations on a PETSc
- * mesh. Object will be replaced by a PyLith Mesh object that inherits
- * or templates over the PETSc mesh object.
+ * @brief Simple operations on a Mesh object.
*/
#if !defined(pylith_topology_meshops_hh)
#define pylith_topology_meshops_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
-namespace pylith {
- namespace topology {
- class MeshOps;
- class TestMeshOps;
- } // topology
-} // pylith
-
+// MeshOps --------------------------------------------------------------
class pylith::topology::MeshOps
{ // MeshOps
friend class TestMeshOps; // unit testing
@@ -40,26 +33,25 @@
/** Check to make sure material id of every cell matches the id of
* one of the materials.
*
- * @param mesh PETSc mesh.
- * @param materialIds Array of ids for all materials and cohesive cell interfaces.
+ * @param mesh Finite-element mesh.
+ * @param materialIds Array of ids for all materials and cohesive
+ * cell interfaces.
* @param numMaterials Size of array.
*/
static
- void checkMaterialIds(const ALE::Obj<Mesh>& mesh,
- int* materialIds,
+ void checkMaterialIds(const Mesh& mesh,
+ int* const materialIds,
const int numMaterials);
// NOT IMPLEMENTED //////////////////////////////////////////////////////
private :
- /// Not implemented
- MeshOps(const MeshOps&);
+ MeshOps(void); ///< Not Implemented
+ MeshOps(const MeshOps&); ///< Not implemented
+ const MeshOps& operator=(const MeshOps&); ///< Not implemented
- /// Not implemented
- const MeshOps& operator=(const MeshOps&);
-
}; // MeshOps
#endif // pylith_topology_meshops_hh
Copied: short/3D/PyLith/trunk/libsrc/topology/SolutionFields.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/SolutionFields.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/SolutionFields.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,143 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "SolutionFields.hh" // implementation of class methods
+
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
+// ----------------------------------------------------------------------
+// Default constructor.
+pylith::topology::SolutionFields::SolutionFields(const Mesh& mesh) :
+ Fields<Field<Mesh> >(mesh),
+ _solutionName(""),
+ _solveSolnName("")
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Destructor.
+pylith::topology::SolutionFields::~SolutionFields(void)
+{ // destructor
+} // destructor
+
+// ----------------------------------------------------------------------
+// Set name of solution field.
+void
+pylith::topology::SolutionFields::solutionName(const char* name)
+{ // solutionName
+ map_type::const_iterator iter = _fields.find(name);
+ if (iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Cannot use unknown field '" << name
+ << "' when setting name of solution field.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _solutionName = name;
+} // solutionName
+
+// ----------------------------------------------------------------------
+// Get solution field.
+const pylith::topology::Field<pylith::topology::Mesh>&
+pylith::topology::SolutionFields::solution(void) const
+{ // solution
+ if (_solutionName == "")
+ throw std::runtime_error("Cannot retrieve solution. Name of solution " \
+ "field has not been specified.");
+ return get(_solutionName.c_str());
+} // solution
+
+// ----------------------------------------------------------------------
+// Get solution field.
+pylith::topology::Field<pylith::topology::Mesh>&
+pylith::topology::SolutionFields::solution(void)
+{ // solution
+ if (_solutionName == "")
+ throw std::runtime_error("Cannot retrieve solution. Name of solution " \
+ "field has not been specified.");
+ return get(_solutionName.c_str());
+} // solution
+
+// ----------------------------------------------------------------------
+// Set field used in the solve.
+void
+pylith::topology::SolutionFields::solveSolnName(const char* name)
+{ // solveSolnName
+ map_type::const_iterator iter = _fields.find(name);
+ if (iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Cannot use unknown field '" << name
+ << "' when setting name of field used in solve.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _solveSolnName = name;
+} // solveSolnName
+
+// ----------------------------------------------------------------------
+// Get solveSoln field.
+const pylith::topology::Field<pylith::topology::Mesh>&
+pylith::topology::SolutionFields::solveSoln(void) const
+{ // solveSoln
+ if (_solveSolnName == "")
+ throw std::runtime_error("Cannot retrieve solve field. Name of solve "
+ "field has not been specified.");
+ return get(_solveSolnName.c_str());
+} // solveSoln
+
+// ----------------------------------------------------------------------
+// Get solveSoln field.
+pylith::topology::Field<pylith::topology::Mesh>&
+pylith::topology::SolutionFields::solveSoln(void)
+{ // solveSoln
+ if (_solveSolnName == "")
+ throw std::runtime_error("Cannot retrieve solve field. Name of solve "
+ "field has not been specified.");
+ return get(_solveSolnName.c_str());
+} // solveSoln
+
+// ----------------------------------------------------------------------
+// Create history manager for a subset of the managed fields.
+void
+pylith::topology::SolutionFields::createHistory(const char* const* fields,
+ const int size)
+{ // createHistory
+ if (size > 0 && 0 != fields) {
+ _history.resize(size);
+ for (int i=0; i < size; ++i) {
+ map_type::const_iterator iter = _fields.find(fields[i]);
+ if (iter == _fields.end()) {
+ std::ostringstream msg;
+ msg << "Cannot use unknown field '" << fields[i]
+ << "' when creating history.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _history[i] = fields[i];
+ } // for
+ } // if
+} // createHistory
+
+// ----------------------------------------------------------------------
+// Shift fields in history.
+void
+pylith::topology::SolutionFields::shiftHistory(void)
+{ // shiftHistory
+ assert(_history.size() > 0);
+ const int size = _history.size();
+ Field<Mesh>* tmp = _fields[_history[size-1]];
+ for (int i=size-1; i > 0; --i)
+ _fields[_history[i]] = _fields[_history[i-1]];
+ _fields[_history[0]] = tmp;
+} // shiftHistory
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/SolutionFields.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/SolutionFields.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/SolutionFields.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/SolutionFields.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,127 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/SolutionFields.hh
+ *
+ * @brief Object for managing solution fields over a finite-element
+ * mesh.
+ */
+
+#if !defined(pylith_topology_solutionfields_hh)
+#define pylith_topology_solutionfields_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+
+#include <vector> // HASA std::vector
+
+#include "Mesh.hh" // ISA Field<Mesh>
+#include "Field.hh" // ISA Fields< Field<Mesh> >
+#include "Fields.hh" // ISA Fields< Field<Mesh> >
+
+// SolutionFields -------------------------------------------------------
+class pylith::topology::SolutionFields : public Fields<Field<Mesh> >
+{ // SolutionFields
+ friend class TestSolutionFields; // unit testing
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ SolutionFields(const Mesh& mesh);
+
+ /// Destructor.
+ ~SolutionFields(void);
+
+ /** Set name of field for the current solution.
+ *
+ * @param name Name of field that holds the solution.
+ */
+ void solutionName(const char* name);
+
+ /** Get current solution field.
+ *
+ * @returns Solution field.
+ */
+ const Field<Mesh>& solution(void) const;
+
+ /** Get current solution field.
+ *
+ * @returns Solution field.
+ */
+ Field<Mesh>& solution(void);
+
+ /** Set name of field that will be used in the solve.
+ *
+ * @param name Name of field used in the solve.
+ */
+ void solveSolnName(const char* name);
+
+ /** Get field used in the solve.
+ *
+ * @returns Field used in the solve.
+ */
+ const Field<Mesh>& solveSoln(void) const;
+
+ /** Get field used in the solve.
+ *
+ * @returns Field used in the solve.
+ */
+ Field<Mesh>& solveSoln(void);
+
+ /** Create history manager for a subset of the managed fields.
+ *
+ * @param fields Fields in history (first is most recent).
+ * @param size Number of fields in history.
+ */
+ void createHistory(const char* const* fields,
+ const int size);
+
+ /** Shift fields in history. Handles to fields are shifted so that
+ * the most recent values become associated with the second most
+ * recent item in the history, etc.
+ */
+ void shiftHistory(void);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ PetscVecScatter _scatter; /// Petsc vector scatter.
+
+ /// Name of field that corresponds to the "working" solution to the
+ /// problem.
+ std::string _solutionName;
+
+ /// Name of field used in the solve (solution of the solve). This
+ /// may be an increment that is applied to the "working" solutio to
+ /// form the complete solution.
+ std::string _solveSolnName;
+
+ /// History manager for a subset of the fields
+ std::vector<std::string> _history;
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ SolutionFields(const SolutionFields&); ///< Not implemented
+ const SolutionFields& operator=(const SolutionFields&); ///< Not implemented
+
+}; // SolutionFields
+
+#endif // pylith_topology_solutionfields_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/SubMesh.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/SubMesh.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/SubMesh.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/SubMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,137 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include <portinfo>
+
+#include "SubMesh.hh" // implementation of class methods
+
+#include "spatialdata/geocoords/CoordSys.hh" // USES CoordSys
+
+#include <Selection.hh> // USES ALE::Selection
+
+// ----------------------------------------------------------------------
+// Default constructor
+pylith::topology::SubMesh::SubMesh(void) :
+ _coordsys(0),
+ _debug(false)
+{ // constructor
+} // constructor
+
+// ----------------------------------------------------------------------
+// Constructor with mesh and label for vertices marking boundary.
+pylith::topology::SubMesh::SubMesh(const Mesh& mesh,
+ const char* label) :
+ _coordsys(0),
+ _debug(false)
+{ // constructor
+ createSubMesh(mesh, label);
+} // constructor
+
+// ----------------------------------------------------------------------
+// Default destructor
+pylith::topology::SubMesh::~SubMesh(void)
+{ // destructor
+ delete _coordsys; _coordsys = 0;
+} // destructor
+
+// ----------------------------------------------------------------------
+// Create Sieve mesh.
+void
+pylith::topology::SubMesh::createSubMesh(const Mesh& mesh,
+ const char* label)
+{ // createSieveMesh
+ _mesh.destroy();
+
+ const ALE::Obj<DomainSieveMesh>& meshSieveMesh = mesh.sieveMesh();
+ assert(!meshSieveMesh.isNull());
+
+ const ALE::Obj<IntSection>& groupField = meshSieveMesh->getIntSection(label);
+ if (groupField.isNull()) {
+ std::ostringstream msg;
+ msg << "Could not find group of points '" << label << "' in mesh.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _mesh =
+ ALE::Selection<DomainSieveMesh>::submeshV<SieveMesh>(meshSieveMesh,
+ groupField);
+ if (_mesh.isNull()) {
+ std::ostringstream msg;
+ msg << "Could not construct boundary mesh for boundary '"
+ << label << "'.";
+ throw std::runtime_error(msg.str());
+ } // if
+ _mesh->setRealSection("coordinates",
+ meshSieveMesh->getRealSection("coordinates"));
+
+ // Create the parallel overlap
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = _mesh->getSieve();
+ assert(!sieve.isNull());
+ ALE::Obj<SieveMesh::send_overlap_type> sendParallelMeshOverlap =
+ _mesh->getSendOverlap();
+ ALE::Obj<SieveMesh::recv_overlap_type> recvParallelMeshOverlap =
+ _mesh->getRecvOverlap();
+
+ SieveMesh::renumbering_type& renumbering = _mesh->getRenumbering();
+
+ DomainSieveMesh::renumbering_type& oldRenumbering =
+ meshSieveMesh->getRenumbering();
+ const SieveMesh::renumbering_type::const_iterator oldBegin =
+ oldRenumbering.begin();
+ const SieveMesh::renumbering_type::const_iterator oldEnd =
+ oldRenumbering.end();
+ for (SieveMesh::renumbering_type::const_iterator r_iter = oldBegin;
+ r_iter != oldEnd;
+ ++r_iter)
+ if (sieve->getChart().hasPoint(r_iter->second) &&
+ (sieve->getConeSize(r_iter->second) ||
+ sieve->getSupportSize(r_iter->second)))
+ renumbering[r_iter->first] = r_iter->second;
+
+ // Can I figure this out in a nicer way?
+ ALE::SetFromMap<std::map<DomainSieveMesh::point_type,
+ DomainSieveMesh::point_type> > globalPoints(renumbering);
+
+ ALE::OverlapBuilder<>::constructOverlap(globalPoints, renumbering,
+ sendParallelMeshOverlap,
+ recvParallelMeshOverlap);
+ _mesh->setCalculatedOverlap(true);
+
+ // Set data from mesh.
+ _mesh->setDebug(mesh.debug());
+ coordsys(mesh);
+} // createSubMesh
+
+// ----------------------------------------------------------------------
+// Set coordinate system using mesh.
+void
+pylith::topology::SubMesh::coordsys(const Mesh& mesh)
+{ // coordsys
+ delete _coordsys; _coordsys = 0;
+ const spatialdata::geocoords::CoordSys* cs = mesh.coordsys();
+ if (0 != cs) {
+ _coordsys = cs->clone();
+ assert(0 != _coordsys);
+ _coordsys->initialize();
+ } // if
+} // coordsys
+
+// ----------------------------------------------------------------------
+// Initialize the finite-element mesh.
+void
+pylith::topology::SubMesh::initialize(void)
+{ // initialize
+ if (0 != _coordsys)
+ _coordsys->initialize();
+} // initialize
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/SubMesh.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/SubMesh.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/SubMesh.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/SubMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,152 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file libsrc/topology/SubMesh.hh
+ *
+ * @brief C++ PyLith finite-element mesh.
+ *
+ * Extends Sieve mesh over subset of domain to include coordinate
+ * system associated with domain.
+ */
+
+#if !defined(pylith_topology_submesh_hh)
+#define pylith_topology_submesh_hh
+
+// Include directives ---------------------------------------------------
+#include "topologyfwd.hh" // forward declarations
+#include "spatialdata/geocoords/geocoordsfwd.hh" // forward declarations
+
+#include "Mesh.hh" // USES Mesh
+
+// SubMesh -----------------------------------------------------------------
+class pylith::topology::SubMesh
+{ // SubMesh
+ friend class TestSubMesh; // unit testing
+
+// PUBLIC TYPEDEFS //////////////////////////////////////////////////////
+public:
+
+ // Typedefs for basic types associated with Sieve mesh.
+ // SieveMesh, RealSection, and IntSection are used in templated code.
+ typedef Mesh::SieveSubMesh SieveMesh;
+ typedef Mesh::RealSection RealSection;
+ typedef Mesh::IntSection IntSection;
+ typedef Mesh::RestrictVisitor RestrictVisitor;
+ typedef Mesh::UpdateAddVisitor UpdateAddVisitor;
+
+ // Sieve mesh for higher level domain (mesh, not submesh)
+ typedef Mesh::SieveMesh DomainSieveMesh;
+
+// PUBLIC METHODS ///////////////////////////////////////////////////////
+public :
+
+ /// Default constructor.
+ SubMesh(void);
+
+ /** Constructor with mesh and label for vertices marking boundary.
+ *
+ * @param mesh Finite-element mesh over domain.
+ * @param label Label for vertices marking boundary.
+ */
+ SubMesh(const Mesh& mesh,
+ const char* label);
+
+ /// Default destructor
+ ~SubMesh(void);
+
+ /** Create Sieve mesh.
+ *
+ * @param mesh Finite-element mesh over domain.
+ * @param label Label for vertices marking boundary.
+ */
+ void createSubMesh(const Mesh& mesh,
+ const char* label);
+
+ /** Get Sieve mesh.
+ *
+ * @returns Sieve mesh.
+ */
+ const ALE::Obj<SieveMesh>& sieveMesh(void) const;
+
+ /** Get Sieve mesh.
+ *
+ * @returns Sieve mesh.
+ */
+ ALE::Obj<SieveMesh>& sieveMesh(void);
+
+ /** Set coordinate system using mesh.
+ *
+ * @param mesh Finite-element mesh over domain.
+ */
+ void coordsys(const Mesh& mesh);
+
+ /** Get coordinate system.
+ *
+ * @returns Coordinate system.
+ */
+ const spatialdata::geocoords::CoordSys* coordsys(void) const;
+
+ /** Set debug flag.
+ *
+ * @param value Turn on debugging if true.
+ */
+ void debug(const bool value);
+
+ /** Get debug flag.
+ *
+ * @param Get debugging flag.
+ */
+ bool debug(void) const;
+
+ /** Get dimension of mesh.
+ *
+ * @returns Dimension of mesh.
+ */
+ int dimension(void) const;
+
+ /** Get MPI communicator associated with mesh.
+ *
+ * @returns MPI communicator.
+ */
+ const MPI_Comm comm(void) const;
+
+ /// Initialize the finite-element mesh.
+ void initialize(void);
+
+ /** Print mesh to stdout.
+ *
+ * @param label Label for mesh.
+ */
+ void view(const char* label);
+
+// PRIVATE MEMBERS //////////////////////////////////////////////////////
+private :
+
+ ALE::Obj<SieveMesh> _mesh; ///< Sieve mesh.
+ spatialdata::geocoords::CoordSys* _coordsys; ///< Coordinate system.
+ bool _debug; ///< Debugging flag for mesh.
+
+// NOT IMPLEMENTED //////////////////////////////////////////////////////
+private :
+
+ SubMesh(const SubMesh&); ///< Not implemented
+ const SubMesh& operator=(const SubMesh&); ///< Not implemented
+
+}; // SubMesh
+
+#include "SubMesh.icc"
+
+#endif // pylith_topology_submesh_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/SubMesh.icc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/SubMesh.icc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/SubMesh.icc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/SubMesh.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_topology_submesh_hh)
+#error "SubMesh.icc must be included only from SubMesh.hh"
+#else
+
+// Get Sieve mesh.
+inline
+const ALE::Obj<pylith::topology::Mesh::SieveSubMesh>&
+pylith::topology::SubMesh::sieveMesh(void) const {
+ return _mesh;
+}
+
+// Get Sieve mesh.
+inline
+ALE::Obj<pylith::topology::Mesh::SieveSubMesh>&
+pylith::topology::SubMesh::sieveMesh(void) {
+ return _mesh;
+}
+
+// Get coordinate system.
+inline
+const spatialdata::geocoords::CoordSys*
+pylith::topology::SubMesh::coordsys(void) const {
+ return _coordsys;
+}
+
+// Set debug flag.
+inline
+void
+pylith::topology::SubMesh::debug(const bool value) {
+ _debug = value;
+ if (!_mesh.isNull())
+ _mesh->setDebug(value);
+}
+
+// Get debug flag.
+inline
+bool
+pylith::topology::SubMesh::debug(void) const {
+ return _debug;
+}
+
+// Get dimension of mesh.
+inline
+int
+pylith::topology::SubMesh::dimension(void) const {
+ return (!_mesh.isNull()) ? _mesh->getDimension() : 0;
+}
+
+// Get MPI communicator associated with mesh.
+inline
+const MPI_Comm
+pylith::topology::SubMesh::comm(void) const {
+ return (!_mesh.isNull()) ? _mesh->comm() : 0;
+}
+
+// Print mesh to stdout.
+inline
+void
+pylith::topology::SubMesh::view(const char* label) {
+ _mesh->view(label);
+}
+
+
+#endif
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/topology/topologyfwd.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/topology/topologyfwd.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/topology/topologyfwd.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/topology/topologyfwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/topology/topologyfwd.hh
+ *
+ * @brief Forward declarations for PyLith topology objects.
+ *
+ * Including this header file eliminates the need to use separate
+ * forward declarations.
+ */
+
+#if !defined(pylith_topology_topologyfwd_hh)
+#define pylith_topology_topologyfwd_hh
+
+namespace pylith {
+ namespace topology {
+
+ class Mesh;
+ class SubMesh;
+ class MeshOps;
+
+ class FieldBase;
+ template<typename mesh_type> class Field;
+ template<typename field_type> class Fields;
+ typedef Fields<Field<Mesh> > FieldsMesh;
+ typedef Fields<Field<SubMesh> > FieldsSubMesh;
+ class SolutionFields;
+
+ class Jacobian;
+
+ class Distributor;
+
+ class MeshRefiner;
+ class RefineUniform;
+
+ } // topology
+} // pylith
+
+
+#endif // pylith_topology_topologyfwd_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/utils/EventLogger.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,18 +21,15 @@
#if !defined(pylith_utils_eventlogger_hh)
#define pylith_utils_eventlogger_hh
+// Include directives ---------------------------------------------------
+#include "utilsfwd.hh" // forward declarations
+
#include <string> // USES std::string
#include <map> // USES std::map
#include "petsclog.h" // USES PetscLogEventBegin/End() in inline methods
-namespace pylith {
- namespace utils {
- class EventLogger;
- class TestEventLogger; // unit testing
- } // utils
-} // pylith
-
+// EventLogger ----------------------------------------------------------
class pylith::utils::EventLogger
{ // EventLogger
friend class TestEventLogger; // unit testing
Modified: short/3D/PyLith/trunk/libsrc/utils/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/utils/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,20 +16,21 @@
subpkginclude_HEADERS = \
EventLogger.hh \
EventLogger.icc \
+ TestArray.hh \
array.hh \
arrayfwd.hh \
constdefs.h \
lapack.h \
macrodefs.h \
petscfwd.h \
+ petscerror.h \
sievefwd.hh \
sievetypes.hh \
- vectorfields.hh
+ utilsfwd.hh
noinst_HEADERS =
-#
- export
+# export
clean-local: clean-subpkgincludeHEADERS
BUILT_SOURCES = export-subpkgincludeHEADERS
CLEANFILES = export-subpkgincludeHEADERS
Copied: short/3D/PyLith/trunk/libsrc/utils/TestArray.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/utils/TestArray.cc)
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/TestArray.cc (rev 0)
+++ short/3D/PyLith/trunk/libsrc/utils/TestArray.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "TestArray.hh" // implementation of class methods
+
+#include "array.hh" // USES double_array
+
+#include <iostream> // USES std::cerr
+#include <cassert> // USES assert()
+
+// ----------------------------------------------------------------------
+// Check to make sure array of values match expected values.
+bool
+pylith::utils::TestArray::check(const double* valuesE,
+ const int nvalues,
+ const double_array& values)
+{ // check(double)
+ assert( (0 == nvalues && 0 == valuesE) ||
+ (0 < nvalues && 0 != valuesE) );
+
+ if (nvalues != values.size()) {
+ std::cerr << "Array size mismatch, expected: " << nvalues
+ << " actual: " << values.size() << std::endl;
+ return false;
+ } // if
+
+ const double tolerance = 1.0e-06;
+ bool okay = true;
+ for (int i=0; i < nvalues; ++i) {
+ okay = true;
+ if (0.0 != valuesE[i]) {
+ if (fabs(1.0 - values[i]/valuesE[i]) > tolerance)
+ okay = false;
+ } else if (fabs(values[i] - valuesE[i]) > tolerance)
+ okay = false;
+
+ if (!okay) {
+ std::cerr << "Mismatch in array at index " << i << ", expected: "
+ << valuesE[i] << ", actual: " << values[i] << std::endl;
+ return false;
+ } // if
+ } // for
+
+ return true;
+} // check(double)
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/utils/TestArray.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/utils/TestArray.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/TestArray.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/utils/TestArray.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/utils/TestArray.hh
+ *
+ * @brief C++ object for testing array values.
+ *
+ * This object is used in unit testing of SWIG interfaces where the
+ * C++ object has an accessor returning a std::valarray. The TestArray
+ * methods provide the ability to compare the array returned by the
+ * accessor against the expected values, which are supplied via a
+ * pointer and a size (number of values).
+ */
+
+#if !defined(pylith_utils_testarray_hh)
+#define pylith_utils_testarray_hh
+
+// Include directives ---------------------------------------------------
+#include "utilsfwd.hh" // forward declarations
+
+#include "arrayfwd.hh" // USES double_array
+
+// TestArray ------------------------------------------------------------
+class pylith::utils::TestArray
+{ // TestArray
+
+// PUBLIC MEMBERS ///////////////////////////////////////////////////////
+public :
+
+ /** Check to make sure array of values match expected values.
+ *
+ * @param valuesE Array of expected values.
+ * @param nvalues Array size.
+ * @param values Array of values to check.
+ */
+ static
+ bool
+ check(const double* valuesE,
+ const int nvalues,
+ const double_array& values);
+
+}; // EventLogger
+
+#endif // pylith_utils_testarray_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/libsrc/utils/petscerror.h (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/utils/petscerror.h)
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/petscerror.h (rev 0)
+++ short/3D/PyLith/trunk/libsrc/utils/petscerror.h 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file pylith/utils/petscerror.h
+ *
+ * @brief Wrappers around PETSc error handling routines.
+ */
+
+#if !defined(pylith_utils_petscerror_h)
+#define pylith_utils_petscerror_h
+
+#undef __FUNCT__
+#if defined(__FUNCTION_NAME__)
+#define __FUNCT__ __FUNCTION_NAME__
+#else
+#define __FUNCT__ "<unknown>"
+#endif
+
+#define CHECK_PETSC_ERROR(err) \
+ if (err) { \
+ PetscError(__LINE__, __FUNCT__, __FILE__, __SDIR__, err, 0, " "); \
+ throw std::runtime_error("PETSc error."); }
+
+#define CHECK_PETSC_ERROR_MSG(err, msg) \
+ if (err) { \
+ PetscError(__LINE__, __FUNCT__, __FILE__, __SDIR__, err, 0, " "); \
+ throw std::runtime_error(msg); }
+
+#endif // pylith_utils_petscerror_h
+
+// End of file
Modified: short/3D/PyLith/trunk/libsrc/utils/petscfwd.h
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/petscfwd.h 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/utils/petscfwd.h 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,13 +26,21 @@
/// forward declaration for PETSc Vec
typedef struct _p_Vec* PetscVec;
+/// forward declaration for PETSc VecScatter
+typedef struct _p_VecScatter* PetscVecScatter;
+
/// forward declaration for PETSc ISLocalToGlobalMapping
typedef struct _p_ISLocalToGlobalMapping* PetscISLocalToGlobalMapping;
+/// forward declaration for PETSc KSP
+typedef struct _p_KSP* PetscKSP;
+
+/// forward declaration for PETSc SNES
+typedef struct _p_SNES* PetscSNES;
+
/// forward declaration for PETSc PetscErrorCode
typedef int PetscErrorCode;
-
#endif // pylith_utils_petscfwd_h
// End of file
Modified: short/3D/PyLith/trunk/libsrc/utils/sievefwd.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/sievefwd.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/utils/sievefwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,7 +19,6 @@
#if !defined(pylith_utils_sievefwd_hh)
#define pylith_utils_sievefwd_hh
-#include <ALE.hh>
/// Namespace for Sieve package.
namespace ALE {
Modified: short/3D/PyLith/trunk/libsrc/utils/sievetypes.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/sievetypes.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/utils/sievetypes.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,19 +23,8 @@
namespace pylith {
-#if NEWPYLITHMESH // For use with pylith::topology::Mesh
- typedef ALE::IMesh<> SieveMesh;
- typedef ALE::IMesh<ALE::LabelSifter<int, SieveMesh::point_type> > SieveSubMesh;
- typedef SieveMesh::real_section_type SieveRealSection;
- typedef SieveMesh::int_section_type SieveIntSection;
-
-#else
typedef ALE::IMesh<> Mesh;
typedef ALE::IMesh<ALE::LabelSifter<int, Mesh::point_type> > SubMesh;
- typedef Mesh::sieve_type sieve_type;
- typedef Mesh::real_section_type real_section_type;
- typedef Mesh::int_section_type int_section_type;
-#endif
} // pylith
Copied: short/3D/PyLith/trunk/libsrc/utils/utilsfwd.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/libsrc/utils/utilsfwd.hh)
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/utilsfwd.hh (rev 0)
+++ short/3D/PyLith/trunk/libsrc/utils/utilsfwd.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file libsrc/utils/utilsfwd.hh
+ *
+ * @brief Forward declarations for PyLith utils objects.
+ *
+ * Including this header file eliminates the need to use separate
+ * forward declarations.
+ */
+
+#if !defined(pylith_utils_utilsfwd_hh)
+#define pylith_utils_utilsfwd_hh
+
+namespace pylith {
+ namespace utils {
+
+ class EventLogger;
+
+ class TestArray;
+
+ } // utils
+} // pylith
+
+
+#endif // pylith_utils_utilsfwd_hh
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/libsrc/utils/vectorfields.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/utils/vectorfields.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/libsrc/utils/vectorfields.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,37 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-/**
- * @file pylith/utils/realspaces.hh
- *
- * @brief Categories of real vector space types.
- */
-
-#if !defined(pylith_utils_vectorfields_hh)
-#define pylith_utils_vectorfields_hh
-
-namespace pylith {
-
- /// Enumeration of types of vector fields.
- enum VectorFieldEnum {
- SCALAR_FIELD, ///< Scalar field
- VECTOR_FIELD, ///< Vector field
- TENSOR_FIELD, ///< Tensor field
- OTHER_FIELD ///< Other type of field
- }; // VectorFieldEnum
-
-} // pylith
-
-#endif // pylith_utils_vectorfields_hh
-
-
-// End of file
Property changes on: short/3D/PyLith/trunk/modulesrc
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
Modified: short/3D/PyLith/trunk/modulesrc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
feassemble \
materials \
meshio \
- solver \
+ mpi \
+ problems \
topology \
utils
Property changes on: short/3D/PyLith/trunk/modulesrc/bc
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
bc.py
bc_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/bc/AbsorbingDampers.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/bc/AbsorbingDampers.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/AbsorbingDampers.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/bc/AbsorbingDampers.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/bc/AbsorbingDampers.i
+ *
+ * @brief Python interface to C++ AbsorbingDampers object.
+ */
+
+namespace pylith {
+ namespace bc {
+
+ class AbsorbingDampers :
+ public BoundaryCondition,
+ public pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >
+ { // class AbsorbingDampers
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ AbsorbingDampers(void);
+
+ /// Destructor.
+ ~AbsorbingDampers(void);
+
+ /** Initialize boundary condition.
+ *
+ * @param mesh Finite-element mesh.
+ * @param upDir Direction perpendicular to horizontal surface tangent
+ * direction that is not collinear with surface normal.
+ */
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3]);
+
+ /** Integrate contributions to residual term (r) for operator.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
+ *
+ * @param mat Sparse matrix
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateJacobian(pylith::topology::Jacobian* mat,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Verify configuration is acceptable.
+ *
+ * @param mesh Finite-element mesh
+ */
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+
+ }; // class AbsorbingDampers
+
+ } // bc
+} //pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/bc/BoundaryCondition.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/bc/BoundaryCondition.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/BoundaryCondition.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/bc/BoundaryCondition.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/bc/BoundaryCondition.i
+ *
+ * @brief Python interface to C++ BoundaryCondition object.
+ */
+
+namespace pylith {
+ namespace bc {
+
+ class BoundaryCondition
+ { // class BoundaryCondition
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ BoundaryCondition(void);
+
+ /// Destructor.
+ virtual
+ ~BoundaryCondition(void);
+
+ /** Set label of boundary condition surface.
+ *
+ * @param value Label of surface (from mesh generator).
+ */
+ void label(const char* value);
+
+ /** Get label of boundary condition surface.
+ *
+ * @returns Label of surface (from mesh generator).
+ */
+ const char* label(void) const;
+
+ /** Set database for boundary condition parameters.
+ *
+ * @param db Spatial database
+ */
+ void db(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Verify configuration.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ virtual
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+
+ /** Initialize boundary condition.
+ *
+ * @param mesh Finite-element mesh.
+ * @param upDir Vertical direction (somtimes used in 3-D problems).
+ */
+ virtual
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3]) = 0;
+
+ }; // class BoundaryCondition
+
+ } // bc
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/bc/DirichletBC.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/bc/DirichletBC.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/DirichletBC.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/bc/DirichletBC.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/bc/DirichletBC.i
+ *
+ * @brief Python interface to C++ DirichletBC object.
+ */
+
+namespace pylith {
+ namespace bc {
+
+ class DirichletBC : public BoundaryCondition,
+ public pylith::feassemble::Constraint
+ { // class DirichletBC
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ DirichletBC(void);
+
+ /// Destructor.
+ ~DirichletBC(void);
+
+ /** Set database for rate of change of values.
+ *
+ * @param db Spatial database
+ */
+ void dbRate(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set indices of fixed degrees of freedom.
+ *
+ * Note: all points associated with boundary condition has same
+ * degrees of freedom fixed.
+ *
+ * Example: [0, 1] to fix x and y degrees of freedom in Cartesian system.
+ *
+ * @param flags Array of indices of fixed degrees of freedom.
+ * @param size Size of array.
+ */
+ %apply(int* INPLACE_ARRAY1, int DIM1) {
+ (const int* flags,
+ const int size)
+ };
+ void fixedDOF(const int* flags,
+ const int size);
+ %clear(const int* flags, const int size);
+
+ /** Set time at which rate of change begins.
+ *
+ * @param t Reference time.
+ */
+ void referenceTime(const double t);
+
+ /** Initialize boundary condition.
+ *
+ * @param mesh PETSc mesh
+ * @param upDir Vertical direction (somtimes used in 3-D problems).
+ */
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3]);
+
+ /** Set number of degrees of freedom that are constrained at
+ * points in field.
+ *
+ * @param field Solution field
+ */
+ void setConstraintSizes(const pylith::topology::Field<pylith::topology::Mesh>& field);
+
+ /** Set which degrees of freedom are constrained at points in field.
+ *
+ * @param field Solution field
+ */
+ void setConstraints(const pylith::topology::Field<pylith::topology::Mesh>& field);
+
+ /** Set values in field.
+ *
+ * @param t Current time
+ * @param field Solution field
+ */
+ void setField(const double t,
+ const pylith::topology::Field<pylith::topology::Mesh>& field);
+
+ }; // class DirichletBC
+
+ } // bc
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/bc/DirichletBoundary.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/bc/DirichletBoundary.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/DirichletBoundary.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/bc/DirichletBoundary.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,64 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/bc/DirichletBoundary.i
+ *
+ * @brief Python interface to C++ DirichletBoundary object.
+ */
+
+namespace pylith {
+ namespace bc {
+
+ class DirichletBoundary : public DirichletBC
+ { // class DirichletBoundary
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ DirichletBoundary(void);
+
+ /// Destructor.
+ ~DirichletBoundary(void);
+
+ /** Initialize boundary condition.
+ *
+ * @param mesh Finite-element mesh.
+ * @param upDir Vertical direction (somtimes used in 3-D problems).
+ */
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3]);
+
+ /** Get boundary mesh.
+ *
+ * @return Boundary mesh.
+ */
+ const pylith::topology::SubMesh& boundaryMesh(void) const;
+
+ /** Get vertex field with BC information.
+ *
+ * @param name Name of field.
+ * @param fields Solution fields.
+ *
+ * @returns Field over vertices.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ vertexField(const char* name,
+ const pylith::topology::SolutionFields& fields);
+
+ }; // class DirichletBoundary
+
+ } // bc
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/bc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/bc/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,40 +13,51 @@
subpackage = bc
include $(top_srcdir)/subpackage.am
-subpkgpyexec_LTLIBRARIES = bcmodule.la
+subpkgpyexec_LTLIBRARIES = _bcmodule.la
-bcmodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = bc.py
+
+swig_sources = \
+ bc.i \
+ BoundaryCondition.i \
+ DirichletBC.i \
+ DirichletBoundary.i \
+ AbsorbingDampers.i \
+ Neumann.i \
+ ../feassemble/Constraint.i \
+ ../feassemble/Quadrature.i \
+ ../feassemble/Integrator.i
+
+swig_generated = \
+ bc_wrap.cxx \
+ bc.py
+
+_bcmodule_la_LDFLAGS = -module -avoid-version \
$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_bcmodule_la_SOURCES = bc.pyxe.src
-nodist_bcmodule_la_SOURCES = \
- bc.pyxe \
- bc.c bc_embed.cpp bc_embed.h
+dist__bcmodule_la_SOURCES = $(swig_sources) $(swig_generated)
-bcmodule_la_LIBADD = \
+_bcmodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
-lspatialdata \
- $(PETSC_LIB)
-
+ $(PETSC_LIBS)
if ENABLE_CUBIT
- bcmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
+ _bcmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
endif
if NO_UNDEFINED
- bcmodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_bcmodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-bc.pyx bc_embed.cpp bc_embed.h: bc.pyxe
- pyrexembed bc.pyxe
-bc.pyxe: $(srcdir)/bc.pyxe.src
- cp $(srcdir)/bc.pyxe.src $@
-bc_embed.cpp: bc_embed.h
-bc_embed.h: bc.pyx
+$(srcdir)/bc_wrap.cxx $(srcdir)/bc.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-.pyx.c:
- pyrexc $<
-CLEANFILES = bc.pyxe bc.pyx bc.c *_embed.*
+MAINTAINERCLEANFILES = \
+ $(srcdir)/bc_wrap.cxx \
+ $(srcdir)/bc.py
+
# End of file
Copied: short/3D/PyLith/trunk/modulesrc/bc/Neumann.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/bc/Neumann.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/Neumann.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/bc/Neumann.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/bc/Neumann.i
+ *
+ * @brief Python interface to C++ Neumann object.
+ */
+
+namespace pylith {
+ namespace bc {
+
+ class Neumann : public BoundaryCondition,
+ public pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >
+ { // class Neumann
+ friend class TestNeumann; // unit testing
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ Neumann(void);
+
+ /// Destructor.
+ ~Neumann(void);
+
+ /** Initialize boundary condition.
+ *
+ * @param mesh Finite-element mesh.
+ * @param upDir Direction perpendicular to horizontal surface tangent
+ * direction that is not collinear with surface normal.
+ */
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3]);
+
+ /** Integrate contributions to residual term (r) for operator.
+ *
+ * @param residual Field containing values for residual.
+ * @param t Current time.
+ * @param fields Solution fields.
+ */
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
+ *
+ * @param jacobian Sparse matrix for Jacobian of system.
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateJacobian(pylith::topology::Jacobian* jacobian,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Verify configuration is acceptable.
+ *
+ * @param mesh Finite-element mesh
+ */
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+
+ /** Get boundary mesh.
+ *
+ * @returns Boundary mesh.
+ */
+ const pylith::topology::SubMesh& boundaryMesh(void) const;
+
+ /** Get cell field with BC information.
+ *
+ * @param fieldType Type of field.
+ * @param name Name of field.
+ * @param mesh Finite-element mesh.
+ * @param fields Solution fields.
+ *
+ * @returns Traction vector at integration points.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ cellField(const char* name,
+ pylith::topology::SolutionFields* const fields);
+
+ }; // class Neumann
+
+ } // bc
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/bc/bc.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/bc/bc.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/bc.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/bc/bc.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module bc
+
+// Header files for module C++ code
+%{
+#include "pylith/bc/BoundaryCondition.hh"
+#include "pylith/bc/DirichletBC.hh"
+#include "pylith/bc/DirichletBoundary.hh"
+#include "pylith/bc/AbsorbingDampers.hh"
+#include "pylith/bc/Neumann.hh"
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+%include "../include/doublearray.i"
+
+// Numpy interface stuff
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "../include/numpy.i"
+%init %{
+import_array();
+%}
+
+// Interfaces
+%include "../feassemble/Constraint.i" // ISA Constraint
+%include "../feassemble/Quadrature.i" // ISA Quadrature
+%include "../feassemble/Integrator.i" // ISA Integrator
+
+// template instantiation
+%template(SubMeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >;
+
+%include "BoundaryCondition.i"
+%include "DirichletBC.i"
+%include "DirichletBoundary.i"
+%include "AbsorbingDampers.i"
+%include "Neumann.i"
+
+// End of file
+
Deleted: short/3D/PyLith/trunk/modulesrc/bc/bc.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/bc/bc.pyxe.src 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/bc/bc.pyxe.src 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,1763 +0,0 @@
-# -*- Pyrex -*-
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-#header{
-#include "pylith/bc/BoundaryCondition.hh"
-#include "pylith/bc/AbsorbingDampers.hh"
-#include "pylith/bc/DirichletPoints.hh"
-#include "pylith/bc/DirichletBoundary.hh"
-#include "pylith/bc/Neumann.hh"
-
-#include "pylith/utils/array.hh"
-
-#include <assert.h>
-#include <stdexcept>
-#include <Python.h>
-#}header
-
-# ----------------------------------------------------------------------
-cdef extern from "Python.h":
- object PyCObject_FromVoidPtr(void*, void (*destruct)(void*))
- void* PyCObject_AsVoidPtr(object)
-
-cdef void* ptrFromHandle(obj):
- """Extract pointer from PyCObject."""
- return PyCObject_AsVoidPtr(obj.handle)
-
-cdef extern from "stdlib.h":
- ctypedef unsigned long size_t
- void* malloc(size_t size)
- void free(void* mem)
-
-# ----------------------------------------------------------------------
-cdef void BoundaryCondition_destructor(void* obj):
- """
- Destroy BoundaryCondition object.
- """
- # create shim for destructor
- #embed{ void BoundaryCondition_destructor_cpp(void* objVptr)
- pylith::bc::BoundaryCondition* pM = (pylith::bc::BoundaryCondition*) objVptr;
- delete pM;
- #}embed
- BoundaryCondition_destructor_cpp(obj)
- return
-
-
-cdef class BoundaryCondition:
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- self.handle = None
- self.thisptr = NULL
- self.name = "pylith_bc_BoundaryCondition"
- return
-
-
- def verifyConfiguration(self, mesh):
- """
- Verify compatibility of configuration settings.
- """
- # create shim for method 'verifyConfiguration'
- #embed{ void BoundaryCondition_verifyConfiguration(void* objVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::BoundaryCondition*) objVptr)->verifyConfiguration(*mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- BoundaryCondition_verifyConfiguration(self.thisptr, ptrFromHandle(mesh))
- return
-
-
- def initialize(self, mesh, cs, upDir):
- """
- Initialize boundary condition.
- """
- # create shim for method 'initialize'
- #embed{ void BoundaryCondition_initialize(void* objVptr, void* meshVptr, void* csVptr, double* upDirPtr)
- try {
- assert(0 != objVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- pylith::double_array upDir(3);
- upDir[0] = upDirPtr[0];
- upDir[1] = upDirPtr[1];
- upDir[2] = upDirPtr[2];
- ((pylith::bc::BoundaryCondition*) objVptr)->initialize(*mesh, cs, upDir);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- if not cs.name == "spatialdata_geocoords_CoordSys":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::geocoords::CoordSys'."
- if 3 != len(upDir):
- raise TypeError, \
- "Argument 'upDir' must be a 3 vector (list)."
- cdef double upDirCpp[3]
- upDirCpp[0] = upDir[0]
- upDirCpp[1] = upDir[1]
- upDirCpp[2] = upDir[2]
- BoundaryCondition_initialize(self.thisptr, ptrFromHandle(mesh), ptrFromHandle(cs), upDirCpp)
- return
-
-
- def _createHandle(self):
- """
- Wrap pointer to C++ object in PyCObject.
- """
- return PyCObject_FromVoidPtr(self.thisptr, BoundaryCondition_destructor)
-
-
- property label:
- def __set__(self, value):
- """
- Set label of material.
- """
- # create shim for method 'label'
- #embed{ void BoundaryCondition_label_set(void* objVptr, char* value)
- try {
- assert(0 != objVptr);
- ((pylith::bc::BoundaryCondition*) objVptr)->label(value);
- } 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
- BoundaryCondition_label_set(self.thisptr, value)
-
-
- property db:
- def __set__(self, value):
- """
- Set spatial database for parameters.
- """
- # create shim for method 'db'
- #embed{ void BoundaryCondition_db_set(void* objVptr, void* dbVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dbVptr);
- spatialdata::spatialdb::SpatialDB* db =
- (spatialdata::spatialdb::SpatialDB*) dbVptr;
- ((pylith::bc::BoundaryCondition*) objVptr)->db(db);
- } 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
- if not value.name == "spatialdata_spatialdb_SpatialDB":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::spatialdb::SpatialDB'."
- BoundaryCondition_db_set(self.thisptr, ptrFromHandle(value))
-
-
-# ----------------------------------------------------------------------
-cdef class DirichletPoints(BoundaryCondition):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* DirichletPoints_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::bc::DirichletPoints);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- BoundaryCondition.__init__(self)
- self.thisptr = DirichletPoints_constructor()
- self.handle = self._createHandle()
- return
-
-
- property referenceTime:
- def __set__(self, value):
- """
- Set reference time for rate of change of values.
- """
- # create shim for method 'referenceTime'
- #embed{ void DirichletPoints_referenceTime_set(void* objVptr, double value)
- try {
- assert(0 != objVptr);
- ((pylith::bc::DirichletPoints*) objVptr)->referenceTime(value);
- } 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
- DirichletPoints_referenceTime_set(self.thisptr, value)
-
-
- property dbRate:
- def __set__(self, value):
- """
- Set spatial database for parameters of rate of change of values.
- """
- # create shim for method 'dbRate'
- #embed{ void DirichletPoints_dbRate_set(void* objVptr, void* dbVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dbVptr);
- spatialdata::spatialdb::SpatialDB* db =
- (spatialdata::spatialdb::SpatialDB*) dbVptr;
- ((pylith::bc::DirichletPoints*) objVptr)->dbRate(db);
- } 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
- if not value.name == "spatialdata_spatialdb_SpatialDB":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::spatialdb::SpatialDB'."
- DirichletPoints_dbRate_set(self.thisptr, ptrFromHandle(value))
-
-
- property fixedDOF:
- def __set__(self, value):
- """
- Set fixed DOF.
- """
- # create shim for method 'fixedDOF'
- #embed{ void DirichletPoints_fixedDOF_set(void* objVptr, int* dofVptr, int numFixedDOF)
- try {
- assert(0 != objVptr);
- assert(0 != dofVptr);
- pylith::int_array fixedDOF((int*) dofVptr, numFixedDOF);
- ((pylith::bc::DirichletPoints*) objVptr)->fixedDOF(fixedDOF);
- } 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 int* fixedDOF
- numFixedDOF = len(value)
- fixedDOF = <int*> malloc(numFixedDOF*sizeof(int))
- assert(fixedDOF != NULL)
- for i from 0 <= i < numFixedDOF:
- fixedDOF[i] = value[i]
- DirichletPoints_fixedDOF_set(self.thisptr, fixedDOF, numFixedDOF)
- free(fixedDOF)
-
-
- property normalizer:
- def __set__(self, value):
- """
- Set nondimensionalizer.
- """
- # create shim for method 'normalizer'
- #embed{ void DirichletPoints_normalizer_set(void* objVptr, void* dimVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dimVptr);
- spatialdata::units::Nondimensional* dim =
- (spatialdata::units::Nondimensional*) dimVptr;
- ((pylith::bc::DirichletPoints*) objVptr)->normalizer(*dim);
- } 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
- if not value.name == "spatialdata_units_Nondimensional":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::units::Nondimensional'."
- DirichletPoints_normalizer_set(self.thisptr, ptrFromHandle(value))
-
-
- def setConstraintSizes(self, field, mesh):
- """
- Set number of degrees of freedom that are constrained at points in field.
- """
- # create shim for method 'setConstraintSizes'
- #embed{ void DirichletPoints_setConstraintSizes(void* objVptr, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::DirichletPoints*) objVptr)->setConstraintSizes(*field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- DirichletPoints_setConstraintSizes(self.thisptr, PyCObject_AsVoidPtr(field),
- ptrFromHandle(mesh))
- return
-
-
- def setConstraints(self, field, mesh):
- """
- Set which degrees of freedom that are constrained at points in field.
- """
- # create shim for method 'setConstraints'
- #embed{ void DirichletPoints_setConstraints(void* objVptr, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::DirichletPoints*) objVptr)->setConstraints(*field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- DirichletPoints_setConstraints(self.thisptr, PyCObject_AsVoidPtr(field), ptrFromHandle(mesh))
- return
-
-
- def setField(self, t, field, mesh):
- """
- Set values in field.
- """
- # create shim for method 'setField'
- #embed{ void DirichletPoints_setField(void* objVptr, double t, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::DirichletPoints*) objVptr)->setField(t, *field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- DirichletPoints_setField(self.thisptr, t, PyCObject_AsVoidPtr(field),
- ptrFromHandle(mesh))
- return
-
-
- property useSolnIncr:
- def __set__(self, flag):
- """
- Set solution increment flag.
- """
- # create shim for method 'useSolnIncr'
- #embed{ void DirichletPoints_useSolnIncr_set(void* objVptr, int flag)
- try {
- assert(0 != objVptr);
- ((pylith::bc::DirichletPoints*) objVptr)->useSolnIncr(flag);
- } 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
- DirichletPoints_useSolnIncr_set(self.thisptr, flag)
-
-
-# ----------------------------------------------------------------------
-cdef class DirichletBoundary(BoundaryCondition):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* DirichletBoundary_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::bc::DirichletBoundary);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- BoundaryCondition.__init__(self)
- self.thisptr = DirichletBoundary_constructor()
- self.handle = self._createHandle()
- return
-
-
- property referenceTime:
- def __set__(self, value):
- """
- Set reference time for rate of change of values.
- """
- # create shim for method 'referenceTime'
- #embed{ void DirichletBoundary_referenceTime_set(void* objVptr, double value)
- try {
- assert(0 != objVptr);
- ((pylith::bc::DirichletBoundary*) objVptr)->referenceTime(value);
- } 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
- DirichletBoundary_referenceTime_set(self.thisptr, value)
-
-
- property dbRate:
- def __set__(self, value):
- """
- Set spatial database for parameters of rate of change of values.
- """
- # create shim for method 'dbRate'
- #embed{ void DirichletBoundary_dbRate_set(void* objVptr, void* dbVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dbVptr);
- spatialdata::spatialdb::SpatialDB* db =
- (spatialdata::spatialdb::SpatialDB*) dbVptr;
- ((pylith::bc::DirichletBoundary*) objVptr)->dbRate(db);
- } 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
- if not value.name == "spatialdata_spatialdb_SpatialDB":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::spatialdb::SpatialDB'."
- DirichletBoundary_dbRate_set(self.thisptr, ptrFromHandle(value))
-
-
- property fixedDOF:
- def __set__(self, value):
- """
- Set fixed DOF.
- """
- # create shim for method 'fixedDOF'
- #embed{ void DirichletBoundary_fixedDOF_set(void* objVptr, int* dofVptr, int numFixedDOF)
- try {
- assert(0 != objVptr);
- assert(0 != dofVptr);
- pylith::int_array fixedDOF((int*) dofVptr, numFixedDOF);
- ((pylith::bc::DirichletBoundary*) objVptr)->fixedDOF(fixedDOF);
- } 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 int* fixedDOF
- numFixedDOF = len(value)
- fixedDOF = <int*> malloc(numFixedDOF*sizeof(int))
- assert(fixedDOF != NULL)
- for i from 0 <= i < numFixedDOF:
- fixedDOF[i] = value[i]
- DirichletBoundary_fixedDOF_set(self.thisptr, fixedDOF, numFixedDOF)
- free(fixedDOF)
-
-
- property normalizer:
- def __set__(self, value):
- """
- Set nondimensionalizer.
- """
- # create shim for method 'normalizer'
- #embed{ void DirichletBoundary_normalizer_set(void* objVptr, void* dimVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dimVptr);
- spatialdata::units::Nondimensional* dim =
- (spatialdata::units::Nondimensional*) dimVptr;
- ((pylith::bc::DirichletBoundary*) objVptr)->normalizer(*dim);
- } 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
- if not value.name == "spatialdata_units_Nondimensional":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::units::Nondimensional'."
- DirichletBoundary_normalizer_set(self.thisptr, ptrFromHandle(value))
-
-
- def setConstraintSizes(self, field, mesh):
- """
- Set number of degrees of freedom that are constrained at points in field.
- """
- # create shim for method 'setConstraintSizes'
- #embed{ void DirichletBoundary_setConstraintSizes(void* objVptr, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::DirichletBoundary*) objVptr)->setConstraintSizes(*field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- DirichletBoundary_setConstraintSizes(self.thisptr, PyCObject_AsVoidPtr(field),
- ptrFromHandle(mesh))
- return
-
-
- def setConstraints(self, field, mesh):
- """
- Set which degrees of freedom that are constrained at points in field.
- """
- # create shim for method 'setConstraints'
- #embed{ void DirichletBoundary_setConstraints(void* objVptr, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::DirichletBoundary*) objVptr)->setConstraints(*field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- DirichletBoundary_setConstraints(self.thisptr, PyCObject_AsVoidPtr(field), ptrFromHandle(mesh))
- return
-
-
- def setField(self, t, field, mesh):
- """
- Set values in field.
- """
- # create shim for method 'setField'
- #embed{ void DirichletBoundary_setField(void* objVptr, double t, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::DirichletBoundary*) objVptr)->setField(t, *field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- DirichletBoundary_setField(self.thisptr, t, PyCObject_AsVoidPtr(field),
- ptrFromHandle(mesh))
- return
-
-
- def boundaryMesh(self, mesh):
- """
- Get mesh associated with fields over boundary.
- """
- # create shim for method 'boundaryMesh'
- #embed{ void DirichletBoundary_boundaryMesh(void* objVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::SubMesh>* mesh = (ALE::Obj<pylith::SubMesh>*) meshVptr;
- *mesh = ((pylith::bc::DirichletBoundary*) objVptr)->boundaryMesh();
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- DirichletBoundary_boundaryMesh(self.thisptr, ptrFromHandle(mesh))
- return
-
-
- def vertexField(self, name, mesh, fields=None):
- """
- Get cell field.
- """
- # create shim for method 'vertexField'
- #embed{ void* DirichletBoundary_vertexField(void* objVptr, int* fieldPtr, char* name, void* meshVptr, void* fieldsVptr)
- void* result = 0;
- try {
- assert(0 != objVptr);
- assert(0 != fieldPtr);
- assert(0 != name);
- assert(0 != meshVptr);
- pylith::bc::DirichletBoundary* bc = (pylith::bc::DirichletBoundary*) objVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- pylith::VectorFieldEnum fieldType;
- const ALE::Obj<pylith::real_section_type>& field =
- bc->vertexField(&fieldType, name, *mesh, fields);
- *fieldPtr = fieldType;
- result = (void*) &field;
- } 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
- return result;
- #}embed
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- if None != fields:
- if not fields.name == "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type " \
- "'pylith::topology::FieldsManager'."
- cdef void* ptr
- cdef int fieldType
- if None != fields:
- ptr = DirichletBoundary_vertexField(self.thisptr, &fieldType, name,
- ptrFromHandle(mesh), ptrFromHandle(fields))
- else:
- ptr = DirichletBoundary_vertexField(self.thisptr, &fieldType, name,
- ptrFromHandle(mesh), NULL)
- return (PyCObject_FromVoidPtr(ptr, NULL), fieldType)
-
-
- property useSolnIncr:
- def __set__(self, flag):
- """
- Set solution increment flag.
- """
- # create shim for method 'useSolnIncr'
- #embed{ void DirichletBoundary_useSolnIncr_set(void* objVptr, int flag)
- try {
- assert(0 != objVptr);
- ((pylith::bc::DirichletBoundary*) objVptr)->useSolnIncr(flag);
- } 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
- DirichletBoundary_useSolnIncr_set(self.thisptr, flag)
-
-
-# ----------------------------------------------------------------------
-cdef class AbsorbingDampers(BoundaryCondition):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* AbsorbingDampers_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::bc::AbsorbingDampers);
- assert(0 != result);
- } 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
- return result;
- #}embed
- BoundaryCondition.__init__(self)
- self.thisptr = AbsorbingDampers_constructor()
- self.handle = self._createHandle()
- return
-
-
- def integrateResidual(self, residual, t, fields, mesh, cs):
- """
- Integrate contributions to residual term (r) for operator.
- """
- # create shim for method 'integrateResidual'
- #embed{ void AbsorbingDampers_integrateResidual(void* objVptr, void* residualVptr, double t, void* fieldsVptr, void* meshVptr, void* csVptr)
- try {
- assert(0 != objVptr);
- assert(0 != residualVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ALE::Obj<pylith::real_section_type>* residual =
- (ALE::Obj<pylith::real_section_type>*) residualVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- ((pylith::bc::AbsorbingDampers*) objVptr)->integrateResidual(*residual,
- t, fields, *mesh, cs);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type 'Mesh'."
- AbsorbingDampers_integrateResidual(self.thisptr,
- PyCObject_AsVoidPtr(residual),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh),
- ptrFromHandle(cs))
- return
-
-
- def integrateJacobian(self, mat, t, fields, mesh):
- """
- Compute contributions to Jacobian matrix (A) associated with operator.
- """
- # create shim for method 'integrateJacobian'
- #embed{ void AbsorbingDampers_integrateJacobian(void* objVptr, void* matVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != matVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- PetscMat* mat = (PetscMat*) matVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ((pylith::bc::AbsorbingDampers*) objVptr)->integrateJacobian(
- mat, t, fields, *mesh);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- AbsorbingDampers_integrateJacobian(self.thisptr,
- PyCObject_AsVoidPtr(mat),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def integrateResidualAssembled(self, residual, t, fields, mesh, cs):
- """
- Integrate contributions to residual term (r) for operator that do
- not require assembly over cells, vertices, or processors.
- """
- # create shim for method 'integrateResidualAssembled'
- #embed{ void AbsorbingDampers_integrateResidualAssembled(void* objVptr, void* residualVptr, double t, void* fieldsVptr, void* meshVptr, void* csVptr)
- try {
- assert(0 != objVptr);
- assert(0 != residualVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ALE::Obj<pylith::real_section_type>* residual =
- (ALE::Obj<pylith::real_section_type>*) residualVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- ((pylith::bc::AbsorbingDampers*) objVptr)->integrateResidualAssembled(*residual,
- t, fields, *mesh, cs);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type 'Mesh'."
- AbsorbingDampers_integrateResidualAssembled(self.thisptr,
- PyCObject_AsVoidPtr(residual),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh),
- ptrFromHandle(cs))
- return
-
-
- def integrateJacobianAssembled(self, mat, t, fields, mesh):
- """
- Compute contributions to Jacobian matrix (A) associated with
- operator that do not require assembly over cells, vertices, or
- processors.
- """
- # create shim for method 'integrateJacobianAssembled'
- #embed{ void AbsorbingDampers_integrateJacobianAssembled(void* objVptr, void* matVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != matVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- PetscMat* mat = (PetscMat*) matVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ((pylith::bc::AbsorbingDampers*) objVptr)->integrateJacobianAssembled(
- mat, t, fields, *mesh);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- AbsorbingDampers_integrateJacobianAssembled(self.thisptr,
- PyCObject_AsVoidPtr(mat),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def updateState(self, t, fields, mesh):
- """
- Update state variables as needed.
- """
- # create shim for method 'updateState'
- #embed{ void AbsorbingDampers_updateState(void* objVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::AbsorbingDampers*) objVptr)->updateState(t, fields, *mesh);
- } 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
- if fields.name != "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type 'FieldsManager'."
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- AbsorbingDampers_updateState(self.thisptr,
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def _createHandle(self):
- """
- Wrap pointer to C++ object in PyCObject.
- """
- return PyCObject_FromVoidPtr(self.thisptr, BoundaryCondition_destructor)
-
-
- property quadrature:
- def __set__(self, q):
- """
- Set quadrature.
- """
- # create shim for method 'quadrature'
- #embed{ void AbsorbingDampers_quadrature_set(void* objVptr, void* qVptr)
- try {
- assert(0 != objVptr);
- pylith::feassemble::Quadrature* quadrature =
- (pylith::feassemble::Quadrature*) qVptr;
- ((pylith::bc::AbsorbingDampers*) objVptr)->quadrature(quadrature);
- } 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
- if not q.name == "pylith_feassemble_Quadrature":
- raise TypeError, \
- "Argument must be extension module type 'Quadrature'."
- AbsorbingDampers_quadrature_set(self.thisptr, ptrFromHandle(q))
-
-
- property normalizer:
- def __set__(self, value):
- """
- Set nondimensionalizer.
- """
- # create shim for method 'normalizer'
- #embed{ void AbsorbingDampers_normalizer_set(void* objVptr, void* dimVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dimVptr);
- spatialdata::units::Nondimensional* dim =
- (spatialdata::units::Nondimensional*) dimVptr;
- ((pylith::bc::AbsorbingDampers*) objVptr)->normalizer(*dim);
- } 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
- if not value.name == "spatialdata_units_Nondimensional":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::units::Nondimensional'."
- AbsorbingDampers_normalizer_set(self.thisptr, ptrFromHandle(value))
-
-
- property timeStep:
- def __set__(self, dt):
- """
- Set timeStep.
- """
- # create shim for method 'timeStep'
- #embed{ void AbsorbingDampers_timeStep_set(void* objVptr, double dt)
- try {
- assert(0 != objVptr);
- ((pylith::bc::AbsorbingDampers*) objVptr)->timeStep(dt);
- } 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
- AbsorbingDampers_timeStep_set(self.thisptr, dt)
-
-
- property stableTimeStep:
- def __get__(self):
- """
- Get stable time step.
- """
- # create shim for method 'stableTimeStep'
- #embed{ double AbsorbingDampers_stableTimeStep_get(void* objVptr)
- double result = 0.0;
- try {
- assert(0 != objVptr);
- result =
- ((pylith::bc::AbsorbingDampers*) objVptr)->stableTimeStep();
- } 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
- return result;
- #}embed
- return AbsorbingDampers_stableTimeStep_get(self.thisptr)
-
-
- property needNewJacobian:
- def __get__(self):
- """
- Set timeStep.
- """
- # create shim for method 'needNewJacobian'
- #embed{ int AbsorbingDampers_needNewJacobian_get(void* objVptr)
- int result = 0;
- try {
- assert(0 != objVptr);
- result =
- ((pylith::bc::AbsorbingDampers*) objVptr)->needNewJacobian();
- } 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
- return result;
- #}embed
- return AbsorbingDampers_needNewJacobian_get(self.thisptr)
-
-
- property useSolnIncr:
- def __set__(self, flag):
- """
- Set solution increment flag.
- """
- # create shim for method 'useSolnIncr'
- #embed{ void AbsorbingDampers_useSolnIncr_set(void* objVptr, int flag)
- try {
- assert(0 != objVptr);
- ((pylith::bc::AbsorbingDampers*) objVptr)->useSolnIncr(flag);
- } 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
- AbsorbingDampers_useSolnIncr_set(self.thisptr, flag)
-
-
-# ----------------------------------------------------------------------
-cdef class Neumann(BoundaryCondition):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* Neumann_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::bc::Neumann);
- assert(0 != result);
- } 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
- return result;
- #}embed
- BoundaryCondition.__init__(self)
- self.thisptr = Neumann_constructor()
- self.handle = self._createHandle()
- return
-
-
- BoundaryCondition.__init__(self)
- self.thisptr = Neumann_constructor()
- self.handle = self._createHandle()
-
-
- def integrateResidual(self, residual, t, fields, mesh, cs):
- """
- Integrate contributions to residual term (r) for operator.
- """
- # create shim for method 'integrateResidual'
- #embed{ void Neumann_integrateResidual(void* objVptr, void* residualVptr, double t, void* fieldsVptr, void* meshVptr, void* csVptr)
- try {
- assert(0 != objVptr);
- assert(0 != residualVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ALE::Obj<pylith::real_section_type>* residual =
- (ALE::Obj<pylith::real_section_type>*) residualVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- ((pylith::bc::Neumann*) objVptr)->integrateResidual(*residual,
- t, fields, *mesh, cs);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type 'Mesh'."
- Neumann_integrateResidual(self.thisptr,
- PyCObject_AsVoidPtr(residual),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh),
- ptrFromHandle(cs))
- return
-
-
- def integrateJacobian(self, mat, t, fields, mesh):
- """
- Compute contributions to Jacobian matrix (A) associated with operator.
- """
- # create shim for method 'integrateJacobian'
- #embed{ void Neumann_integrateJacobian(void* objVptr, void* matVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != matVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- PetscMat* mat = (PetscMat*) matVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ((pylith::bc::Neumann*) objVptr)->integrateJacobian(
- mat, t, fields, *mesh);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- Neumann_integrateJacobian(self.thisptr,
- PyCObject_AsVoidPtr(mat),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def integrateResidualAssembled(self, residual, t, fields, mesh, cs):
- """
- Integrate contributions to residual term (r) for operator that do
- not require assembly over cells, vertices, or processors.
- """
- # create shim for method 'integrateResidualAssembled'
- #embed{ void Neumann_integrateResidualAssembled(void* objVptr, void* residualVptr, double t, void* fieldsVptr, void* meshVptr, void* csVptr)
- try {
- assert(0 != objVptr);
- assert(0 != residualVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ALE::Obj<pylith::real_section_type>* residual =
- (ALE::Obj<pylith::real_section_type>*) residualVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- ((pylith::bc::Neumann*) objVptr)->integrateResidualAssembled(*residual,
- t, fields, *mesh, cs);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type 'Mesh'."
- Neumann_integrateResidualAssembled(self.thisptr,
- PyCObject_AsVoidPtr(residual),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh),
- ptrFromHandle(cs))
- return
-
-
- def integrateJacobianAssembled(self, mat, t, fields, mesh):
- """
- Compute contributions to Jacobian matrix (A) associated with
- operator that do not require assembly over cells, vertices, or
- processors.
- """
- # create shim for method 'integrateJacobianAssembled'
- #embed{ void Neumann_integrateJacobianAssembled(void* objVptr, void* matVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != matVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- PetscMat* mat = (PetscMat*) matVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ((pylith::bc::Neumann*) objVptr)->integrateJacobianAssembled(
- mat, t, fields, *mesh);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- Neumann_integrateJacobianAssembled(self.thisptr,
- PyCObject_AsVoidPtr(mat),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def updateState(self, t, fields, mesh):
- """
- Update state variables as needed.
- """
- # create shim for method 'updateState'
- #embed{ void Neumann_updateState(void* objVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::bc::Neumann*) objVptr)->updateState(t, fields, *mesh);
- } 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
- if fields.name != "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type 'FieldsManager'."
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- Neumann_updateState(self.thisptr,
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def boundaryMesh(self, mesh):
- """
- Get mesh associated with fields over boundary.
- """
- # create shim for method 'boundaryMesh'
- #embed{ void Neumann_boundaryMesh(void* objVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::SubMesh>* mesh = (ALE::Obj<pylith::SubMesh>*) meshVptr;
- *mesh = ((pylith::bc::Neumann*) objVptr)->boundaryMesh();
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- Neumann_boundaryMesh(self.thisptr, ptrFromHandle(mesh))
- return
-
-
- def cellField(self, name, mesh, fields=None):
- """
- Get cell field.
- """
- # create shim for method 'cellField'
- #embed{ void* Neumann_cellField(void* objVptr, int* fieldPtr, char* name, void* meshVptr, void* fieldsVptr)
- void* result = 0;
- try {
- assert(0 != objVptr);
- assert(0 != fieldPtr);
- assert(0 != name);
- assert(0 != meshVptr);
- pylith::bc::Neumann* bc = (pylith::bc::Neumann*) objVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- pylith::VectorFieldEnum fieldType;
- const ALE::Obj<pylith::real_section_type>& field =
- bc->cellField(&fieldType, name, *mesh, fields);
- *fieldPtr = fieldType;
- result = (void*) &field;
- } 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
- return result;
- #}embed
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- if None != fields:
- if not fields.name == "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type " \
- "'pylith::topology::FieldsManager'."
- cdef void* ptr
- cdef int fieldType
- if None != fields:
- ptr = Neumann_cellField(self.thisptr, &fieldType, name,
- ptrFromHandle(mesh), ptrFromHandle(fields))
- else:
- ptr = Neumann_cellField(self.thisptr, &fieldType, name,
- ptrFromHandle(mesh), NULL)
- return (PyCObject_FromVoidPtr(ptr, NULL), fieldType)
-
-
- def _createHandle(self):
- """
- Wrap pointer to C++ object in PyCObject.
- """
- return PyCObject_FromVoidPtr(self.thisptr, BoundaryCondition_destructor)
-
-
- property quadrature:
- def __set__(self, q):
- """
- Set quadrature.
- """
- # create shim for method 'quadrature'
- #embed{ void Neumann_quadrature_set(void* objVptr, void* qVptr)
- try {
- assert(0 != objVptr);
- pylith::feassemble::Quadrature* quadrature =
- (pylith::feassemble::Quadrature*) qVptr;
- ((pylith::bc::Neumann*) objVptr)->quadrature(quadrature);
- } 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
- if not q.name == "pylith_feassemble_Quadrature":
- raise TypeError, \
- "Argument must be extension module type 'Quadrature'."
- Neumann_quadrature_set(self.thisptr, ptrFromHandle(q))
-
-
- property normalizer:
- def __set__(self, value):
- """
- Set nondimensionalizer.
- """
- # create shim for method 'normalizer'
- #embed{ void Neumann_normalizer_set(void* objVptr, void* dimVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dimVptr);
- spatialdata::units::Nondimensional* dim =
- (spatialdata::units::Nondimensional*) dimVptr;
- ((pylith::bc::Neumann*) objVptr)->normalizer(*dim);
- } 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
- if not value.name == "spatialdata_units_Nondimensional":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::units::Nondimensional'."
- Neumann_normalizer_set(self.thisptr, ptrFromHandle(value))
-
-
- property timeStep:
- def __set__(self, dt):
- """
- Set timeStep.
- """
- # create shim for method 'timeStep'
- #embed{ void Neumann_timeStep_set(void* objVptr, double dt)
- try {
- assert(0 != objVptr);
- ((pylith::bc::Neumann*) objVptr)->timeStep(dt);
- } 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
- Neumann_timeStep_set(self.thisptr, dt)
-
-
- property stableTimeStep:
- def __get__(self):
- """
- Get stable time step.
- """
- # create shim for method 'stableTimeStep'
- #embed{ double Neumann_stableTimeStep_get(void* objVptr)
- double result = 0.0;
- try {
- assert(0 != objVptr);
- result =
- ((pylith::bc::Neumann*) objVptr)->stableTimeStep();
- } 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
- return result;
- #}embed
- return Neumann_stableTimeStep_get(self.thisptr)
-
-
- property needNewJacobian:
- def __get__(self):
- """
- Set timeStep.
- """
- # create shim for method 'needNewJacobian'
- #embed{ int Neumann_needNewJacobian_get(void* objVptr)
- int result = 0;
- try {
- assert(0 != objVptr);
- result =
- ((pylith::bc::Neumann*) objVptr)->needNewJacobian();
- } 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
- return result;
- #}embed
- return Neumann_needNewJacobian_get(self.thisptr)
-
-
- property useSolnIncr:
- def __set__(self, flag):
- """
- Set solution increment flag.
- """
- # create shim for method 'useSolnIncr'
- #embed{ void Neumann_useSolnIncr_set(void* objVptr, int flag)
- try {
- assert(0 != objVptr);
- ((pylith::bc::Neumann*) objVptr)->useSolnIncr(flag);
- } 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
- Neumann_useSolnIncr_set(self.thisptr, flag)
-
-
-# End of file
-
Property changes on: short/3D/PyLith/trunk/modulesrc/faults
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
faults.py
faults_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/faults/BruneSlipFn.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/BruneSlipFn.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/BruneSlipFn.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/BruneSlipFn.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/BruneSlipFn.hh
+ *
+ * @brief Python interface to C++ Fault object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class BruneSlipFn : public SlipTimeFn
+ { // class BruneSlipFn
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ BruneSlipFn(void);
+
+ /// Destructor.
+ ~BruneSlipFn(void);
+
+ /** Set spatial database for final slip.
+ *
+ * @param db Spatial database
+ */
+ void dbFinalSlip(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for slip initiation time.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for rise time (0 -> 0.95 final slip).
+ *
+ * @param db Spatial database
+ */
+ void dbRiseTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh
+ * @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
+ */
+ void initialize(const pylith::topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime =0.0);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ void slip(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t);
+
+ /** Get slip increment on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t0 Time t.
+ * @param t1 Time t+dt.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ void slipIncr(pylith::topology::Field<pylith::topology::SubMesh>* slipField,
+ const double t0,
+ const double t1);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& finalSlip(void);
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& slipTime(void);
+
+ }; // class BruneSlipFn
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/ConstRateSlipFn.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/ConstRateSlipFn.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/ConstRateSlipFn.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/ConstRateSlipFn.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/ConstRateSlipFn.i
+ *
+ * @brief Python interface to C++ Fault object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class ConstRateSlipFn : public SlipTimeFn
+ { // class ConstRateSlipFn
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ ConstRateSlipFn(void);
+
+ /// Destructor.
+ ~ConstRateSlipFn(void);
+
+ /** Set spatial database for slip rate.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipRate(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for slip initiation time.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh
+ * @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
+ */
+ void initialize(const pylith::topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime =0.0);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ void slip(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t);
+
+ /** Get slip increment on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t0 Time t.
+ * @param t1 Time t+dt.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ void slipIncr(pylith::topology::Field<pylith::topology::SubMesh>* slipField,
+ const double t0,
+ const double t1);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& finalSlip(void);
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& slipTime(void);
+
+ }; // class ConstRateSlipFn
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/EqKinSrc.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/EqKinSrc.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/EqKinSrc.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/EqKinSrc.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/EqKinSrc.i
+ *
+ * @brief Python interface to C++ EqKinSrc object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class EqKinSrc
+ { // class EqKinSrc
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ EqKinSrc(void);
+
+ /// Destructor.
+ ~EqKinSrc(void);
+
+ /** Set origin time for earthquake source.
+ *
+ * @param value Origin time for earthquake source.
+ */
+ void originTime(const double value);
+
+ /** Get origin time for earthquake source.
+ *
+ * @returns Origin time for earthquake source.
+ */
+ double originTime(void) const;
+
+ /** Set slip time function.
+ *
+ * @param slipfn Slip time function.
+ */
+ void slipfn(SlipTimeFn* slipfn);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param normalizer Nondimensionalization of scales.
+ */
+ void initialize(const pylith::topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault mesh.
+ * @param t Time t.
+ */
+ void slip(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t);
+
+ /** Get increment of slip on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip increment field over fault mesh.
+ * @param t0 Time for start of slip increment.
+ * @param t1 Time for end of slip increment.
+ */
+ void slipIncr(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t0,
+ const double t1);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& finalSlip(void) const;
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& slipTime(void) const;
+
+ }; // class EqKinSrc
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/Fault.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/Fault.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/Fault.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/Fault.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/Fault.i
+ *
+ * @brief Python interface to C++ Fault object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class Fault
+ { // class Fault
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ Fault(void);
+
+ /// Destructor.
+ virtual
+ ~Fault(void);
+
+ /** Set material identifier of fault.
+ *
+ * @param value Fault identifier
+ */
+ void id(const int value);
+
+ /** Get material identifier of fault.
+ *
+ * @returns Fault identifier
+ */
+ int id(void) const;
+
+ /** Set label of group of vertices associated with fault.
+ *
+ * @param value Label of fault
+ */
+ void label(const char* value);
+
+ /** Get label of group of vertices associated with fault.
+ *
+ * @returns Label of fault
+ */
+ const char* label(void) const;
+
+ /** Adjust mesh topology for fault implementation.
+ *
+ * @param mesh PETSc mesh
+ */
+ virtual
+ void adjustTopology(pylith::topology::Mesh* const mesh,
+ const bool flipFault =false) = 0;
+
+ /** Initialize fault. Determine orientation and setup boundary
+ * condition parameters.
+ *
+ * @param mesh PETSc mesh
+ * @param cs Coordinate system for mesh
+ * @param upDir Direction perpendicular to along-strike direction that is
+ * not collinear with fault normal (usually "up" direction but could
+ * be up-dip direction; only applies to fault surfaces in a 3-D domain).
+ * @param normalDir General preferred direction for fault normal
+ * (used to pick which of two possible normal directions for
+ * interface; only applies to fault surfaces in a 3-D domain).
+ * @param matDB Database of bulk elastic properties for fault region
+ * (used to improve conditioning of Jacobian matrix)
+ */
+ virtual
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
+ spatialdata::spatialdb::SpatialDB* matDB) = 0;
+
+ /** Get mesh associated with fault fields.
+ *
+ * @returns PETSc mesh object
+ */
+ const pylith::topology::SubMesh& faultMesh(void) const;
+
+ /** Get vertex field associated with integrator.
+ *
+ * @param name Name of vertex field.
+ * @param fields Solution fields.
+ * @returns Vertex field.
+ */
+ virtual
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ vertexField(const char* name,
+ const pylith::topology::SolutionFields* fields =0) = 0;
+
+ /** Get cell field associated with integrator.
+ *
+ * @param name Name of cell field.
+ * @param fields Solution fields.
+ * @returns Cell field.
+ */
+ virtual
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ cellField(const char* name,
+ const pylith::topology::SolutionFields* fields =0) = 0;
+
+ }; // class Fault
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/FaultCohesive.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesive.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/FaultCohesive.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/FaultCohesive.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/FaultCohesive.i
+ *
+ * @brief Python interface to C++ FaultCohesive object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class FaultCohesive : public Fault
+ { // class FaultCohesive
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ FaultCohesive(void);
+
+ /// Destructor.
+ virtual
+ ~FaultCohesive(void);
+
+ /** Set flag for using fault mesh or group of vertices to define
+ * fault surface.
+ *
+ * @param flag True if using fault mesh, false if using vertices.
+ */
+ void useFaultMesh(const bool flag);
+
+ // TEMPORARY
+ /** Set filename of UCD file for fault mesh.
+ *
+ * @param filename Filename for UCD file.
+ */
+ void faultMeshFilename(const char* filename);
+
+ /** Adjust mesh topology for fault implementation.
+ *
+ * @param mesh PETSc mesh.
+ * @param flipFault Flip fault orientation.
+ */
+ void adjustTopology(pylith::topology::Mesh* const mesh,
+ const bool flipFault =false);
+
+ // PROTECTED METHODS //////////////////////////////////////////////////
+ protected :
+
+ /** Cohesive cells use Lagrange multiplier constraints?
+ *
+ * @returns True if implementation using Lagrange multiplier
+ * constraints, false otherwise.
+ */
+ virtual
+ bool _useLagrangeConstraints(void) const = 0;
+
+ }; // class FaultCohesive
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveDyn.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveDyn.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveDyn.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveDyn.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,118 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/FaultCohesiveDyn.i
+ *
+ * @brief Python interface to C++ FaultCohesiveDyn object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class FaultCohesiveDyn : public FaultCohesive,
+ public pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >
+ { // class FaultCohesiveDyn
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ FaultCohesiveDyn(void);
+
+ /// Destructor.
+ virtual
+ ~FaultCohesiveDyn(void);
+
+ /** Initialize fault. Determine orientation and setup boundary
+ * condition parameters.
+ *
+ * @param mesh Finite-element mesh.
+ * @param upDir Direction perpendicular to along-strike direction that is
+ * not collinear with fault normal (usually "up" direction but could
+ * be up-dip direction; only applies to fault surfaces in a 3-D domain).
+ * @param normalDir General preferred direction for fault normal
+ * (used to pick which of two possible normal directions for
+ * interface; only applies to fault surfaces in a 3-D domain).
+ * @param matDB Database of bulk elastic properties for fault region
+ * (used to improve conditioning of Jacobian matrix)
+ */
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
+ spatialdata::spatialdb::SpatialDB* matDB);
+
+ /** Integrate contribution of cohesive cells to residual term.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
+ *
+ * @param jacobian Sparse matrix for Jacobian of system.
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateJacobian(pylith::topology::Jacobian* jacobian,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Verify configuration is acceptable.
+ *
+ * @param mesh Finite-element mesh
+ */
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+
+ /** Get vertex field associated with integrator.
+ *
+ * @param name Name of vertex field.
+ * @param fields Solution fields.
+ *
+ * @returns Vertex field.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ vertexField(const char* name,
+ const pylith::topology::SolutionFields* fields =0);
+
+ /** Get cell field associated with integrator.
+ *
+ * @param name Name of cell field.
+ * @param fields Solution fields.
+ *
+ * @returns Cell field.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ cellField(const char* name,
+ const pylith::topology::SolutionFields* fields =0);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Cohesive cells use Lagrange multiplier constraints?
+ *
+ * @returns True if implementation using Lagrange multiplier
+ * constraints, false otherwise.
+ */
+ bool _useLagrangeConstraints(void) const;
+
+ }; // class FaultCohesiveDyn
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveKin.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/FaultCohesiveKin.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveKin.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/FaultCohesiveKin.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,155 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/FaultCohesiveKin.i
+ *
+ * @brief Python interface to C++ FaultCohesiveKin object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class FaultCohesiveKin : public FaultCohesive,
+ public pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh> >
+ { // class FaultCohesiveKin
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ FaultCohesiveKin(void);
+
+ /// Destructor.
+ virtual
+ ~FaultCohesiveKin(void);
+
+ /** Set kinematic earthquake sources.
+ *
+ * @param names Array of kinematic earthquake source names.
+ * @param numNames Number of earthquake sources.
+ * @param sources Array of kinematic earthquake sources.
+ * @param numSources Number of earthquake sources.
+ */
+ %apply(const char* const* string_list, const int list_len){
+ (const char* const* names,
+ const int numNames)
+ };
+ void eqsrcs(const char* const* names,
+ const int numNames,
+ EqKinSrc** sources,
+ const int numSources);
+
+ /** Initialize fault. Determine orientation and setup boundary
+ * condition parameters.
+ *
+ * @param mesh Finite-element mesh.
+ * @param upDir Direction perpendicular to along-strike direction that is
+ * not collinear with fault normal (usually "up" direction but could
+ * be up-dip direction; only applies to fault surfaces in a 3-D domain).
+ * @param normalDir General preferred direction for fault normal
+ * (used to pick which of two possible normal directions for
+ * interface; only applies to fault surfaces in a 3-D domain).
+ * @param matDB Database of bulk elastic properties for fault region
+ * (used to improve conditioning of Jacobian matrix)
+ */
+ void initialize(const pylith::topology::Mesh& mesh,
+ const double upDir[3],
+ const double normalDir[3],
+ spatialdata::spatialdb::SpatialDB* matDB);
+
+ /** Integrate contributions to residual term (r) for operator that
+ * require assembly across processors.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to residual term (r) for operator that
+ * do not require assembly across cells, vertices, or processors.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateResidualAssembled(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator that do not require assembly across cells, vertices, or
+ * processors.
+ *
+ * @param mat Sparse matrix
+ * @param t Current time
+ * @param fields Solution fields
+ * @param mesh Finite-element mesh
+ */
+ void integrateJacobianAssembled(pylith::topology::Jacobian* jacobian,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Update state variables as needed.
+ *
+ * @param t Current time
+ * @param fields Solution fields
+ * @param mesh Finite-element mesh
+ */
+ void updateStateVars(const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Verify configuration is acceptable.
+ *
+ * @param mesh Finite-element mesh
+ */
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+
+ /** Get vertex field associated with integrator.
+ *
+ * @param name Name of cell field.
+ * @param fields Solution fields.
+ * @returns Vertex field.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ vertexField(const char* name,
+ const pylith::topology::SolutionFields* fields =0);
+
+ /** Get cell field associated with integrator.
+ *
+ * @param name Name of cell field.
+ * @param fields Solution fields.
+ * @returns Cell field.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>&
+ cellField(const char* name,
+ const pylith::topology::SolutionFields* fields =0);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Cohesive cells use Lagrange multiplier constraints?
+ *
+ * @returns True if implementation using Lagrange multiplier
+ * constraints, false otherwise.
+ */
+ bool _useLagrangeConstraints(void) const;
+
+ }; // class FaultCohesiveKin
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/LiuCosSlipFn.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/LiuCosSlipFn.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/LiuCosSlipFn.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/LiuCosSlipFn.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,104 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/LiuCosSlipFn.i
+ *
+ * @brief Python interface to C++ Fault object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class LiuCosSlipFn : public SlipTimeFn
+ { // class LiuCosSlipFn
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ LiuCosSlipFn(void);
+
+ /// Destructor.
+ ~LiuCosSlipFn(void);
+
+ /** Set spatial database for final slip.
+ *
+ * @param db Spatial database
+ */
+ void dbFinalSlip(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for slip initiation time.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for rise time. The rise time is the time it
+ * takes for the slip to increase from 0.0 to 0.95 of the final
+ * value.
+ *
+ * @param db Spatial database
+ */
+ void dbRiseTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh
+ * @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
+ */
+ void initialize(const pylith::topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime =0.0);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ void slip(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t);
+
+ /** Get slip increment on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t0 Time t.
+ * @param t1 Time t+dt.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ void slipIncr(pylith::topology::Field<pylith::topology::SubMesh>* slipField,
+ const double t0,
+ const double t1);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& finalSlip(void);
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& slipTime(void);
+
+ }; // class LiuCosSlipFn
+
+ } // faults
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/faults/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,40 +13,56 @@
subpackage = faults
include $(top_srcdir)/subpackage.am
-subpkgpyexec_LTLIBRARIES = faultsmodule.la
+subpkgpyexec_LTLIBRARIES = _faultsmodule.la
-faultsmodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = faults.py
+
+swig_sources = \
+ faults.i \
+ SlipTimeFn.i \
+ ConstRateSlipFn.i \
+ StepSlipFn.i \
+ BruneSlipFn.i \
+ LiuCosSlipFn.i \
+ EqKinSrc.i \
+ Fault.i \
+ FaultCohesive.i \
+ FaultCohesiveDyn.i \
+ FaultCohesiveKin.i \
+ ../topology/SubMesh.i \
+ ../feassemble/Quadrature.i \
+ ../feassemble/Integrator.i
+
+swig_generated = \
+ faults_wrap.cxx \
+ faults.py
+
+_faultsmodule_la_LDFLAGS = -module -avoid-version \
$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_faultsmodule_la_SOURCES = faults.pyxe.src
-nodist_faultsmodule_la_SOURCES = \
- faults.pyxe \
- faults.c faults_embed.cpp faults_embed.h
+dist__faultsmodule_la_SOURCES = $(swig_sources) $(swig_generated)
-faultsmodule_la_LIBADD = \
+_faultsmodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
-lspatialdata \
- $(PETSC_LIB)
-
+ $(PETSC_LIBS)
if ENABLE_CUBIT
- faultsmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
+ _faultsmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
endif
if NO_UNDEFINED
- faultsmodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_faultsmodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-faults.pyx faults_embed.cpp faults_embed.h: faults.pyxe
- pyrexembed faults.pyxe
-faults.pyxe: $(srcdir)/faults.pyxe.src
- cp $(srcdir)/faults.pyxe.src $@
-faults_embed.cpp: faults_embed.h
-faults_embed.h: faults.pyx
+$(srcdir)/faults_wrap.cxx $(srcdir)/faults.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-.pyx.c:
- pyrexc $<
-CLEANFILES = faults.pyxe faults.pyx faults.c *_embed.*
+MAINTAINERCLEANFILES = \
+ $(srcdir)/faults_wrap.cxx \
+ $(srcdir)/faults.py
+
# End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/SlipTimeFn.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/SlipTimeFn.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/SlipTimeFn.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/SlipTimeFn.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/SlipTimeFn.i
+ *
+ * @brief Python interface to C++ Fault object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class SlipTimeFn
+ { // class SlipTimeFn
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ SlipTimeFn(void);
+
+ /// Destructor.
+ virtual
+ ~SlipTimeFn(void);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh
+ * @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
+ */
+ virtual
+ void initialize(const pylith::topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime =0.0) = 0;
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ virtual
+ void slip(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t) = 0;
+
+ /** Get slip increment on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t0 Time t.
+ * @param t1 Time t+dt.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ virtual
+ void slipIncr(pylith::topology::Field<pylith::topology::SubMesh>* slipField,
+ const double t0,
+ const double t1) = 0;
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ virtual
+ const pylith::topology::Field<pylith::topology::SubMesh>& finalSlip(void) = 0;
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ virtual
+ const pylith::topology::Field<pylith::topology::SubMesh>& slipTime(void) = 0;
+
+ }; // class SlipTimeFn
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/StepSlipFn.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/StepSlipFn.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/StepSlipFn.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/StepSlipFn.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,96 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/faults/StepSlipFn.i
+ *
+ * @brief Python interface to C++ Fault object.
+ */
+
+namespace pylith {
+ namespace faults {
+
+ class StepSlipFn : public SlipTimeFn
+ { // class StepSlipFn
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ StepSlipFn(void);
+
+ /// Destructor.
+ ~StepSlipFn(void);
+
+ /** Set spatial database for final slip.
+ *
+ * @param db Spatial database
+ */
+ void dbFinalSlip(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Set spatial database for slip initiation time.
+ *
+ * @param db Spatial database
+ */
+ void dbSlipTime(spatialdata::spatialdb::SpatialDB* const db);
+
+ /** Initialize slip time function.
+ *
+ * @param faultMesh Finite-element mesh of fault.
+ * @param cs Coordinate system for mesh
+ * @param normalizer Nondimensionalization of scales.
+ * @param originTime Origin time for earthquake source.
+ */
+ void initialize(const pylith::topology::SubMesh& faultMesh,
+ const spatialdata::units::Nondimensional& normalizer,
+ const double originTime =0.0);
+
+ /** Get slip on fault surface at time t.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t Time t.
+ *
+ * @returns Slip vector as left-lateral/reverse/normal.
+ */
+ void slip(pylith::topology::Field<pylith::topology::SubMesh>* const slipField,
+ const double t);
+
+ /** Get slip increment on fault surface between time t0 and t1.
+ *
+ * @param slipField Slip field over fault surface.
+ * @param t0 Time t.
+ * @param t1 Time t+dt.
+ *
+ * @returns Increment in slip vector as left-lateral/reverse/normal.
+ */
+ void slipIncr(pylith::topology::Field<pylith::topology::SubMesh>* slipField,
+ const double t0,
+ const double t1);
+
+ /** Get final slip.
+ *
+ * @returns Final slip.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& finalSlip(void);
+
+ /** Get time when slip begins at each point.
+ *
+ * @returns Time when slip begins.
+ */
+ const pylith::topology::Field<pylith::topology::SubMesh>& slipTime(void);
+
+ }; // class StepSlipFn
+
+ } // faults
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/faults/faults.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/faults/faults.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module faults
+
+// Header files for module C++ code
+%{
+#include "pylith/faults/SlipTimeFn.hh"
+#include "pylith/faults/StepSlipFn.hh"
+#include "pylith/faults/ConstRateSlipFn.hh"
+#include "pylith/faults/BruneSlipFn.hh"
+#include "pylith/faults/LiuCosSlipFn.hh"
+#include "pylith/faults/EqKinSrc.hh"
+#include "pylith/faults/Fault.hh"
+#include "pylith/faults/FaultCohesive.hh"
+#include "pylith/faults/FaultCohesiveDyn.hh"
+#include "pylith/faults/FaultCohesiveKin.hh"
+
+#include "pylith/topology/SubMesh.hh"
+#include "pylith/feassemble/Quadrature.hh"
+#include "pylith/feassemble/Integrator.hh"
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+%include "../include/doublearray.i"
+%include "../include/chararray.i"
+%include "../include/eqkinsrcarray.i"
+
+// Numpy interface stuff
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "../include/numpy.i"
+%init %{
+import_array();
+%}
+
+// Interfaces
+%include "../topology/SubMesh.i" // ISA Integrator<Quadrature<SubMesh> >
+%include "../feassemble/Quadrature.i" // ISA Integrator<Quadrature<SubMesh> >
+%include "../feassemble/Integrator.i" // ISA Integrator<Quadrature<SubMesh> >
+
+// Template instatiation
+%template(SubMeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::SubMesh > >;
+
+%include "SlipTimeFn.i"
+%include "StepSlipFn.i"
+%include "ConstRateSlipFn.i"
+%include "BruneSlipFn.i"
+%include "LiuCosSlipFn.i"
+%include "EqKinSrc.i"
+%include "Fault.i"
+%include "FaultCohesive.i"
+%include "FaultCohesiveDyn.i"
+%include "FaultCohesiveKin.i"
+
+// End of file
+
Modified: short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/faults/faults.pyxe.src 2009-05-04 23:09:34 UTC (rev 14863)
@@ -533,7 +533,7 @@
PetscMat* mat = (PetscMat*) matVptr;
pylith::topology::FieldsManager* fields =
(pylith::topology::FieldsManager*) fieldsVptr;
- ((pylith::faults::FaultCohesiveKin*) objVptr)->integrateJacobian(
+ ((pylith::faults::FaultCohesiveKin*) objVptr)->integrateJacobianAssembled(
mat, t, fields, *mesh);
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
@@ -776,9 +776,11 @@
#embed{ void FaultCohesiveKin_quadrature_set(void* objVptr, void* qVptr)
try {
assert(0 != objVptr);
+#if TODO
pylith::feassemble::Quadrature* quadrature =
(pylith::feassemble::Quadrature*) qVptr;
((pylith::faults::FaultCohesiveKin*) objVptr)->quadrature(quadrature);
+#endif
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -808,7 +810,9 @@
assert(0 != dimVptr);
spatialdata::units::Nondimensional* dim =
(spatialdata::units::Nondimensional*) dimVptr;
+#ifdef TODO
((pylith::faults::FaultCohesiveKin*) objVptr)->normalizer(*dim);
+#endif
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -836,7 +840,9 @@
#embed{ void FaultCohesiveKin_timeStep_set(void* objVptr, double dt)
try {
assert(0 != objVptr);
+#ifdef TODO
((pylith::faults::FaultCohesiveKin*) objVptr)->timeStep(dt);
+#endif
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -861,8 +867,10 @@
double result = 0.0;
try {
assert(0 != objVptr);
+#ifdef TODO
result =
((pylith::faults::FaultCohesiveKin*) objVptr)->stableTimeStep();
+#endif
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -888,8 +896,10 @@
int result = 0;
try {
assert(0 != objVptr);
+#ifdef TODO
result =
((pylith::faults::FaultCohesiveKin*) objVptr)->needNewJacobian();
+#endif
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
@@ -914,7 +924,9 @@
#embed{ void FaultCohesiveKin_useSolnIncr_set(void* objVptr, int flag)
try {
assert(0 != objVptr);
+#ifdef TODO
((pylith::faults::FaultCohesiveKin*) objVptr)->useSolnIncr(flag);
+#endif
} catch (const std::exception& err) {
PyErr_SetString(PyExc_RuntimeError,
const_cast<char*>(err.what()));
Property changes on: short/3D/PyLith/trunk/modulesrc/feassemble
___________________________________________________________________
Name: svn:ignore
+ Makefile.am
feassemble.py
feassemble_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/CellGeometry.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/CellGeometry.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/CellGeometry.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/CellGeometry.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,160 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/CellGeometry.i
+ *
+ * @brief Python interface to C++ CellGeometry object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class CellGeometry
+ { // CellGeometry
+
+ // PUBLIC ENUMS ///////////////////////////////////////////////////
+ public :
+
+ enum ShapeEnum {
+ POINT=0, // 0-D point cell
+ LINE=2, // 1-D line cell (2 points)
+ TRIANGLE=4, // 2-D triangular cell (3 edges)
+ QUADRILATERAL=5, // 2-D quadrilateral cell (4 edges)
+ TETRAHEDRON=16, // 3-D tetrahedral cell (4 faces)
+ HEXAHEDRON=17 // 3-D hexahedral cell (6 faces)
+ };
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param shape String identifying shape of cell
+ * @param spaceDim Dimension of coordinate space.
+ */
+ CellGeometry(const ShapeEnum shape,
+ const int spaceDim);
+
+ /// Default destructor.
+ virtual
+ ~CellGeometry(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ virtual
+ CellGeometry* clone(void) const = 0;
+
+ /** Get dimension of cell.
+ *
+ * @returns Spatial dimension of cell.
+ */
+ int cellDim(void) const;
+
+ /** Get dimension of coordinate space.
+ *
+ * @returns Dimension of coordinate space.
+ */
+ int spaceDim(void) const;
+
+ /** Get number of vertices in cell.
+ *
+ * @returns Number of vertices in cell.
+ */
+ int numCorners(void) const;
+
+ /** Get coordinates of vertices in reference cell (dual basis).
+ *
+ * @returns Array of coordinates of vertices in reference cell
+ */
+ const pylith::double_array& vertices(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ virtual
+ CellGeometry* geometryLowerDim(void) const = 0;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ virtual
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts) const = 0;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ virtual
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const = 0;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ virtual
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts) const = 0;
+
+ /** Compute orientation of cell at location.
+ *
+ * The orientation is returned as an array of direction cosines
+ * weighted by the determinant of the Jacobian.
+ *
+ * size = spaceDim*spaceDim
+ * index = iDir*spaceDim + iComponent
+ *
+ * @param orientation Array of direction cosines (weighted by Jacobian).
+ * @param jacobian Jacobian matrix at point.
+ * @param jacobianDet Determinant of Jacobian matrix at point.
+ * @param upDir Direction perpendicular to horizontal direction that is
+ * not collinear with cell normal (usually "up" direction).
+ */
+ void orientation(pylith::double_array* orientation,
+ const pylith::double_array& jacobian,
+ const double jacobianDet,
+ const pylith::double_array& upDir) const;
+
+ }; // CellGeometry
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/Constraint.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/Constraint.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/Constraint.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/Constraint.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/feassemble/Constraint.i
+ *
+ * @brief Python interface to C++ abstract base Constraint.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class Constraint
+ { // class Constraint
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ Constraint(void);
+
+ /// Destructor.
+ virtual
+ ~Constraint(void);
+
+ /** Set manager of scales used to nondimensionalize problem.
+ *
+ * @param dim Nondimensionalizer.
+ */
+ void normalizer(const spatialdata::units::Nondimensional& dim);
+
+ /** Set number of degrees of freedom that are constrained at
+ * points in field.
+ *
+ * @param field Solution field
+ */
+ virtual
+ void setConstraintSizes(const pylith::topology::Field<pylith::topology::Mesh>& field) = 0;
+
+ /** Set which degrees of freedom are constrained at points in field.
+ *
+ * @param field Solution field
+ */
+ virtual
+ void setConstraints(const pylith::topology::Field<pylith::topology::Mesh>& field) = 0;
+
+ /** Set flag for setting constraints for total field solution or
+ * incremental field solution.
+ *
+ * @param flag True if using incremental solution, false otherwise.
+ */
+ virtual
+ void useSolnIncr(const bool flag);
+
+ /** Set values in field.
+ *
+ * @param t Current time
+ * @param field Solution field
+ */
+ virtual
+ void setField(const double t,
+ const pylith::topology::Field<pylith::topology::Mesh>& field) = 0;
+
+ }; // class Constraint
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityExplicit.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/ElasticityExplicit.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityExplicit.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityExplicit.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/feassemble/ElasticityExplicit.i
+ *
+ * @brief Python interface to C++ ElasticityExplicit object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class ElasticityExplicit : public IntegratorElasticity
+ { // ElasticityExplicit
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ ElasticityExplicit(void);
+
+ /// Destructor
+ ~ElasticityExplicit(void);
+
+ /** Set time step for advancing from time t to time t+dt.
+ *
+ * @param dt Time step
+ */
+ void timeStep(const double dt);
+
+ /** Set flag for setting constraints for total field solution or
+ * incremental field solution.
+ *
+ * @param flag True if using incremental solution, false otherwise.
+ */
+ void useSolnIncr(const bool flag);
+
+ /** Integrate contributions to residual term (r) for operator.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
+ *
+ * @param jacobian Sparse matrix for Jacobian of system.
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateJacobian(pylith::topology::Jacobian* jacobian,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ }; // ElasticityExplicit
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityImplicit.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/ElasticityImplicit.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityImplicit.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/ElasticityImplicit.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,90 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/feassemble/ElasticityImplicit.i
+ *
+ * @brief Python interface to C++ ElasticityImplicit object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class ElasticityImplicit : public IntegratorElasticity
+ { // ElasticityImplicit
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ ElasticityImplicit(void);
+
+ /// Destructor
+ ~ElasticityImplicit(void);
+
+ /** Set time step for advancing from time t to time t+dt.
+ *
+ * @param dt Time step
+ */
+ void timeStep(const double dt);
+
+ /** Get stable time step for advancing from time t to time t+dt.
+ *
+ * Default is current time step.
+ *
+ * @param mesh Finite-element mesh.
+ * @returns Time step
+ */
+ double stableTimeStep(const pylith::topology::Mesh& mesh);
+
+ /** Set flag for setting constraints for total field solution or
+ * incremental field solution.
+ *
+ * @param flag True if using incremental solution, false otherwise.
+ */
+ void useSolnIncr(const bool flag);
+
+ /** Integrate residual part of RHS for 3-D finite elements.
+ * Includes gravity and element internal force contribution.
+ *
+ * We assume that the effects of boundary conditions are already
+ * included in the residual (tractions, concentrated nodal forces,
+ * and contributions to internal force vector due to
+ * displacement/velocity BC). This routine computes the additional
+ * external loads due to body forces plus the
+ * element internal forces for the current stress state.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
+ *
+ * @param jacobian Sparse matrix for Jacobian of system.
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ void integrateJacobian(pylith::topology::Jacobian* jacobian,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ }; // ElasticityImplicit
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryHex3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryHex3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryHex3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryHex3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryHex3D.i
+ *
+ * @brief Python interface to C++ GeometryHex3D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryHex3D : public CellGeometry
+ { // GeometryHex3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryHex3D(void);
+
+ /// Default destructor.
+ ~GeometryHex3D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryHex3D
+
+ } // feassemble
+} // pylith
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine1D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryLine1D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine1D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine1D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryLine1D.i
+ *
+ * @brief Python interface to C++ GeometryLine1D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryLine1D : public CellGeometry
+ { // GeometryLine1D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryLine1D(void);
+
+ /// Default destructor.
+ ~GeometryLine1D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryLine1D
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine2D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryLine2D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine2D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine2D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryLine2D.i
+ *
+ * @brief Python interface to C++ GeometryLine2D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryLine2D : public CellGeometry
+ { // GeometryLine2D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryLine2D(void);
+
+ /// Default destructor.
+ ~GeometryLine2D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryLine2D
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryLine3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryLine3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryLine3D.i
+ *
+ * @brief Python interface to C++ GeometryLine3D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryLine3D : public CellGeometry
+ { // GeometryLine3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryLine3D(void);
+
+ /// Default destructor.
+ ~GeometryLine3D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryLine3D
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint1D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryPoint1D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint1D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint1D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryPoint1D.i
+ *
+ * @brief Python interface to C++ GeometryPoint1D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryPoint1D : public CellGeometry
+ { // GeometryPoint1D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryPoint1D(void);
+
+ /// Default destructor.
+ ~GeometryPoint1D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryPoint1D
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint2D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryPoint2D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint2D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint2D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryPoint2D.i
+ *
+ * @brief Python interface to C++ GeometryPoint2D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryPoint2D : public CellGeometry
+ { // GeometryPoint2D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryPoint2D(void);
+
+ /// Default destructor.
+ ~GeometryPoint2D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryPoint2D
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryPoint3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryPoint3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryPoint3D.i
+ *
+ * @brief Python interface to C++ GeometryPoint3D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryPoint3D : public CellGeometry
+ { // GeometryPoint3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryPoint3D(void);
+
+ /// Default destructor.
+ ~GeometryPoint3D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryPoint3D
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad2D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryQuad2D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad2D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad2D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryQuad2D.i
+ *
+ * @brief Python interface to C++ GeometryQuad2D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryQuad2D : public CellGeometry
+ { // GeometryQuad2D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryQuad2D(void);
+
+ /// Default destructor.
+ ~GeometryQuad2D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryQuad2D
+
+ } // feassemble
+} // pylith
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryQuad3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryQuad3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryQuad3D.i
+ *
+ * @brief Python interface to C++ GeometryQuad3D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryQuad3D : public CellGeometry
+ { // GeometryQuad3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryQuad3D(void);
+
+ /// Default destructor.
+ ~GeometryQuad3D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryQuad3D
+
+ } // feassemble
+} // pylith
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTet3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryTet3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTet3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTet3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryTet3D.i
+ *
+ * @brief Python interface to C++ GeometryTet3D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryTet3D : public CellGeometry
+ { // GeometryTet3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryTet3D(void);
+
+ /// Default destructor.
+ ~GeometryTet3D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryTet3D
+
+ } // feassemble
+} // pylith
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri2D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryTri2D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri2D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri2D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryTri2D.i
+ *
+ * @brief Python interface to C++ GeometryTri2D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryTri2D : public CellGeometry
+ { // GeometryTri2D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryTri2D(void);
+
+ /// Default destructor.
+ ~GeometryTri2D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryTri2D
+
+ } // feassemble
+} // pylith
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/GeometryTri3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/GeometryTri3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/GeometryTri3D.i
+ *
+ * @brief Python interface to C++ GeometryTri3D object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class GeometryTri3D : public CellGeometry
+ { // GeometryTri3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ GeometryTri3D(void);
+
+ /// Default destructor.
+ ~GeometryTri3D(void);
+
+ /** Create a copy of geometry.
+ *
+ * @returns Copy of geometry.
+ */
+ CellGeometry* clone(void) const;
+
+ /** Get cell geometry for lower dimension cell.
+ *
+ * @returns Pointer to cell geometry object corresponding to next
+ * lower dimension, NULL if there is no lower dimension object.
+ */
+ CellGeometry* geometryLowerDim(void) const;
+
+ /** Transform coordinates in reference cell to global coordinates.
+ *
+ * @param ptsGlobal Array of points in global coordinate system.
+ * @param ptsRef Array of points in reference cell.
+ * @param vertices Array of cell vertices in global coordinates.
+ * @param dim Dimension of global coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void ptsRefToGlobal(double* ptsGlobal,
+ const double* ptsRef,
+ const double* vertices,
+ const int dim,
+ const int npts =1) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param location Location in reference cell at which to compute Jacobian.
+ */
+ void jacobian(pylith::double_array* jacobian,
+ double* det,
+ const pylith::double_array& vertices,
+ const pylith::double_array& location) const;
+
+ /** Compute Jacobian at location in cell.
+ *
+ * @param jacobian Jacobian at location.
+ * @param det Determinant of Jacobian at location.
+ * @param vertices Coordinates of vertices of cell.
+ * @param ptsRef Points in reference cell at which to compute Jacobian.
+ * @param dim Dimension of coordinate system.
+ * @param npts Number of points to transform.
+ */
+ void jacobian(double* jacobian,
+ double* det,
+ const double* vertices,
+ const double* ptsRef,
+ const int dim,
+ const int npts =1) const;
+
+ }; // GeometryTri3D
+
+ } // feassemble
+} // pylith
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/Integrator.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/Integrator.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/Integrator.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/Integrator.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,165 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/feassemble/Integrator.i
+ *
+ * @brief Python interface to C++ abstract Integrator object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ template<typename quadrature_type>
+ class Integrator
+ { // Integrator
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ Integrator(void);
+
+ /// Destructor
+ virtual
+ ~Integrator(void);
+
+ /** Set quadrature for integrating finite-element
+ * quantities. Quadrature should already be initialized.
+ *
+ * @param q Quadrature for integrating.
+ */
+ void quadrature(const quadrature_type* q);
+
+ /** Set manager of scales used to nondimensionalize problem.
+ *
+ * @param dim Nondimensionalizer.
+ */
+ void normalizer(const spatialdata::units::Nondimensional& dim);
+
+ /** Set gravity field.
+ *
+ * @param g Gravity field.
+ */
+ void gravityField(spatialdata::spatialdb::GravityField* const gravityField);
+
+ /** Set time step for advancing from time t to time t+dt.
+ *
+ * @param dt Time step
+ */
+ virtual
+ void timeStep(const double dt);
+
+ /** Get stable time step for advancing from time t to time t+dt.
+ *
+ * Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
+ *
+ * @param mesh Finite-element mesh.
+ * @returns Time step
+ */
+ virtual
+ double stableTimeStep(const pylith::topology::Mesh& mesh);
+
+ /** Check whether Jacobian needs to be recomputed.
+ *
+ * @returns True if Jacobian needs to be recomputed, false otherwise.
+ */
+ virtual
+ bool needNewJacobian(void) const;
+
+ /** Set flag for setting constraints for total field solution or
+ * incremental field solution.
+ *
+ * @param flag True if using incremental solution, false otherwise.
+ */
+ virtual
+ void useSolnIncr(const bool flag);
+
+ /** Initialize integrator.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ virtual
+ void initialize(const pylith::topology::Mesh& mesh);
+
+ /** Integrate contributions to residual term (r) for operator.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ virtual
+ void integrateResidual(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator.
+ *
+ * @param jacobian Sparse matrix for Jacobian of system.
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ virtual
+ void integrateJacobian(pylith::topology::Jacobian* jacobian,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to residual term (r) for operator that
+ * do not require assembly over cells, vertices, or processors.
+ *
+ * @param residual Field containing values for residual
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ virtual
+ void integrateResidualAssembled(const pylith::topology::Field<pylith::topology::Mesh>& residual,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Integrate contributions to Jacobian matrix (A) associated with
+ * operator that do not require assembly over cells, vertices, or
+ * processors
+ *
+ * @param jacobian Sparse matrix for Jacobian of system.
+ * @param t Current time
+ * @param fields Solution fields
+ */
+ virtual
+ void integrateJacobianAssembled(pylith::topology::Jacobian* jacobian,
+ const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Update state variables as needed.
+ *
+ * @param t Current time
+ * @param fields Solution fields
+ * @param mesh Finite-element mesh
+ */
+ virtual
+ void updateStateVars(const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Verify configuration is acceptable.
+ *
+ * @param mesh Finite-element mesh
+ */
+ virtual
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const = 0;
+
+
+ }; // Integrator
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/IntegratorElasticity.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/IntegratorElasticity.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/IntegratorElasticity.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/IntegratorElasticity.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,94 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/feassemble/Integrator.i
+ *
+ * @brief Python interface to C++ abstract Integrator object.
+ */
+
+%template(MeshIntegrator) pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::Mesh> >;
+
+namespace pylith {
+ namespace feassemble {
+
+ class IntegratorElasticity :
+ public pylith::feassemble::Integrator<pylith::feassemble::Quadrature<pylith::topology::Mesh> >
+ { // IntegratorElasticity
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ IntegratorElasticity(void);
+
+ /// Destructor
+ ~IntegratorElasticity(void);
+
+ /** Set material.
+ *
+ * @param m Elastic material.
+ */
+ void material(pylith::materials::ElasticMaterial* m);
+
+ /** Determine whether we need to recompute the Jacobian.
+ *
+ * @returns True if Jacobian needs to be recomputed, false otherwise.
+ */
+ bool needNewJacobian(void);
+
+ /** Set flag for setting constraints for total field solution or
+ * incremental field solution.
+ *
+ * @param flag True if using incremental solution, false otherwise.
+ */
+ void useSolnIncr(const bool flag);
+
+ /** Initialize integrator.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ void initialize(const pylith::topology::Mesh& mesh);
+
+ /** Update state variables as needed.
+ *
+ * @param t Current time
+ * @param fields Solution fields
+ * @param mesh Finite-element mesh
+ */
+ void updateStateVars(const double t,
+ pylith::topology::SolutionFields* const fields);
+
+ /** Verify configuration is acceptable.
+ *
+ * @param mesh Finite-element mesh
+ */
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+
+ /** Get cell field associated with integrator.
+ *
+ * @param name Name of vertex field.
+ * @param mesh Finite-element mesh for problem.
+ * @param fields Fields manager.
+ * @returns Cell field.
+ */
+ const pylith::topology::Field<pylith::topology::Mesh>&
+ cellField(const char* name,
+ const pylith::topology::Mesh& mesh,
+ pylith::topology::SolutionFields* const fields =0);
+
+ }; // IntegratorElasticity
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,40 +13,58 @@
subpackage = feassemble
include $(top_srcdir)/subpackage.am
-subpkgpyexec_LTLIBRARIES = feassemblemodule.la
+subpkgpyexec_LTLIBRARIES = _feassemblemodule.la
-feassemblemodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = feassemble.py
+
+swig_sources = \
+ feassemble.i \
+ CellGeometry.i \
+ GeometryPoint1D.i \
+ GeometryPoint2D.i \
+ GeometryPoint3D.i \
+ GeometryLine1D.i \
+ GeometryLine2D.i \
+ GeometryLine3D.i \
+ GeometryTri2D.i \
+ GeometryTri3D.i \
+ QuadratureRefCell.i \
+ Quadrature.i \
+ Integrator.i \
+ IntegratorElasticity.i \
+ ElasticityImplicit.i \
+ ElasticityExplicit.i
+
+swig_generated = \
+ feassemble_wrap.cxx \
+ feassemble.py
+
+_feassemblemodule_la_LDFLAGS = -module -avoid-version \
$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_feassemblemodule_la_SOURCES = feassemble.pyxe.src
-nodist_feassemblemodule_la_SOURCES = \
- feassemble.pyxe \
- feassemble.c feassemble_embed.cpp feassemble_embed.h
+dist__feassemblemodule_la_SOURCES = $(swig_sources) $(swig_generated)
-feassemblemodule_la_LIBADD = \
+_feassemblemodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
-lspatialdata \
- $(PETSC_LIB)
-
+ $(PETSC_LIBS)
if ENABLE_CUBIT
- feassemblemodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
+ _feassemblemodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
endif
if NO_UNDEFINED
- feassemblemodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_feassemblemodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-feassemble.pyx feassemble_embed.cpp feassemble_embed.h: feassemble.pyxe
- pyrexembed feassemble.pyxe
-feassemble.pyxe: $(srcdir)/feassemble.pyxe.src
- cp $(srcdir)/feassemble.pyxe.src $@
-feassemble_embed.cpp: feassemble_embed.h
-feassemble_embed.h: feassemble.pyx
+$(srcdir)/feassemble_wrap.cxx $(srcdir)/feassemble.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-.pyx.c:
- pyrexc $<
-CLEANFILES = feassemble.pyxe feassemble.pyx feassemble.c *_embed.*
+MAINTAINERCLEANFILES = \
+ $(srcdir)/feassemble_wrap.cxx \
+ $(srcdir)/feassemble.py
+
# End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/Quadrature.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/Quadrature.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/Quadrature.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/Quadrature.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/Quadrature.i
+ *
+ * @brief Python interface to C++ Quadrature object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ template<typename mesh_type>
+ class Quadrature : public QuadratureRefCell
+ { // Quadrature
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ Quadrature(void);
+
+ /// Destructor
+ ~Quadrature(void);
+
+ /** Copy constructor.
+ *
+ * @param q Quadrature to copy
+ */
+ Quadrature(const Quadrature& q);
+
+ /** Set flag for checking ill-conditioning.
+ *
+ * @param flag True to check for ill-conditioning, false otherwise.
+ */
+ void checkConditioning(const bool flag);
+
+ /** Get flag for checking ill-conditioning.
+ *
+ * @returns True if checking for ill-conditioning, false otherwise.
+ */
+ bool checkConditioning(void) const;
+
+ /// Deallocate temporary storage.
+ void clear(void);
+
+ }; // Quadrature
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/QuadratureRefCell.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/QuadratureRefCell.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,187 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/** @file modulesrc/feassemble/Quadrature.i
+ *
+ * @brief Python interface to C++ Quadrature object.
+ */
+
+namespace pylith {
+ namespace feassemble {
+
+ class QuadratureRefCell
+ { // Quadrature
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ QuadratureRefCell(void);
+
+ /// Destructor
+ ~QuadratureRefCell(void);
+
+ /** Set basis functions and their derivatives, and coordinates and
+ * weights of the quadrature points.
+ *
+ * @param basis Array of basis functions evaluated at quadrature pts
+ * N0Qp0, N1Qp0, ...
+ * N0Qp1, N1Qp1, ...
+ * ...
+ * size = numQuadPts * numBasis
+ * index = iQuadPt*numBasis + iBasis
+ *
+ * @param basisDerivRef Array of basis function derivaties evaluated at
+ * quadrature pts, where derivatives are with respect to cell's
+ * local coordinates.
+ * N0pQp0, N0qQp0, N0rQp0, N1pQp0, N1qQp0, N1rQp0, ...
+ * N0pQp1, N0qQp1, N0rQp1, N1pQp1, N1qQp1, N1rQp1, ...
+ * ...
+ * size = numQuadPts * numBasis * cellDim
+ * index = iQuadPt*numBasis*cellDim + iBasis*cellDim + iDim
+ *
+ * @param quadPts Array of coordinates of quadrature points in
+ * reference cell
+ * Qp0p, Qp0q, Qp0r
+ * Qp1p, Qp1q, Qp1r
+ * size = numQuadPts * numDims
+ * index = iQuadPt*numDims + iDim
+ *
+ * @param quadWts Array of weights of quadrature points
+ * WtQp0, WtQp1, ...
+ * index = iQuadPt
+ *
+ * @param cellDim Number of dimensions in reference cell
+ * @param numBasis Number of basis functions for a cell
+ * @param numQuadPts Number of quadrature points
+ * @param spaceDim Number of dimensions in coordinates of cell vertices
+ */
+ %apply(double* IN_ARRAY2, int DIM1, int DIM2) {
+ (const double* basis,
+ const int numQuadPts1,
+ const int numBasis1)
+ };
+ %apply(double* IN_ARRAY3, int DIM1, int DIM2, int DIM3) {
+ (const double* basisDerivRef,
+ const int numQuadPts2,
+ const int numBasis2,
+ const int cellDim2)
+ };
+ %apply(double* IN_ARRAY2, int DIM1, int DIM2) {
+ (const double* quadPtsRef,
+ const int numQuadPts3,
+ const int cellDim3)
+ };
+ %apply(double* IN_ARRAY1, int DIM1) {
+ (const double* quadWts,
+ const int numQuadPts4)
+ };
+ void initialize(const double* basis,
+ const int numQuadPts1,
+ const int numBasis1,
+ const double* basisDerivRef,
+ const int numQuadPts2,
+ const int numBasis2,
+ const int cellDim2,
+ const double* quadPtsRef,
+ const int numQuadPts3,
+ const int cellDim3,
+ const double* quadWts,
+ const int numQuadPts4,
+ const int spaceDim);
+ %clear(const double* basis, const int numQuadPts, const int numBasis);
+ %clear(const double* basisDerivRef, const int numQuadPts,
+ const int numBasis, const int spaceDim);
+ %clear(const double* quadPtsRef, const int numQuadPts,
+ const int cellDim);
+ %clear(const double* quadWts, const int numQuadPts);
+
+ /** Set geometry associated with reference cell.
+ *
+ * @param geometry Geometry of reference cell.
+ */
+ void refGeometry(CellGeometry* const geometry);
+
+ /** Get geometry associated with reference cell.
+ *
+ * @returns Geometry of reference cell.
+ */
+ const CellGeometry& refGeometry(void) const;
+
+ /** Set minimum allowable determinant of Jacobian.
+ *
+ * @param tolerance Minimum allowable value for Jacobian
+ */
+ void minJacobian(const double min);
+
+ /** Get minimum allowable determinant of Jacobian.
+ *
+ * @returns Minimum allowable value for Jacobian
+ */
+ double minJacobian(void) const;
+
+ /** Get coordinates of quadrature points in reference cell.
+ *
+ * @returns Array of coordinates of quadrature points in reference cell.
+ */
+ const pylith::double_array& quadPtsRef(void) const;
+
+ /** Get weights of quadrature points.
+ *
+ * @returns Weights of quadrature points
+ */
+ const pylith::double_array& quadWts(void) const;
+
+ /** Get basis fns evaluated at quadrature points.
+ *
+ * @returns Array of basis fns evaluated at quadrature points
+ */
+ const pylith::double_array& basis(void) const;
+
+ /** Get derivates of basis fns evaluated at quadrature points.
+ *
+ * @returns Array of derivates of basis fns evaluated at
+ * quadrature points
+ */
+ const pylith::double_array& basisDerivRef(void) const;
+
+ /** Get number of dimensions in reference cell.
+ *
+ * @returns Number of dimensions in reference cell
+ */
+ int cellDim(void) const;
+
+ /** Get number of basis functions for cell.
+ *
+ * @returns Number of basis functions for cell
+ */
+ int numBasis(void) const;
+
+ /** Get number of quadrature points.
+ *
+ * @returns Number of quadrature points
+ */
+ int numQuadPts(void) const;
+
+ /** Get number of dimensions in coordinates of cell vertices.
+ *
+ * @returns Number of dimensions in coordinates of cell vertices
+ */
+ int spaceDim(void) const;
+
+ }; // QuadratureRefCell
+
+ } // feassemble
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/feassemble/feassemble.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,89 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module feassemble
+
+// Header files for module C++ code
+%{
+#include "pylith/feassemble/CellGeometry.hh"
+#include "pylith/feassemble/GeometryPoint1D.hh"
+#include "pylith/feassemble/GeometryPoint2D.hh"
+#include "pylith/feassemble/GeometryPoint3D.hh"
+#include "pylith/feassemble/GeometryLine1D.hh"
+#include "pylith/feassemble/GeometryLine2D.hh"
+#include "pylith/feassemble/GeometryLine3D.hh"
+#include "pylith/feassemble/GeometryTri2D.hh"
+#include "pylith/feassemble/GeometryTri3D.hh"
+#include "pylith/feassemble/GeometryQuad2D.hh"
+#include "pylith/feassemble/GeometryQuad3D.hh"
+#include "pylith/feassemble/GeometryTet3D.hh"
+#include "pylith/feassemble/GeometryHex3D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
+
+#include "pylith/topology/Mesh.hh"
+#include "pylith/topology/SubMesh.hh"
+#include "pylith/feassemble/Quadrature.hh"
+#include "pylith/feassemble/ElasticityImplicit.hh"
+#include "pylith/feassemble/ElasticityExplicit.hh"
+
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+%include "../include/doublearray.i"
+
+// Numpy interface stuff
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "../include/numpy.i"
+%init %{
+import_array();
+%}
+
+%include "CellGeometry.i"
+%include "GeometryPoint1D.i"
+%include "GeometryPoint2D.i"
+%include "GeometryPoint3D.i"
+%include "GeometryLine1D.i"
+%include "GeometryLine2D.i"
+%include "GeometryLine3D.i"
+%include "GeometryTri2D.i"
+%include "GeometryTri3D.i"
+%include "GeometryQuad2D.i"
+%include "GeometryQuad3D.i"
+%include "GeometryTet3D.i"
+%include "GeometryHex3D.i"
+%include "QuadratureRefCell.i"
+
+%include "Quadrature.i"
+%include "Integrator.i"
+%include "IntegratorElasticity.i"
+%include "ElasticityImplicit.i"
+%include "ElasticityExplicit.i"
+
+// Template instatiation
+%template(MeshQuadrature) pylith::feassemble::Quadrature<pylith::topology::Mesh>;
+%template(SubMeshQuadrature) pylith::feassemble::Quadrature<pylith::topology::SubMesh>;
+
+
+// End of file
+
Deleted: short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/feassemble/feassemble.pyxe.src 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,1776 +0,0 @@
-# -*- Pyrex -*-
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-#header{
-#include "pylith/feassemble/CellGeometry.hh"
-#include "pylith/feassemble/GeometryPoint1D.hh"
-#include "pylith/feassemble/GeometryPoint2D.hh"
-#include "pylith/feassemble/GeometryPoint3D.hh"
-#include "pylith/feassemble/GeometryLine1D.hh"
-#include "pylith/feassemble/GeometryLine2D.hh"
-#include "pylith/feassemble/GeometryLine3D.hh"
-#include "pylith/feassemble/GeometryTri2D.hh"
-#include "pylith/feassemble/GeometryTri3D.hh"
-#include "pylith/feassemble/GeometryQuad2D.hh"
-#include "pylith/feassemble/GeometryQuad3D.hh"
-#include "pylith/feassemble/GeometryTet3D.hh"
-#include "pylith/feassemble/GeometryHex3D.hh"
-
-#include "pylith/feassemble/Quadrature.hh"
-#include "pylith/feassemble/Quadrature0D.hh"
-#include "pylith/feassemble/Quadrature1D.hh"
-#include "pylith/feassemble/Quadrature1Din2D.hh"
-#include "pylith/feassemble/Quadrature1Din3D.hh"
-#include "pylith/feassemble/Quadrature2D.hh"
-#include "pylith/feassemble/Quadrature2Din3D.hh"
-#include "pylith/feassemble/Quadrature3D.hh"
-
-#include "pylith/feassemble/Integrator.hh"
-#include "pylith/feassemble/IntegratorElasticity.hh"
-#include "pylith/feassemble/ElasticityExplicit.hh"
-#include "pylith/feassemble/ElasticityImplicit.hh"
-
-#include "pylith/feassemble/Constraint.hh"
-
-#include "pylith/utils/petscfwd.h"
-
-#include <assert.h>
-#include <stdexcept>
-#include <Python.h>
-#}header
-
-# ----------------------------------------------------------------------
-cdef extern from "Python.h":
- object PyCObject_FromVoidPtr(void*, void (*destruct)(void*))
- void* PyCObject_AsVoidPtr(object)
-
-cdef void* ptrFromHandle(obj):
- """Extract pointer from PyCObject."""
- return PyCObject_AsVoidPtr(obj.handle)
-
-cdef extern from "stdlib.h":
- ctypedef unsigned long size_t
- void* malloc(size_t size)
- void free(void* mem)
-
-# ----------------------------------------------------------------------
-cdef void CellGeometry_destructor(void* obj):
- """
- Destroy CellGeometry object.
- """
- # create shim for destructor
- #embed{ void CellGeometry_destructor_cpp(void* objVptr)
- pylith::feassemble::CellGeometry* pQ =
- (pylith::feassemble::CellGeometry*) objVptr;
- delete pQ;
- #}embed
- CellGeometry_destructor_cpp(obj)
- return
-
-cdef class CellGeometry:
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- self.handle = None
- self.thisptr = NULL
- self.name = "pylith_feassemble_CellGeometry"
- return
-
-
- def _createHandle(self):
- """Wrap pointer to C++ object in PyCObject."""
- return PyCObject_FromVoidPtr(self.thisptr, CellGeometry_destructor)
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryPoint1D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryPoint1D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryPoint1D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryPoint1D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryPoint2D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryPoint2D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryPoint2D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryPoint2D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryPoint3D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryPoint3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryPoint3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryPoint3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryLine1D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryLine1D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryLine1D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryLine1D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryLine2D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryLine2D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryLine2D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryLine2D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryLine3D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryLine3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryLine3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryLine3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryTri2D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryTri2D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryTri2D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryTri2D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryTri3D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryTri3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryTri3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryTri3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryQuad2D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryQuad2D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryQuad2D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryQuad2D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryQuad3D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryQuad3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryQuad3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryQuad3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryTet3D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryTet3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryTet3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryTet3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GeometryHex3D(CellGeometry):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* GeometryHex3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::GeometryHex3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- CellGeometry.__init__(self)
- self.thisptr = GeometryHex3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef void Quadrature_destructor(void* obj):
- """
- Destroy Quadrature object.
- """
- # create shim for destructor
- #embed{ void Quadrature_destructor_cpp(void* objVptr)
- pylith::feassemble::Quadrature* pQ =
- (pylith::feassemble::Quadrature*) objVptr;
- delete pQ;
- #}embed
- Quadrature_destructor_cpp(obj)
- return
-
-cdef class Quadrature:
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- self.handle = None
- self.thisptr = NULL
- self.name = "pylith_feassemble_Quadrature"
- return
-
-
- def initialize(self,
- basis, basisDeriv,
- quadPts, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim):
- """
- Set basis functions and their derivatives, and coordinates and
- weights of quadrature points.
-
- @param basis Basis functions evaluated at the quadrature points
- @param basisDeriv Basis function derivatives evaluated at quad pts
- @param quadPts Coordinates of quadrature points in reference cell
- @param quadWts Weights of quadrature points
- @param cellDim Dimension of reference cell
- @param numBasis Number of basis functions
- @param numQuadPts Number of quadrature points
- @param spaceDim Number of dimensions associated with cell vertices
- """
- # create shim for method 'initialize'
- #embed{ void Quadrature_initialize(void* objVptr, double* basis, double* basisDeriv, double* quadPts, double* quadWts, int cellDim, int numBasis, int numQuadPts, int spaceDim)
- try {
- ((pylith::feassemble::Quadrature*) objVptr)->initialize(
- basis, basisDeriv,
- quadPts, quadWts,
- cellDim, numBasis,
- numQuadPts, spaceDim);
- } 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
-
- import spatialdata.utils.simplearray
-
- # basis
- basis = spatialdata.utils.simplearray.objAsSimpleArray(basis)
- if not basis.isCompatible(nd=2, simpletype="double",
- contiguous=True, notswapped=True):
- raise TypeError, \
- "Argument 'basis' must be a contiguous, 2-D array " \
- "of type double."
- if numQuadPts != basis.shape[0] or numBasis != basis.shape[1]:
- raise TypeError, \
- "Shape of argument 'basis' must be (numQuadPts, numBasis)."
-
- # basisDeriv
- basisDeriv = spatialdata.utils.simplearray.objAsSimpleArray(basisDeriv)
- if not basisDeriv.isCompatible(nd=3, simpletype="double",
- contiguous=True, notswapped=True):
- raise TypeError, \
- "Argument 'basisDeriv' must be a contiguous, 3-D array " \
- "of type double."
- if cellDim > 0:
- if numQuadPts != basisDeriv.shape[0] or \
- numBasis != basisDeriv.shape[1] or \
- cellDim != basisDeriv.shape[2]:
- raise TypeError, \
- "Shape of argument 'basisDeriv' must be (numQuadPts, " \
- "numBasis, cellDim)."
- else:
- if 1 != basisDeriv.shape[0] or \
- 1 != basisDeriv.shape[1] or \
- 1 != basisDeriv.shape[2]:
- raise TypeError, \
- "Shape of argument 'basisDeriv' must be (1, 1, 1) for 0-D cell."
-
- # quadPts
- quadPts = spatialdata.utils.simplearray.objAsSimpleArray(quadPts)
- if not quadPts.isCompatible(nd=2, simpletype="double",
- contiguous=True, notswapped=True):
- raise TypeError, \
- "Argument 'quadPts' must be a contiguous, 2-D array " \
- "of type double."
- if cellDim > 0:
- if numQuadPts != quadPts.shape[0] or cellDim != quadPts.shape[1]:
- raise TypeError, \
- "Shape of argument 'quadPts' must be (numQuadPts, cellDim)."
- else:
- if 1 != quadPts.shape[0] or 1 != quadPts.shape[1]:
- raise TypeError, \
- "Shape of argument 'quadPts' must be (1, 1) for 0-D cell."
-
- # quadWts
- quadWts = spatialdata.utils.simplearray.objAsSimpleArray(quadWts)
- if not quadWts.isCompatible(nd=1, simpletype="double",
- contiguous=True, notswapped=True):
- raise TypeError, \
- "Argument 'quadWts' must be a contiguous, 1-D array " \
- "of type double."
- if numQuadPts != quadWts.shape[0]:
- raise TypeError, \
- "Shape of argument 'quadWts' must be (numQuadPts)."
-
- cdef double* basisCpp
- cdef double* basisDerivCpp
- cdef double* quadPtsCpp
- cdef double* quadWtsCpp
- basisCpp = <double*> PyCObject_AsVoidPtr(basis.data)
- basisDerivCpp = <double*> PyCObject_AsVoidPtr(basisDeriv.data)
- quadPtsCpp = <double*> PyCObject_AsVoidPtr(quadPts.data)
- quadWtsCpp = <double*> PyCObject_AsVoidPtr(quadWts.data)
-
- Quadrature_initialize(self.thisptr,
- basisCpp, basisDerivCpp,
- quadPtsCpp, quadWtsCpp,
- cellDim, numBasis,
- numQuadPts, spaceDim)
- return
-
-
- def _createHandle(self):
- """Wrap pointer to C++ object in PyCObject."""
- return PyCObject_FromVoidPtr(self.thisptr, Quadrature_destructor)
-
-
- property minJacobian:
- def __set__(self, value):
- """Set minimum allowable Jacobian."""
- # create shim for method 'minJacobian'
- #embed{ void Quadrature_minJacobian_set(void* objVptr, double value)
- try {
- assert(0 != objVptr);
- ((pylith::feassemble::Quadrature*) objVptr)->minJacobian(value);
- } 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
- Quadrature_minJacobian_set(self.thisptr, value)
-
- def __get__(self):
- """Get minimum allowable Jacobian."""
- # create shim for method 'minJacobian'
- #embed{ double Quadrature_minJacobian_get(void* objVptr)
- double result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::feassemble::Quadrature*) objVptr)->minJacobian();
- } 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
- return result;
- #}embed
- return Quadrature_minJacobian_get(self.thisptr)
-
-
- property checkConditioning:
- def __set__(self, flag):
- """Set minimum allowable Jacobian."""
- # create shim for method 'checkConditioning'
- #embed{ void Quadrature_checkConditioning_set(void* objVptr, int flag)
- try {
- assert(0 != objVptr);
- ((pylith::feassemble::Quadrature*) objVptr)->checkConditioning(flag);
- } 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
- Quadrature_checkConditioning_set(self.thisptr, flag)
-
- def __get__(self):
- """Get minimum allowable Jacobian."""
- # create shim for method 'checkConditioning'
- #embed{ int Quadrature_checkConditioning_get(void* objVptr)
- int result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::feassemble::Quadrature*) objVptr)->checkConditioning();
- } 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
- return result;
- #}embed
- return Quadrature_checkConditioning_get(self.thisptr)
-
-
- property refGeometry:
- def __set__(self, value):
- """
- Set geometry associated with reference cell.
- """
- # create shim for method 'refGeometry'
- #embed{ void Quadrature_refGeometry_set(void* objVptr, void* geomVptr)
- try {
- assert(0 != objVptr);
- assert(0 != geomVptr);
- pylith::feassemble::CellGeometry* geom =
- (pylith::feassemble::CellGeometry*) geomVptr;
- ((pylith::feassemble::Quadrature*) objVptr)->refGeometry(geom);
- } 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
- if not value.name == "pylith_feassemble_CellGeometry":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::feassemble::CellGeometry'."
- Quadrature_refGeometry_set(self.thisptr, ptrFromHandle(value))
-
-
-# ----------------------------------------------------------------------
-cdef class Quadrature0D(Quadrature):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* Quadrature0D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::Quadrature0D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Quadrature.__init__(self)
- self.thisptr = Quadrature0D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class Quadrature1D(Quadrature):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* Quadrature1D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::Quadrature1D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Quadrature.__init__(self)
- self.thisptr = Quadrature1D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class Quadrature1Din2D(Quadrature):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* Quadrature1Din2D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::Quadrature1Din2D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Quadrature.__init__(self)
- self.thisptr = Quadrature1Din2D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class Quadrature1Din3D(Quadrature):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* Quadrature1Din3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::Quadrature1Din3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Quadrature.__init__(self)
- self.thisptr = Quadrature1Din3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class Quadrature2D(Quadrature):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* Quadrature2D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::Quadrature2D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Quadrature.__init__(self)
- self.thisptr = Quadrature2D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class Quadrature2Din3D(Quadrature):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* Quadrature2Din3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::Quadrature2Din3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Quadrature.__init__(self)
- self.thisptr = Quadrature2Din3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class Quadrature3D(Quadrature):
-
- def __init__(self):
- """Constructor."""
- # create shim for constructor
- #embed{ void* Quadrature3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::Quadrature3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Quadrature.__init__(self)
- self.thisptr = Quadrature3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef void Integrator_destructor(void* obj):
- """
- Destroy Integrator object.
- """
- # create shim for destructor
- #embed{ void Integrator_destructor_cpp(void* objVptr)
- pylith::feassemble::Integrator* pQ =
- (pylith::feassemble::Integrator*) objVptr;
- delete pQ;
- #}embed
- Integrator_destructor_cpp(obj)
- return
-
-
-cdef class Integrator:
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- self.handle = None
- self.thisptr = NULL
- self.name = "pylith_feassemble_integrator"
- return
-
-
- def integrateResidual(self, residual, t, fields, mesh, cs):
- """
- Integrate contributions to residual term (r) for operator.
- """
- # create shim for method 'integrateResidual'
- #embed{ void Integrator_integrateResidual(void* objVptr, void* residualVptr, double t, void* fieldsVptr, void* meshVptr, void* csVptr)
- try {
- assert(0 != objVptr);
- assert(0 != residualVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ALE::Obj<pylith::real_section_type>* residual =
- (ALE::Obj<pylith::real_section_type>*) residualVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- ((pylith::feassemble::Integrator*) objVptr)->integrateResidual(*residual,
- t, fields, *mesh,
- cs);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type 'Mesh'."
- Integrator_integrateResidual(self.thisptr,
- PyCObject_AsVoidPtr(residual),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh),
- ptrFromHandle(cs))
- return
-
-
- def integrateJacobian(self, mat, t, fields, mesh):
- """
- Compute contributions to Jacobian matrix (A) associated with operator.
- """
- # create shim for method 'integrateJacobian'
- #embed{ void Integrator_integrateJacobian(void* objVptr, void* matVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != matVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- PetscMat* mat = (PetscMat*) matVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ((pylith::feassemble::Integrator*) objVptr)->integrateJacobian(
- mat, t, fields, *mesh);
- } 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
- if fields.name != "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type 'FieldsManager'."
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- Integrator_integrateJacobian(self.thisptr,
- PyCObject_AsVoidPtr(mat),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def integrateResidualAssembled(self, residual, t, fields, mesh, cs):
- """
- Integrate contributions to residual term (r) for operator that do
- not require assembly over cells, vertices, or processors.
- """
- # create shim for method 'integrateResidualAssembled'
- #embed{ void Integrator_integrateResidualAssembled(void* objVptr, void* residualVptr, double t, void* fieldsVptr, void* meshVptr, void* csVptr)
- try {
- assert(0 != objVptr);
- assert(0 != residualVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ALE::Obj<pylith::real_section_type>* residual =
- (ALE::Obj<pylith::real_section_type>*) residualVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- ((pylith::feassemble::Integrator*) objVptr)->integrateResidualAssembled(*residual,
- t, fields, *mesh,
- cs);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type 'Mesh'."
- Integrator_integrateResidualAssembled(self.thisptr,
- PyCObject_AsVoidPtr(residual),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh),
- ptrFromHandle(cs))
- return
-
-
- def integrateJacobianAssembled(self, mat, t, fields, mesh):
- """
- Compute contributions to Jacobian matrix (A) associated with
- operator that do not require assembly over cells, vertices, or
- processors.
- """
- # create shim for method 'integrateJacobianAssembled'
- #embed{ void Integrator_integrateJacobianAssembled(void* objVptr, void* matVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != matVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- PetscMat* mat = (PetscMat*) matVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ((pylith::feassemble::Integrator*) objVptr)->integrateJacobianAssembled(
- mat, t, fields, *mesh);
- } 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
- if fields.name != "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type 'FieldsManager'."
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- Integrator_integrateJacobianAssembled(self.thisptr,
- PyCObject_AsVoidPtr(mat),
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def updateState(self, t, fields, mesh):
- """
- Update state variables as needed.
- """
- # create shim for method 'updateState'
- #embed{ void Integrator_updateState(void* objVptr, double t, void* fieldsVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldsVptr);
- assert(0 != meshVptr);
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::feassemble::Integrator*) objVptr)->updateState(t, fields, *mesh);
- } 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
- if fields.name != "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type 'FieldsManager'."
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- Integrator_updateState(self.thisptr,
- t,
- ptrFromHandle(fields),
- ptrFromHandle(mesh))
- return
-
-
- def verifyConfiguration(self, mesh):
- """
- Verify compatibility of configuration settings.
- """
- # create shim for method 'verifyConfiguration'
- #embed{ void Integrator_verifyConfiguration(void* objVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::Mesh>* mesh =
- (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::feassemble::Integrator*) objVptr)->verifyConfiguration(*mesh);
- } 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
- if mesh.name != "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type 'Mesh'."
- Integrator_verifyConfiguration(self.thisptr,
- ptrFromHandle(mesh))
- return
-
-
- def _createHandle(self):
- """
- Wrap pointer to C++ object in PyCObject.
- """
- return PyCObject_FromVoidPtr(self.thisptr, Integrator_destructor)
-
-
- property quadrature:
- def __set__(self, q):
- """
- Set quadrature.
- """
- # create shim for method 'quadrature'
- #embed{ void Integrator_quadrature_set(void* objVptr, void* qVptr)
- try {
- assert(0 != objVptr);
- assert(0 != qVptr);
- pylith::feassemble::Quadrature* quadrature =
- (pylith::feassemble::Quadrature*) qVptr;
- ((pylith::feassemble::Integrator*) objVptr)->quadrature(quadrature);
- } 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
- if not q.name == "pylith_feassemble_Quadrature":
- raise TypeError, \
- "Argument must be extension module type 'Quadrature'."
- Integrator_quadrature_set(self.thisptr, ptrFromHandle(q))
-
-
- property normalizer:
- def __set__(self, value):
- """
- Set nondimensionalizer.
- """
- # create shim for method 'normalizer'
- #embed{ void Integrator_normalizer_set(void* objVptr, void* dimVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dimVptr);
- spatialdata::units::Nondimensional* dim =
- (spatialdata::units::Nondimensional*) dimVptr;
- ((pylith::feassemble::Integrator*) objVptr)->normalizer(*dim);
- } 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
- if not value.name == "spatialdata_units_Nondimensional":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::units::Nondimensional'."
- Integrator_normalizer_set(self.thisptr, ptrFromHandle(value))
-
-
- property gravityField:
- def __set__(self, g):
- """
- Set gravity field.
- """
- # create shim for method 'gravityField'
- #embed{ void Integrator_gravityField_set(void* objVptr, void* gVptr)
- try {
- assert(0 != objVptr);
- spatialdata::spatialdb::GravityField* gravityField =
- (spatialdata::spatialdb::GravityField*) gVptr;
- ((pylith::feassemble::Integrator*) objVptr)->gravityField(gravityField);
- } 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
- if not g.name == "spatialdata_spatialdb_SpatialDB":
- raise TypeError, \
- "Argument must be extension module type 'SpatialDB'."
- if None == g:
- Integrator_gravityField_set(self.thisptr, NULL)
- else:
- Integrator_gravityField_set(self.thisptr, ptrFromHandle(g))
-
-
- property timeStep:
- def __set__(self, dt):
- """
- Set timeStep.
- """
- # create shim for method 'timeStep'
- #embed{ void Integrator_timeStep_set(void* objVptr, double dt)
- try {
- assert(0 != objVptr);
- ((pylith::feassemble::Integrator*) objVptr)->timeStep(dt);
- } 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
- Integrator_timeStep_set(self.thisptr, dt)
-
-
- property stableTimeStep:
- def __get__(self):
- """
- Get stable time step.
- """
- # create shim for method 'stableTimeStep'
- #embed{ double Integrator_stableTimeStep_get(void* objVptr)
- double result = 0.0;
- try {
- assert(0 != objVptr);
- result =
- ((pylith::feassemble::Integrator*) objVptr)->stableTimeStep();
- } 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
- return result;
- #}embed
- return Integrator_stableTimeStep_get(self.thisptr)
-
-
- property needNewJacobian:
- def __get__(self):
- """
- Set timeStep.
- """
- # create shim for method 'needNewJacobian'
- #embed{ int Integrator_needNewJacobian_get(void* objVptr)
- int result = 0;
- try {
- assert(0 != objVptr);
- result =
- ((pylith::feassemble::Integrator*) objVptr)->needNewJacobian();
- } 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
- return result;
- #}embed
- return Integrator_needNewJacobian_get(self.thisptr)
-
-
- property useSolnIncr:
- def __set__(self, flag):
- """
- Set solution increment flag.
- """
- # create shim for method 'useSolnIncr'
- #embed{ void Integrator_useSolnIncr_set(void* objVptr, int flag)
- try {
- assert(0 != objVptr);
- ((pylith::feassemble::Integrator*) objVptr)->useSolnIncr(flag);
- } 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
- Integrator_useSolnIncr_set(self.thisptr, flag)
-
-
-# ----------------------------------------------------------------------
-cdef class IntegratorElasticity(Integrator):
-
- def __init__(self):
- """
- Constructor.
- """
- Integrator.__init__(self)
- return
-
-
- def cellField(self, name, mesh, fields=None):
- """
- Get cell field.
- """
- # create shim for method 'cellField'
- #embed{ void* IntegratorElasticity_cellField(void* objVptr, int* fieldPtr, char* name, void* meshVptr, void* fieldsVptr)
- void* result = 0;
- try {
- assert(0 != objVptr);
- assert(0 != fieldPtr);
- assert(0 != name);
- assert(0 != meshVptr);
- pylith::feassemble::IntegratorElasticity* integrator = (pylith::feassemble::IntegratorElasticity*) objVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- pylith::topology::FieldsManager* fields =
- (pylith::topology::FieldsManager*) fieldsVptr;
- pylith::VectorFieldEnum fieldType;
- const ALE::Obj<pylith::real_section_type>& field =
- integrator->cellField(&fieldType, name, *mesh, fields);
- *fieldPtr = fieldType;
- result = (void*) &field;
- } 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
- return result;
- #}embed
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- if None != fields:
- if not fields.name == "pylith_topology_FieldsManager":
- raise TypeError, \
- "Argument 'fields' must be extension module type " \
- "'pylith::topology::FieldsManager'."
- cdef void* ptr
- cdef int fieldType
- fieldType = 3
- if None != fields:
- ptr = IntegratorElasticity_cellField(self.thisptr, &fieldType, name,
- ptrFromHandle(mesh),
- ptrFromHandle(fields))
- else:
- ptr = IntegratorElasticity_cellField(self.thisptr, &fieldType, name,
- ptrFromHandle(mesh), NULL)
- return (PyCObject_FromVoidPtr(ptr, NULL), fieldType)
-
-
- property material:
- def __set__(self, m):
- """
- Set material.
- """
- # create shim for method 'material'
- #embed{ void IntegratorElasticity_material_set(void* objVptr, void* mVptr)
- try {
- assert(0 != objVptr);
- pylith::materials::ElasticMaterial* material =
- (pylith::materials::ElasticMaterial*) mVptr;
- ((pylith::feassemble::IntegratorElasticity*) objVptr)->material(material);
- } 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
- if not m.name == "pylith_materials_ElasticMaterial":
- raise TypeError, \
- "Argument must be extension module type 'ElasticMaterial'."
- IntegratorElasticity_material_set(self.thisptr, ptrFromHandle(m))
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticityExplicit(IntegratorElasticity):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* ElasticityExplicit_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::ElasticityExplicit);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Integrator.__init__(self)
- self.thisptr = ElasticityExplicit_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticityImplicit(IntegratorElasticity):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* ElasticityImplicit_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::feassemble::ElasticityImplicit);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- Integrator.__init__(self)
- self.thisptr = ElasticityImplicit_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef void Constraint_destructor(void* obj):
- """
- Destroy Constraint object.
- """
- # create shim for destructor
- #embed{ void Constraint_destructor_cpp(void* objVptr)
- pylith::feassemble::Constraint* pQ =
- (pylith::feassemble::Constraint*) objVptr;
- delete pQ;
- #}embed
- Constraint_destructor_cpp(obj)
- return
-
-
-cdef class Constraint:
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- self.handle = None
- self.thisptr = NULL
- self.name = "pylith_feassemble_constraint"
- return
-
-
- def setConstraintSizes(self, field, mesh):
- """
- Set number of degrees of freedom that are constrained at points in field.
- """
- # create shim for method 'setConstraintSizes'
- #embed{ void Constraint_setConstraintSizes(void* objVptr, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::feassemble::Constraint*) objVptr)->setConstraintSizes(*field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- Constraint_setConstraintSizes(self.thisptr, PyCObject_AsVoidPtr(field),
- ptrFromHandle(mesh))
- return
-
-
- def setConstraints(self, field, mesh):
- """
- Set which degrees of freedom that are constrained at points in field.
- """
- # create shim for method 'setConstraints'
- #embed{ void Constraint_setConstraints(void* objVptr, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::feassemble::Constraint*) objVptr)->setConstraints(*field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- Constraint_setConstraints(self.thisptr, PyCObject_AsVoidPtr(field), ptrFromHandle(mesh))
- return
-
-
- def setField(self, t, field, mesh):
- """
- Set values in field.
- """
- # create shim for method 'setField'
- #embed{ void Constraint_setField(void* objVptr, double t, void* fieldVptr, void* meshVptr)
- try {
- assert(0 != objVptr);
- assert(0 != fieldVptr);
- assert(0 != meshVptr);
- ALE::Obj<pylith::real_section_type>* field = (ALE::Obj<pylith::real_section_type>*) fieldVptr;
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- ((pylith::feassemble::Constraint*) objVptr)->setField(t, *field, *mesh);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument 'mesh' must be extension module type " \
- "'pylith::topology::Mesh'."
- Constraint_setField(self.thisptr, t, PyCObject_AsVoidPtr(field),
- ptrFromHandle(mesh))
- return
-
-
- property normalizer:
- def __set__(self, value):
- """
- Set nondimensionalizer.
- """
- # create shim for method 'normalizer'
- #embed{ void Constraint_normalizer_set(void* objVptr, void* dimVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dimVptr);
- spatialdata::units::Nondimensional* dim =
- (spatialdata::units::Nondimensional*) dimVptr;
- ((pylith::feassemble::Constraint*) objVptr)->normalizer(*dim);
- } 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
- if not value.name == "spatialdata_units_Nondimensional":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::units::Nondimensional'."
- Constraint_normalizer_set(self.thisptr, ptrFromHandle(value))
-
-
- property useSolnIncr:
- def __set__(self, flag):
- """
- Set use solution increment flag.
- """
- # create shim for method 'useSolnIncr'
- #embed{ void Constraint_useSolnIncr_set(void* objVptr, int flag)
- try {
- assert(0 != objVptr);
- ((pylith::feassemble::Constraint*) objVptr)->useSolnIncr(flag);
- } 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
- Constraint_useSolnIncr_set(self.thisptr, flag)
-
-
- def _createHandle(self):
- """
- Wrap pointer to C++ object in PyCObject.
- """
- return PyCObject_FromVoidPtr(self.thisptr, Constraint_destructor)
-
-
-# End of file
Copied: short/3D/PyLith/trunk/modulesrc/include (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/include)
Property changes on: short/3D/PyLith/trunk/modulesrc/materials
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
materials.py
materials_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/materials/ElasticIsotropic3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/ElasticIsotropic3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/ElasticIsotropic3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/ElasticIsotropic3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,158 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/ElasticIsotropic3D.i
+ *
+ * Python interface to C++ ElasticIsotropic3D object.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class ElasticIsotropic3D : public ElasticMaterial
+ { // class ElasticIsotropic3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor
+ ElasticIsotropic3D(void);
+
+ /// Destructor
+ ~ElasticIsotropic3D(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * Order of values in arrays matches order used in dbValues() and
+ * parameterNames().
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _nondimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _dimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated
+ * state variables.
+ */
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars);
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+
+ }; // class ElasticIsotropic3D
+
+ } // materials
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/ElasticMaterial.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/ElasticMaterial.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/ElasticMaterial.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/ElasticMaterial.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,183 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/ElasticMaterial.i
+ *
+ * Python interface to C++ abstract base ElasticMaterial.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class ElasticMaterial : public Material
+ { // class ElasticMaterial
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param dimension Spatial dimension associated with material.
+ * @param tensorSize Array of names of database values for material.
+ * @param numElasticConsts Number of elastic constants.
+ * @param metadata Metadata for physical properties and state variables.
+ */
+ ElasticMaterial(const int dimension,
+ const int tensorSize,
+ const int numElasticConsts,
+ const Metadata& metadata);
+
+ /// Destructor.
+ virtual
+ ~ElasticMaterial(void);
+
+ /** Set database for initial stress state.
+ *
+ * @param db Spatial database.
+ */
+ void dbInitialStress(spatialdata::spatialdb::SpatialDB* db);
+
+ /** Set database for initial strain state.
+ *
+ * @param db Spatial database.
+ */
+ void dbInitialStrain(spatialdata::spatialdb::SpatialDB* db);
+
+ /** Get flag indicating whether material implements an empty
+ * _updateProperties() method.
+ *
+ * @returns False if _updateProperties() is empty, true otherwise.
+ */
+ bool hasStateVars(void) const;
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @pre Must call retrievePropsAndVars for cell before calling
+ * stableTimeStep().
+ *
+ * Default is MAXFLOAT (or 1.0e+30 if MAXFLOAT is not defined in math.h).
+ *
+ * @returns Time step
+ */
+ virtual
+ double stableTimeStepImplicit(const pylith::topology::Mesh& mesh);
+
+ /** Set whether elastic or inelastic constitutive relations are used.
+ *
+ * @param flag True to use elastic, false to use inelastic.
+ */
+ virtual
+ void useElasticBehavior(const bool flag);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ virtual
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) = 0;
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated
+ * state variables.
+ */
+ virtual
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars) = 0;
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ virtual
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize) = 0;
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ virtual
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const = 0;
+
+ }; // class ElasticMaterial
+
+ } // materials
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStrain.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/ElasticPlaneStrain.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStrain.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStrain.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,158 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/ElasticPlaneStrain.i
+ *
+ * Python interface to C++ ElasticPlaneStrain object.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class ElasticPlaneStrain : public ElasticMaterial
+ { // class ElasticPlaneStrain
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor
+ ElasticPlaneStrain(void);
+
+ /// Destructor
+ ~ElasticPlaneStrain(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * Order of values in arrays matches order used in dbValues() and
+ * parameterNames().
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _nondimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _dimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated
+ * state variables.
+ */
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars);
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+
+ }; // class ElasticPlaneStrain
+
+ } // materials
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStress.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/ElasticPlaneStress.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStress.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/ElasticPlaneStress.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,158 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/ElasticPlaneStress.i
+ *
+ * Python interface to C++ ElasticPlaneStress object.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class ElasticPlaneStress : public ElasticMaterial
+ { // class ElasticPlaneStress
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor
+ ElasticPlaneStress(void);
+
+ /// Destructor
+ ~ElasticPlaneStress(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * Order of values in arrays matches order used in dbValues() and
+ * parameterNames().
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _nondimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _dimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated
+ * state variables.
+ */
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars);
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+
+ }; // class ElasticPlaneStress
+
+ } // materials
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/ElasticStrain1D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/ElasticStrain1D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/ElasticStrain1D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/ElasticStrain1D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,158 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/ElasticStrain1D.i
+ *
+ * Python interface to C++ ElasticStrain1D object.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class ElasticStrain1D : public ElasticMaterial
+ { // class ElasticStrain1D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor
+ ElasticStrain1D(void);
+
+ /// Destructor
+ ~ElasticStrain1D(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * Order of values in arrays matches order used in dbValues() and
+ * parameterNames().
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _nondimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _dimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated
+ * state variables.
+ */
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars);
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+
+ }; // class ElasticStrain1D
+
+ } // materials
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/ElasticStress1D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/ElasticStress1D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/ElasticStress1D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/ElasticStress1D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,158 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/ElasticStress1D.i
+ *
+ * Python interface to C++ ElasticStress1D object.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class ElasticStress1D : public ElasticMaterial
+ { // class ElasticStress1D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor
+ ElasticStress1D(void);
+
+ /// Destructor
+ ~ElasticStress1D(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * Order of values in arrays matches order used in dbValues() and
+ * parameterNames().
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _nondimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _dimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated
+ * state variables.
+ */
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars);
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+
+ }; // class ElasticStress1D
+
+ } // materials
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/materials/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/materials/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,40 +13,51 @@
subpackage = materials
include $(top_srcdir)/subpackage.am
-subpkgpyexec_LTLIBRARIES = materialsmodule.la
+subpkgpyexec_LTLIBRARIES = _materialsmodule.la
-materialsmodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = materials.py
+
+swig_sources = \
+ materials.i \
+ Material.i \
+ ElasticMaterial.i \
+ ElasticStrain1D.i \
+ ElasticStress1D.i \
+ ElasticPlaneStrain.i \
+ ElasticPlaneStress.i \
+ ElasticIsotropic3D.i \
+ MaxwellIsotropic3D.i
+
+swig_generated = \
+ materials_wrap.cxx \
+ materials.py
+
+_materialsmodule_la_LDFLAGS = -module -avoid-version \
$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_materialsmodule_la_SOURCES = materials.pyxe.src
-nodist_materialsmodule_la_SOURCES = \
- materials.pyxe \
- materials.c materials_embed.cpp materials_embed.h
+dist__materialsmodule_la_SOURCES = $(swig_sources) $(swig_generated)
-materialsmodule_la_LIBADD = \
+_materialsmodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
-lspatialdata \
- $(PETSC_LIB)
-
+ $(PETSC_LIBS)
if ENABLE_CUBIT
- materialsmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
+ _materialsmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
endif
if NO_UNDEFINED
- materialsmodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_materialsmodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-materials.pyx materials_embed.cpp materials_embed.h: materials.pyxe
- pyrexembed materials.pyxe
-materials.pyxe: $(srcdir)/materials.pyxe.src
- cp $(srcdir)/materials.pyxe.src $@
-materials_embed.cpp: materials_embed.h
-materials_embed.h: materials.pyx
+$(srcdir)/materials_wrap.cxx $(srcdir)/materials.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-.pyx.c:
- pyrexc $<
-CLEANFILES = materials.pyxe materials.pyx materials.c *_embed.*
+MAINTAINERCLEANFILES = \
+ $(srcdir)/materials_wrap.cxx \
+ $(srcdir)/materials.py
+
# End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/Material.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/Material.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/Material.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/Material.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,164 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/Material.i
+ *
+ * Python interface to C++ abstract base Material.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class Material
+ { // class Material
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param dimension Spatial dimension associated with material.
+ * @param tensorSize Array of names of database values for material.
+ * @param metadata Metadata for physical properties and state variables.
+ */
+ Material(const int dimension,
+ const int tensorSize,
+ const pylith::materials::Metadata& metadata);
+
+ /// Destructor.
+ virtual
+ ~Material(void);
+
+ /** Get spatial dimension of material.
+ *
+ * @returns Spatial dimension.
+ */
+ int dimension(void) const;
+
+ /** Set identifier of material.
+ *
+ * @param value Material identifier
+ */
+ void id(const int value);
+
+ /** Get identifier of material.
+ *
+ * @returns Material identifier
+ */
+ int id(void) const;
+
+ /** Set label of material.
+ *
+ * @param value Label of material
+ */
+ void label(const char* value);
+
+ /** Get label of material.
+ *
+ * @returns Label of material
+ */
+ const char* label(void) const;
+
+ /** Set current time step.
+ *
+ * @param dt Current time step.
+ */
+ virtual
+ void timeStep(const double dt);
+
+ /** Get current time step.
+ *
+ * @returns Current time step.
+ */
+ double timeStep(void) const;
+
+ /** Set database for physical property parameters.
+ *
+ * @param value Pointer to database.
+ */
+ void dbProperties(spatialdata::spatialdb::SpatialDB* value);
+
+ /** Set database for initial state variables.
+ *
+ * @param value Pointer to database.
+ */
+ void dbInitialState(spatialdata::spatialdb::SpatialDB* value);
+
+ /** Set scales used to nondimensionalize physical properties.
+ *
+ * @param dim Nondimensionalizer
+ */
+ void normalizer(const spatialdata::units::Nondimensional& dim);
+
+ /** Get size of stress/strain tensor associated with material.
+ *
+ * @returns Size of array holding stress/strain tensor.
+ */
+ int tensorSize(void) const;
+
+ /** Get flag indicating whether Jacobian matrix must be reformed for
+ * current state.
+ *
+ * @returns True if Jacobian matrix must be reformed, false otherwise.
+ */
+ bool needNewJacobian(void) const;
+
+ /// Reset flag indicating whether Jacobian matrix must be reformed for
+ /// current state.
+ void resetNeedNewJacobian(void);
+
+ /** Get physical property or state variable field. Data is returned
+ * via the argument.
+ *
+ * @param field Field over material cells.
+ * @param name Name of field to retrieve.
+ */
+ void getField(pylith::topology::Field<pylith::topology::Mesh>* field,
+ const char* name) const;
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ virtual
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const = 0;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ virtual
+ void _nondimProperties(double* const values,
+ const int nvalues) const = 0;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ virtual
+ void _dimProperties(double* const values,
+ const int nvalues) const = 0;
+
+ }; // class Material
+
+ } // materials
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/MaxwellIsotropic3D.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/MaxwellIsotropic3D.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/MaxwellIsotropic3D.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/MaxwellIsotropic3D.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,205 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/** @file modulesrc/materials/MaxwellIsotropic3D.ii
+ *
+ * @brief Python interface to C++ MaxwellIsotropic3D object.
+ */
+
+namespace pylith {
+ namespace materials {
+
+ class MaxwellIsotropic3D : public ElasticMaterial
+ { // class MaxwellIsotropic3D
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor
+ MaxwellIsotropic3D(void);
+
+ /// Destructor
+ ~MaxwellIsotropic3D(void);
+
+ /** Set current time step.
+ *
+ * @param dt Current time step.
+ */
+ void timeStep(const double dt);
+
+ /** Set whether elastic or inelastic constitutive relations are used.
+ *
+ * @param flag True to use elastic, false to use inelastic.
+ */
+ void useElasticBehavior(const bool flag);
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /** Compute properties from values in spatial database.
+ *
+ * Order of values in arrays matches order used in dbValues() and
+ * parameterNames().
+ *
+ * @param propValues Array of property values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToProperties(double* const propValues,
+ const double_array& dbValues) const;
+
+ /** Nondimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _nondimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Dimensionalize properties.
+ *
+ * @param values Array of property values.
+ * @param nvalues Number of values.
+ */
+ void _dimProperties(double* const values,
+ const int nvalues) const;
+
+ /** Compute initial state variables from values in spatial database.
+ *
+ * @param stateValues Array of state variable values.
+ * @param dbValues Array of database values.
+ */
+ void _dbToStateVars(double* const stateValues,
+ const double_array& dbValues) const;
+
+ // Note: We do not need to dimensionalize or nondimensionalize state
+ // variables because there are strains, which are dimensionless.
+
+
+ /** Compute density from properties.
+ *
+ * @param density Array for density.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ */
+ void _calcDensity(double* const density,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars);
+
+ /** Compute stress tensor from properties and state variables. If
+ * the state variables are from the previous time step, then the
+ * computeStateVars flag should be set to true so that the state
+ * variables are updated (but not stored) when computing the
+ * stresses.
+ *
+ * @param stress Array for stress tensor.
+ * @param stressSize Size of stress tensor.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ * @param computeStateVars Flag indicating to compute updated state variables.
+ */
+ void _calcStress(double* const stress,
+ const int stressSize,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize,
+ const bool computeStateVars);
+
+ /** Compute derivatives of elasticity matrix from properties.
+ *
+ * @param elasticConsts Array for elastic constants.
+ * @param numElasticConsts Number of elastic constants.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _calcElasticConsts(double* const elasticConsts,
+ const int numElasticConsts,
+ const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Update state variables (for next time step).
+ *
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param totalStrain Total strain at location.
+ * @param strainSize Size of strain tensor.
+ * @param initialStress Initial stress tensor at location.
+ * @param initialStressSize Size of initial stress array.
+ * @param initialStrain Initial strain tensor at location.
+ * @param initialStrainSize Size of initial strain array.
+ */
+ void _updateStateVars(double* const stateVars,
+ const int numStateVars,
+ const double* properties,
+ const int numProperties,
+ const double* totalStrain,
+ const int strainSize,
+ const double* initialStress,
+ const int initialStressSize,
+ const double* initialStrain,
+ const int initialStrainSize);
+
+ /** Get stable time step for implicit time integration.
+ *
+ * @param properties Properties at location.
+ * @param numProperties Number of properties.
+ * @param stateVars State variables at location.
+ * @param numStateVars Number of state variables.
+ *
+ * @returns Time step
+ */
+ double _stableTimeStepImplicit(const double* properties,
+ const int numProperties,
+ const double* stateVars,
+ const int numStateVars) const;
+
+ }; // class MaxwellIsotropic3D
+
+ } // materials
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/materials/materials.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/materials/materials.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/materials.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/materials/materials.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,69 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module materials
+
+// Header files for module C++ code
+%{
+#include "pylith/materials/materialsfwd.hh" // forward declarations
+
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // forward declarations
+#include "spatialdata/units/unitsfwd.hh" // forward declarations
+
+#include "pylith/materials/ElasticMaterial.hh"
+#include "pylith/materials/ElasticStrain1D.hh"
+#include "pylith/materials/ElasticStress1D.hh"
+#include "pylith/materials/ElasticPlaneStrain.hh"
+#include "pylith/materials/ElasticPlaneStress.hh"
+#include "pylith/materials/ElasticIsotropic3D.hh"
+#include "pylith/materials/MaxwellIsotropic3D.hh"
+//#include "pylith/materials/GenMaxwellIsotropic3D.hh"
+
+#include "pylith/utils/arrayfwd.hh"
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+%include "../include/doublearray.i"
+
+// Numpy interface stuff
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "../include/numpy.i"
+%init %{
+import_array();
+%}
+
+// Interfaces
+%include "Material.i"
+%include "ElasticMaterial.i"
+%include "ElasticStrain1D.i"
+%include "ElasticStress1D.i"
+%include "ElasticPlaneStrain.i"
+%include "ElasticPlaneStress.i"
+%include "ElasticIsotropic3D.i"
+%include "MaxwellIsotropic3D.i"
+//%include "GenMaxwellIsotropic3D.i"
+
+
+// End of file
+
Deleted: short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/materials/materials.pyxe.src 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,581 +0,0 @@
-# -*- Pyrex -*-
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-#header{
-#include "pylith/materials/Material.hh"
-#include "pylith/materials/ElasticMaterial.hh"
-#include "pylith/materials/ElasticStrain1D.hh"
-#include "pylith/materials/ElasticStress1D.hh"
-#include "pylith/materials/ElasticIsotropic3D.hh"
-#include "pylith/materials/ElasticPlaneStrain.hh"
-#include "pylith/materials/ElasticPlaneStress.hh"
-#include "pylith/materials/MaxwellIsotropic3D.hh"
-#include "pylith/materials/GenMaxwellIsotropic3D.hh"
-
-#include <assert.h>
-#include <stdexcept>
-#include <Python.h>
-#}header
-
-# ----------------------------------------------------------------------
-cdef extern from "Python.h":
- object PyCObject_FromVoidPtr(void*, void (*destruct)(void*))
- void* PyCObject_AsVoidPtr(object)
-
-cdef void* ptrFromHandle(obj):
- """Extract pointer from PyCObject."""
- return PyCObject_AsVoidPtr(obj.handle)
-
-cdef extern from "stdlib.h":
- ctypedef unsigned long size_t
- void* malloc(size_t size)
- void free(void* mem)
-
-cdef void Material_destructor(void* obj):
- """
- Destroy Material object.
- """
- # create shim for destructor
- #embed{ void Material_destructor_cpp(void* pObj)
- pylith::materials::Material* pM =
- (pylith::materials::Material*) pObj;
- delete pM;
- #}embed
- Material_destructor_cpp(obj)
- return
-
-
-# ----------------------------------------------------------------------
-cdef class Material:
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- self.handle = None
- self.thisptr = NULL
- self.name = "pylith_materials_Material"
- return
-
-
- def initialize(self, mesh, cs, quadrature):
- """
- Initialize material by getting physical property parameters from
- database.
- """
- # create shim for method 'initialize'
- #embed{ void Material_initialize(void* objVptr, void* meshVptr, void* csVptr, void* qVptr)
- try {
- assert(0 != objVptr);
- assert(0 != meshVptr);
- assert(0 != csVptr);
- assert(0 != qVptr);
- ALE::Obj<pylith::Mesh>* mesh = (ALE::Obj<pylith::Mesh>*) meshVptr;
- spatialdata::geocoords::CoordSys* cs =
- (spatialdata::geocoords::CoordSys*) csVptr;
- pylith::feassemble::Quadrature* quadrature =
- (pylith::feassemble::Quadrature*) qVptr;
- ((pylith::materials::Material*) objVptr)->initialize(*mesh, cs, quadrature);
- } 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
-
- if not mesh.name == "pylith_topology_Mesh":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::topology::Mesh'."
- if not cs.name == "spatialdata_geocoords_CoordSys":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::geocoords::CoordSys'."
- if not quadrature.name == "pylith_feassemble_Quadrature":
- raise TypeError, \
- "Argument must be extension module type " \
- "'pylith::feassemble::Quadrature'."
- Material_initialize(self.thisptr, ptrFromHandle(mesh), ptrFromHandle(cs),
- ptrFromHandle(quadrature))
- return
-
-
- def _createHandle(self):
- """
- Wrap pointer to C++ object in PyCObject.
- """
- return PyCObject_FromVoidPtr(self.thisptr, Material_destructor)
-
-
- property db:
- def __set__(self, value):
- """
- Set database for physical property parameters.
- """
- # create shim for method 'db'
- #embed{ void Material_db_set(void* objVptr, void* dbVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dbVptr);
- spatialdata::spatialdb::SpatialDB* db =
- (spatialdata::spatialdb::SpatialDB*) dbVptr;
- ((pylith::materials::Material*) objVptr)->db(db);
- } 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
- if not value.name == "spatialdata_spatialdb_SpatialDB":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::spatialdb::SpatialDB'."
- Material_db_set(self.thisptr, ptrFromHandle(value))
-
-
- property initialStateDB:
- def __set__(self, value):
- """
- Set database for initial state variables.
- """
- # create shim for method 'initialStateDB'
- #embed{ void Material_initialStateDB_set(void* objVptr, void* isVptr)
- try {
- assert(0 != objVptr);
- spatialdata::spatialdb::SpatialDB* initialStateDB =
- (spatialdata::spatialdb::SpatialDB*) isVptr;
- ((pylith::materials::Material*) objVptr)->initialStateDB(initialStateDB);
- } 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
- if not value.name == "spatialdata_spatialdb_SpatialDB":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::spatialdb::SpatialDB'."
- if None == value:
- Material_initialStateDB_set(self.thisptr, NULL)
- else:
- Material_initialStateDB_set(self.thisptr, ptrFromHandle(value))
-
-
-
- property id:
- def __set__(self, value):
- """
- Set identifier of material.
- """
- # create shim for method 'id'
- #embed{ void Material_id_set(void* objVptr, int value)
- try {
- assert(0 != objVptr);
- ((pylith::materials::Material*) objVptr)->id(value);
- } 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
- Material_id_set(self.thisptr, value)
-
- def __get__(self):
- """
- Get identifier of material.
- """
- # create shim for method 'id'
- #embed{ int Material_id_get(void* objVptr)
- int result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::materials::Material*) objVptr)->id();
- } 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
- return result;
- #}embed
- return Material_id_get(self.thisptr)
-
-
- property label:
- def __set__(self, value):
- """
- Set label of material.
- """
- # create shim for method 'label'
- #embed{ void Material_label_set(void* objVptr, char* value)
- try {
- assert(0 != objVptr);
- ((pylith::materials::Material*) objVptr)->label(value);
- } 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
- Material_label_set(self.thisptr, value)
-
-
- property dimension:
- def __get__(self):
- """
- Get dimension associated with material.
- """
- # create shim for method 'dimension'
- #embed{ int Material_dimension_get(void* objVptr)
- int result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::materials::Material*) objVptr)->dimension();
- } 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
- return result;
- #}embed
- return Material_dimension_get(self.thisptr)
-
-
- property normalizer:
- def __set__(self, value):
- """
- Set scales for nondimensionalizing physical properties.
- """
- # create shim for method 'normalizer'
- #embed{ void Material_normalizer_set(void* objVptr, void* dimVptr)
- try {
- assert(0 != objVptr);
- assert(0 != dimVptr);
- spatialdata::units::Nondimensional* dim =
- (spatialdata::units::Nondimensional*) dimVptr;
- ((pylith::materials::Material*) objVptr)->normalizer(*dim);
- } 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
- if not value.name == "spatialdata_units_Nondimensional":
- raise TypeError, \
- "Argument must be extension module type " \
- "'spatialdata::units::Nondimensional'."
- Material_normalizer_set(self.thisptr, ptrFromHandle(value))
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticMaterial(Material):
-
- def __init__(self):
- """
- Constructor.
- """
- Material.__init__(self)
- self.name = "pylith_materials_ElasticMaterial"
- return
-
-
- property useElasticBehavior:
- def __set__(self, value):
- """
- Set useElasticBehavior flag.
- """
- # create shim for method 'useElasticBehavior'
- #embed{ void Material_useElasticBehavior_set(void* objVptr, int value)
- try {
- assert(0 != objVptr);
- ((pylith::materials::ElasticMaterial*) objVptr)->useElasticBehavior(value);
- } 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
- Material_useElasticBehavior_set(self.thisptr, value)
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticStrain1D(ElasticMaterial):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* ElasticStrain1D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::materials::ElasticStrain1D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- ElasticMaterial.__init__(self)
- self.thisptr = ElasticStrain1D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticStress1D(ElasticMaterial):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* ElasticStress1D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::materials::ElasticStress1D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- ElasticMaterial.__init__(self)
- self.thisptr = ElasticStress1D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticPlaneStrain(ElasticMaterial):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* ElasticPlaneStrain_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::materials::ElasticPlaneStrain);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- ElasticMaterial.__init__(self)
- self.thisptr = ElasticPlaneStrain_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticPlaneStress(ElasticMaterial):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* ElasticPlaneStress_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::materials::ElasticPlaneStress);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- ElasticMaterial.__init__(self)
- self.thisptr = ElasticPlaneStress_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class ElasticIsotropic3D(ElasticMaterial):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* ElasticIsotropic3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::materials::ElasticIsotropic3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- ElasticMaterial.__init__(self)
- self.thisptr = ElasticIsotropic3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class GenMaxwellIsotropic3D(ElasticMaterial):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* GenMaxwellIsotropic3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::materials::GenMaxwellIsotropic3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- ElasticMaterial.__init__(self)
- self.thisptr = GenMaxwellIsotropic3D_constructor()
- self.handle = self._createHandle()
- return
-
-
-# ----------------------------------------------------------------------
-cdef class MaxwellIsotropic3D(ElasticMaterial):
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* MaxwellIsotropic3D_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::materials::MaxwellIsotropic3D);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- ElasticMaterial.__init__(self)
- self.thisptr = MaxwellIsotropic3D_constructor()
- self.handle = self._createHandle()
- return
-
-# End of file
Property changes on: short/3D/PyLith/trunk/modulesrc/meshio
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
meshio.py
meshio_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/meshio/CellFilter.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/CellFilter.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/CellFilter.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/CellFilter.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/CellFilter.i
+ *
+ * @brief Python interface to C++ CellFilter object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ template<typename mesh_type, typename field_type>
+ class pylith::meshio::CellFilter
+ { // CellFilter
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ CellFilter(void);
+
+ /// Destructor
+ ~CellFilter(void);
+
+ /** Create copy of filter.
+ *
+ * @returns Copy of filter.
+ */
+ virtual
+ CellFilter* clone(void) const = 0;
+
+ /** Set quadrature associated with cells.
+ *
+ * @param q Quadrature for cells.
+ */
+ void quadrature(const pylith::feassemble::Quadrature<mesh_type>* q);
+
+ /** Filter field. Field type of filtered field is returned via an argument.
+ *
+ * @param fieldIn Field to filter.
+ * @param label Value of label of cells to filter.
+ * @param labelId Id associated with label of cells to filter.
+ *
+ * @returns Averaged field.
+ */
+ virtual
+ const field_type& filter(const field_type& fieldIn,
+ const char* label =0,
+ const int labelId =0) = 0;
+
+ }; // CellFilter
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/CellFilterAvg.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/CellFilterAvg.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/CellFilterAvg.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/CellFilterAvg.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/CellFilterAvg.i
+ *
+ * @brief Python interface to C++ CellFilterAvg object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ template<typename mesh_type, typename field_type>
+ class pylith::meshio::CellFilterAvg :
+ public CellFilter<mesh_type, field_type>
+ { // CellFilterAvg
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ CellFilterAvg(void);
+
+ /// Destructor
+ ~CellFilterAvg(void);
+
+ /** Create copy of filter.
+ *
+ * @returns Copy of filter.
+ */
+ CellFilter<mesh_type, field_type>* clone(void) const;
+
+ /** Filter field over cells.
+ *
+ * @param fieldIn Field to filter.
+ * @param label Label identifying cells.
+ * @param labelId Value of label of cells to filter.
+ *
+ * @returns Averaged field.
+ */
+ const field_type& filter(const field_type& fieldIn,
+ const char* label =0,
+ const int labelId =0);
+
+ }; // CellFilterAvg
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/DataWriter.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/DataWriter.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,108 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/DataWriter.i
+ *
+ * @brief Python interface to C++ DataWriter object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ template<typename mesh_type, typename field_type>
+ class pylith::meshio::DataWriter
+ { // DataWriter
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ DataWriter(void);
+
+ /// Destructor
+ virtual
+ ~DataWriter(void);
+
+ /** Make copy of this object.
+ *
+ * @returns Copy of this.
+ */
+ virtual
+ DataWriter* clone(void) const = 0;
+
+ /** Prepare for writing files.
+ *
+ * @param mesh Finite-element mesh.
+ * @param numTimeSteps Expected number of time steps for fields.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ virtual
+ void open(const mesh_type& mesh,
+ const int numTimeSteps,
+ const char* label =0,
+ const int labelId =0);
+
+ /// Close output files.
+ virtual
+ void close(void);
+
+ /** Prepare file for data at a new time step.
+ *
+ * @param t Time stamp for new data
+ * @param mesh PETSc mesh object
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ virtual
+ void openTimeStep(const double t,
+ const mesh_type& mesh,
+ const char* label =0,
+ const int labelId =0);
+
+ /// Cleanup after writing data for a time step.
+ virtual
+ void closeTimeStep(void);
+
+ /** Write field over vertices to file.
+ *
+ * @param t Time associated with field.
+ * @param field Field over vertices.
+ */
+ virtual
+ void writeVertexField(const double t,
+ const field_type& field) = 0;
+
+ /** Write field over cells to file.
+ *
+ * @param t Time associated with field.
+ * @param field Field over cells.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ virtual
+ void writeCellField(const double t,
+ const field_type& field,
+ const char* label =0,
+ const int labelId =0) = 0;
+
+ }; // DataWriter
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/DataWriterVTK.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/DataWriterVTK.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/DataWriterVTK.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/DataWriterVTK.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/DataWriterVTK.i
+ *
+ * @brief Python interface to C++ DataWriterVTK object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ template<typename mesh_type, typenam field_type>
+ class pylith::meshio::DataWriterVTK :
+ public DataWriter<mesh_type, field_type>
+ { // DataWriterVTK
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ DataWriterVTK(void);
+
+ /// Destructor
+ ~DataWriterVTK(void);
+
+ /** Make copy of this object.
+ *
+ * @returns Copy of this.
+ */
+ DataWriter<mesh_type, field_type>* clone(void) const;
+
+ /** Set filename for VTK file.
+ *
+ * @param filename Name of VTK file.
+ */
+ void filename(const char* filename);
+
+ /** Set time format for time stamp in name of VTK file.
+ *
+ * @param format C style time format for filename.
+ */
+ void timeFormat(const char* format);
+
+ /** Set value used to normalize time stamp in name of VTK file.
+ *
+ * Time stamp is divided by this value (time in seconds).
+ *
+ * @param value Value (time in seconds) used to normalize time stamp in
+ * filename.
+ */
+ void timeConstant(const double value);
+
+ /** Prepare file for data at a new time step.
+ *
+ * @param t Time stamp for new data
+ * @param mesh Finite-element mesh.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ void openTimeStep(const double t,
+ const mesh_type& mesh,
+ const char* label =0,
+ const int labelId =0);
+
+ /// Cleanup after writing data for a time step.
+ void closeTimeStep(void);
+
+ /** Write field over vertices to file.
+ *
+ * @param t Time associated with field.
+ * @param field Field over vertices.
+ */
+ void writeVertexField(const double t,
+ const field_type& field);
+
+ /** Write field over cells to file.
+ *
+ * @param t Time associated with field.
+ * @param field Field over cells.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ void writeCellField(const double t,
+ const field_type& field,
+ const char* label =0,
+ const int labelId =0);
+
+ }; // DataWriterVTK
+
+ } // meshio
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/meshio/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,42 +13,53 @@
subpackage = meshio
include $(top_srcdir)/subpackage.am
-subpkgpyexec_LTLIBRARIES = meshiomodule.la
+subpkgpyexec_LTLIBRARIES = _meshiomodule.la
-meshiomodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = meshio.py
+
+swig_sources = \
+ meshio.i \
+ MeshIOObj.i \
+ MeshIOAscii.i \
+ MeshIOLagrit.i \
+ MeshIOCubit.i \
+ VertexFilter.i \
+ VertexFilterVecNorm.i \
+ DataWriter.i \
+ DataWriterVTK.i \
+ OutputManager.i \
+ OutputSolnSubset.i
+
+swig_generated = \
+ meshio_wrap.cxx \
+ meshio.py
+
+_meshiomodule_la_LDFLAGS = -module -avoid-version \
$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_meshiomodule_la_SOURCES = meshio.pyxe.src
-nodist_meshiomodule_la_SOURCES = \
- meshio.pyxe \
- meshio.c meshio_embed.cpp meshio_embed.h
+dist__meshiomodule_la_SOURCES = $(swig_sources) $(swig_generated)
-meshiomodule_la_LIBADD = \
+_meshiomodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
-lspatialdata \
- $(PETSC_LIB)
-
+ $(PETSC_LIBS)
if ENABLE_CUBIT
- meshiomodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
+ _meshiomodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
endif
if NO_UNDEFINED
- meshiomodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_meshiomodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-PYREX_INCLUDES = -I$(top_srcdir)/modulesrc/topology
+$(srcdir)/meshio_wrap.cxx $(srcdir)/meshio.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-meshio.pyx meshio_embed.cpp meshio_embed.h: meshio.pyxe
- pyrexembed meshio.pyxe
-meshio.pyxe: $(srcdir)/meshio.pyxe.src
- cp $(srcdir)/meshio.pyxe.src $@
-meshio_embed.cpp: meshio_embed.h
-meshio_embed.h: meshio.pyx
-.pyx.c:
- pyrexc $< $(PYREX_INCLUDES)
+MAINTAINERCLEANFILES = \
+ $(srcdir)/meshio_wrap.cxx \
+ $(srcdir)/meshio.py
-CLEANFILES = meshio.pyxe meshio.pyx meshio.c *_embed.*
# End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/MeshIOAscii.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOAscii.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/MeshIOAscii.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/MeshIOAscii.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/MeshIOAscii.i
+ *
+ * @brief Python interface to C++ MeshIOAscii object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ class MeshIOAscii : public MeshIO
+ { // MeshIOAscii
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ MeshIOAscii(void);
+
+ /// Destructor
+ ~MeshIOAscii(void);
+
+ /** Set filename for ASCII file.
+ *
+ * @param filename Name of file
+ */
+ void filename(const char* name);
+
+ /** Get filename of ASCII file.
+ *
+ * @returns Name of file
+ */
+ const char* filename(void) const;
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /// Write mesh
+ void _write(void) const;
+
+ /// Read mesh
+ void _read(void);
+
+ }; // MeshIOAscii
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/MeshIOCubit.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOCubit.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/MeshIOCubit.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/MeshIOCubit.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/MeshIOCubit.i
+ *
+ * @brief Python interface to C++ MeshIOCubit object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ class MeshIOCubit : public MeshIO
+ { // MeshIOCubit
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ MeshIOCubit(void);
+
+ /// Destructor
+ ~MeshIOCubit(void);
+
+ /** Set filename for Cubit file.
+ *
+ * @param filename Name of file
+ */
+ void filename(const char* name);
+
+ /** Get filename of Cubit file.
+ *
+ * @returns Name of file
+ */
+ const char* filename(void) const;
+
+ // PROTECTED METHODS ////////////////////////////////////////////////////
+ protected :
+
+ /// Write mesh
+ void _write(void) const;
+
+ /// Read mesh
+ void _read(void);
+
+ }; // MeshIOCubit
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/MeshIOLagrit.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOLagrit.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/MeshIOLagrit.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/MeshIOLagrit.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,124 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/MeshIOLagrit.i
+ *
+ * @brief Python interface to C++ MeshIOLagrit object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ class MeshIOLagrit : public MeshIO
+ { // MeshIOLagrit
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ MeshIOLagrit(void);
+
+ /// Destructor
+ ~MeshIOLagrit(void);
+
+ /** Set filename for mesh GMV file.
+ *
+ * @param filename Name of file
+ */
+ void filenameGmv(const char* name);
+
+ /** Get filename of mesh GMV file.
+ *
+ * @returns Name of file
+ */
+ const char* filenameGmv(void) const;
+
+ /** Set filename for PSET mesh file.
+ *
+ * @param filename Name of file
+ */
+ void filenamePset(const char* name);
+
+ /** Get filename of PSET mesh file.
+ *
+ * @returns Name of file
+ */
+ const char* filenamePset(void) const;
+
+ /** Set flag to write ASCII or binary files.
+ *
+ * @param flag True if writing ASCII, false if writing binary
+ */
+ void writerAscii(const bool flag);
+
+ /** Get flag for writing ASCII or binary files.
+ *
+ * @returns True if writing ASCII, false if writing binary.
+ */
+ bool writeAscii(void) const;
+
+ /** Set flag to flip endian type when reading/writing from binary files.
+ *
+ * @param flag True if flipping endian, false otherwise
+ */
+ void flipEndian(const bool flag);
+
+ /** Get flag for flipping endian type when reading/writing from
+ * binary files.
+ *
+ * @returns True if flipping endian, false othewise.
+ */
+ bool flipEndian(void) const;
+
+ /** Set flag indicating LaGriT Pset files use 32-bit integers.
+ *
+ * @param flag True if using 32-bit integers, false if using
+ * 64-bit integers.
+ */
+ void ioInt32(const bool flag);
+
+ /** Get flag indicating LaGriT Pset files use 32-bit integers.
+ *
+ * @returns True if using 32-bit integers, false if using 64-bit integers.
+ */
+ bool ioInt32(void) const;
+
+ /** Set Fortran record header size flag.
+ *
+ * @param flag True if Fortran record header size is 32-bit,
+ * false if 64-bit.
+ */
+ void isRecordHeader32Bit(const bool flag);
+
+ /** Get Fortran record header size flag.
+ *
+ * @param returns True if Fortran record header size is 32-bit,
+ * false if 64-bit.
+ */
+ bool isRecordHeader32Bit(void) const;
+
+ // PROTECTED METHODS //////////////////////////////////////////////
+ protected :
+
+ /// Write mesh
+ void _write(void) const;
+
+ /// Read mesh
+ void _read(void);
+
+ }; // MeshIOLagrit
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/MeshIOObj.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/MeshIOObj.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/MeshIOObj.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/MeshIOObj.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,110 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/MeshIO.i
+ *
+ * @brief Python interface to C++ MeshIO object.
+ */
+
+namespace pylith {
+ namespace topology {
+ class Mesh;
+ } // topology
+
+ namespace meshio {
+
+ class MeshIO
+ { // MeshIO
+
+ // PUBLIC TYPEDEFS ////////////////////////////////////////////////
+ public :
+
+ /// Type of points in a group.
+ enum GroupPtType {
+ VERTEX=0,
+ CELL=1,
+ }; // GroupPtType
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ MeshIO(void);
+
+ /// Destructor
+ virtual
+ ~MeshIO(void);
+
+ /** Set debug flag for mesh.
+ *
+ * @param flag True to print debugging information.
+ */
+ void debug(const bool flag);
+
+ /** Get debug flag for mesh.
+ *
+ * @returns True if debugging is on.
+ */
+ bool debug(void) const;
+
+ /** Set flag associated with building intermediate mesh topology
+ * elements.
+ *
+ * @param flag True to build intermediate topology, false not to build
+ */
+ void interpolate(const bool flag);
+
+ /** Get flag associated with building intermediate mesh topology
+ * elements.
+ *
+ * @returns True if building intermediate topology, false if not building
+ */
+ bool interpolate(void) const;
+
+ /** Set scales used to nondimensionalize mesh.
+ *
+ * @param dim Nondimensionalizer.
+ */
+ void normalizer(const spatialdata::units::Nondimensional& dim);
+
+ /** Read mesh from file.
+ *
+ * @param mesh PyLith finite-element mesh.
+ */
+ void read(pylith::topology::Mesh* mesh);
+
+ /** Write mesh to file.
+ *
+ * @param mesh PyLith finite-element mesh.
+ */
+ void write(pylith::topology::Mesh* const mesh);
+
+ // PROTECTED MEMBERS //////////////////////////////////////////////
+ protected :
+
+ /// Write mesh
+ virtual
+ void _write(void) const = 0;
+
+ /// Read mesh
+ virtual
+ void _read(void) = 0;
+
+ }; // MeshIO
+
+ } // meshio
+} // pylith
+
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/OutputManager.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/OutputManager.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/OutputManager.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/OutputManager.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/OutputManager.i
+ *
+ * @brief Python interface to C++ OutputManager object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ template<typename mesh_type, typename field_type>
+ class pylith::meshio::OutputManager
+ { // OutputManager
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ OutputManager(void);
+
+ /// Destructor
+ virtual
+ ~OutputManager(void);
+
+ /** Set coordinate system in output. The vertex fields in the output
+ * are not affected by any change in coordinates.
+ *
+ * @param cs Coordinate system in output.
+ */
+ void coordsys(const spatialdata::geocoords::CoordSys* cs);
+
+ /** Set writer to write data to file.
+ *
+ * @param datawriter Writer for data.
+ */
+ void writer(DataWriter<mesh_type, field_type>* const datawriter);
+
+ /** Set filter for vertex data.
+ *
+ * @param filter Filter to apply to vertex data before writing.
+ */
+ void vertexFilter(VertexFilter<field_type>* const filter);
+
+ /** Set filter for cell data.
+ *
+ * @param filter Filter to apply to cell data before writing.
+ */
+ void cellFilter(CellFilter<mesh_type, field_type>* const filter);
+
+ /** Prepare for output.
+ *
+ * @param mesh Finite-element mesh object.
+ * @param numTimeSteps Expected number of time steps.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ void open(const mesh_type& mesh,
+ const int numTimeSteps,
+ const char* label =0,
+ const int labelId =0);
+
+ /// Close output files.
+ void close(void);
+
+ /** Setup file for writing fields at time step.
+ *
+ * @param t Time of time step.
+ * @param mesh Finite-element mesh object.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ void openTimeStep(const double t,
+ const mesh_type& mesh,
+ const char* label =0,
+ const int labelId =0);
+
+ /// End writing fields at time step.
+ void closeTimeStep(void);
+
+ /** Append finite-element vertex field to file.
+ *
+ * @param t Time associated with field.
+ * @param field Vertex field.
+ */
+ void appendVertexField(const double t,
+ const field_type& field);
+
+ /** Append finite-element cell field to file.
+ *
+ * @param t Time associated with field.
+ * @param field Cell field.
+ * @param label Name of label defining cells to include in output
+ * (=0 means use all cells in mesh).
+ * @param labelId Value of label defining which cells to include.
+ */
+ void appendCellField(const double t,
+ const field_type& field,
+ const char* label =0,
+ const int labelId =0);
+
+ }; // OutputManager
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/OutputSolnSubset.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/OutputSolnSubset.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/OutputSolnSubset.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/OutputSolnSubset.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,70 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/OutputSolnSubset.i
+ *
+ * @brief Python interface to C++ OutputSolnSubset object.
+ */
+
+%template(_SubMeshOutputManager) pylith::meshio::OutputManager<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::Mesh> >;
+
+namespace pylith {
+ namespace meshio {
+
+ class pylith::meshio::OutputSolnSubset : public OutputManager<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::Mesh> >
+ { // OutputSolnSubset
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ OutputSolnSubset(void);
+
+ /// Destructor
+ ~OutputSolnSubset(void);
+
+ /** Set label identifier for subdomain.
+ *
+ * @param value Label of subdomain.
+ */
+ void label(const char* value);
+
+ /** Verify configuration.
+ *
+ * @param mesh PETSc mesh
+ */
+ void verifyConfiguration(const pylith::topology::Mesh& mesh) const;
+
+ /** Get mesh associated with subdomain.
+ *
+ * @returns Mesh associated with subdomain.
+ */
+ const pylith::topology::SubMesh& subdomainMesh(const pylith::topology::Mesh& mesh);
+
+ /** Append finite-element vertex field to file.
+ *
+ * @param t Time associated with field.
+ * @param field Vertex field.
+ */
+ void appendVertexField(const double t,
+ const pylith::topology::Field<pylith::topology::Mesh>& field);
+
+
+
+ }; // OutputSolnSubset
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/VertexFilter.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/VertexFilter.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/VertexFilter.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/VertexFilter.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/VertexFilter.i
+ *
+ * @brief Python interface to C++ VertexFilter object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ template<typename field_type>
+ class pylith::meshio::VertexFilter
+ { // VertexFilter
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ VertexFilter(void);
+
+ /// Destructor
+ ~VertexFilter(void);
+
+ /** Create copy of filter.
+ *
+ * @returns Copy of filter.
+ */
+ virtual
+ VertexFilter* clone(void) const = 0;
+
+ /** Filter field over vertices of a mesh.
+ *
+ * @param fieldIn Field to filter.
+ */
+ virtual
+ const field_type& filter(const field_type& fieldIn) = 0;
+
+ }; // VertexFilter
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/VertexFilterVecNorm.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/VertexFilterVecNorm.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/VertexFilterVecNorm.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/VertexFilterVecNorm.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/meshio/VertexFilterVecNorm.i
+ *
+ * @brief Python interface to C++ VertexFilterVecNorm object.
+ */
+
+namespace pylith {
+ namespace meshio {
+
+ template<typename field_type>
+ class pylith::meshio::VertexFilterVecNorm : public VertexFilter<field_type>
+ { // VertexFilterVecNorm
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ VertexFilterVecNorm(void);
+
+ /// Destructor
+ ~VertexFilterVecNorm(void);
+
+ /** Create copy of filter.
+ *
+ * @returns Copy of filter.
+ */
+ VertexFilter<field_type>* clone(void) const;
+
+ /** Filter vertex field.
+ *
+ * @param fieldIn Field to filter.
+ */
+ const field_type& filter(const field_type& fieldIn);
+
+ }; // VertexFilterVecNorm
+
+ } // meshio
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/meshio/meshio.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/meshio/meshio.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/meshio/meshio.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/meshio/meshio.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module meshio
+
+// Header files for module C++ code
+%{
+#include "pylith/meshio/MeshIO.hh"
+#include "pylith/meshio/MeshIOAscii.hh"
+#include "pylith/meshio/MeshIOLagrit.hh"
+#include "pylith/meshio/MeshIOCubit.hh"
+
+#include "pylith/meshio/VertexFilter.hh"
+#include "pylith/meshio/VertexFilterVecNorm.hh"
+#include "pylith/meshio/CellFilter.hh"
+#include "pylith/meshio/CellFilterAvg.hh"
+#include "pylith/meshio/DataWriter.hh"
+#include "pylith/meshio/DataWriterVTK.hh"
+#include "pylith/meshio/OutputManager.hh"
+#include "pylith/meshio/OutputSolnSubset.hh"
+
+#include "pylith/utils/arrayfwd.hh"
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+
+// Interfaces
+%include "MeshIOObj.i"
+%include "MeshIOAscii.i"
+%include "MeshIOLagrit.i"
+%include "MeshIOCubit.i"
+
+%include "VertexFilter.i"
+%include "VertexFilterVecNorm.i"
+%include "CellFilter.i"
+%include "CellFilterAvg.i"
+%include "DataWriter.i"
+%include "DataWriterVTK.i"
+%include "OutputManager.i"
+%include "OutputSolnSubset.i"
+
+// Template instatiation
+%template(MeshVertexFilter) pylith::meshio::VertexFilter<pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshVertexFilter) pylith::meshio::VertexFilter<pylith::topology::Field<pylith::topology::SubMesh> >;
+%template(MeshVertexFilterVecNorm) pylith::meshio::VertexFilterVecNorm<pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshVertexFilterVecNorm) pylith::meshio::VertexFilterVecNorm<pylith::topology::Field<pylith::topology::SubMesh> >;
+
+%template(MeshCellFilter) pylith::meshio::CellFilter<pylith::topology::Mesh, pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshCellFilter) pylith::meshio::CellFilter<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::SubMesh> >;
+%template(MeshCellFilterAvg) pylith::meshio::CellFilterAvg<pylith::topology::Mesh, pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshCellFilterAvg) pylith::meshio::CellFilterAvg<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::SubMesh> >;
+
+%template(MeshDataWriter) pylith::meshio::DataWriter<pylith::topology::Mesh, pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshDataWriter) pylith::meshio::DataWriter<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubSubMeshDataWriter) pylith::meshio::DataWriter<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::SubMesh> >;
+
+%template(MeshDataWriterVTK) pylith::meshio::DataWriterVTK<pylith::topology::Mesh, pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshDataWriterVTK) pylith::meshio::DataWriterVTK<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubSubMeshDataWriterVTK) pylith::meshio::DataWriterVTK<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::SubMesh> >;
+
+%template(MeshOutputManager) pylith::meshio::OutputManager<pylith::topology::Mesh, pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshOutputManager) pylith::meshio::OutputManager<pylith::topology::SubMesh, pylith::topology::Field<pylith::topology::SubMesh> >;
+
+// End of file
+
Copied: short/3D/PyLith/trunk/modulesrc/mpi (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/mpi)
Property changes on: short/3D/PyLith/trunk/modulesrc/mpi
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
mpi.py
mpi_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/problems (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/problems)
Property changes on: short/3D/PyLith/trunk/modulesrc/problems
___________________________________________________________________
Name: svn:ignore
+ problems.py
problems_wrap.cxx
Makefile.in
Property changes on: short/3D/PyLith/trunk/modulesrc/topology
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
topology.py
topology_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/topology/Distributor.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Distributor.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Distributor.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/Distributor.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,61 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Distributor.i
+ *
+ * @brief Python interface to C++ Distributor object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class Distributor
+ { // Distributor
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ Distributor(void);
+
+ /// Destructor
+ ~Distributor(void);
+
+ /** Distribute mesh among processors.
+ *
+ * @param newMesh Distributed mesh (result).
+ * @param origMesh Mesh to distribute.
+ * @param partitioner Name of partitioner to use in distributing mesh.
+ */
+ static
+ void distribute(pylith::topology::Mesh* const newMesh,
+ const pylith::topology::Mesh& origMesh,
+ const char* partitioner);
+
+ /** Write partitioning info for distributed mesh.
+ *
+ * @param writer Data writer for partition information.
+ * @param mesh Distributed mesh.
+ * @param cs Coordinate system for mesh.
+ */
+ static
+ void write(pylith::meshio::DataWriter<pylith::topology::Mesh, pylith::topology::Field<pylith::topology::Mesh> >* const writer,
+ const pylith::topology::Mesh& mesh);
+
+ }; // Distributor
+
+ } // topology
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/Field.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Field.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Field.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/Field.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,201 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Field.hh
+ *
+ * @brief Python interface to C++ Field object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ template<typename mesh_type>
+ class Field : public FieldBase
+ { // Field
+
+ // PRIVATE TYPEDEFS ///////////////////////////////////////////////
+ private:
+
+ // Convenience typedefs
+ typedef typename mesh_type::RealSection RealSection;
+ typedef typename mesh_type::SieveMesh SieveMesh;
+ typedef typename SieveMesh::label_sequence label_sequence;
+ typedef typename RealSection::chart_type chart_type;
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ Field(const mesh_type& mesh);
+
+ /// Destructor.
+ ~Field(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Get mesh associated with field.
+ *
+ * @returns Finite-element mesh.
+ */
+ const mesh_type& mesh(void) const;
+
+ /** Set label for field.
+ *
+ * @param value Label for field.
+ */
+ void label(const char* value);
+
+ /** Get label for field.
+ *
+ * @returns Label for field.
+ */
+ const char* label(void) const;
+
+ /** Set vector field type
+ *
+ * @param value Type of vector field.
+ */
+ void vectorFieldType(const pylith::topology::FieldBase::VectorFieldEnum value);
+
+ /** Get vector field type
+ *
+ * @returns Type of vector field.
+ */
+ pylith::topology::FieldBase::VectorFieldEnum vectorFieldType(void) const;
+
+ /** Set scale for dimensionalizing field.
+ *
+ * @param value Scale associated with field.
+ */
+ void scale(const double value);
+
+ /** Get scale for dimensionalizing field.
+ *
+ * @returns Scale associated with field.
+ */
+ double scale(void) const;
+
+ /** Set flag indicating whether it is okay to dimensionalize field.
+ *
+ * @param value True if it is okay to dimensionalize field.
+ */
+ void addDimensionOkay(const bool value);
+
+ /** Set flag indicating whether it is okay to dimensionalize field.
+ *
+ * @param value True if it is okay to dimensionalize field.
+ */
+ bool addDimensionOkay(void) const;
+
+ /** Get spatial dimension of domain.
+ *
+ * @returns Spatial dimension of domain.
+ */
+ int spaceDim(void) const;
+
+ /// Create sieve section.
+ void newSection(void);
+
+ /** Create sieve section and set chart and fiber dimesion.
+ *
+ * @param domain Type of points over which to define section.
+ * @param dim Fiber dimension for section.
+ * @param stratum Stratum depth (for vertices) and height (for cells).
+ */
+ void newSection(const pylith::topology::FieldBase::DomainEnum domain,
+ const int fiberDim,
+ const int stratum =0);
+
+ /** Create section with same layout (fiber dimension and
+ * constraints) as another section. This allows the layout data
+ * structures to be reused across multiple fields, reducing memory
+ * usage.
+ *
+ * @param sec Section defining layout.
+ */
+ void newSection(const Field& src);
+
+ /// Clear variables associated with section.
+ void clear(void);
+
+ /// Allocate field.
+ void allocate(void);
+
+ /// Zero section values.
+ void zero(void);
+
+ /// Complete section by assembling across processors.
+ void complete(void);
+
+ /** Copy field values and metadata.
+ *
+ * @param field Field to copy.
+ */
+ void copy(const Field& field);
+
+ /** Add two fields, storing the result in one of the fields.
+ *
+ * @param field Field to add.
+ */
+ void operator+=(const Field& field);
+
+ /** Dimensionalize field. Throws runtime_error if field is not
+ * allowed to be dimensionalized.
+ */
+ void dimensionalize(void);
+
+ /** Print field to standard out.
+ *
+ * @param label Label for output.
+ */
+ void view(const char* label);
+
+ /// Create PETSc vector for field.
+ void createVector(void);
+
+ /** Get PETSc vector associated with field.
+ *
+ * @returns PETSc vector.
+ */
+ PetscVec vector(void);
+
+ /** Get PETSc vector associated with field.
+ *
+ * @returns PETSc vector.
+ */
+ const PetscVec vector(void) const;
+
+ /// Create PETSc vector scatter for field. This is used to transfer
+ /// information from the "global" PETSc vector view to the "local"
+ /// Sieve section view.
+ void createScatter(void);
+
+ /// Scatter section information across processors to update the
+ /// PETSc vector view of the field.
+ void scatterSectionToVector(void) const;
+
+ /// Scatter PETSc vector information across processors to update the
+ /// Sieve section view of the field.
+ void scatterVectorToSection(void) const;
+
+ }; // Field
+
+ } // topology
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/FieldBase.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/FieldBase.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/FieldBase.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/FieldBase.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Field.hh
+ *
+ * @brief Python interface to C++ FieldBase object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class FieldBase
+ { // FieldBase
+
+ // PUBLIC ENUMS ///////////////////////////////////////////////////
+ public :
+
+ enum VectorFieldEnum {
+ SCALAR=0, ///< Scalar.
+ VECTOR=1, ///< Vector.
+ TENSOR=2, ///< Tensor.
+ OTHER=3, ///< Not a scalar, vector, or tensor.
+ MULTI_SCALAR=4, ///< Scalar at multiple points.
+ MULTI_VECTOR=5, ///< Vector at multiple points.
+ MULTI_TENSOR=6, ///< Tensor at multiple points.
+ MULTI_OTHER=7, ///< Not a scalar, vector, or tensor at multiple points.
+ }; // VectorFieldEnum
+
+ enum DomainEnum {
+ VERTICES_FIELD=0, ///< FieldBase over vertices.
+ CELLS_FIELD=1, ///< FieldBase over cells.
+ }; // DomainEnum
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ FieldBase(void); ///< Default constructor.
+ ~FieldBase(void); ///< Default destructor.
+
+ }; // FieldBase
+
+ } // topology
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/Fields.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Fields.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Fields.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/Fields.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,97 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Fields.i
+ *
+ * @brief Python interface to C++ Fields object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ template<typename field_type>
+ class Fields
+ { // Fields
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ Fields(const typename field_type::Mesh& mesh);
+
+ /// Destructor.
+ ~Fields(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field.
+ */
+ void add(const char* name,
+ const char* label);
+
+ /** Add field.
+ *
+ * @param name Name of field.
+ * @param label Label for field.
+ * @param domain Type of points over which to define field.
+ * @param fiberDim Fiber dimension for field.
+ */
+ void add(const char* name,
+ const char* label,
+ const pylith::topology::FieldBase::DomainEnum domain,
+ const int fiberDim);
+
+ /** Delete field.
+ *
+ * @param name Name of field.
+ */
+ void delField(const char* name);
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ */
+ const field_type& get(const char* name) const;
+
+ /** Get field.
+ *
+ * @param name Name of field.
+ */
+ field_type& get(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;
+
+ }; // Fields
+
+ } // topology
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Jacobian.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/Jacobian.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Jacobian.i
+ *
+ * @brief Python interface to C++ Jacobian object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class Jacobian
+ { // Jacobian
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param fields Fields associated with mesh and solution of the problem.
+ */
+ Jacobian(const SolutionFields& fields);
+
+ /// Destructor.
+ ~Jacobian(void);
+
+ /// Deallocate PETSc and local data structures.
+ void deallocate(void);
+
+ /** Get PETSc matrix.
+ *
+ * @returns PETSc sparse matrix.
+ */
+ const PetscMat* matrix(void) const;
+
+ /** Get PETSc matrix.
+ *
+ * @returns PETSc sparse matrix.
+ */
+ PetscMat* matrix(void);
+
+ /** Assemble matrix.
+ *
+ * @param mode Assembly mode.
+ */
+ void assemble(const char* mode);
+
+ /// Set entries in matrix to zero (retain structure).
+ void zero(void);
+
+ /// View matrix to stdout.
+ void view(void);
+
+ /** Write matrix to binary file.
+ *
+ * @param filename Name of file.
+ */
+ void write(const char* filename);
+
+ }; // Jacobian
+
+ } // topology
+} // pylith
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/topology/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,40 +13,49 @@
subpackage = topology
include $(top_srcdir)/subpackage.am
-subpkgpyexec_LTLIBRARIES = topologymodule.la
+subpkgpyexec_LTLIBRARIES = _topologymodule.la
-topologymodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = topology.py
+
+swig_sources = \
+ topology.i \
+ Mesh.i \
+ SubMesh.i \
+ MeshOps.i \
+ FieldBase.i \
+ Field.i \
+ Fields.i \
+ SolutionFields.i \
+ Jacobian.i \
+ Distributor.i
+
+swig_generated = \
+ topology_wrap.cxx \
+ topology.py
+
+_topologymodule_la_LDFLAGS = -module -avoid-version \
$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_topologymodule_la_SOURCES = topology.pyxe.src
-nodist_topologymodule_la_SOURCES = \
- topology.pyxe \
- topology.c topology_embed.cpp topology_embed.h
+dist__topologymodule_la_SOURCES = $(swig_sources) $(swig_generated)
-topologymodule_la_LIBADD = \
+_topologymodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
-lspatialdata \
- $(PETSC_LIB)
-
-if ENABLE_CUBIT
- topologymodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
-endif
+ $(PETSC_LIBS)
if NO_UNDEFINED
- topologymodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_topologymodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
-INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-topology.pyx topology_embed.cpp topology_embed.h: topology.pyxe
- pyrexembed topology.pyxe
-topology.pyxe: $(srcdir)/topology.pyxe.src
- cp $(srcdir)/topology.pyxe.src $@
-topology_embed.cpp: topology_embed.h
-topology_embed.h: topology.pyx
+$(srcdir)/topology_wrap.cxx $(srcdir)/topology.py: $(swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-.pyx.c:
- pyrexc $(PYTHON_EGG_PYXFLAGS) $<
-CLEANFILES = topology.pyxe topology.pyx topology.c *_embed.*
+MAINTAINERCLEANFILES = \
+ $(srcdir)/topology_wrap.cxx \
+ $(srcdir)/topology.py
+
# End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/Mesh.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/Mesh.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/Mesh.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/Mesh.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,106 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/Mesh.hh
+ *
+ * @brief Python interface to C++ PyLith Mesh object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ // Mesh -------------------------------------------------------------
+ class Mesh
+ { // Mesh
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ Mesh(void);
+
+ /** Constructor with dimension and communicator.
+ *
+ * @param dim Dimension associated with mesh cells.
+ * @param comm MPI communicator for mesh.
+ */
+ Mesh(const int dim,
+ const MPI_Comm& comm =PETSC_COMM_WORLD);
+
+ /// Default destructor
+ ~Mesh(void);
+
+ /** Create Sieve mesh.
+ *
+ * @param dim Dimension associated with mesh cells.
+ */
+ void createSieveMesh(const int dim=3);
+
+ /** Set coordinate system.
+ *
+ * @param cs Coordinate system.
+ */
+ void coordsys(const spatialdata::geocoords::CoordSys* cs);
+
+ /** Get coordinate system.
+ *
+ * @returns Coordinate system.
+ */
+ const spatialdata::geocoords::CoordSys* coordsys(void) const;
+
+ /** Set debug flag.
+ *
+ * @param value Turn on debugging if true.
+ */
+ void debug(const bool value);
+
+ /** Get debug flag.
+ *
+ * @param Get debugging flag.
+ */
+ bool debug(void) const;
+
+ /** Get dimension of mesh.
+ *
+ * @returns Dimension of mesh.
+ */
+ int dimension(void) const;
+
+ /** Set MPI communicator associated with mesh.
+ *
+ * @param value MPI communicator.
+ */
+ void comm(const MPI_Comm value);
+
+ /** Get MPI communicator associated with mesh.
+ *
+ * @returns MPI communicator.
+ */
+ const MPI_Comm comm(void) const;
+
+ /// Initialize the finite-element mesh.
+ void initialize(void);
+
+ /** Print mesh to stdout.
+ *
+ * @param label Label for mesh.
+ */
+ void view(const char* label);
+
+ }; // Mesh
+
+ } // topology
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/MeshOps.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/MeshOps.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/MeshOps.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/MeshOps.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/MeshOps.i
+ *
+ * @brief Python interface to C++ MeshOps.
+ */
+
+%apply(int* IN_ARRAY1, int DIM1) {
+ (int* const materialIds, const int numMaterials)
+ };
+%inline %{
+ /** Check to make sure material id of every cell matches the id of
+ * one of the materials.
+ *
+ * @param mesh PETSc mesh.
+ * @param materialIds Array of ids for all materials and cohesive
+ * cell interfaces.
+ * @param numMaterials Size of array.
+ */
+ void
+ MeshOps_checkMaterialIds(const pylith::topology::Mesh& mesh,
+ int* const materialIds,
+ const int numMaterials) {
+ pylith::topology::MeshOps::checkMaterialIds(mesh,
+ materialIds, numMaterials);
+ } // checkMaterialIds
+%}
+%clear(int* const materialIds, const int numMaterials);
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/SolutionFields.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SolutionFields.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/SolutionFields.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/SolutionFields.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/SolutionFields.i
+ *
+ * @brief Python interface to C++ SolutionFields object.
+ */
+
+%template(SolutionFieldsBase) pylith::topology::Fields<pylith::topology::Field<pylith::topology::Mesh> >;
+
+namespace pylith {
+ namespace topology {
+
+ class SolutionFields : public Fields <Field <Mesh> >
+ { // SolutionFields
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /** Default constructor.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ SolutionFields(const Mesh& mesh);
+
+ /// Destructor.
+ ~SolutionFields(void);
+
+ /** Set name of solution field.
+ *
+ * @param name Name of field that is the solution.
+ */
+ void solutionName(const char* name);
+
+ /** Get solution field.
+ *
+ * @returns Solution field.
+ */
+ const Field<Mesh>& solution(void) const;
+
+ /** Get solution field.
+ *
+ * @returns Solution field.
+ */
+ Field<Mesh>& solution(void);
+
+ /** Set name of field that will be used in the solve.
+ *
+ * @param name Name of field used in the solve.
+ */
+ void solveSolnName(const char* name);
+
+ /** Get field used in the solve.
+ *
+ * @returns Field used in the solve.
+ */
+ const Field<Mesh>& solveSoln(void) const;
+
+ /** Get field used in the solve.
+ *
+ * @returns Field used in the solve.
+ */
+ Field<Mesh>& solveSoln(void);
+
+ /** Create history manager for a subset of the managed fields.
+ *
+ * @param fields Fields in history (first is most recent).
+ * @param size Number of fields in history.
+ */
+ %apply(const char* const* string_list, const int list_len){
+ (const char* const* fields,
+ const int size)
+ };
+ void createHistory(const char* const* fields,
+ const int size);
+ %clear(const char* const* fields, const int size);
+
+ /** Shift fields in history. Handles to fields are shifted so that
+ * the most recent values become associated with the second most
+ * recent item in the history, etc.
+ */
+ void shiftHistory(void);
+
+ }; // SolutionFields
+
+ } // topology
+} // pylith
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/SubMesh.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/SubMesh.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/SubMesh.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/SubMesh.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/topology/SubMesh.i
+ *
+ * @brief Python interface to C++ Mesh object.
+ */
+
+namespace pylith {
+ namespace topology {
+
+ class SubMesh
+ { // SubMesh
+
+ // PUBLIC METHODS /////////////////////////////////////////////////
+ public :
+
+ /// Default constructor.
+ SubMesh(void);
+
+ /** Constructor with mesh and label for vertices marking boundary.
+ *
+ * @param mesh Finite-element mesh over domain.
+ * @param label Label for vertices marking boundary.
+ */
+ SubMesh(const pylith::topology::Mesh& mesh,
+ const char* label);
+
+ /// Default destructor
+ ~SubMesh(void);
+
+ /** Create Sieve mesh.
+ *
+ * @param mesh Finite-element mesh over domain.
+ * @param label Label for vertices marking boundary.
+ */
+ void createSubMesh(const pylith::topology::Mesh& mesh,
+ const char* label);
+
+ /** Get coordinate system.
+ *
+ * @returns Coordinate system.
+ */
+ const spatialdata::geocoords::CoordSys* coordsys(void) const;
+
+ /** Set debug flag.
+ *
+ * @param value Turn on debugging if true.
+ */
+ void debug(const bool value);
+
+ /** Get debug flag.
+ *
+ * @param Get debugging flag.
+ */
+ bool debug(void) const;
+
+ /** Get dimension of mesh.
+ *
+ * @returns Dimension of mesh.
+ */
+ int dimension(void) const;
+
+ /** Get MPI communicator associated with mesh.
+ *
+ * @returns MPI communicator.
+ */
+ const MPI_Comm comm(void) const;
+
+ /// Initialize the finite-element mesh.
+ void initialize(void);
+
+ /** Print mesh to stdout.
+ *
+ * @param label Label for mesh.
+ */
+ void view(const char* label);
+
+ }; // SubMesh
+
+ } // topology
+} // pylith
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/topology/topology.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/topology/topology.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/topology/topology.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/topology/topology.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,69 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module topology
+
+// Header files for module C++ code
+%{
+#include "pylith/topology/Mesh.hh"
+#include "pylith/topology/SubMesh.hh"
+#include "pylith/topology/MeshOps.hh"
+#include "pylith/topology/FieldBase.hh"
+#include "pylith/topology/Field.hh"
+#include "pylith/topology/Fields.hh"
+#include "pylith/topology/SolutionFields.hh"
+#include "pylith/topology/Jacobian.hh"
+#include "pylith/topology/Distributor.hh"
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+%include "../include/chararray.i"
+%include "../include/submeshfield.i"
+
+// Numpy interface stuff
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "../include/numpy.i"
+%init %{
+import_array();
+%}
+
+// Interfaces
+%include "Mesh.i"
+%include "SubMesh.i"
+%include "MeshOps.i"
+%include "FieldBase.i"
+%include "Field.i"
+%include "Fields.i"
+%include "SolutionFields.i"
+%include "Jacobian.i"
+%include "Distributor.i"
+
+// Template instatiation
+%template(MeshField) pylith::topology::Field<pylith::topology::Mesh>;
+%template(SubMeshField) pylith::topology::Field<pylith::topology::SubMesh>;
+%template(MeshFields) pylith::topology::Fields<pylith::topology::Field<pylith::topology::Mesh> >;
+%template(SubMeshFields) pylith::topology::Fields<pylith::topology::Field<pylith::topology::SubMesh> >;
+
+// End of file
+
Property changes on: short/3D/PyLith/trunk/modulesrc/utils
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
petsc.py
petsc_wrap.cxx
utils.py
utils_wrap.cxx
Copied: short/3D/PyLith/trunk/modulesrc/utils/EventLogger.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/utils/EventLogger.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/EventLogger.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/utils/EventLogger.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/utils/EventLogger.i
+ *
+ * @brief Python interface to C++ EventLogger.
+ */
+
+
+namespace pylith {
+ namespace utils {
+
+ class EventLogger
+ { // EventLogger
+
+ // PUBLIC MEMBERS /////////////////////////////////////////////////
+ public :
+
+ /// Constructor
+ EventLogger(void);
+
+ /// Destructor
+ ~EventLogger(void);
+
+ /** Set name of logging class.
+ *
+ * @param name Name of logging class.
+ */
+ void className(const char* name);
+
+ /** Get name of logging class.
+ *
+ * @returns Name of logging class.
+ */
+ const char* className(void) const;
+
+ /// Setup logging class.
+ void initialize(void);
+
+ /** Register event.
+ *
+ * @prerequisite Must call initialize() before registerEvent().
+ *
+ * @param name Name of event.
+ * @returns Event identifier.
+ */
+ int registerEvent(const char* name);
+
+ /** Get event identifier.
+ *
+ * @param name Name of event.
+ * @returns Event identifier.
+ */
+ int eventId(const char* name);
+
+ /** Log event begin.
+ *
+ * @param id Event identifier.
+ */
+ void eventBegin(const int id);
+
+ /** Log event end.
+ *
+ * @param id Event identifier.
+ */
+ void eventEnd(const int id);
+
+ /** Register stage.
+ *
+ * @prerequisite Must call initialize() before registerStage().
+ *
+ * @param name Name of stage.
+ * @returns Stage identifier.
+ */
+ int registerStage(const char* name);
+
+ /** Get stage identifier.
+ *
+ * @param name Name of stage.
+ * @returns Stage identifier.
+ */
+ int stageId(const char* name);
+
+ /** Log stage begin.
+ *
+ * @param id Stage identifier.
+ */
+ void stagePush(const int id);
+
+ /// Log stage end.
+ void stagePop(void);
+
+ }; // EventLogger
+
+ } // utils
+} // pylith
+
+
+// End of file
Modified: short/3D/PyLith/trunk/modulesrc/utils/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/utils/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,64 +13,81 @@
subpackage = utils
include $(top_srcdir)/subpackage.am
-subpkgpyexec_LTLIBRARIES = petscmodule.la utilsmodule.la
+subpkgpyexec_LTLIBRARIES = \
+ _petscmodule.la \
+ _utilsmodule.la
-petscmodule_la_LDFLAGS = -module -avoid-version \
+subpkgpyexec_PYTHON = \
+ petsc.py \
+ utils.py
+
+petsc_swig_sources = \
+ petsc.i \
+ petsc_general.i \
+ petsc_mat.i
+
+petsc_swig_generated = \
+ petsc_wrap.cxx \
+ petsc.py
+
+utils_swig_sources = \
+ utils.i \
+ EventLogger.i \
+ TestArray.i
+
+utils_swig_generated = \
+ utils_wrap.cxx \
+ utils.py
+
+swig_sources = $(petsc_swig_sources) $(utils_swig_sources)
+
+swig_generated = $(petsc_swig_generated) $(utils_swig_generated)
+
+# PETSc module
+_petscmodule_la_LDFLAGS = -module -avoid-version \
$(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_petscmodule_la_SOURCES = petsc.pyxe.src
-nodist_petscmodule_la_SOURCES = \
- petsc.pyxe \
- petsc.c petsc_embed.cpp petsc_embed.h
-petscmodule_la_LIBADD = \
+
+dist__petscmodule_la_SOURCES = $(petsc_swig_sources) $(petsc_swig_generated)
+
+_petscmodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
- $(PETSC_LIB)
-if ENABLE_CUBIT
- petscmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
-endif
+ -lspatialdata \
+ $(PETSC_LIBS)
if NO_UNDEFINED
- petscmodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_petscmodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
+# utils module
+_utilsmodule_la_LDFLAGS = -module -avoid-version \
+ $(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-utilsmodule_la_LDFLAGS = -module -avoid-version \
- $(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-dist_utilsmodule_la_SOURCES = utils.pyxe.src
-nodist_utilsmodule_la_SOURCES = \
- utils.pyxe \
- utils.c utils_embed.cpp utils_embed.h
-utilsmodule_la_LIBADD = \
+dist__utilsmodule_la_SOURCES = $(utils_swig_sources) $(utils_swig_generated)
+
+_utilsmodule_la_LIBADD = \
$(top_builddir)/libsrc/libpylith.la \
- $(PETSC_LIB)
-if ENABLE_CUBIT
- utilsmodule_la_LIBADD += -lnetcdf_c++ -lnetcdf
-endif
+ -lspatialdata \
+ $(PETSC_LIBS)
if NO_UNDEFINED
- utilsmodule_la_LIBADD += $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
+_utilsmodule_la_LIBADD += \
+ $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
endif
+INCLUDES += $(PYTHON_EGG_CPPFLAGS) -I$(NUMPY_INCDIR) -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
+$(srcdir)/petsc_wrap.cxx $(srcdir)/petsc.py: $(petsc_swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-petsc.pyx petsc_embed.cpp petsc_embed.h: petsc.pyxe
- pyrexembed petsc.pyxe
-petsc.pyxe: $(srcdir)/petsc.pyxe.src
- cp $(srcdir)/petsc.pyxe.src $@
-petsc_embed.cpp: petsc_embed.h
-petsc_embed.h: petsc.pyx
+$(srcdir)/utils_wrap.cxx $(srcdir)/utils.py: $(utils_swig_sources)
+ $(SWIG) -Wall -c++ -python $<
-utils.pyx utils_embed.cpp utils_embed.h: utils.pyxe
- pyrexembed utils.pyxe
-utils.pyxe: $(srcdir)/utils.pyxe.src
- cp $(srcdir)/utils.pyxe.src $@
-utils_embed.cpp: utils_embed.h
-utils_embed.h: utils.pyx
-.pyx.c:
- pyrexc $< $(PYREX_INCLUDES)
+MAINTAINERCLEANFILES = \
+ $(srcdir)/petsc_wrap.cxx \
+ $(srcdir)/petsc.py \
+ $(srcdir)/utils_wrap.cxx \
+ $(srcdir)/utils.py
-CLEANFILES = *_embed.* \
- petsc.pyxe petsc.pyx petsc.c \
- utils.pyxe utils.pyx utils.c
# End of file
Copied: short/3D/PyLith/trunk/modulesrc/utils/TestArray.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/utils/TestArray.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/TestArray.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/utils/TestArray.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+/**
+ * @file modulesrc/utils/TestArray.i
+ *
+ * @brief Python interface to C++ TestArray object.
+ */
+
+%apply(double* IN_ARRAY1, int DIM1) {
+ (const double* valuesE,
+ const int nvalues)
+ };
+%inline %{
+ /** Check to make sure array of values match expected values.
+ *
+ * @param valuesE Array of expected values.
+ * @param nvalues Array size.
+ * @param values Array of values to check.
+ */
+ bool
+ TestArray_checkDouble(const double* valuesE,
+ const int nvalues,
+ const pylith::double_array& values) {
+ pylith::utils::TestArray::check(valuesE, nvalues, values);
+ } // check(double)
+%} // inline
+%clear(const double* valuesE, const int nvalues);
+
+
+// End of file
Copied: short/3D/PyLith/trunk/modulesrc/utils/petsc.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/utils/petsc.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/petsc.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/utils/petsc.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module petsc
+
+// Header files for module C++ code
+%{
+#include <petsc.h>
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+%include "../include/chararray.i"
+
+// Interfaces
+%include "petsc_general.i"
+
+// End of file
+
Deleted: short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/utils/petsc.pyxe.src 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,171 +0,0 @@
-# -*- Pyrex -*-
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-#header{
-#include <petsc.h>
-#include <petscmat.h>
-#include <string.h>
-#include <stdexcept>
-#}header
-
-# ----------------------------------------------------------------------
-cdef extern from "Python.h":
- object PyCObject_FromVoidPtr(void*, void (*destruct)(void*))
- void* PyCObject_AsVoidPtr(object)
-
-cdef void* ptrFromHandle(obj):
- """Extract pointer from PyCObject."""
- return PyCObject_AsVoidPtr(obj.handle)
-
-cdef extern from "stdlib.h":
- ctypedef unsigned long size_t
- void* malloc(size_t size)
- void free(void* mem)
-
-cdef extern from "string.h":
- void strcpy(char*, char*)
- int strlen(char*)
-
-# ----------------------------------------------------------------------
-def petsc_initialize(options):
- """
- Initialize PETSc.
- """
- # create shim for 'PetscInitialize'
- #embed{ int Petsc_initialize(int* argc, char*** argv)
- PetscErrorCode err = PetscInitialize(argc, argv, NULL, NULL); CHKERRQ(err);
- return 0;
- #}embed
- cdef int err
- cdef char** argv
- cdef char* arg
- cdef int argc
-
- argc = len(options)
- argv = <char**> malloc((argc+1)*sizeof(char*));
- for i from 0 <= i < argc:
- arg = options[i]
- argv[i] = <char*> malloc((strlen(arg)+1)*sizeof(char));
- strcpy(argv[i], arg);
- argv[argc] = NULL;
- err = Petsc_initialize(&argc, &argv);
- if err:
- raise RuntimeError("Error initializing PETSc.")
-
- for i from 0 <= i < argc:
- free(argv[i])
- free(argv)
- return
-
-
-def petsc_finalize():
- """
- Finalize PETSc.
- """
- # create shim for 'PetscFinalize'
- #embed{ int Petsc_finalize()
- PetscErrorCode err = PetscFinalize(); CHKERRQ(err);
- return 0;
- #}embed
- cdef int err
- err = Petsc_finalize()
- if err:
- raise RuntimError("Error finalizing PETSc.")
-
- return
-
-
-def mat_assemble(mat, mode):
- """
- Assemble matrix.
- """
- # create shim for 'MatAssemblyBegin/MatAssemblyEnd'
- #embed{ int Mat_assemble(void* matVptr, char* mode)
- Mat* mat = (Mat*) matVptr;
- PetscErrorCode err = 0;
- if (0 == strcmp(mode, "final_assembly")) {
- err = MatAssemblyBegin(*mat, MAT_FINAL_ASSEMBLY);CHKERRQ(err);
- err = MatAssemblyEnd(*mat, MAT_FINAL_ASSEMBLY);CHKERRQ(err);
- } else if (0 == strcmp(mode, "flush_assembly")) {
- err = MatAssemblyBegin(*mat, MAT_FLUSH_ASSEMBLY); CHKERRQ(err);
- err = MatAssemblyEnd(*mat, MAT_FLUSH_ASSEMBLY); CHKERRQ(err);
- } else {
- throw std::runtime_error("Unknown mode");
- }
- return 0;
- #}embed
- cdef void* matVptr
- matVptr = PyCObject_AsVoidPtr(mat)
- if mode != "final_assembly" and mode != "flush_assembly":
- raise ValueError("Unknown mode '%s' for mat_assemble." % mode)
- err = Mat_assemble(matVptr, mode)
- if err:
- raise RuntimError("Error assembling matrix.")
-
- return
-
-
-def mat_setzero(mat):
- """
- Zero out entries in matrix (retain structure).
- """
- # create shim for 'MatZeroEntries'
- #embed{ int Mat_setzero(void* matVptr)
- Mat* mat = (Mat*) matVptr;
- PetscErrorCode err = 0;
- err = MatZeroEntries(*mat);
- return 0;
- #}embed
- cdef void* matVptr
- matVptr = PyCObject_AsVoidPtr(mat)
- err = Mat_setzero(matVptr)
- if err:
- raise RuntimError("Error zeroing matrix values.")
- return
-
-
-def mat_view(mat):
- """
- Dump matrix to stdout.
- """
- # create shim for 'MatView'
- #embed{ int Mat_view(void* matVptr)
- Mat* mat = (Mat*) matVptr;
- MatView(*mat, PETSC_VIEWER_STDOUT_WORLD);
- return 0;
- #}embed
- cdef void* matVptr
- err = Mat_view(PyCObject_AsVoidPtr(mat))
-
- return
-
-
-def mat_view_binary(mat, filename):
- """
- Dump matrix to stdout.
- """
- # create shim for 'MatView'
- #embed{ int Mat_view_binary(void* matVptr, char *filename)
- Mat* mat = (Mat*) matVptr;
- PetscViewer viewer;
- PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename, FILE_MODE_WRITE, &viewer);
- MatView(*mat, viewer);
- PetscViewerDestroy(viewer);
- return 0;
- #}embed
- cdef void* matVptr
- err = Mat_view_binary(PyCObject_AsVoidPtr(mat), filename)
-
- return
-
-
-# End of file
Copied: short/3D/PyLith/trunk/modulesrc/utils/petsc_general.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/utils/petsc_general.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/petsc_general.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/utils/petsc_general.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,38 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// ----------------------------------------------------------------------
+// initialize
+%inline %{
+ int
+ initialize(int argc, char** argv)
+ { // initialize
+ PetscErrorCode err =
+ PetscInitialize(&argc, &argv, NULL, NULL); CHKERRQ(err);
+ return 0;
+ } // initialize
+%} // inline
+
+// ----------------------------------------------------------------------
+// finalize
+%inline %{
+ int
+ finalize(void)
+ { // finalize
+ PetscErrorCode err = PetscFinalize(); CHKERRQ(err);
+ return 0;
+ } // finalize
+%} // inline
+
+
+// End of file
+
Copied: short/3D/PyLith/trunk/modulesrc/utils/petsc_mat.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/utils/petsc_mat.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/petsc_mat.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/utils/petsc_mat.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// ----------------------------------------------------------------------
+// mat_assemble
+// Assemble matrix.
+%inline %{
+ int
+ mat_assemble(Mat* mat,
+ const char* mode)
+ { // mat_assemble
+ PetscErrorCode err = 0;
+ if (0 == strcmp(mode, "final_assembly")) {
+ err = MatAssemblyBegin(*mat, MAT_FINAL_ASSEMBLY);CHKERRQ(err);
+ err = MatAssemblyEnd(*mat, MAT_FINAL_ASSEMBLY);CHKERRQ(err);
+ } else if (0 == strcmp(mode, "flush_assembly")) {
+ err = MatAssemblyBegin(*mat, MAT_FLUSH_ASSEMBLY); CHKERRQ(err);
+ err = MatAssemblyEnd(*mat, MAT_FLUSH_ASSEMBLY); CHKERRQ(err);
+ } else
+ throw std::runtime_error("Unknown mode");
+ return 0;
+ } // mat_assemble
+%} // inline
+
+// ----------------------------------------------------------------------
+// mat_setzero
+// Zero out entries in matrix (retain structure).
+%inline %{
+ int
+ mat_setzero(Mat* mat)
+ { // mat_setzero
+ PetscErrorCode err = MatZeroEntries(*mat); CHKERRQ(err);
+ return 0;
+ } // mat_setzero
+%} // inline
+
+// ----------------------------------------------------------------------
+// mat_view
+// View matrix.
+%inline %{
+ int
+ mat_view(Mat* mat)
+ { // mat_view
+ PetscErrorCode err =
+ MatView(*mat, PETSC_VIEWER_STDOUT_WORLD); CHKERRQ(err);
+ return 0;
+ } // mat_view
+%} // inline
+
+// ----------------------------------------------------------------------
+// mat_view_binary
+// Write matrix to binary file.
+%inline %{
+ int
+ mat_view_binary(Mat* mat,
+ const char* filename)
+ { // mat_view_binary
+ PetscViewer viewer;
+ PetscErrorCode err =
+ PetscViewerBinaryOpen(PETSC_COMM_WORLD, filename,
+ FILE_MODE_WRITE, &viewer); CHKERRQ(err);
+ err = MatView(*mat, viewer); CHKERRQ(err);
+ err = PetscViewerDestroy(viewer); CHKERRQ(err);
+ return 0;
+ } // mat_view_binary
+%} // inline
+
+
+// End of file
+
Copied: short/3D/PyLith/trunk/modulesrc/utils/utils.i (from rev 14862, short/3D/PyLith/branches/pylith-swig/modulesrc/utils/utils.i)
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/utils.i (rev 0)
+++ short/3D/PyLith/trunk/modulesrc/utils/utils.i 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,50 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+// SWIG interface
+%module utils
+
+// Header files for module C++ code
+%{
+#include "pylith/utils/EventLogger.hh"
+#include "pylith/utils/TestArray.hh"
+
+#include <petsclog.h> // USES PetscLogEventBegin/End() in inline methods
+#include "pylith/utils/arrayfwd.hh" // USES double_array
+%}
+
+%include "exception.i"
+%exception {
+ try {
+ $action
+ } catch (const std::exception& err) {
+ SWIG_exception(SWIG_RuntimeError, err.what());
+ } // try/catch
+ } // exception
+
+%include "typemaps.i"
+
+// Numpy interface stuff
+%{
+#define SWIG_FILE_WITH_INIT
+%}
+%include "../include/numpy.i"
+%init %{
+import_array();
+%}
+
+// Interfaces
+%include "EventLogger.i"
+%include "TestArray.i"
+
+// End of file
+
Deleted: short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src
===================================================================
--- short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/modulesrc/utils/utils.pyxe.src 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,332 +0,0 @@
-# -*- Pyrex -*-
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-#header{
-#include "pylith/utils/EventLogger.hh"
-
-#include <assert.h>
-#include <stdexcept>
-#include <Python.h>
-#}header
-
-# ----------------------------------------------------------------------
-cdef extern from "Python.h":
- object PyCObject_FromVoidPtr(void*, void (*destruct)(void*))
- void* PyCObject_AsVoidPtr(object)
-
-cdef void* ptrFromHandle(obj):
- """Extract pointer from PyCObject."""
- return PyCObject_AsVoidPtr(obj.handle)
-
-cdef extern from "stdlib.h":
- ctypedef unsigned long size_t
- void* malloc(size_t size)
- void free(void* mem)
-
-cdef void EventLogger_destructor(void* obj):
- """
- Destroy EventLogger object.
- """
- # create shim for destructor
- #embed{ void EventLogger_destructor_cpp(void* objVptr)
- pylith::utils::EventLogger* logger = (pylith::utils::EventLogger*) objVptr;
- delete logger;
- #}embed
- EventLogger_destructor_cpp(obj)
- return
-
-
-# ----------------------------------------------------------------------
-cdef class EventLogger:
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* EventLogger_constructor()
- void* result = 0;
- try {
- result = (void*)(new pylith::utils::EventLogger);
- assert(0 != result);
- } 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
- return result;
- #}embed
-
- self.thisptr = EventLogger_constructor()
- self.handle = self._createHandle()
- self.name = "pylith_utils_EventLogger"
- return
-
-
- def initialize(self):
- """
- Initialize event logger.
- """
- # create shim for method 'initialize'
- #embed{ void EventLogger_initialize(void* objVptr)
- try {
- assert(0 != objVptr);
- ((pylith::utils::EventLogger*) objVptr)->initialize();
- } 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
-
- EventLogger_initialize(self.thisptr)
- return
-
-
- def registerEvent(self, name):
- """
- Register event.
- """
- # create shim for method 'registerEvent'
- #embed{ int EventLogger_registerEvent(void* objVptr, char* name)
- int result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::utils::EventLogger*) objVptr)->registerEvent(name);
- } 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
- return result;
- #}embed
-
- return EventLogger_registerEvent(self.thisptr, name)
-
-
- def eventId(self, name):
- """
- Get event identifier.
- """
- # create shim for method 'eventId'
- #embed{ int EventLogger_eventId(void* objVptr, char* name)
- int result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::utils::EventLogger*) objVptr)->eventId(name);
- } 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
- return result;
- #}embed
-
- return EventLogger_eventId(self.thisptr, name)
-
-
- def eventBegin(self, id):
- """
- Log event begin.
- """
- # create shim for method 'eventBegin'
- #embed{ void EventLogger_eventBegin(void* objVptr, int id)
- try {
- assert(0 != objVptr);
- ((pylith::utils::EventLogger*) objVptr)->eventBegin(id);
- } 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
-
- EventLogger_eventBegin(self.thisptr, id)
- return
-
-
- def eventEnd(self, id):
- """
- Log event end.
- """
- # create shim for method 'eventEnd'
- #embed{ void EventLogger_eventEnd(void* objVptr, int id)
- try {
- assert(0 != objVptr);
- ((pylith::utils::EventLogger*) objVptr)->eventEnd(id);
- } 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
-
- EventLogger_eventEnd(self.thisptr, id)
- return
-
-
- def registerStage(self, name):
- """
- Register stage.
- """
- # create shim for method 'registerStage'
- #embed{ int EventLogger_registerStage(void* objVptr, char* name)
- int result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::utils::EventLogger*) objVptr)->registerStage(name);
- } 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
- return result;
- #}embed
-
- return EventLogger_registerStage(self.thisptr, name)
-
-
- def stageId(self, name):
- """
- Get stage identifier.
- """
- # create shim for method 'stageId'
- #embed{ int EventLogger_stageId(void* objVptr, char* name)
- int result = 0;
- try {
- assert(0 != objVptr);
- result = ((pylith::utils::EventLogger*) objVptr)->stageId(name);
- } 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
- return result;
- #}embed
-
- return EventLogger_stageId(self.thisptr, name)
-
-
- def stagePush(self, id):
- """
- Log stage begin.
- """
- # create shim for method 'stagePush'
- #embed{ void EventLogger_stagePush(void* objVptr, int id)
- try {
- assert(0 != objVptr);
- ((pylith::utils::EventLogger*) objVptr)->stagePush(id);
- } 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
-
- EventLogger_stagePush(self.thisptr, id)
- return
-
-
- def stagePop(self):
- """
- Log stage end.
- """
- # create shim for method 'stagePop'
- #embed{ void EventLogger_stagePop(void* objVptr)
- try {
- assert(0 != objVptr);
- ((pylith::utils::EventLogger*) objVptr)->stagePop();
- } 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
-
- EventLogger_stagePop(self.thisptr)
- return
-
-
- def _createHandle(self):
- """
- Wrap pointer to C++ object in PyCObject.
- """
- return PyCObject_FromVoidPtr(self.thisptr, EventLogger_destructor)
-
-
- property className:
- def __set__(self, name):
- """
- Set name of logging class.
- """
- # create shim for method 'className'
- #embed{ void EventLogger_className_set(void* objVptr, char* name)
- try {
- assert(0 != objVptr);
- ((pylith::utils::EventLogger*) objVptr)->className(name);
- } 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
- EventLogger_className_set(self.thisptr, name)
-
- def __get__(self):
- """
- Get name of logging class.
- """
- # create shim for method 'className'
- #embed{ char* EventLogger_className_get(void* objVptr)
- char* result = 0;
- try {
- assert(0 != objVptr);
- result = (char*)((pylith::utils::EventLogger*) objVptr)->className();
- } 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
- return result;
- #}embed
- return EventLogger_className_get(self.thisptr)
-
-
-# End of file
Copied: short/3D/PyLith/trunk/playpen/petscapp (from rev 14862, short/3D/PyLith/branches/pylith-swig/playpen/petscapp)
Modified: short/3D/PyLith/trunk/pylith/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/pylith/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,12 +11,14 @@
#
nobase_pkgpyexec_PYTHON = \
- PyLithApp.py \
__init__.py \
+ apps/__init__.py \
+ apps/PyLithApp.py \
+ apps/PetscApplication.py \
bc/__init__.py \
bc/AbsorbingDampers.py \
bc/BoundaryCondition.py \
- bc/DirichletPoints.py \
+ bc/DirichletBC.py \
bc/DirichletBoundary.py \
bc/FixedDOFDB.py \
bc/Neumann.py \
@@ -40,29 +42,8 @@
feassemble/Integrator.py \
feassemble/IntegratorElasticity.py \
feassemble/ReferenceCell.py \
- feassemble/quadrature/__init__.py \
- feassemble/quadrature/Quadrature.py \
- feassemble/quadrature/Quadrature0D.py \
- feassemble/quadrature/Quadrature1D.py \
- feassemble/quadrature/Quadrature1Din2D.py \
- feassemble/quadrature/Quadrature1Din3D.py \
- feassemble/quadrature/Quadrature2D.py \
- feassemble/quadrature/Quadrature2Din3D.py \
- feassemble/quadrature/Quadrature3D.py \
- feassemble/geometry/__init__.py \
- feassemble/geometry/CellGeometry.py \
- feassemble/geometry/GeometryPoint1D.py \
- feassemble/geometry/GeometryPoint2D.py \
- feassemble/geometry/GeometryPoint3D.py \
- feassemble/geometry/GeometryLine1D.py \
- feassemble/geometry/GeometryLine2D.py \
- feassemble/geometry/GeometryLine3D.py \
- feassemble/geometry/GeometryTri2D.py \
- feassemble/geometry/GeometryTri3D.py \
- feassemble/geometry/GeometryQuad2D.py \
- feassemble/geometry/GeometryQuad3D.py \
- feassemble/geometry/GeometryTet3D.py \
- feassemble/geometry/GeometryHex3D.py \
+ feassemble/Quadrature.py \
+ feassemble/CellGeometry.py \
materials/__init__.py \
materials/ElasticMaterial.py \
materials/ElasticIsotropic3D.py \
@@ -76,15 +57,21 @@
materials/MaxwellIsotropic3D.py \
meshio/__init__.py \
meshio/CellFilter.py \
- meshio/CellFilterAvg.py \
+ meshio/CellFilterAvgMesh.py \
+ meshio/CellFilterAvgSubMesh.py \
meshio/DataWriter.py \
meshio/DataWriterVTK.py \
- meshio/MeshIO.py \
+ meshio/DataWriterVTKMesh.py \
+ meshio/DataWriterVTKSubMesh.py \
+ meshio/DataWriterVTKSubSubMesh.py \
+ meshio/MeshIOObj.py \
meshio/MeshIOAscii.py \
meshio/MeshIOCubit.py \
meshio/MeshIOLagrit.py \
meshio/OutputDirichlet.py \
meshio/OutputManager.py \
+ meshio/OutputManagerMesh.py \
+ meshio/OutputManagerSubMesh.py \
meshio/OutputSoln.py \
meshio/OutputFaultKin.py \
meshio/OutputMatElastic.py \
@@ -92,25 +79,32 @@
meshio/OutputSolnSubset.py \
meshio/SingleOutput.py \
meshio/VertexFilter.py \
- meshio/VertexFilterVecNorm.py \
+ meshio/VertexFilterVecNormMesh.py \
+ meshio/VertexFilterVecNormSubMesh.py \
+ mpi/__init__.py \
+ mpi/Communicator.py \
problems/__init__.py \
problems/Explicit.py \
problems/Formulation.py \
problems/Implicit.py \
problems/Problem.py \
+ problems/Solver.py \
+ problems/SolverLinear.py \
+ problems/SolverNonlinear.py \
problems/TimeDependent.py \
problems/TimeStep.py \
problems/TimeStepAdapt.py \
problems/TimeStepUniform.py \
problems/TimeStepUser.py \
- solver/__init__.py \
- solver/Solver.py \
- solver/SolverLinear.py \
- solver/SolverNonlinear.py \
topology/__init__.py \
topology/Distributor.py \
- topology/FieldsManager.py \
topology/Mesh.py \
+ topology/SubMesh.py \
+ topology/Field.py \
+ topology/Fields.py \
+ topology/SolutionFields.py \
+ topology/Jacobian.py \
+ topology/JacobianViewer.py \
topology/MeshGenerator.py \
topology/MeshImporter.py \
topology/MeshRefiner.py \
@@ -120,6 +114,7 @@
utils/CppData.py \
utils/EmptyBin.py \
utils/EventLogger.py \
+ utils/PetscComponent.py \
utils/PetscManager.py \
utils/VTKDataReader.py \
utils/importing.py \
Deleted: short/3D/PyLith/trunk/pylith/PyLithApp.py
===================================================================
--- short/3D/PyLith/trunk/pylith/PyLithApp.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/PyLithApp.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,159 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file pylith/PyLithApp.py
-##
-## @brief Python PyLith application
-
-from mpi import Application
-
-# PyLithApp class
-class PyLithApp(Application):
- """
- Python PyLithApp application.
- """
-
- # INVENTORY //////////////////////////////////////////////////////////
-
- class Inventory(Application.Inventory):
- """
- Python object for managing PyLithApp facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing PyLithApp facilities and properties.
- ##
- ## \b Properties
-
- ## @li None
- ##
- ## \b Facilities
- ## @li \b mesher Generates or imports the computational mesh.
- ## @li \b problem Computational problem to solve
- ## @li \b petsc Manager for PETSc options
-
- import pyre.inventory
-
- from pylith.topology.MeshImporter import MeshImporter
- mesher = pyre.inventory.facility("mesh_generator", family="mesh_generator",
- factory=MeshImporter)
- mesher.meta['tip'] = "Generates or imports the computational mesh."
-
- from pylith.problems.TimeDependent import TimeDependent
- problem = pyre.inventory.facility("problem", family="problem",
- factory=TimeDependent)
- problem.meta['tip'] = "Computational problem to solve."
-
- # Dummy facility for passing options to PETSc
- from pylith.utils.PetscManager import PetscManager
- petsc = pyre.inventory.facility("petsc", family="petsc_manager",
- factory=PetscManager)
- petsc.meta['tip'] = "Manager for PETSc options."
-
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="pylithapp"):
- """
- Constructor.
- """
- Application.__init__(self, name)
- self._loggingPrefix = "PyLith "
- return
-
-
- def main(self, *args, **kwds):
- """
- Run the application.
- """
- from pylith.utils.profiling import resourceUsageString
-
- self.petsc.initialize()
- self._debug.log(resourceUsageString())
-
- self._setupLogging()
- self._logger.eventBegin("PyLith main")
-
- # Create mesh (adjust to account for interfaces (faults) if necessary)
- self._logger.stagePush("Meshing")
- interfaces = None
- if "interfaces" in dir(self.problem):
- interfaces = self.problem.interfaces.components()
- mesh = self.mesher.create(self.problem.normalizer, interfaces)
- self._debug.log(resourceUsageString())
- self._logger.stagePop()
-
- # Setup problem, verify configuration, and then initialize
- self._logger.stagePush("Setup")
- self.problem.preinitialize(mesh)
- self._debug.log(resourceUsageString())
-
- self.problem.verifyConfiguration()
-
- self.problem.initialize()
- self._debug.log(resourceUsageString())
-
- self._logger.stagePop()
-
- # Run problem
- self._logger.stagePush("Run")
- self.problem.run(self)
- self._debug.log(resourceUsageString())
- self._logger.stagePop()
-
- # Cleanup
- self._logger.stagePush("Finalize")
- self.problem.finalize()
- self._logger.stagePop()
-
- self._logger.eventEnd("PyLith main")
- self.petsc.finalize()
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Setup members using inventory.
- """
- Application._configure(self)
- self.mesher = self.inventory.mesher
- self.problem = self.inventory.problem
- self.petsc = self.inventory.petsc
-
- import journal
- self._debug = journal.debug(self.name)
- return
-
- def _setupLogging(self):
- """
- Setup event logging.
- """
- from pylith.utils.EventLogger import EventLogger
- logger = EventLogger()
- logger.setClassName("PyLith")
- logger.initialize()
- logger.registerEvent("PyLith main")
-
- stages = ["Meshing",
- "Setup",
- "Run",
- "Finalize"]
- for stage in stages:
- logger.registerStage(stage)
-
- self._logger = logger
- return
-
-
-# End of file
Modified: short/3D/PyLith/trunk/pylith/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/__init__.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/__init__.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,14 +14,17 @@
## @brief Python top-level PyLith module initialization
-__all__ = ['PyLithApp',
+__all__ = ['apps',
+ 'bc',
+ 'faults',
'feassemble',
'materials',
'meshio',
+ 'mpi',
'problems',
- 'solver',
'topology',
- 'utils']
+ 'utils',
+ ]
# End of file
Copied: short/3D/PyLith/trunk/pylith/apps (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/apps)
Modified: short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/bc/AbsorbingDampers.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,9 +19,10 @@
from BoundaryCondition import BoundaryCondition
from pylith.feassemble.Integrator import Integrator
+from bc import AbsorbingDampers as ModuleAbsorbingDampers
# AbsorbingDampers class
-class AbsorbingDampers(BoundaryCondition, Integrator):
+class AbsorbingDampers(BoundaryCondition, Integrator, ModuleAbsorbingDampers):
"""
Python object for managing absorbing boundary condition using simple
dashpots.
@@ -47,8 +48,9 @@
import pyre.inventory
- from pylith.feassemble.quadrature.Quadrature import Quadrature
- quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = pyre.inventory.facility("quadrature",
+ factory=SubMeshQuadrature)
quadrature.meta['tip'] = "Quadrature object for numerical integration."
@@ -70,7 +72,8 @@
"""
BoundaryCondition.preinitialize(self, mesh)
Integrator.preinitialize(self, mesh)
- self.quadrature.preinitialize()
+ self.bcQuadrature.preinitialize(mesh.coordsys().spaceDim())
+ self.quadrature(self.bcQuadrature)
return
@@ -81,14 +84,14 @@
logEvent = "%sverify" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- BoundaryCondition.verifyConfiguration(self)
+ BoundaryCondition.verifyConfiguration(self, self.mesh)
Integrator.verifyConfiguration(self)
- if self.quadrature.cellDim != self.mesh.dimension()-1:
+ if self.bcQuadrature.cellDim() != self.mesh.dimension()-1:
raise ValueError, \
"Quadrature scheme and mesh are incompatible.\n" \
"Dimension for quadrature: %d\n" \
"Dimension of mesh boundary '%s': %d" % \
- (self.quadrature.cellDim,
+ (self.bcQuadrature.cellDim,
self.label, self.mesh.dimension()-1)
self._logger.eventEnd(logEvent)
@@ -102,9 +105,7 @@
logEvent = "%sinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
-
- self.cppHandle.quadrature = self.quadrature.cppHandle
+ Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
self._logger.eventEnd(logEvent)
@@ -118,17 +119,15 @@
Setup members using inventory.
"""
BoundaryCondition._configure(self)
- self.quadrature = self.inventory.quadrature
+ self.bcQuadrature = self.inventory.quadrature
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to corresponding C++ object.
"""
- if None == self.cppHandle:
- import pylith.bc.bc as bindings
- self.cppHandle = bindings.AbsorbingDampers()
+ ModuleAbsorbingDampers.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/bc/BoundaryCondition.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,6 +23,7 @@
## Factory: boundary_condition
from pyre.components.Component import Component
+from bc import BoundaryCondition as ModuleBoundaryCondition
# Validator for direction
def validateDir(value):
@@ -42,7 +43,7 @@
# BoundaryCondition class
-class BoundaryCondition(Component):
+class BoundaryCondition(Component, ModuleBoundaryCondition):
"""
Python abstract base class for managing a boundary condition.
@@ -92,8 +93,7 @@
Constructor.
"""
Component.__init__(self, name, facility="boundary_condition")
- self.cppHandle = None
- self.upDir = [0, 0, 1]
+ self._createModuleObj()
return
@@ -101,30 +101,17 @@
"""
Setup boundary condition.
"""
- self._createCppHandle()
- self.cppHandle.label = self.label
+ self.label(self.inventory.label)
+ self.db(self.inventory.db)
self.mesh = mesh
return
- def verifyConfiguration(self):
- """
- Verify compatibility of configuration.
- """
- assert(None != self.cppHandle)
- self.cppHandle.verifyConfiguration(self.mesh.cppHandle)
- return
-
-
def initialize(self, totalTime, numTimeSteps, normalizer):
"""
Initialize boundary condition.
- """
- self.db.initialize()
- self.cppHandle.db = self.db.cppHandle
- self.cppHandle.initialize(self.mesh.cppHandle,
- self.mesh.coordsys.cppHandle,
- self.upDir)
+ """
+ ModuleBoundaryCondition.initialize(self, self.mesh, self.upDir)
return
@@ -135,18 +122,16 @@
Setup members using inventory.
"""
Component._configure(self)
- self.label = self.inventory.label
self.upDir = map(float, self.inventory.upDir)
- self.db = self.inventory.db
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- raise NotImplementedError("Please implement _createCppHandle() in " \
- "derived class.")
-
-
+ raise NotImplementedError, \
+ "Please implement _createModuleObj() in derived class."
+
+
# End of file
Copied: short/3D/PyLith/trunk/pylith/bc/DirichletBC.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/bc/DirichletBC.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletBC.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletBC.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,172 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/bc/DirichletBC.py
+##
+## @brief Python object for managing a Dirichlet (prescribed
+## displacements) boundary condition with a set of points.
+##
+## Factory: boundary_condition
+
+from BoundaryCondition import BoundaryCondition
+from pylith.feassemble.Constraint import Constraint
+from bc import DirichletBC as ModuleDirichletBC
+
+def validateDOF(value):
+ """
+ Validate list of fixed degrees of freedom.
+ """
+ try:
+ size = len(value)
+ num = map(int, value)
+ for v in num:
+ if v < 0:
+ raise ValueError
+ except:
+ raise ValueError, \
+ "'fixed_dof' must be a zero based list of indices of fixed " \
+ "degrees of freedom."
+ return num
+
+
+# DirichletBC class
+class DirichletBC(BoundaryCondition, Constraint, ModuleDirichletBC):
+ """
+ Python object for managing a DirichletBC (prescribed displacements)
+ boundary condition.
+
+ Factory: boundary_condition
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(BoundaryCondition.Inventory):
+ """
+ Python object for managing BoundaryCondition facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing BoundaryCondition facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b fixed_dof Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc).
+ ## @li \b reference_t Reference time for rate of change of values.
+ ##
+ ## \b Facilities
+ ## @li \b initial_db Database of parameters for initial values.
+ ## @li \b rate_db Database of parameters for rate of change of values.
+
+ import pyre.inventory
+
+ fixedDOF = pyre.inventory.list("fixed_dof", default=[],
+ validator=validateDOF)
+ fixedDOF.meta['tip'] = "Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc)."
+
+ from pyre.units.time import s
+ tRef = pyre.inventory.dimensional("reference_t", default=0.0*s)
+ tRef.meta['tip'] = "Reference time for rate of change of values."
+
+ from FixedDOFDB import FixedDOFDB
+ db = pyre.inventory.facility("db", factory=FixedDOFDB,
+ family="spatial_database")
+ db.meta['tip'] = "Database of parameters for initial values."
+
+ dbRate = pyre.inventory.facility("rate_db", factory=FixedDOFDB,
+ family="spatial_database")
+ dbRate.meta['tip'] = "Database of parameters for rate of change of values."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="dirichletbc"):
+ """
+ Constructor.
+ """
+ BoundaryCondition.__init__(self, name)
+ Constraint.__init__(self)
+ self._loggingPrefix = "DiBC "
+ return
+
+
+ def preinitialize(self, mesh):
+ """
+ Do pre-initialization setup.
+ """
+ BoundaryCondition.preinitialize(self, mesh)
+ Constraint.preinitialize(self, mesh)
+ self.dbRate(self.inventory.dbRate)
+ import numpy
+ fixedDOF = numpy.array(self.inventory.fixedDOF, dtype=numpy.int32)
+ self.fixedDOF(fixedDOF)
+ return
+
+
+ def verifyConfiguration(self):
+ """
+ Verify compatibility of configuration.
+ """
+ logEvent = "%sverify" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ BoundaryCondition.verifyConfiguration(self, self.mesh)
+
+ self._logger.eventEnd(logEvent)
+ return
+
+
+ def initialize(self, totalTime, numTimeSteps, normalizer):
+ """
+ Initialize DirichletBC boundary condition.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ timeScale = normalizer.timeScale()
+ tRef = normalizer.nondimensionalize(self.inventory.tRef, timeScale)
+ self.referenceTime(tRef)
+
+ self.normalizer(normalizer)
+
+ BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
+
+ self._logger.eventEnd(logEvent)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Setup members using inventory.
+ """
+ BoundaryCondition._configure(self)
+ return
+
+
+ def _createModuleObj(self):
+ """
+ Create handle to corresponding C++ object.
+ """
+ ModuleDirichletBC.__init__(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def boundary_condition():
+ """
+ Factory associated with DirichletBC.
+ """
+ return DirichletBC()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletBoundary.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,28 +17,12 @@
##
## Factory: boundary_condition
-from BoundaryCondition import BoundaryCondition
-from pylith.feassemble.Constraint import Constraint
+from DirichletBC import DirichletBC
+from DirichletBC import validateDOF
+from bc import DirichletBoundary as ModuleDirichletBoundary
-def validateDOF(value):
- """
- Validate list of fixed degrees of freedom.
- """
- try:
- size = len(value)
- num = map(int, value)
- for v in num:
- if v < 0:
- raise ValueError
- except:
- raise ValueError, \
- "'fixed_dof' must be a zero based list of indices of fixed " \
- "degrees of freedom."
- return num
-
-
# DirichletBoundary class
-class DirichletBoundary(BoundaryCondition, Constraint):
+class DirichletBoundary(DirichletBC, ModuleDirichletBoundary):
"""
Python object for managing a DirichletBoundary (prescribed displacements)
boundary condition with points on a surface.
@@ -48,42 +32,22 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(BoundaryCondition.Inventory):
+ class Inventory(DirichletBC.Inventory):
"""
- Python object for managing BoundaryCondition facilities and properties.
+ Python object for managing DirichletBoundary facilities and properties.
"""
## @class Inventory
- ## Python object for managing BoundaryCondition facilities and properties.
+ ## Python object for managing DirichletBoundary facilities and properties.
##
## \b Properties
- ## @li \b fixed_dof Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc).
- ## @li \b reference_t Reference time for rate of change of values.
+ ## @li None
##
## \b Facilities
- ## @li \b initial_db Database of parameters for initial values.
- ## @li \b rate_db Database of parameters for rate of change of values.
## @li \b output Output manager associated with diagnostic output.
import pyre.inventory
- fixedDOF = pyre.inventory.list("fixed_dof", default=[],
- validator=validateDOF)
- fixedDOF.meta['tip'] = "Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc)."
-
- from pyre.units.time import s
- tRef = pyre.inventory.dimensional("reference_t", default=0.0*s)
- tRef.meta['tip'] = "Reference time for rate of change of values."
-
- from FixedDOFDB import FixedDOFDB
- db = pyre.inventory.facility("db", factory=FixedDOFDB,
- family="spatial_database")
- db.meta['tip'] = "Database of parameters for initial values."
-
- dbRate = pyre.inventory.facility("rate_db", factory=FixedDOFDB,
- family="spatial_database")
- dbRate.meta['tip'] = "Database of parameters for rate of change of values."
-
from pylith.meshio.OutputDirichlet import OutputDirichlet
output = pyre.inventory.facility("output", family="output_manager",
factory=OutputDirichlet)
@@ -96,10 +60,8 @@
"""
Constructor.
"""
- BoundaryCondition.__init__(self, name)
- Constraint.__init__(self)
+ DirichletBC.__init__(self, name)
self._loggingPrefix = "DiBC "
- self.fixedDOF = []
self.availableFields = \
{'vertex': \
{'info': ["initial", "rate-of-change"],
@@ -114,9 +76,7 @@
"""
Do pre-initialization setup.
"""
- BoundaryCondition.preinitialize(self, mesh)
- Constraint.preinitialize(self, mesh)
- self.cppHandle.fixedDOF = self.fixedDOF
+ DirichletBC.preinitialize(self, mesh)
self.output.preinitialize(self)
return
@@ -128,8 +88,7 @@
logEvent = "%sverify" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- BoundaryCondition.verifyConfiguration(self)
- Constraint.verifyConfiguration(self)
+ DirichletBC.verifyConfiguration(self)
self.output.verifyConfiguration(self.mesh)
self._logger.eventEnd(logEvent)
@@ -142,23 +101,9 @@
"""
logEvent = "%sinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
-
- timeScale = normalizer.timeScale()
- self.tRef = normalizer.nondimensionalize(self.tRef, timeScale)
-
- assert(None != self.cppHandle)
- self.cppHandle.referenceTime = self.tRef
- self.dbRate.initialize()
- self.cppHandle.dbRate = self.dbRate.cppHandle
- self.cppHandle.normalizer = normalizer.cppHandle
- BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
+ DirichletBC.initialize(self, totalTime, numTimeSteps, normalizer)
- from pylith.topology.Mesh import Mesh
- self.boundaryMesh = Mesh()
- self.boundaryMesh.initialize(self.mesh.coordsys)
- self.cppHandle.boundaryMesh(self.boundaryMesh.cppHandle)
-
self.output.initialize(normalizer)
self.output.writeInfo()
@@ -170,7 +115,9 @@
"""
Get mesh associated with data fields.
"""
- return (self.boundaryMesh, None, None)
+ label = ""
+ labelId = 0
+ return (self.boundaryMesh(), label, labelId)
def getVertexField(self, name, fields=None):
@@ -178,13 +125,10 @@
Get vertex field.
"""
if None == fields:
- (field, fieldType) = self.cppHandle.vertexField(name,
- self.mesh.cppHandle)
+ field = self.vertexField(name)
else:
- (field, fieldType) = self.cppHandle.vertexField(name,
- self.mesh.cppHandle,
- fields.cppHandle)
- return (field, fieldType)
+ field = self.vertexField(name, fields)
+ return field
# PRIVATE METHODS ////////////////////////////////////////////////////
@@ -193,21 +137,16 @@
"""
Setup members using inventory.
"""
- BoundaryCondition._configure(self)
- self.tRef = self.inventory.tRef
- self.fixedDOF = self.inventory.fixedDOF
- self.dbRate = self.inventory.dbRate
+ DirichletBC._configure(self)
self.output = self.inventory.output
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to corresponding C++ object.
"""
- if None == self.cppHandle:
- import pylith.bc.bc as bindings
- self.cppHandle = bindings.DirichletBoundary()
+ ModuleDirichletBoundary.__init__(self)
return
Deleted: short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/bc/DirichletPoints.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,178 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file pylith/bc/DirichletPoints.py
-##
-## @brief Python object for managing a Dirichlet (prescribed
-## displacements) boundary condition with a set of points.
-##
-## Factory: boundary_condition
-
-from BoundaryCondition import BoundaryCondition
-from pylith.feassemble.Constraint import Constraint
-
-def validateDOF(value):
- """
- Validate list of fixed degrees of freedom.
- """
- try:
- size = len(value)
- num = map(int, value)
- for v in num:
- if v < 0:
- raise ValueError
- except:
- raise ValueError, \
- "'fixed_dof' must be a zero based list of indices of fixed " \
- "degrees of freedom."
- return num
-
-
-# DirichletPoints class
-class DirichletPoints(BoundaryCondition, Constraint):
- """
- Python object for managing a DirichletPoints (prescribed displacements)
- boundary condition.
-
- Factory: boundary_condition
- """
-
- # INVENTORY //////////////////////////////////////////////////////////
-
- class Inventory(BoundaryCondition.Inventory):
- """
- Python object for managing BoundaryCondition facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing BoundaryCondition facilities and properties.
- ##
- ## \b Properties
- ## @li \b fixed_dof Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc).
- ## @li \b reference_t Reference time for rate of change of values.
- ##
- ## \b Facilities
- ## @li \b initial_db Database of parameters for initial values.
- ## @li \b rate_db Database of parameters for rate of change of values.
-
- import pyre.inventory
-
- fixedDOF = pyre.inventory.list("fixed_dof", default=[],
- validator=validateDOF)
- fixedDOF.meta['tip'] = "Indices of fixed DOF (0=1st DOF, 1=2nd DOF, etc)."
-
- from pyre.units.time import s
- tRef = pyre.inventory.dimensional("reference_t", default=0.0*s)
- tRef.meta['tip'] = "Reference time for rate of change of values."
-
- from FixedDOFDB import FixedDOFDB
- db = pyre.inventory.facility("db", factory=FixedDOFDB,
- family="spatial_database")
- db.meta['tip'] = "Database of parameters for initial values."
-
- dbRate = pyre.inventory.facility("rate_db", factory=FixedDOFDB,
- family="spatial_database")
- dbRate.meta['tip'] = "Database of parameters for rate of change of values."
-
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="dirichletpoints"):
- """
- Constructor.
- """
- BoundaryCondition.__init__(self, name)
- Constraint.__init__(self)
- self._loggingPrefix = "DiBC "
- self.fixedDOF = []
- return
-
-
- def preinitialize(self, mesh):
- """
- Do pre-initialization setup.
- """
- BoundaryCondition.preinitialize(self, mesh)
- Constraint.preinitialize(self, mesh)
- self.cppHandle.fixedDOF = self.fixedDOF
- return
-
-
- def verifyConfiguration(self):
- """
- Verify compatibility of configuration.
- """
- logEvent = "%sverify" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- BoundaryCondition.verifyConfiguration(self)
- Constraint.verifyConfiguration(self)
-
- self._logger.eventEnd(logEvent)
- return
-
-
- def initialize(self, totalTime, numTimeSteps, normalizer):
- """
- Initialize DirichletPoints boundary condition.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- timeScale = normalizer.timeScale()
- self.tRef = normalizer.nondimensionalize(self.tRef, timeScale)
-
- assert(None != self.cppHandle)
- self.cppHandle.referenceTime = self.tRef
- self.dbRate.initialize()
- self.cppHandle.dbRate = self.dbRate.cppHandle
- self.cppHandle.normalizer = normalizer.cppHandle
-
- BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
-
- self._logger.eventEnd(logEvent)
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Setup members using inventory.
- """
- BoundaryCondition._configure(self)
- self.tRef = self.inventory.tRef
- self.fixedDOF = self.inventory.fixedDOF
- self.dbRate = self.inventory.dbRate
- return
-
-
- def _createCppHandle(self):
- """
- Create handle to corresponding C++ object.
- """
- if None == self.cppHandle:
- import pylith.bc.bc as bindings
- self.cppHandle = bindings.DirichletPoints()
- return
-
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def boundary_condition():
- """
- Factory associated with DirichletPoints.
- """
- return DirichletPoints()
-
-
-# End of file
Modified: short/3D/PyLith/trunk/pylith/bc/Neumann.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/Neumann.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/bc/Neumann.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,9 +18,10 @@
from BoundaryCondition import BoundaryCondition
from pylith.feassemble.Integrator import Integrator
+from bc import Neumann as ModuleNeumann
# Neumann class
-class Neumann(BoundaryCondition, Integrator):
+class Neumann(BoundaryCondition, Integrator, ModuleNeumann):
"""
Python object for managing traction boundary conditions.
@@ -46,8 +47,9 @@
import pyre.inventory
- from pylith.feassemble.quadrature.Quadrature import Quadrature
- quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = pyre.inventory.facility("quadrature",
+ factory=SubMeshQuadrature)
quadrature.meta['tip'] = "Quadrature object for numerical integration."
from pylith.meshio.OutputNeumann import OutputNeumann
@@ -81,7 +83,8 @@
"""
BoundaryCondition.preinitialize(self, mesh)
Integrator.preinitialize(self, mesh)
- self.quadrature.preinitialize()
+ self.bcQuadrature.preinitialize(mesh.coordsys().spaceDim())
+ self.quadrature(self.bcQuadrature)
self.output.preinitialize(self)
return
@@ -93,16 +96,17 @@
logEvent = "%sverify" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- BoundaryCondition.verifyConfiguration(self)
+ BoundaryCondition.verifyConfiguration(self, self.mesh)
Integrator.verifyConfiguration(self)
- if self.quadrature.cellDim != self.mesh.dimension()-1:
+ if self.bcQuadrature.cellDim() != self.mesh.dimension()-1:
raise ValueError, \
"Quadrature scheme and mesh are incompatible.\n" \
"Dimension for quadrature: %d\n" \
"Dimension of mesh boundary '%s': %d" % \
- (self.quadrature.cellDim,
- self.label, self.mesh.dimension()-1)
+ (self.bcQuadrature.cellDim(),
+ self.label(), self.mesh.dimension()-1)
self.output.verifyConfiguration(self.mesh)
+ ModuleNeumann.verifyConfiguration(self, self.mesh)
self._logger.eventEnd(logEvent)
return
@@ -116,18 +120,16 @@
self._logger.eventBegin(logEvent)
Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
-
- self.cppHandle.quadrature = self.quadrature.cppHandle
BoundaryCondition.initialize(self, totalTime, numTimeSteps, normalizer)
- from pylith.topology.Mesh import Mesh
- self.boundaryMesh = Mesh()
- self.boundaryMesh.initialize(self.mesh.coordsys)
- self.cppHandle.boundaryMesh(self.boundaryMesh.cppHandle)
+ #from pylith.topology.Mesh import Mesh
+ #self.boundaryMesh = Mesh()
+ #self.boundaryMesh.initialize(self.mesh.coordsys)
+ #self.cppHandle.boundaryMesh(self.boundaryMesh.cppHandle)
- if None != self.output:
- self.output.initialize(normalizer, self.quadrature)
- self.output.writeInfo()
+ #if None != self.output:
+ # self.output.initialize(normalizer, self.quadrature)
+ # self.output.writeInfo()
self._logger.eventEnd(logEvent)
return
@@ -145,10 +147,9 @@
Get vertex field.
"""
if None == fields:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle)
+ (field, fieldType) = self.cellField(name)
else:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle,
- fields.cppHandle)
+ (field, fieldType) = self.cellField(name, fields)
return (field, fieldType)
@@ -159,18 +160,16 @@
Setup members using inventory.
"""
BoundaryCondition._configure(self)
- self.quadrature = self.inventory.quadrature
+ self.bcQuadrature = self.inventory.quadrature
self.output = self.inventory.output
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to corresponding C++ object.
"""
- if None == self.cppHandle:
- import pylith.bc.bc as bindings
- self.cppHandle = bindings.Neumann()
+ ModuleNeumann.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/bc/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/bc/__init__.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/bc/__init__.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,8 +16,8 @@
__all__ = ['AbsorbingDampers',
'BoundaryCondition',
+ 'DirichletBC',
'DirichletBoundary',
- 'DirichletPoints',
'FixedDOFDB',
'Neumann',
]
Modified: short/3D/PyLith/trunk/pylith/faults/BruneSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/BruneSlipFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/BruneSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,49 +18,44 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import BruneSlipFn as ModuleBruneSlipFn
# BruneSlipFn class
-class BruneSlipFn(SlipTimeFn):
+class BruneSlipFn(SlipTimeFn, ModuleBruneSlipFn):
"""
Python object for slip time function that follows the integral of
Brune's (1970) far-field time function.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip Spatial database of final slip
+ @li \b slip_time Spatial database of slip initiation time
+ @li \b rise_time Spatial database of rise time
+
Factory: slip_time_fn
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SlipTimeFn.Inventory):
- """
- Python object for managing BruneSlipFn facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing BruneSlipFn facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b slip Spatial database of final slip
- ## @li \b slip_time Spatial database of slip initiation time
- ## @li \b slip_rate Spatial database of peak slip rate
+ import pyre.inventory
- import pyre.inventory
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
-
- slip = pyre.inventory.facility("slip", family="spatial_database",
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ dbSlip = pyre.inventory.facility("slip", family="spatial_database",
factory=SimpleDB)
- slip.meta['tip'] = "Spatial database of slip."
-
- slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ dbSlip.meta['tip'] = "Spatial database of slip."
+
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
factory=SimpleDB)
- slipTime.meta['tip'] = "Spatial database of slip initiation time."
-
- slipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbRiseTime = pyre.inventory.facility("rise_time", family="spatial_database",
factory=SimpleDB)
- slipRate.meta['tip'] = "Spatial database of peak slip rate."
+ dbRiseTime.meta['tip'] = "Spatial database of rise time."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -70,30 +65,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleBruneSlipFn.__init__(self)
self._loggingPrefix = "BrSF "
return
- def initialize(self):
- """
- Initialize.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.slip.initialize()
- self.slipTime.initialize()
- self.slipRate.initialize()
- assert(None != self.cppHandle)
-
- self.cppHandle.dbFinalSlip = self.slip.cppHandle
- self.cppHandle.dbSlipTime = self.slipTime.cppHandle
- self.cppHandle.dbPeakRate = self.slipRate.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -101,22 +77,12 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slip = self.inventory.slip
- self.slipTime = self.inventory.slipTime
- self.slipRate = self.inventory.slipRate
+ ModuleBruneSlipFn.dbFinalSlip(self, self.inventory.dbSlip)
+ ModuleBruneSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
+ ModuleBruneSlipFn.dbRiseTime(self, self.inventory.dbRiseTime)
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.BruneSlipFn()
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def slip_time_fn():
Modified: short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/ConstRateSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,43 +17,38 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import ConstRateSlipFn as ModuleConstRateSlipFn
# ConstRateSlipFn class
-class ConstRateSlipFn(SlipTimeFn):
+class ConstRateSlipFn(SlipTimeFn, ModuleConstRateSlipFn):
"""
Python object for a constant slip rate slip time function.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip_rate Spatial database of slip rate
+ @li \b slip_time Spatial database of slip initiation time
+
Factory: slip_time_fn
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SlipTimeFn.Inventory):
- """
- Python object for managing ConstRateSlipFn facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing ConstRateSlipFn facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b slip_rate Spatial database of slip rate
- ## @li \b slip_time Spatial database of slip initiation time
+ import pyre.inventory
- import pyre.inventory
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
-
- slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
factory=SimpleDB)
- slipTime.meta['tip'] = "Spatial database of slip initiation time."
-
- slipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbSlipRate = pyre.inventory.facility("slip_rate", family="spatial_database",
factory=SimpleDB)
- slipRate.meta['tip'] = "Spatial database of slip rate."
+ dbSlipRate.meta['tip'] = "Spatial database of slip rate."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -63,28 +58,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleConstRateSlipFn.__init__(self)
self._loggingPrefix = "CrSF "
return
- def initialize(self):
- """
- Initialize.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.slipRate.initialize()
- self.slipTime.initialize()
- assert(None != self.cppHandle)
-
- self.cppHandle.dbSlipRate = self.slipRate.cppHandle
- self.cppHandle.dbSlipTime = self.slipTime.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -92,21 +70,11 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slipRate = self.inventory.slipRate
- self.slipTime = self.inventory.slipTime
+ ModuleConstRateSlipFn.dbSlipRate(self, self.inventory.dbSlipRate)
+ ModuleConstRateSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.ConstRateSlipFn()
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def slip_time_fn():
Modified: short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/EqKinSrc.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,52 +21,47 @@
##
## Factory: eq_kinematic_src
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
+from faults import EqKinSrc as ModuleEqKinSrc
# EqKinSrc class
-class EqKinSrc(Component):
+class EqKinSrc(PetscComponent, ModuleEqKinSrc):
"""
Python object for managing parameters for a kinematic earthquake sources.
+ Inventory
+
+ \b Properties
+ @li \b origin_time Origin time for earthquake rupture.
+
+ \b Facilities
+ @li \b slip_function Slip time history function.
+
Factory: eq_kinematic_src
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing EqKinSrc facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing EqKinSrc facilities and properties.
- ##
- ## \b Properties
- ## @li \b origin_time Origin time for earthquake rupture.
- ##
- ## \b Facilities
- ## @li \b slip_function Slip time history function.
+ import pyre.inventory
+
+ from pyre.units.time import second
+ originTime = pyre.inventory.dimensional("origin_time", default=0.0*second)
+ originTime.meta['tip'] = "Origin time for earthquake rupture."
+
+ from StepSlipFn import StepSlipFn
+ slipfn = pyre.inventory.facility("slip_function", family="slip_time_fn",
+ factory=StepSlipFn)
+ slipfn.meta['tip'] = "Slip time history function."
+
- import pyre.inventory
-
- from pyre.units.time import second
- originTime = pyre.inventory.dimensional("origin_time", default=0.0*second)
- originTime.meta['tip'] = "Origin time for earthquake rupture."
-
- from StepSlipFn import StepSlipFn
- slipfn = pyre.inventory.facility("slip_function", family="slip_time_fn",
- factory=StepSlipFn)
- slipfn.meta['tip'] = "Slip time history function."
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="eqkinsrc"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="eqkinsrc")
- self.cppHandle = None
+ PetscComponent.__init__(self, name, facility="eqkinsrc")
+ self._createModuleObj()
self._loggingPrefix = "EqKi "
return
@@ -76,10 +71,7 @@
Do pre-initialization setup.
"""
self._setupLogging()
- self._createCppHandle()
- self.cppHandle.originTime = self.originTime.value
self.slipfn.preinitialize()
- self.cppHandle.slipfn = self.slipfn.cppHandle
return
@@ -115,19 +107,17 @@
"""
Setup members using inventory.
"""
- Component._configure(self)
- self.originTime = self.inventory.originTime
- self.slipfn = self.inventory.slipfn
+ PetscComponent._configure(self)
+ ModuleEqKinSrc.originTime(self, self.inventory.originTime.value)
+ ModuleEqKinSrc.slipfn(self, self.inventory.slipfn)
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to corresponding C++ object.
"""
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.EqKinSrc()
+ ModuleEqKinSrc.__init__(self)
return
@@ -140,7 +130,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Constraint")
+ logger.className("Kinematic Earthquake Source")
logger.initialize()
events = ["verify",
Modified: short/3D/PyLith/trunk/pylith/faults/Fault.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/Fault.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/Fault.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,7 +20,8 @@
##
## Factory: fault
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
+from faults import Fault as ModuleFault
# Validator for direction
def validateDir(value):
@@ -36,115 +37,91 @@
nums = map(float, value)
except:
raise ValueError(msg)
- return value
+ return nums
# Fault class
-class Fault(Component):
+class Fault(PetscComponent, ModuleFault):
"""
Python abstract base class for a fault surface.
This implementation of a fault associates both physical
properties and a quadrature scheme with the fault.
+ Inventory
+
+ \b Properties
+ @li \b id Fault identifier
+ @li \b name Name of fault
+ @li \b up_dir Up-dip or up direction
+ (perpendicular to along-strike and not collinear with fault normal;
+ only applies to fault surfaces in a 3-D domain).
+ @li \b normal_dir General preferred direction for fault normal
+ (used to pick which of two possible normal directions for
+ interface; only applies to fault surfaces in a 3-D domain).
+ @li \b mat_db Spatial database for bulk material properties
+ (used in improving conditioning of Jacobian matrix).
+
+ \b Facilities
+ @li \b quadrature Quadrature object for numerical integration
+
Factory: fault
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing Fault facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing Fault facilities and properties.
- ##
- ## \b Properties
- ## @li \b id Fault identifier
- ## @li \b name Name of fault
- ## @li \b up_dir Up-dip or up direction
- ## (perpendicular to along-strike and not collinear with fault normal;
- ## only applies to fault surfaces in a 3-D domain).
- ## @li \b normal_dir General preferred direction for fault normal
- ## (used to pick which of two possible normal directions for
- ## interface; only applies to fault surfaces in a 3-D domain).
- ## @li \b mat_db Spatial database for bulk material properties
- ## (used in improving conditioning of Jacobian matrix).
- ##
- ## \b Facilities
- ## @li \b quadrature Quadrature object for numerical integration
+ import pyre.inventory
+
+ matId = pyre.inventory.int("id", default=100)
+ matId.meta['tip'] = "Fault identifier (must be unique across all faults " \
+ "and materials)."
+
+ faultLabel = pyre.inventory.str("label", default="")
+ faultLabel.meta['tip'] = "Name of fault."
+
+ upDir = pyre.inventory.list("up_dir", default=[0, 0, 1],
+ validator=validateDir)
+ upDir.meta['tip'] = "Up-dip or up direction " \
+ "(perpendicular to along-strike and not collinear " \
+ "with fault normal; only applies to fault surface " \
+ "in a 3-D domain)."
+
+ normalDir = pyre.inventory.list("normal_dir", default=[1, 0, 0],
+ validator=validateDir)
+ normalDir.meta['tip'] = "General preferred direction for fault normal " \
+ "(used to pick which of two possible normal directions for " \
+ "interface; only applies to fault surfaces in a 3-D domain)."
+
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = pyre.inventory.facility("quadrature", factory=SubMeshQuadrature)
+ quadrature.meta['tip'] = "Quadrature object for numerical integration."
+
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ matDB = pyre.inventory.facility("mat_db", family="spatial_database",
+ factory=SimpleDB)
+ matDB.meta['tip'] = "Spatial database for bulk material properties " \
+ "(used in improving conditioning of Jacobian matrix)."
- import pyre.inventory
-
- id = pyre.inventory.int("id", default=100)
- id.meta['tip'] = "Fault identifier (must be unique across all faults " \
- "and materials)."
-
- label = pyre.inventory.str("label", default="")
- label.meta['tip'] = "Name of fault."
-
- upDir = pyre.inventory.list("up_dir", default=[0, 0, 1],
- validator=validateDir)
- upDir.meta['tip'] = "Up-dip or up direction " \
- "(perpendicular to along-strike and not collinear " \
- "with fault normal; only applies to fault surface " \
- "in a 3-D domain)."
-
- normalDir = pyre.inventory.list("normal_dir", default=[1, 0, 0],
- validator=validateDir)
- normalDir.meta['tip'] = "General preferred direction for fault normal " \
- "(used to pick which of two possible normal directions for " \
- "interface; only applies to fault surfaces in a 3-D domain)."
-
- from pylith.feassemble.quadrature.Quadrature import Quadrature
- quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
- quadrature.meta['tip'] = "Quadrature object for numerical integration."
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
- matDB = pyre.inventory.facility("mat_db", family="spatial_database",
- factory=SimpleDB)
- matDB.meta['tip'] = "Spatial database for bulk material properties " \
- "(used in improving conditioning of Jacobian matrix)."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="fault"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="fault")
- self.cppHandle = None
+ PetscComponent.__init__(self, name, facility="fault")
+ self._createModuleObj()
self.mesh = None
self.output = None
return
- def adjustTopology(self, mesh):
- """
- Adjust mesh topology for fault implementation.
- """
- self._createCppHandle()
-
- assert(None != self.cppHandle)
- self.cppHandle.id = self.id
- self.cppHandle.label = self.label
- self.cppHandle.adjustTopology(mesh.cppHandle)
- return
-
-
def preinitialize(self, mesh):
"""
Setup fault.
"""
- self._createCppHandle()
- self.cppHandle.id = self.id
- self.cppHandle.label = self.label
-
self.mesh = mesh
- self.quadrature.preinitialize()
- self.cppHandle.quadrature = self.quadrature.cppHandle
+ self.faultQuadrature.preinitialize(mesh.coordsys().spaceDim())
if None != self.output:
self.output.preinitialize(self)
@@ -160,15 +137,12 @@
self._logger.eventBegin(logEvent)
faultDim = self.mesh.dimension() - 1
- if faultDim != self.quadrature.cell.cellDim:
+ if faultDim != self.faultQuadrature.cell.cellDim:
raise ValueError, \
"Quadrature is incompatible with fault surface.\n" \
"Dimensions for quadrature: %d, dimensions of fault: %d" % \
- (self.quadrature.cell.cellDim, faultDim)
+ (self.faultQuadrature.cell.cellDim, faultDim)
- assert(None != self.cppHandle)
- self.cppHandle.verifyConfiguration(self.mesh.cppHandle)
-
if None != self.output:
self.output.verifyConfiguration(self.mesh)
@@ -183,21 +157,12 @@
logEvent = "%sinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- self.quadrature.initialize()
- self.matDB.initialize()
+ self.faultQuadrature.initialize()
+ ModuleFault.initialize(self,
+ self.mesh, self.upDir, self.normalDir, self.matDB)
- assert(None != self.cppHandle)
- self.cppHandle.initialize(self.mesh.cppHandle,
- self.mesh.coordsys.cppHandle,
- self.upDir, self.normalDir,
- self.matDB.cppHandle)
- from pylith.topology.Mesh import Mesh
- self.faultMesh = Mesh()
- self.faultMesh.initialize(self.mesh.coordsys)
- self.cppHandle.faultMesh(self.faultMesh.cppHandle)
-
if None != self.output:
- self.output.initialize(normalizer, self.quadrature)
+ self.output.initialize(normalizer, self.faultQuadrature)
self.output.writeInfo()
self.output.open(totalTime, numTimeSteps)
@@ -223,7 +188,7 @@
"""
Get mesh associated with data fields.
"""
- return (self.faultMesh, None, None)
+ return (self.faultMesh(), None, None)
def getVertexField(self, name, fields=None):
@@ -248,21 +213,21 @@
"""
Setup members using inventory.
"""
- Component._configure(self)
- self.id = self.inventory.id
- self.label = self.inventory.label
+ PetscComponent._configure(self)
+ self.faultQuadrature = self.inventory.quadrature
self.upDir = map(float, self.inventory.upDir)
self.normalDir = map(float, self.inventory.normalDir)
- self.quadrature = self.inventory.quadrature
self.matDB = self.inventory.matDB
+ ModuleFault.id(self, self.inventory.matId)
+ ModuleFault.label(self, self.inventory.faultLabel)
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to corresponding C++ object.
"""
- raise NotImplementedError("Please implement _createCppHandle() in " \
+ raise NotImplementedError("Please implement _createModuleObj() in " \
"derived class.")
Modified: short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/FaultCohesive.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,52 +19,50 @@
## Factory: fault
from Fault import Fault
+from faults import FaultCohesive as ModuleFaultCohesive
# FaultCohesive class
-class FaultCohesive(Fault):
+class FaultCohesive(Fault, ModuleFaultCohesive):
"""
Python abstract base class for a fault surface implemeted with
cohesive elements.
+ Inventory
+
+ @class Inventory
+ Python object for managing FaultCohesive facilities and properties.
+
+ \b Properties
+ @li \b use_fault_mesh If true, use fault mesh to define fault;
+ otherwise, use group of vertices to define fault.
+
+ \b Facilities
+ @li \b fault_mesh_importer Importer for fault mesh.
+
Factory: fault
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Fault.Inventory):
- """
- Python object for managing FaultCohesive facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing FaultCohesive facilities and properties.
- ##
- ## \b Properties
- ## @li \b use_fault_mesh If true, use fault mesh to define fault;
- ## otherwise, use group of vertices to define fault.
- ##
- ## \b Facilities
- ## @li \b fault_mesh_importer Importer for fault mesh.
+ import pyre.inventory
- import pyre.inventory
+ useMesh = pyre.inventory.bool("use_fault_mesh", default=False)
+ useMesh.meta['tip'] = "If true, use fault mesh to define fault; " \
+ "otherwise, use group of vertices to define fault."
- useFaultMesh = pyre.inventory.bool("use_fault_mesh", default=False)
- useFaultMesh.meta['tip'] = "If true, use fault mesh to define fault; " \
- "otherwise, use group of vertices to define fault."
+ # Future, improved implementation
+ #from pylith.meshio.MeshIOAscii imoport MeshIOAscii
+ #faultMeshImporter = pyre.inventory.facility("fault_mesh_importer",
+ # factory=MeshIOLagrit,
+ # family="mesh_io")
+ #faultMeshImporter.meta['tip'] = "Importer for fault mesh."
- # Future, improved implementation
- #from pylith.meshio.MeshIOAscii imoport MeshIOAscii
- #faultMeshImporter = pyre.inventory.facility("fault_mesh_importer",
- # factory=MeshIOLagrit,
- # family="mesh_io")
- #faultMeshImporter.meta['tip'] = "Importer for fault mesh."
+ # Current kludge
+ meshFilename = pyre.inventory.str("fault_mesh_filename",
+ default="fault.inp")
+ meshFilename.meta['tip'] = "Filename for fault mesh UCD file."
- # Current kludge
- faultMeshFilename = pyre.inventory.str("fault_mesh_filename",
- default="fault.inp")
- faultMeshFilename.meta['tip'] = "Filename for fault mesh UCD file."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="faultcohesive"):
@@ -75,20 +73,6 @@
return
- def adjustTopology(self, mesh):
- """
- Adjust mesh topology for fault implementation.
- """
- self._createCppHandle()
- assert(None != self.cppHandle)
- self.cppHandle.useFaultMesh = self.useFaultMesh
- #self.cppHandle.faultMeshImporter = self.faultMeshImporter.cppHandle
- self.cppHandle.faultMeshFilename = self.faultMeshFilename # TEMPORARY
-
- Fault.adjustTopology(self, mesh)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -96,9 +80,12 @@
Setup members using inventory.
"""
Fault._configure(self)
- self.useFaultMesh = self.inventory.useFaultMesh
- #self.faultMeshImporter = self.inventory.faultMeshImporter
- self.faultMeshFilename = self.inventory.faultMeshFilename # TEMPORARY
+ ModuleFaultCohesive.useFaultMesh(self, self.inventory.useMesh)
+ #ModuleFaultCohesive.faultMeshImporter(self,
+ # self.inventory.faultMeshImporter)
+ # TEMPORARY
+ ModuleFaultCohesive.faultMeshFilename(self,
+ self.inventory.meshFilename)
return
Modified: short/3D/PyLith/trunk/pylith/faults/FaultCohesiveKin.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/FaultCohesiveKin.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/FaultCohesiveKin.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,7 @@
from FaultCohesive import FaultCohesive
from pylith.feassemble.Integrator import Integrator
+from faults import FaultCohesiveKin as ModuleFaultCohesiveKin
# ITEM FACTORIES ///////////////////////////////////////////////////////
@@ -33,45 +34,41 @@
# FaultCohesiveKin class
-class FaultCohesiveKin(FaultCohesive, Integrator):
+class FaultCohesiveKin(FaultCohesive, Integrator, ModuleFaultCohesiveKin):
"""
Python object for a fault surface with kinematic (prescribed) slip
implemented with cohesive elements.
+ Inventory
+
+ @class Inventory
+ Python object for managing FaultCohesiveKin facilities and properties.
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b eq_srcs Kinematic earthquake sources information.
+ @li \b output Output manager associated with fault data.
+
Factory: fault
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(FaultCohesive.Inventory):
- """
- Python object for managing FaultCohesiveKin facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing FaultCohesiveKin facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b eq_srcs Kinematic earthquake sources information.
- ## @li \b output Output manager associated with fault data.
+ import pyre.inventory
- import pyre.inventory
+ from SingleRupture import SingleRupture
+ eqsrcs = pyre.inventory.facilityArray("eq_srcs", itemFactory=eqsrcFactory,
+ factory=SingleRupture)
+ eqsrcs.meta['tip'] = "Kinematic earthquake sources information."
+
+ from pylith.meshio.OutputFaultKin import OutputFaultKin
+ output = pyre.inventory.facility("output", family="output_manager",
+ factory=OutputFaultKin)
+ output.meta['tip'] = "Output manager associated with fault data."
+
- from SingleRupture import SingleRupture
- eqsrcs = pyre.inventory.facilityArray("eq_srcs", itemFactory=eqsrcFactory,
- factory=SingleRupture)
- eqsrcs.meta['tip'] = "Kinematic earthquake sources information."
-
- from pylith.meshio.OutputFaultKin import OutputFaultKin
- output = pyre.inventory.facility("output", family="output_manager",
- factory=OutputFaultKin)
- output.meta['tip'] = "Output manager associated with fault data."
-
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="faultcohesivekin"):
@@ -99,14 +96,16 @@
"""
Do pre-initialization setup.
"""
- self._info.log("Pre-initializing fault '%s'." % self.label)
+ self._info.log("Pre-initializing fault '%s'." % self.label())
FaultCohesive.preinitialize(self, mesh)
Integrator.preinitialize(self, mesh)
- assert(None != self.cppHandle)
+
+ ModuleFaultCohesiveKin.quadrature(self, self.faultQuadrature)
+
for eqsrc in self.eqsrcs.components():
eqsrc.preinitialize()
- self.cppHandle.eqsrcs(self.eqsrcs.inventory.facilityNames(),
- self.eqsrcs.components())
+ ModuleFaultCohesiveKin.eqsrcs(self, self.eqsrcs.inventory.facilityNames(),
+ self.eqsrcs.components())
for name in self.eqsrcs.inventory.facilityNames():
self.availableFields['vertex']['info'] += ["final_slip_%s" % name]
@@ -129,6 +128,8 @@
FaultCohesive.verifyConfiguration(self)
Integrator.verifyConfiguration(self)
+ ModuleFaultCohesiveKin.verifyConfiguration(self, self.mesh)
+
for eqsrc in self.eqsrcs.components():
eqsrc.verifyConfiguration()
@@ -142,7 +143,7 @@
"""
logEvent = "%sinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- self._info.log("Initializing fault '%s'." % self.label)
+ self._info.log("Initializing fault '%s'." % self.label())
Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
@@ -173,13 +174,10 @@
Get vertex field.
"""
if None == fields:
- (field, fieldType) = self.cppHandle.vertexField(name,
- self.mesh.cppHandle)
+ field = ModuleFaultCohesiveKin.vertexField(self, name)
else:
- (field, fieldType) = self.cppHandle.vertexField(name,
- self.mesh.cppHandle,
- fields.cppHandle)
- return (field, fieldType)
+ field = ModuleFaultCohesiveKin.vertexField(self, name, fields)
+ return field
def getCellField(self, name, fields=None):
@@ -187,11 +185,10 @@
Get cell field.
"""
if None == fields:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle)
+ field = ModuleFaultCohesiveKin.cellField(self, name)
else:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle,
- fields.cppHandle)
- return (field, fieldType)
+ field = ModuleFaultCohesiveKin.cellField(self, name, fields)
+ return field
# PRIVATE METHODS ////////////////////////////////////////////////////
@@ -206,13 +203,11 @@
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
Create handle to C++ FaultCohesiveKin.
"""
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.FaultCohesiveKin()
+ ModuleFaultCohesiveKin.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/faults/LiuCosSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/LiuCosSlipFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/LiuCosSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,50 +19,45 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import LiuCosSlipFn as ModuleLiuCosSlipFn
# LiuCosSlipFn class
-class LiuCosSlipFn(SlipTimeFn):
+class LiuCosSlipFn(SlipTimeFn, ModuleLiuCosSlipFn):
"""
Sine/cosine slip time function from Liu, Archuleta, and Hartzell,
BSSA, 2006 (doi:10.1785/0120060036) which has a rapid rise and then
a gradual falloff with a finite duration.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip Spatial database of final slip.
+ @li \b slip_time Spatial database of slip initiation time.
+ @li \b rise_time Spatial database of rise time (t95).
+
Factory: slip_time_fn
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SlipTimeFn.Inventory):
- """
- Python object for managing LiuCosSlipFn facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing LiuCosSlipFn facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b slip Spatial database of final slip.
- ## @li \b slip_time Spatial database of slip initiation time.
- ## @li \b rise_time Spatial database of rise time (t95).
-
- import pyre.inventory
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
-
- slip = pyre.inventory.facility("slip", family="spatial_database",
+ import pyre.inventory
+
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+
+ dbSlip = pyre.inventory.facility("slip", family="spatial_database",
factory=SimpleDB)
- slip.meta['tip'] = "Spatial database of slip."
-
- slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ dbSlip.meta['tip'] = "Spatial database of slip."
+
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
factory=SimpleDB)
- slipTime.meta['tip'] = "Spatial database of slip initiation time."
-
- riseTime = pyre.inventory.facility("rise_time", family="spatial_database",
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbRiseTime = pyre.inventory.facility("rise_time", family="spatial_database",
factory=SimpleDB)
- riseTime.meta['tip'] = "Spatial database of rise time (t95)."
+ dbRiseTime.meta['tip'] = "Spatial database of rise time (t95)."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -72,30 +67,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleLiuCosSlipFn.__init__(self)
self._loggingPrefix = "BrSF "
return
- def initialize(self):
- """
- Initialize.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.slip.initialize()
- self.slipTime.initialize()
- self.riseTime.initialize()
- assert(None != self.cppHandle)
-
- self.cppHandle.dbFinalSlip = self.slip.cppHandle
- self.cppHandle.dbSlipTime = self.slipTime.cppHandle
- self.cppHandle.dbRiseTime = self.riseTime.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -103,22 +79,12 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slip = self.inventory.slip
- self.slipTime = self.inventory.slipTime
- self.riseTime = self.inventory.riseTime
+ ModuleLiuCosSlipFn.dbFinalSlip(self, self.inventory.dbSlip)
+ ModuleLiuCosSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
+ ModuleLiuCosSlipFn.dbRiseTime(self, self.inventory.dbRiseTime)
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.LiuCosSlipFn()
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def slip_time_fn():
Modified: short/3D/PyLith/trunk/pylith/faults/SingleRupture.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/SingleRupture.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/SingleRupture.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,45 +14,43 @@
##
## @brief Python kinematic rupture container with one rupture.
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
# SingleRupture class
-class SingleRupture(Component):
+class SingleRupture(PetscComponent):
"""
Python kinematic rupture container with one rupture.
+
+ Inventory
+
+ @class Inventory
+ Python object for managing SingleRupture facilities and properties.
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b rupture Kinematic earthquake rupture in problem
+
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing SingleRupture facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing SingleRupture facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b rupture Kinematic earthquake rupture in problem
+ import pyre.inventory
- import pyre.inventory
+ from EqKinSrc import EqKinSrc
+ rupture = pyre.inventory.facility("rupture", family="eq_kinematic_src",
+ factory=EqKinSrc)
+ rupture.meta['tip'] = "Kinematic earthquake rupture in problem."
- from EqKinSrc import EqKinSrc
- rupture = pyre.inventory.facility("rupture", family="eq_kinematic_src",
- factory=EqKinSrc)
- rupture.meta['tip'] = "Kinematic earthquake rupture in problem."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="singlerupture"):
"""
Constructor.
"""
- Component.__init__(self, name)
+ PetscComponent.__init__(self, name, facility="rupture")
return
Modified: short/3D/PyLith/trunk/pylith/faults/SlipTimeFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/SlipTimeFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/SlipTimeFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -34,7 +34,6 @@
Constructor.
"""
Component.__init__(self, name, facility="sliptimefn")
- self.cppHandle = None
return
@@ -43,7 +42,6 @@
Do pre-initialization setup.
"""
self._setupLogging()
- self._createCppHandle()
return
@@ -79,14 +77,6 @@
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- raise NotImplementedError("Please implement _createCppHandle().")
- return
-
-
def _setupLogging(self):
"""
Setup event logging.
@@ -96,7 +86,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Constraint")
+ logger.className("Slip Time Function")
logger.initialize()
events = ["verify",
Modified: short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/faults/StepSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,43 +17,38 @@
## Factory: slip_time_fn
from SlipTimeFn import SlipTimeFn
+from faults import StepSlipFn as ModuleStepSlipFn
# StepSlipFn class
-class StepSlipFn(SlipTimeFn):
+class StepSlipFn(SlipTimeFn, ModuleStepSlipFn):
"""
Python object for a step-function slip time function.
+ Inventory
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b slip Spatial database of final slip.
+ @li \b slip_time Spatial database of slip initiation time.
+
Factory: slip_time_fn
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(SlipTimeFn.Inventory):
- """
- Python object for managing StepSlipFn facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing StepSlipFn facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b slip Spatial database of final slip.
- ## @li \b slip_time Spatial database of slip initiation time.
+ import pyre.inventory
- import pyre.inventory
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
- from spatialdata.spatialdb.SimpleDB import SimpleDB
-
- slipTime = pyre.inventory.facility("slip_time", family="spatial_database",
- factory=SimpleDB)
- slipTime.meta['tip'] = "Spatial database of slip initiation time."
-
- slip = pyre.inventory.facility("slip", family="spatial_database",
+ dbSlipTime = pyre.inventory.facility("slip_time", family="spatial_database",
+ factory=SimpleDB)
+ dbSlipTime.meta['tip'] = "Spatial database of slip initiation time."
+
+ dbSlip = pyre.inventory.facility("slip", family="spatial_database",
factory=SimpleDB)
- slip.meta['tip'] = "Spatial database of final slip."
+ dbSlip.meta['tip'] = "Spatial database of final slip."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -63,28 +58,11 @@
Constructor.
"""
SlipTimeFn.__init__(self, name)
+ ModuleStepSlipFn.__init__(self)
self._loggingPrefix = "StSF "
return
- def initialize(self):
- """
- Initialize.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self.slip.initialize()
- self.slipTime.initialize()
- assert(None != self.cppHandle)
-
- self.cppHandle.dbFinalSlip = self.slip.cppHandle
- self.cppHandle.dbSlipTime = self.slipTime.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
@@ -92,21 +70,11 @@
Setup members using inventory.
"""
SlipTimeFn._configure(self)
- self.slip = self.inventory.slip
- self.slipTime = self.inventory.slipTime
+ ModuleStepSlipFn.dbSlipTime(self, self.inventory.dbSlipTime)
+ ModuleStepSlipFn.dbFinalSlip(self, self.inventory.dbSlip)
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.faults.faults as bindings
- self.cppHandle = bindings.StepSlipFn()
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def slip_time_fn():
Copied: short/3D/PyLith/trunk/pylith/feassemble/CellGeometry.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/feassemble/CellGeometry.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/CellGeometry.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/feassemble/CellGeometry.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,245 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/feassemble/geometry/CellGeometry.py
+##
+## @brief Python abstract base class for geometry of a finite-element cell.
+
+import feassemble
+
+# ----------------------------------------------------------------------
+# CellGeometry class
+class CellGeometry(object):
+ """
+ Python abstract base class for geometry of a finite-element cell.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryPoint1D class
+class GeometryPoint1D(feassemble.GeometryPoint1D):
+ """
+ Python object for geometry of a 0-D finite-element cell in 1-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryPoint1D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryPoint2D class
+class GeometryPoint2D(feassemble.GeometryPoint2D):
+ """
+ Python object for geometry of a 0-D finite-element cell in 2-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryPoint2D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryPoint3D class
+class GeometryPoint3D(feassemble.GeometryPoint3D):
+ """
+ Python object for geometry of a 0-D finite-element cell in 3-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryPoint3D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryLine1D class
+class GeometryLine1D(feassemble.GeometryLine1D):
+ """
+ Python object for geometry of a 1-D finite-element cell in 1-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryLine1D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryLine2D class
+class GeometryLine2D(feassemble.GeometryLine2D):
+ """
+ Python object for geometry of a 1-D finite-element cell in 2-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryLine2D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryLine3D class
+class GeometryLine3D(feassemble.GeometryLine3D):
+ """
+ Python object for geometry of a 1-D finite-element cell in 3-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryLine3D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryTri2D class
+class GeometryTri2D(feassemble.GeometryTri2D):
+ """
+ Python object for geometry of a 2-D triangular finite-element cell
+ in 2-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryTri2D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryTri3D class
+class GeometryTri3D(feassemble.GeometryTri3D):
+ """
+ Python object for geometry of a 2-D triangular finite-element cell
+ in 3-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryTri3D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryQuad2D class
+class GeometryQuad2D(feassemble.GeometryQuad2D):
+ """
+ Python object for geometry of a 2-D quadrilateral finite-element cell
+ in 2-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryQuad2D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryQuad3D class
+class GeometryQuad3D(feassemble.GeometryQuad3D):
+ """
+ Python object for geometry of a 2-D quadrilateral finite-element cell
+ in 3-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryQuad3D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryTet3D class
+class GeometryTet3D(feassemble.GeometryTet3D):
+ """
+ Python object for geometry of a 3-D tetrahedral finite-element cell
+ in 3-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryTet3D.__init__(self)
+ return
+
+
+# ----------------------------------------------------------------------
+# GeometryHex3D class
+class GeometryHex3D(feassemble.GeometryHex3D):
+ """
+ Python object for geometry of a 3-D hexahedral finite-element cell
+ in 3-D.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ feassemble.GeometryHex3D.__init__(self)
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/feassemble/Constraint.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/Constraint.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/Constraint.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,6 @@
##
## @brief Python abstract base class for constraints on operator
## actions with finite-elements.
-##
-## Factory: fe_constraint.
def implementsConstraint(obj):
"""
@@ -26,7 +24,6 @@
required = ["preinitialize",
"verifyConfiguration",
"initialize",
- "timeStep",
"setConstraintSizes",
"setConstraints",
"useSolnIncr",
@@ -45,8 +42,6 @@
"""
Python abstract base class for constraints on operator
actions with finite-elements.
-
- Factory: constraint.
"""
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -55,8 +50,6 @@
"""
Constructor.
"""
- self.cppHandle = None
- self.mesh = None
return
@@ -64,123 +57,24 @@
"""
Setup constraint.
"""
- self.mesh = mesh
self._setupLogging()
return
- def verifyConfiguration(self):
- """
- Verify compatibility of configuration.
- """
- logEvent = "%sverify" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self._logger.eventEnd(logEvent)
- return
-
-
- def initialize(self, totalTime, numTimeSteps, normalizer):
- """
- Do initialization.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.normalizer = normalizer.cppHandle
-
- self._logger.eventEnd(logEvent)
- return
-
-
- def timeStep(self, dt):
- """
- Set time step for advancing from time t to time t+dt.
- """
- assert(None != self.cppHandle)
- self.cppHandle.timeStep = dt
- return
-
-
- def setConstraintSizes(self, field):
- """
- Set constraint sizes in field.
- """
- logEvent = "%ssetSizes" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.setConstraintSizes(field, self.mesh.cppHandle)
-
- self._logger.eventEnd(logEvent)
- return
-
-
- def setConstraints(self, field):
- """
- Set constraints for field.
- """
- logEvent = "%sconstraints" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.setConstraints(field, self.mesh.cppHandle)
-
- self._logger.eventEnd(logEvent)
- return
-
-
- def useSolnIncr(self, flag):
- """
- Set behavior for using total field solution or incremental field solution.
- """
- logEvent = "%ssolnIncr" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.useSolnIncr = flag
-
- self._logger.eventEnd(logEvent)
- return
-
-
- def setField(self, t, field):
- """
- Set constrained values in field at time t.
- """
- logEvent = "%ssetField" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.setField(t, field, self.mesh.cppHandle)
-
- self._logger.eventEnd(logEvent)
- return
-
-
def poststep(self, t, dt, totalTime, fields):
"""
Hook for doing stuff after advancing time step.
"""
- logEvent = "%spoststep" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self._logger.eventEnd(logEvent)
return
+
-
def finalize(self):
"""
- Cleanup after time stepping.
+ Cleanup.
"""
- logEvent = "%sfinalize" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self._logger.eventEnd(logEvent)
return
-
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _setupLogging(self):
@@ -192,7 +86,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Constraint")
+ logger.className("FE Constraint")
logger.initialize()
events = ["verify",
Modified: short/3D/PyLith/trunk/pylith/feassemble/ElasticityExplicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/ElasticityExplicit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/ElasticityExplicit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,9 +18,10 @@
## Factory: integrator
from IntegratorElasticity import IntegratorElasticity
+from feassemble import ElasticityExplicit as ModuleElasticityExplicit
# ElasticityExplicit class
-class ElasticityExplicit(IntegratorElasticity):
+class ElasticityExplicit(IntegratorElasticity, ModuleElasticityExplicit):
"""
Python object for explicit time integration of dynamic elasticity
equation using finite-elements.
@@ -33,10 +34,23 @@
Constructor.
"""
IntegratorElasticity.__init__(self, name)
+ ModuleElasticityExplicit.__init__(self)
self._loggingPrefix = "ElEx "
+ return
- import pylith.feassemble.feassemble as bindings
- self.cppHandle = bindings.ElasticityExplicit()
+
+ def initialize(self, totalTime, numTimeSteps, normalizer):
+ """
+ Do initialization.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ IntegratorElasticity.initialize(self, totalTime, numTimeSteps, normalizer)
+ ModuleElasticityExplicit.initialize(self, self.mesh)
+ self._initializeOutput(totalTime, numTimeSteps, normalizer)
+
+ self._logger.eventEnd(logEvent)
return
Modified: short/3D/PyLith/trunk/pylith/feassemble/ElasticityImplicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/ElasticityImplicit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/ElasticityImplicit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,11 +18,12 @@
## Factory: integrator
from IntegratorElasticity import IntegratorElasticity
+from feassemble import ElasticityImplicit as ModuleElasticityImplicit
# ElasticityImplicit class
-class ElasticityImplicit(IntegratorElasticity):
+class ElasticityImplicit(IntegratorElasticity, ModuleElasticityImplicit):
"""
- Python object for implicit time integration of dynamic elasticity
+ Python object for implicit time integration of elasticity
equation using finite-elements.
"""
@@ -33,10 +34,23 @@
Constructor.
"""
IntegratorElasticity.__init__(self, name)
+ ModuleElasticityImplicit.__init__(self)
self._loggingPrefix = "ElIm "
+ return
- import pylith.feassemble.feassemble as bindings
- self.cppHandle = bindings.ElasticityImplicit()
+
+ def initialize(self, totalTime, numTimeSteps, normalizer):
+ """
+ Do initialization.
+ """
+ logEvent = "%sinit" % self._loggingPrefix
+ self._logger.eventBegin(logEvent)
+
+ IntegratorElasticity.initialize(self, totalTime, numTimeSteps, normalizer)
+ ModuleElasticityImplicit.initialize(self, self.mesh)
+ self._initializeOutput(totalTime, numTimeSteps, normalizer)
+
+ self._logger.eventEnd(logEvent)
return
Modified: short/3D/PyLith/trunk/pylith/feassemble/FIATLagrange.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/FIATLagrange.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/FIATLagrange.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -86,8 +86,8 @@
if self.cellDim > 0:
quadrature = self._setupQuadrature()
- element = self._setupElement()
- dim = self.cellDim
+ element = self._setupElement()
+ dim = self.cellDim
# Get coordinates of vertices (dual basis)
vertices = numpy.array(self._setupVertices(element))
@@ -681,38 +681,30 @@
"""
Setup reference cell geometry object.
"""
+ import CellGeometry
self.geometry = None
if 3 == self.cellDim:
if 3 == spaceDim:
- from geometry.GeometryHex3D import GeometryHex3D
- self.geometry = GeometryHex3D()
+ self.geometry = CellGeometry.GeometryHex3D()
elif 2 == self.cellDim:
if 2 == spaceDim:
- from geometry.GeometryQuad2D import GeometryQuad2D
- self.geometry = GeometryQuad2D()
+ self.geometry = CellGeometry.GeometryQuad2D()
elif 3 == spaceDim:
- from geometry.GeometryQuad3D import GeometryQuad3D
- self.geometry = GeometryQuad3D()
+ self.geometry = CellGeometry.GeometryQuad3D()
elif 1 == self.cellDim:
if 1 == spaceDim:
- from geometry.GeometryLine1D import GeometryLine1D
- self.geometry = GeometryLine1D()
+ self.geometry = CellGeometry.GeometryLine1D()
elif 2 == spaceDim:
- from geometry.GeometryLine2D import GeometryLine2D
- self.geometry = GeometryLine2D()
+ self.geometry = CellGeometry.GeometryLine2D()
elif 3 == spaceDim:
- from geometry.GeometryLine3D import GeometryLine3D
- self.geometry = GeometryLine3D()
+ self.geometry = CellGeometry.GeometryLine3D()
elif 0 == self.cellDim:
if 1 == spaceDim:
- from geometry.GeometryPoint1D import GeometryPoint1D
- self.geometry = GeometryPoint1D()
+ self.geometry = CellGeometry.GeometryPoint1D()
elif 2 == spaceDim:
- from geometry.GeometryPoint2D import GeometryPoint2D
- self.geometry = GeometryPoint2D()
+ self.geometry = CellGeometry.GeometryPoint2D()
elif 3 == spaceDim:
- from geometry.GeometryPoint3D import GeometryPoint3D
- self.geometry = GeometryPoint3D()
+ self.geometry = CellGeometry.GeometryPoint3D()
if None == self.geometry:
raise ValueError("Could not set shape of cell for '%s' in spatial " \
"dimension '%s'." % (self.name, spaceDim))
Modified: short/3D/PyLith/trunk/pylith/feassemble/FIATSimplex.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/FIATSimplex.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/FIATSimplex.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -68,7 +68,7 @@
degree.meta['tip'] = "Degree of finite-element cell."
order = pyre.inventory.int("quad_order", default=-1)
- order.meta['tip'] = "Order of quadrature rule."
+ order.meta['tip'] = "Order of quadrature rule [-1, order = degree]."
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -158,39 +158,32 @@
"""
Setup reference cell geometry object.
"""
+ import CellGeometry
+
self.geometry = None
name = self.shape.lower()
if "tetrahedron" == name:
if 3 == spaceDim:
- from geometry.GeometryTet3D import GeometryTet3D
- self.geometry = GeometryTet3D()
+ self.geometry = CellGeometry.GeometryTet3D()
elif "triangle" == name:
if 2 == spaceDim:
- from geometry.GeometryTri2D import GeometryTri2D
- self.geometry = GeometryTri2D()
+ self.geometry = CellGeometry.GeometryTri2D()
elif 3 == spaceDim:
- from geometry.GeometryTri3D import GeometryTri3D
- self.geometry = GeometryTri3D()
+ self.geometry = CellGeometry.GeometryTri3D()
elif "line" == name:
if 1 == spaceDim:
- from geometry.GeometryLine1D import GeometryLine1D
- self.geometry = GeometryLine1D()
+ self.geometry = CellGeometry.GeometryLine1D()
elif 2 == spaceDim:
- from geometry.GeometryLine2D import GeometryLine2D
- self.geometry = GeometryLine2D()
+ self.geometry = CellGeometry.GeometryLine2D()
elif 3 == spaceDim:
- from geometry.GeometryLine3D import GeometryLine3D
- self.geometry = GeometryLine3D()
+ self.geometry = CellGeometry.GeometryLine3D()
elif "point" == name:
if 1 == spaceDim:
- from geometry.GeometryPoint1D import GeometryPoint1D
- self.geometry = GeometryPoint1D()
+ self.geometry = CellGeometry.GeometryPoint1D()
elif 2 == spaceDim:
- from geometry.GeometryPoint2D import GeometryPoint2D
- self.geometry = GeometryPoint2D()
+ self.geometry = CellGeometry.GeometryPoint2D()
elif 3 == spaceDim:
- from geometry.GeometryPoint3D import GeometryPoint3D
- self.geometry = GeometryPoint3D()
+ self.geometry = CellGeometry.GeometryPoint3D()
if None == self.geometry:
raise ValueError("Could not set shape of cell for '%s' in spatial " \
"dimension '%s'." % (self.name, spaceDim))
Modified: short/3D/PyLith/trunk/pylith/feassemble/Integrator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/Integrator.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/Integrator.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -57,9 +57,8 @@
"""
Constructor.
"""
- self.quadrature = None
- self.gravityField = None
self.mesh = None
+ self.gravityField = None
return
@@ -68,7 +67,6 @@
Do pre-initialization setup.
"""
self._setupLogging()
-
return
@@ -76,13 +74,6 @@
"""
Verify compatibility of configuration.
"""
- logEvent = "%sverify" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.verifyConfiguration(self.mesh.cppHandle)
-
- self._logger.eventEnd(logEvent)
return
@@ -93,128 +84,14 @@
logEvent = "%sinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- assert(None != self.cppHandle)
- self.cppHandle.normalizer = normalizer.cppHandle
+ self.normalizer(normalizer)
if None != self.gravityField:
- self.cppHandle.gravityField = self.gravityField.cppHandle
+ self.gravityField(self.gravityField)
self._logger.eventEnd(logEvent)
return
- def timeStep(self, dt):
- """
- Set time step for advancing from time t to time t+dt.
- """
- assert(None != self.cppHandle)
- self.cppHandle.timeStep = dt
- return
-
-
- def stableTimeStep(self):
- """
- Get stable time step for advancing from time t to time t+dt.
- """
- logEvent = "%stimestep" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- dt = self.cppHandle.stableTimeStep
-
- self._logger.eventEnd(logEvent)
- return dt
-
-
- def useSolnIncr(self, flag):
- """
- Set behavior for using total field solution or incremental field solution.
- """
- logEvent = "%ssolnIncr" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.useSolnIncr = flag
-
- self._logger.eventEnd(logEvent)
- return
-
-
- def needNewJacobian(self):
- """
- Returns true if we need to recompute Jacobian matrix for operator,
- false otherwise.
- """
- logEvent = "%snewJacobian" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- flag = self.cppHandle.needNewJacobian
- self._logger.eventEnd(logEvent)
- return flag
-
-
- def integrateResidual(self, residual, t, fields):
- """
- Integrate contributions to residual term at time t.
- """
- logEvent = "%sresidual" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.integrateResidual(residual, t, fields.cppHandle,
- self.mesh.cppHandle,
- self.mesh.coordsys.cppHandle)
- self._logger.eventEnd(logEvent)
- return
-
-
- def integrateJacobian(self, jacobian, t, fields):
- """
- Integrate contributions to Jacobian term at time t.
- """
- logEvent = "%sjacobian" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.integrateJacobian(jacobian, t, fields.cppHandle,
- self.mesh.cppHandle)
- self._logger.eventEnd(logEvent)
- return
-
-
- def integrateResidualAssembled(self, residual, t, fields):
- """
- Integrate contributions to residual term at time t that do not
- require assembly over cells, vertices, or processors.
- """
- logEvent = "%sresidualAs" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.integrateResidualAssembled(residual, t,
- fields.cppHandle,
- self.mesh.cppHandle,
- self.mesh.coordsys.cppHandle)
- self._logger.eventEnd(logEvent)
- return
-
-
- def integrateJacobianAssembled(self, jacobian, t, fields):
- """
- Integrate contributions to Jacobian term at time t that do not
- require assembly over cells, vertices, or processors.
- """
- logEvent = "%sjacobianAs" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- assert(None != self.cppHandle)
- self.cppHandle.integrateJacobianAssembled(jacobian, t,
- fields.cppHandle,
- self.mesh.cppHandle)
- self._logger.eventEnd(logEvent)
- return
-
-
def poststep(self, t, dt, totalTime, fields):
"""
Hook for doing stuff after advancing time step.
@@ -222,8 +99,7 @@
logEvent = "%spoststep" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- assert(None != self.cppHandle)
- self.cppHandle.updateState(t, fields.cppHandle, self.mesh.cppHandle)
+ self.updateStateVars(t, fields)
self._logger.eventEnd(logEvent)
return
@@ -247,18 +123,12 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Integrator")
+ logger.className("FE Integrator")
logger.initialize()
- events = ["verify",
+ events = ["preinit",
+ "verify",
"init",
- "timestep",
- "solnIncr",
- "newJacobian",
- "residual",
- "jacobian",
- "residualAs",
- "jacobianAs",
"poststep",
"finalize"]
for event in events:
Modified: short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/IntegratorElasticity.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -33,11 +33,13 @@
Constructor.
"""
Integrator.__init__(self)
- import journal
- self._info = journal.info(name)
self.output = None
self.availableFields = None
self.name = "Integrator Elasticity"
+
+ # Setup journal (not a Component, so not setup already)
+ import journal
+ self._info = journal.info(name)
return
@@ -45,21 +47,18 @@
"""
Setup integrator.
"""
- Integrator.preinitialize(self, mesh)
-
- assert(None != self.cppHandle)
self.mesh = mesh
-
- material.preinitialize()
-
- self.quadrature = material.quadrature
- self.cppHandle.quadrature = self.quadrature.cppHandle
-
- self.material = material
- self.cppHandle.material = self.material.cppHandle
self.output = material.output
self.availableFields = material.availableFields
+ self.materialObj = material
+
+ Integrator.preinitialize(self, mesh)
+ material.preinitialize(mesh)
self.output.preinitialize(self)
+
+ # Set integrator's quadrature using quadrature from material
+ self.quadrature(material.quadrature)
+ self.material(material)
return
@@ -71,10 +70,8 @@
self._logger.eventBegin(logEvent)
Integrator.verifyConfiguration(self)
- self.material.verifyConfiguration()
self.output.verifyConfiguration(self.mesh)
-
self._logger.eventEnd(logEvent)
return
@@ -87,15 +84,9 @@
self._logger.eventBegin(logEvent)
self._info.log("Initializing integrator for material '%s'." % \
- self.material.label)
-
+ self.materialObj.label)
Integrator.initialize(self, totalTime, numTimeSteps, normalizer)
- self.material.initialize(self.mesh, totalTime, numTimeSteps, normalizer)
- self.output.initialize(normalizer, self.quadrature)
- self.output.writeInfo()
- self.output.open(totalTime, numTimeSteps)
-
self._logger.eventEnd(logEvent)
return
@@ -120,7 +111,7 @@
"""
Get mesh associated with data fields.
"""
- return self.material.getDataMesh()
+ return self.materialObj.getDataMesh()
def getCellField(self, name, fields=None):
@@ -128,11 +119,20 @@
Get cell field.
"""
if None == fields:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle)
+ field = self.cellField(name, self.mesh)
else:
- (field, fieldType) = self.cppHandle.cellField(name, self.mesh.cppHandle,
- fields.cppHandle)
- return (field, fieldType)
+ field = self.cellField(name, self.mesh, fields)
+ return field
+ def _initializeOutput(self, totalTime, numTimeSteps, normalizer):
+ """
+ Initialize output.
+ """
+ self.output.initialize(normalizer, self.materialObj.quadrature)
+ self.output.writeInfo()
+ self.output.open(totalTime, numTimeSteps)
+ return
+
+
# End of file
Copied: short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/feassemble/Quadrature.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/feassemble/Quadrature.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,172 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/feassemble/quadrature/Qudrature.py
+##
+## @brief Python abstract base class for integrating over
+## finite-elements using quadrature.
+##
+## Factory: quadrature.
+
+from pyre.components.Component import Component
+
+# ----------------------------------------------------------------------
+# QuadratureBase class
+class QuadratureBase(Component):
+ """
+ Python abstract base class for integrating over finite-elements
+ using quadrature.
+
+ Factory: quadrature.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """Python object for managing Quadrature facilities and properties."""
+
+ ## @class Inventory
+ ## Python object for managing Quadrature facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b min_jacobian Minimum allowable determinant of Jacobian.
+ ## @li \b check_conditoning Check element matrices for
+ ## ill-conditioning.
+ ##
+ ## \b Facilities
+ ## @li \b cell Reference cell with basis functions and quadrature rules
+
+ import pyre.inventory
+
+ minJacobian = pyre.inventory.float("min_jacobian", default=1.0e-06)
+ minJacobian.meta['tip'] = "Minimum allowable determinant of Jacobian."
+
+ checkConditioning = pyre.inventory.bool("check_conditioning",
+ default=False)
+ checkConditioning.meta['tip'] = \
+ "Check element matrices for ill-conditioning."
+
+ from pylith.feassemble.FIATSimplex import FIATSimplex
+ cell = pyre.inventory.facility("cell", family="reference_cell",
+ factory=FIATSimplex)
+ cell.meta['tip'] = "Reference cell with basis fns and quadrature rules."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="quadrature"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name, facility="quadrature")
+ return
+
+
+ def preinitialize(self, spaceDim):
+ """
+ Setup quadrature object.
+ """
+ self._info.log("Initializing reference cell.")
+ cell = self.cell
+ cell.initialize(spaceDim)
+
+ self._info.log("Initializing C++ quadrature.")
+ self._initialize(cell)
+ self.refGeometry(cell.geometry)
+ return
+
+
+ def initialize(self):
+ """
+ Initialize quadrature object.
+ """
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ Component._configure(self)
+ self.minJacobian(self.inventory.minJacobian)
+ self.checkConditioning(self.inventory.checkConditioning)
+ self.cell = self.inventory.cell
+ return
+
+
+# ----------------------------------------------------------------------
+from feassemble import MeshQuadrature as ModuleMeshQuadrature
+
+# MeshQuadrature class
+class MeshQuadrature(QuadratureBase, ModuleMeshQuadrature):
+ """
+ Python object for integrating over finite-elements using quadrature.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="meshquadrature"):
+ """
+ Constructor.
+ """
+ QuadratureBase.__init__(self, name)
+ ModuleMeshQuadrature.__init__(self)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _initialize(self, cell):
+ """
+ Initialize C++ quadrature object.
+ """
+ ModuleMeshQuadrature.initialize(self, cell.basis, cell.basisDeriv,
+ cell.quadPts, cell.quadWts,
+ cell.geometry.spaceDim())
+ return
+
+
+# ----------------------------------------------------------------------
+from feassemble import SubMeshQuadrature as ModuleSubMeshQuadrature
+
+# SubMeshQuadrature class
+class SubMeshQuadrature(QuadratureBase, ModuleSubMeshQuadrature):
+ """
+ Python object for integrating over finite-elements using quadrature.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="submeshquadrature"):
+ """
+ Constructor.
+ """
+ QuadratureBase.__init__(self, name)
+ ModuleSubMeshQuadrature.__init__(self)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _initialize(self, cell):
+ """
+ Initialize C++ quadrature object.
+ """
+ ModuleSubMeshQuadrature.initialize(self, cell.basis, cell.basisDeriv,
+ cell.quadPts, cell.quadWts,
+ cell.geometry.spaceDim())
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/feassemble/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/feassemble/__init__.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/feassemble/__init__.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,15 +14,16 @@
##
## @brief Python PyLith finite-element assembler module initialization
-__all__ = ['Constraint',
+__all__ = ['CellGeometry',
+ 'Constraint',
'ElasticityExplicit',
'ElasticityImplicit',
'FIATLagrange',
'FIATSimplex',
'IntegratorElasticity',
'Integrator',
+ 'Quadrature',
'ReferenceCell',
- 'quadrature'
]
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticIsotropic3D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,9 +17,10 @@
## Factory: material.
from ElasticMaterial import ElasticMaterial
+from materials import ElasticIsotropic3D as ModuleElasticIsotropic3D
# ElasticIsotropic3D class
-class ElasticIsotropic3D(ElasticMaterial):
+class ElasticIsotropic3D(ElasticMaterial, ModuleElasticIsotropic3D):
"""
Python object implementing 3-D isotropic linear elastic material.
@@ -44,14 +45,13 @@
return
- def _createCppHandle(self):
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- if None == self.cppHandle:
- import pylith.materials.materials as bindings
- self.cppHandle = bindings.ElasticIsotropic3D()
- self.dimension = self.cppHandle.dimension
+ ModuleElasticIsotropic3D.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticMaterial.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticMaterial.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticMaterial.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -62,22 +62,6 @@
return
- def useElasticBehavior(self, flag):
- """
- Set useElasticBehavior flag (True=elastic, False=inelastic if applicable).
- """
- assert(None != self.cppHandle)
- self.cppHandle.useElasticBehavior = flag
- return
-
-
- def getCellField(self, name):
- """
- Get cell field.
- """
- return self.cppHandle.cellField(name, self.mesh.cppHandle)
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStrain.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,9 +18,10 @@
## Factory: material.
from ElasticMaterial import ElasticMaterial
+from materials import ElasticPlaneStrain as ModuleElasticPlaneStrain
# ElasticPlaneStrain class
-class ElasticPlaneStrain(ElasticMaterial):
+class ElasticPlaneStrain(ElasticMaterial, ModuleElasticPlaneStrain):
"""
Python object implementing 2-D isotropic linear elastic material for
plane strain.
@@ -46,14 +47,13 @@
return
- def _createCppHandle(self):
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- if None == self.cppHandle:
- import pylith.materials.materials as bindings
- self.cppHandle = bindings.ElasticPlaneStrain()
- self.dimension = self.cppHandle.dimension
+ ModuleElasticPlaneStrain.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticPlaneStress.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,9 +18,10 @@
## Factory: material.
from ElasticMaterial import ElasticMaterial
+from materials import ElasticPlaneStress as ModuleElasticPlaneStress
# ElasticPlaneStress class
-class ElasticPlaneStress(ElasticMaterial):
+class ElasticPlaneStress(ElasticMaterial, ModuleElasticPlaneStress):
"""
Python object implementing 2-D isotropic linear elastic material for
plane stress.
@@ -46,14 +47,13 @@
return
- def _createCppHandle(self):
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- if None == self.cppHandle:
- import pylith.materials.materials as bindings
- self.cppHandle = bindings.ElasticPlaneStress()
- self.dimension = self.cppHandle.dimension
+ ModuleElasticPlaneStress.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticStrain1D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,9 +18,10 @@
## Factory: material.
from ElasticMaterial import ElasticMaterial
+from materials import ElasticStrain1D as ModuleElasticStrain1D
# ElasticStrain1D class
-class ElasticStrain1D(ElasticMaterial):
+class ElasticStrain1D(ElasticMaterial, ModuleElasticStrain1D):
"""
Python object implementing 1-D linear elastic material with axial strain.
@@ -45,14 +46,13 @@
return
- def _createCppHandle(self):
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- if None == self.cppHandle:
- import pylith.materials.materials as bindings
- self.cppHandle = bindings.ElasticStrain1D()
- self.dimension = self.cppHandle.dimension
+ ModuleElasticStrain1D.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/ElasticStress1D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,9 +18,10 @@
## Factory: material.
from ElasticMaterial import ElasticMaterial
+from materials import ElasticStress1D as ModuleElasticStress1D
# ElasticStress1D class
-class ElasticStress1D(ElasticMaterial):
+class ElasticStress1D(ElasticMaterial, ModuleElasticStress1D):
"""
Python object implementing 1-D linear elastic material with axial stress.
@@ -45,14 +46,13 @@
return
- def _createCppHandle(self):
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- if None == self.cppHandle:
- import pylith.materials.materials as bindings
- self.cppHandle = bindings.ElasticStress1D()
- self.dimension = self.cppHandle.dimension
+ ModuleElasticStress1D.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/materials/Material.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/Material.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/Material.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,7 +14,7 @@
##
## @brief Python abstract base class for managing physical properties
-## of a material.
+## and state variables of a material.
##
## This implementation of a material associates both physical
## properties and a quadrature scheme with the material. Thus,
@@ -56,7 +56,7 @@
## \b Facilities
## @li \b db Database of material property parameters
## @li \b quadrature Quadrature object for numerical integration
- ## @li \b initialStateDB Database for initial state.
+ ## @li \b dbInitialState Database for initial state.
import pyre.inventory
@@ -70,17 +70,18 @@
label.meta['tip'] = "Name of material."
from spatialdata.spatialdb.SimpleDB import SimpleDB
- db = pyre.inventory.facility("db", family="spatial_database",
- factory=SimpleDB)
- db.meta['tip'] = "Database of material property parameters."
+ dbProperties = pyre.inventory.facility("properties_db",
+ family="spatial_database",
+ factory=SimpleDB)
+ dbProperties.meta['tip'] = "Database for physical property parameters."
- initialStateDB = pyre.inventory.facility("initial_state_db",
- family="spatial_database",
- factory=SimpleDB)
- initialStateDB.meta['tip'] = "Database used for initial state."
-
- from pylith.feassemble.quadrature.Quadrature import Quadrature
- quadrature = pyre.inventory.facility("quadrature", factory=Quadrature)
+ dbInitialState = pyre.inventory.facility("initial_state_db",
+ family="spatial_database",
+ factory=SimpleDB)
+ dbInitialState.meta['tip'] = "Database for initial state variables."
+
+ from pylith.feassemble.Quadrature import MeshQuadrature
+ quadrature = pyre.inventory.facility("quadrature", factory=MeshQuadrature)
quadrature.meta['tip'] = "Quadrature object for numerical integration."
@@ -91,21 +92,18 @@
Constructor.
"""
Component.__init__(self, name, facility="material")
- self.cppHandle = None
- self.dimension = None
+ self._createModuleObj()
self.output = None
return
- def preinitialize(self):
+ def preinitialize(self, mesh):
"""
Do pre-initialization setup.
"""
- self._createCppHandle()
- self.cppHandle.id = self.id
- self.cppHandle.label = self.label
- self.quadrature.preinitialize()
self._setupLogging()
+ self.mesh = mesh
+ self.quadrature.preinitialize(self.mesh.coordsys().spaceDim())
return
@@ -116,46 +114,27 @@
logEvent = "%sverify" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- if self.quadrature.spaceDim != self.dimension:
+ if self.quadrature.cellDim != self.mesh.dimension() or \
+ self.quadrature.spaceDim != self.mesh.coordsys.spaceDim():
raise ValueError, \
- "Quadrature scheme and material are incompatible.\n" \
- "Dimension for quadrature: %d\n" \
- "Dimension for material '%s': %d" % \
- (self.quadrature.spaceDim, self.label, self.dimension)
+ "Quadrature scheme for material '%s' and mesh are incompatible.\n" \
+ "Quadrature cell dimension: %d\n" \
+ "Quadrature spatial dimension: %d\n" \
+ "Mesh cell dimension: %d\n" \
+ "Mesh spatial dimension: %d" % \
+ (self.label(),
+ self.quadrature.cellDim, self.quadrature.spaceDim,
+ self.mesh.dimension(), self.mesh.coordsys().spaceDim())
self._logger.eventEnd(logEvent)
return
- def initialize(self, mesh, totalTime, numTimeSteps, normalizer):
- """
- Initialize material property manager.
- """
- logEvent = "%sinit" % self._loggingPrefix
- self._logger.eventBegin(logEvent)
-
- self._info.log("Initializing material '%s'." % self.label)
- self.mesh = mesh
- assert(None != self.cppHandle)
- self.db.initialize()
- self.cppHandle.db = self.db.cppHandle
- self.cppHandle.normalizer = normalizer.cppHandle
- if self.initialStateDB != None:
- self._info.log("Initializing initial state database.")
- self.initialStateDB.initialize()
- self.cppHandle.initialStateDB = self.initialStateDB.cppHandle
- self.cppHandle.initialize(mesh.cppHandle, mesh.coordsys.cppHandle,
- self.quadrature.cppHandle)
-
- self._logger.eventEnd(logEvent)
- return
-
-
def getDataMesh(self):
"""
Get mesh associated with data fields.
"""
- return (self.mesh, "material-id", self.id)
+ return (self.mesh, "material-id", self.id())
# PRIVATE METHODS ////////////////////////////////////////////////////
@@ -165,25 +144,24 @@
Setup members using inventory.
"""
Component._configure(self)
- self.id = self.inventory.id
- self.label = self.inventory.label
- self.db = self.inventory.db
- self.quadrature = self.inventory.quadrature
+ self.id(self.inventory.id)
+ self.label(self.inventory.label)
+ self.dbProperties(self.inventory.dbProperties)
if self.inventory.useInitialState:
- self.initialStateDB = self.inventory.initialStateDB
- else:
- self.initialStateDB = None
+ self.dbInitialState(self.inventory.dbInitialState)
+
+ self.quadrature = self.inventory.quadrature
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- raise NotImplementedError("Please implement _createCppHandle() in " \
- "derived class.")
-
-
+ raise NotImplementedError, \
+ "Please implement _createModuleOb() in derived class."
+
+
def _setupLogging(self):
"""
Setup event logging.
@@ -193,7 +171,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Material")
+ logger.className("FE Material")
logger.initialize()
events = ["verify",
Modified: short/3D/PyLith/trunk/pylith/materials/MaxwellIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/pylith/materials/MaxwellIsotropic3D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/materials/MaxwellIsotropic3D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,16 +12,19 @@
## @file pylith/materials/MaxwellIsotropic3D.py
##
-## @brief Python object implementing 3-D isotropic linear Maxwell viscoelastic material.
+## @brief Python object implementing 3-D isotropic linear Maxwell
+## viscoelastic material.
##
## Factory: material.
from ElasticMaterial import ElasticMaterial
+from materials import MaxwellIsotropic3D as ModuleMaxwellIsotropic3D
# MaxwellIsotropic3D class
-class MaxwellIsotropic3D(ElasticMaterial):
+class MaxwellIsotropic3D(ElasticMaterial, ModuleMaxwellIsotropic3D):
"""
- Python object implementing 3-D isotropic linear Maxwell viscoelastic material.
+ Python object implementing 3-D isotropic linear Maxwell viscoelastic
+ material.
Factory: material.
"""
@@ -44,14 +47,11 @@
return
- def _createCppHandle(self):
+ def _createModuleObj(self):
"""
- Create handle to corresponding C++ object.
+ Call constructor for module object for access to C++ object.
"""
- if None == self.cppHandle:
- import pylith.materials.materials as bindings
- self.cppHandle = bindings.MaxwellIsotropic3D()
- self.dimension = self.cppHandle.dimension
+ ModuleMaxwellIsotropic3D.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/meshio/CellFilter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/CellFilter.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/CellFilter.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,10 @@
##
## Factory: output_cell_filter
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
# CellFilter class
-class CellFilter(Component):
+class CellFilter(PetscComponent):
"""
Python abstract base class for filtering cell fields when writing
finite-element data.
@@ -28,33 +28,14 @@
Factory: output_cell_filter
"""
- # INVENTORY //////////////////////////////////////////////////////////
-
- class Inventory(Component.Inventory):
- """
- Python object for managing CellFilter facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing CellFilter facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li None
-
- import pyre.inventory
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="cellfilter"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="cellfilter")
- self.cppHandle = None
+ PetscComponent.__init__(self, name, facility="cellfilter")
+ self.filter = None
return
@@ -69,38 +50,14 @@
"""
Initialize output manager.
"""
- self._createCppHandle()
-
- if None != self.cppHandle and quadrature != None:
- # Only set quadrature if filter is specified and quadrature is
- # provided.
- assert(None != self.cppHandle)
- self.cppHandle.quadrature = quadrature.cppHandle
return
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Set members based using inventory.
- """
- Component._configure(self)
- return
-
-
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def output_cell_filter():
"""
- Factory associated with CellFilter.
+ Factory associated with MeshCellFilter.
"""
return CellFilter()
Deleted: short/3D/PyLith/trunk/pylith/meshio/CellFilterAvg.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/CellFilterAvg.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/CellFilterAvg.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,62 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file pyre/meshio/CellFilterAvg.py
-##
-## @brief Python class for averageing cell fields over each cell's
-## quadrature points when writing finite-element data.
-##
-## Factory: output_cell_filter
-
-from CellFilter import CellFilter
-
-# CellFilterAvg class
-class CellFilterAvg(CellFilter):
- """
- Python class for average cell fields over each cell's quadrature
- points when writing finite-element data.
-
- Factory: output_cell_filter
- """
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="cellfilteravg"):
- """
- Constructor.
- """
- CellFilter.__init__(self, name)
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import meshio as bindings
- self.cppHandle = bindings.CellFilterAvg()
- return
-
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def output_cell_filter():
- """
- Factory associated with CellFilter.
- """
- return CellFilterAvg()
-
-
-# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/CellFilterAvgMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/CellFilterAvgMesh.py
+##
+## @brief Python class for averageing cell fields over each cell's
+## quadrature points when writing finite-element data.
+##
+## Factory: output_cell_filter
+
+from CellFilter import CellFilter
+from meshio import MeshCellFilterAvg as ModuleCellFilterAvg
+
+# CellFilterAvgMesh class
+class CellFilterAvgMesh(CellFilter, ModuleCellFilterAvg):
+ """
+ Python class for average cell fields over each cell's quadrature
+ points when writing finite-element data.
+
+ Factory: output_cell_filter
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="cellfilteravgmesh"):
+ """
+ Constructor.
+ """
+ CellFilter.__init__(self, name)
+ ModuleCellFilterAvg.__init__(self)
+ return
+
+
+ def initialize(self, quadrature):
+ """
+ Initialize output manager.
+ """
+ self.quadrature(quadrature)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_cell_filter():
+ """
+ Factory associated with CellFilter.
+ """
+ return CellFilterAvgMesh()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgSubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/CellFilterAvgSubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgSubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/CellFilterAvgSubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/CellFilterAvgSubMesh.py
+##
+## @brief Python class for averageing cell fields over each cell's
+## quadrature points when writing finite-element data.
+##
+## Factory: output_cell_filter
+
+from CellFilter import CellFilter
+from meshio import SubMeshCellFilterAvg as ModuleCellFilterAvg
+
+# CellFilterAvgSubMesh class
+class CellFilterAvgSubMesh(CellFilter, ModuleCellFilterAvg):
+ """
+ Python class for average cell fields over each cell's quadrature
+ points when writing finite-element data.
+
+ Factory: output_cell_filter
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="cellfilteravgsubmesh"):
+ """
+ Constructor.
+ """
+ CellFilter.__init__(self, name)
+ ModuleCellFilterAvg.__init__(self)
+ return
+
+
+ def initialize(self, quadrature):
+ """
+ Initialize output manager.
+ """
+ self.quadrature(quadrature)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_cell_filter():
+ """
+ Factory associated with CellFilter.
+ """
+ return CellFilterAvgSubMesh()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/DataWriter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriter.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriter.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,41 +16,25 @@
##
## Factory: output_data_writer
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
# DataWriter class
-class DataWriter(Component):
+class DataWriter(PetscComponent):
"""
Python abstract base class for writing finite-element data.
"""
# INVENTORY //////////////////////////////////////////////////////////
+
+ # None
- class Inventory(Component.Inventory):
- """
- Python object for managing DataWriter facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing DataWriter facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li None
-
- import pyre.inventory
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="datawriter"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="datawriter")
- self.cppHandle = None
+ PetscComponent.__init__(self, name, facility="datawriter")
return
@@ -65,27 +49,7 @@
"""
Initialize writer.
"""
- self._createCppHandle()
-
return
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Set members based using inventory.
- """
- Component._configure(self)
- return
-
-
- def _createCppHandle(self):
- """
- Create handle to corresponding C++ object.
- """
- raise NotImplementedError("Please implement _createCppHandle() in " \
- "derived class.")
-
-
# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriterVTK.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,8 +13,6 @@
## @file pyre/meshio/DataWriterVTK.py
##
## @brief Python object for writing finite-element data to VTK file.
-##
-## Factory: output_data_writer
from DataWriter import DataWriter
@@ -23,44 +21,36 @@
"""
Python object for writing finite-element data to VTK file.
- Factory: output_data_writer
+ Inventory
+
+ \b Properties
+ @li \b filename Name of VTK file.
+ @li \b time_format C style format string for time stamp in filename.
+ @li \b time_constant Value used to normalize time stamp in filename.
+
+ \b Facilities
+ @li None
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(DataWriter.Inventory):
- """
- Python object for managing DataWriterVTK facilities and properties.
- """
+ import pyre.inventory
- ## @class Inventory
- ## Python object for managing DataWriterVTK facilities and properties.
- ##
- ## \b Properties
- ## @li \b filename Name of VTK file.
- ## @li \b time_format C style format string for time stamp in filename.
- ## @li \b time_constant Value used to normalize time stamp in filename.
- ##
- ## \b Facilities
- ## @li None
+ filename = pyre.inventory.str("filename", default="output.vtk")
+ filename.meta['tip'] = "Name of VTK file."
- import pyre.inventory
+ timeFormat = pyre.inventory.str("time_format", default="%f")
+ timeFormat.meta['tip'] = "C style format string for time stamp in filename."
- filename = pyre.inventory.str("filename", default="output.vtk")
- filename.meta['tip'] = "Name of VTK file."
+ from pyre.units.time import second
+ timeConstant = pyre.inventory.dimensional("time_constant",
+ default=1.0*second,
+ validator=pyre.inventory.greater(0.0*second))
+ timeConstant.meta['tip'] = "Values used to normalize time stamp in filename."
- timeFormat = pyre.inventory.str("time_format", default="%f")
- timeFormat.meta['tip'] = "C style format string for time stamp in filename."
-
- from pyre.units.time import second
- timeConstant = pyre.inventory.dimensional("time_constant",
- default=1.0*second,
- validator=pyre.inventory.greater(0.0*second))
- timeConstant.meta['tip'] = "Values used to normalize time stamp in filename."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
- def __init__(self, name="solutioniovtk"):
+ def __init__(self, name="datawritervtk"):
"""
Constructor.
"""
@@ -78,43 +68,7 @@
timeScale = normalizer.timeScale()
self.timeConstant = normalizer.nondimensionalize(self.timeConstant,
timeScale)
-
- self.cppHandle.filename = self.filename
- self.cppHandle.timeFormat = self.timeFormat
- self.cppHandle.timeConstant = self.timeConstant
return
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
- def _configure(self):
- """
- Set members based using inventory.
- """
- DataWriter._configure(self)
- self.filename = self.inventory.filename
- self.timeFormat = self.inventory.timeFormat
- self.timeConstant = self.inventory.timeConstant
- return
-
-
- def _createCppHandle(self):
- """
- Create handle to corresponding C++ object.
- """
- if None == self.cppHandle:
- import pylith.meshio.meshio as bindings
- self.cppHandle = bindings.DataWriterVTK()
- return
-
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def output_data_writer():
- """
- Factory associated with DataWriterVTK.
- """
- return DataWriterVTK()
-
-
# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/DataWriterVTKMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/DataWriterVTKMesh.py
+##
+## @brief Python object for writing finite-element data to VTK file.
+
+from DataWriterVTK import DataWriterVTK
+from meshio import MeshDataWriterVTK as ModuleDataWriterVTK
+
+# DataWriterVTKMesh class
+class DataWriterVTKMesh(DataWriterVTK, ModuleDataWriterVTK):
+ """
+ Python object for writing finite-element data to VTK file.
+
+ Inventory
+
+ Factory: output_data_writer
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="datawritervtkmesh"):
+ """
+ Constructor.
+ """
+ DataWriterVTK.__init__(self, name)
+ ModuleDataWriterVTK.__init__(self)
+ return
+
+
+ def initialize(self, normalizer):
+ """
+ Initialize writer.
+ """
+ DataWriterVTK.initialize(self, normalizer)
+
+ ModuleDataWriterVTK.filename(self, self.filename)
+ ModuleDataWriterVTK.timeFormat(self, self.timeFormat)
+ ModuleDataWriterVTK.timeConstant(self, self.timeConstant.value)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_data_writer():
+ """
+ Factory associated with DataWriter.
+ """
+ return DataWriterVTKMesh()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/DataWriterVTKSubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/DataWriterVTKSubMesh.py
+##
+## @brief Python object for writing finite-element data to VTK file.
+
+from DataWriterVTK import DataWriterVTK
+from meshio import SubMeshDataWriterVTK as ModuleDataWriterVTK
+
+# DataWriterVTKSubMesh class
+class DataWriterVTKSubMesh(DataWriterVTK, ModuleDataWriterVTK):
+ """
+ Python object for writing finite-element data to VTK file.
+
+ Inventory
+
+ Factory: output_data_writer
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="datawritervtksubmesh"):
+ """
+ Constructor.
+ """
+ DataWriterVTK.__init__(self, name)
+ ModuleDataWriterVTK.__init__(self)
+ return
+
+
+ def initialize(self, normalizer):
+ """
+ Initialize writer.
+ """
+ DataWriterVTK.initialize(self, normalizer)
+
+ ModuleDataWriterVTK.filename(self, self.filename)
+ ModuleDataWriterVTK.timeFormat(self, self.timeFormat)
+ ModuleDataWriterVTK.timeConstant(self, self.timeConstant.value)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_data_writer():
+ """
+ Factory associated with DataWriter.
+ """
+ return DataWriterVTKSubMesh()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubSubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/DataWriterVTKSubSubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubSubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/DataWriterVTKSubSubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/DataWriterVTKSubSubMesh.py
+##
+## @brief Python object for writing finite-element data to VTK file.
+
+from DataWriterVTK import DataWriterVTK
+from meshio import SubSubMeshDataWriterVTK as ModuleDataWriterVTK
+
+# DataWriterVTKSubSubMesh class
+class DataWriterVTKSubSubMesh(DataWriterVTK, ModuleDataWriterVTK):
+ """
+ Python object for writing finite-element data to VTK file.
+
+ Inventory
+
+ Factory: output_data_writer
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="datawritervtksubmesh"):
+ """
+ Constructor.
+ """
+ DataWriterVTK.__init__(self, name)
+ ModuleDataWriterVTK.__init__(self)
+ return
+
+
+ def initialize(self, normalizer):
+ """
+ Initialize writer.
+ """
+ DataWriterVTK.initialize(self, normalizer)
+
+ ModuleDataWriterVTK.filename(self, self.filename)
+ ModuleDataWriterVTK.timeFormat(self, self.timeFormat)
+ ModuleDataWriterVTK.timeConstant(self, self.timeConstant.value)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_data_writer():
+ """
+ Factory associated with DataWriter.
+ """
+ return DataWriterVTKSubSubMesh()
+
+
+# End of file
Deleted: short/3D/PyLith/trunk/pylith/meshio/MeshIO.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIO.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIO.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,96 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file pyre/meshio/MeshIO.py
-##
-## @brief Python abstract base class for finite-element mesh I/O.
-##
-## Factory: mesh_io
-
-from pyre.components.Component import Component
-
-# MeshIO class
-class MeshIO(Component):
- """
- Python abstract base class for finite-element mesh I/O.
- """
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="meshio"):
- """
- Constructor.
- """
- Component.__init__(self, name, facility="mesh_io")
- self.cppHandle = None
- self.coordsys = None
- return
-
-
- def read(self, normalizer, debug, interpolate):
- """
- Read finite-element mesh and store in Sieve mesh object.
-
- @returns PETSc mesh object containing finite-element mesh
- """
- self._info.log("Reading finite-element mesh")
-
- # Set flags
- self._sync()
- self.cppHandle.normalizer = normalizer.cppHandle
- self.cppHandle.debug = debug
- self.cppHandle.interpolate = interpolate
-
- # Initialize coordinate system
- if self.coordsys is None:
- raise ValueError, "Coordinate system for mesh is unknown."
- self.coordsys.initialize()
-
- from pylith.topology.Mesh import Mesh
- mesh = Mesh()
- mesh.initialize(self.coordsys)
-
- # Read mesh
- self.cppHandle.read(mesh.cppHandle)
- return mesh
-
-
- def write(self, mesh):
- """
- Write finite-element mesh.stored in Sieve mesh object.
-
- @param mesh PETSc mesh object containing finite-element mesh
- """
- self._info.log("Writing finite-element mesh")
- self._sync()
- self.cppHandle.write(mesh.cppHandle)
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Set members based using inventory.
- """
- Component._configure(self)
- return
-
-
- def _sync(self):
- """
- Force synchronization between Python and C++.
- """
- return
-
-
-# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIOAscii.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,11 @@
##
## Factory: mesh_io
-from MeshIO import MeshIO
+from MeshIOObj import MeshIOObj
+from meshio import MeshIOAscii as ModuleMeshIOAscii
# MeshIOAscii class
-class MeshIOAscii(MeshIO):
+class MeshIOAscii(MeshIOObj, ModuleMeshIOAscii):
"""
Python object for reading/writing finite-element mesh from simple
ASCII file.
@@ -30,7 +31,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(MeshIO.Inventory):
+ class Inventory(MeshIOObj.Inventory):
"""
Python object for managing MeshIOAscii facilities and properties.
"""
@@ -61,7 +62,7 @@
"""
Constructor.
"""
- MeshIO.__init__(self, name)
+ MeshIOObj.__init__(self, name)
return
@@ -71,22 +72,17 @@
"""
Set members based using inventory.
"""
- MeshIO._configure(self)
- self.filename = self.inventory.filename
+ MeshIOObj._configure(self)
self.coordsys = self.inventory.coordsys
+ self.filename(self.inventory.filename)
return
- def _sync(self):
+ def _createModuleObj(self):
"""
- Force synchronization between Python and C++.
+ Create C++ MeshIOAscii object.
"""
- if None == self.cppHandle:
- import pylith.meshio.meshio as bindings
- self.cppHandle = bindings.MeshIOAscii()
-
- MeshIO._sync(self)
- self.cppHandle.filename = self.filename
+ ModuleMeshIOAscii.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/meshio/MeshIOCubit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIOCubit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIOCubit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,11 @@
##
## Factory: mesh_io
-from MeshIO import MeshIO
+from MeshIOObj import MeshIOObj
+from meshio import MeshIOCubit as ModuleMeshIOCubit
# MeshIOCubit class
-class MeshIOCubit(MeshIO):
+class MeshIOCubit(MeshIOObj, ModuleMeshIOCubit):
"""
Python object for reading/writing finite-element mesh from Cubit.
@@ -29,7 +30,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(MeshIO.Inventory):
+ class Inventory(MeshIOObj.Inventory):
"""
Python object for managing MeshIOCubit facilities and properties.
"""
@@ -60,7 +61,7 @@
"""
Constructor.
"""
- MeshIO.__init__(self, name)
+ MeshIOObj.__init__(self, name)
return
@@ -70,22 +71,17 @@
"""
Set members based using inventory.
"""
- MeshIO._configure(self)
- self.filename = self.inventory.filename
+ MeshIOObj._configure(self)
self.coordsys = self.inventory.coordsys
+ self.filename(self.inventory.filename)
return
- def _sync(self):
+ def _createModuleObj(self):
"""
- Force synchronization between Python and C++.
+ Create C++ MeshIOCubit object.
"""
- if None == self.cppHandle:
- import pylith.meshio.meshio as bindings
- self.cppHandle = bindings.MeshIOCubit()
-
- MeshIO._sync(self)
- self.cppHandle.filename = self.filename
+ ModuleMeshIOCubit.__init__(self)
return
Modified: short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIOLagrit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,11 @@
##
## Factory: mesh_io
-from MeshIO import MeshIO
+from MeshIOObj import MeshIOObj
+from meshio import MeshIOLagrit as ModuleMeshIOLagrit
# MeshIOLagrit class
-class MeshIOLagrit(MeshIO):
+class MeshIOLagrit(MeshIOObj, ModuleMeshIOLagrit):
"""
Python object for reading/writing finite-element mesh from LaGriT.
@@ -29,7 +30,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(MeshIO.Inventory):
+ class Inventory(MeshIOObj.Inventory):
"""
Python object for managing MeshIOLagrit facilities and properties.
"""
@@ -78,7 +79,7 @@
"""
Constructor.
"""
- MeshIO.__init__(self, name)
+ MeshIOObj.__init__(self, name)
return
@@ -88,30 +89,21 @@
"""
Set members based using inventory.
"""
- MeshIO._configure(self)
- self.filenameGmv = self.inventory.filenameGmv
- self.filenamePset = self.inventory.filenamePset
+ MeshIOObj._configure(self)
self.coordsys = self.inventory.coordsys
- self.flipEndian = self.inventory.flipEndian
- self.ioInt32 = self.inventory.ioInt32
- self.isRecordHeader32Bit = self.inventory.isRecordHeader32Bit
+ self.filenameGmv(self.inventory.filenameGmv)
+ self.filenamePset(self.inventory.filenamePset)
+ self.flipEndian(self.inventory.flipEndian)
+ self.ioInt32(self.inventory.ioInt32)
+ self.isRecordHeader32Bit(self.inventory.isRecordHeader32Bit)
return
- def _sync(self):
+ def _createModuleObj(self):
"""
- Force synchronization between Python and C++.
+ Create C++ MeshIOLagrit object.
"""
- if None == self.cppHandle:
- import pylith.meshio.meshio as bindings
- self.cppHandle = bindings.MeshIOLagrit()
-
- MeshIO._sync(self)
- self.cppHandle.filenameGmv = self.filenameGmv
- self.cppHandle.filenamePset = self.filenamePset
- self.cppHandle.flipEndian = self.flipEndian
- self.cppHandle.ioInt32 = self.ioInt32
- self.cppHandle.isRecordHeader32Bit = self.isRecordHeader32Bit
+ ModuleMeshIOLagrit.__init__(self)
return
Copied: short/3D/PyLith/trunk/pylith/meshio/MeshIOObj.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/MeshIOObj.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/MeshIOObj.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/MeshIOObj.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/MeshIOObj.py
+##
+## @brief Python abstract base class for finite-element mesh I/O.
+##
+## Factory: mesh_io
+
+from pyre.components.Component import Component
+from meshio import MeshIO as ModuleMeshIO
+
+# MeshIOObj class
+class MeshIOObj(Component, ModuleMeshIO):
+ """
+ Python abstract base class for finite-element mesh I/O.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="meshio"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name, facility="mesh_io")
+ self.coordsys = None
+ self._createModuleObj()
+ return
+
+
+ def read(self, normalizer, debug, interpolate):
+ """
+ Read finite-element mesh and store in Sieve mesh object.
+
+ @returns PETSc mesh object containing finite-element mesh
+ """
+ self._info.log("Reading finite-element mesh")
+
+ # Set flags
+ self.normalizer(normalizer)
+ self.debug(debug)
+ self.interpolate(interpolate)
+
+ # Initialize coordinate system
+ if self.coordsys is None:
+ raise ValueError, "Coordinate system for mesh is unknown."
+
+ from pylith.mpi.Communicator import petsc_comm_world
+ from pylith.topology.Mesh import Mesh
+ mesh = Mesh()
+ mesh.setComm(petsc_comm_world())
+ mesh.coordsys(self.coordsys)
+ mesh.initialize()
+
+ # Read mesh
+ ModuleMeshIO.read(self, mesh)
+ return mesh
+
+
+ def write(self, mesh):
+ """
+ Write finite-element mesh.stored in Sieve mesh object.
+
+ @param mesh PETSc mesh object containing finite-element mesh
+ """
+ self._info.log("Writing finite-element mesh")
+ ModuleMeshIO.write(self, mesh)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ Component._configure(self)
+ return
+
+
+ def _createModuleObj(self):
+ """
+ Create C++ MeshIO object.
+ """
+ raise NotImplementedError("MeshIO is an abstract base class.")
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputDirichlet.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputDirichlet.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputDirichlet.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,10 @@
##
## Factory: output_manager
-from OutputManager import OutputManager
+from OutputManager import OutputManagerSubMesh
# OutputDirichlet class
-class OutputDirichlet(OutputManager):
+class OutputDirichlet(OutputManagerSubMesh):
"""
Python object for managing output of finite-element information for
Dirichlet boundary conditions.
@@ -30,7 +30,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(OutputManager.Inventory):
+ class Inventory(OutputManagerSubMesh.Inventory):
"""
Python object for managing OutputDirichlet facilities and properties.
"""
@@ -57,7 +57,7 @@
"""
Constructor.
"""
- OutputManager.__init__(self, name)
+ OutputManagerSubMesh.__init__(self, name)
return
@@ -67,7 +67,7 @@
"""
Set members based using inventory.
"""
- OutputManager._configure(self)
+ OutputManagerSubMesh._configure(self)
self.vertexInfoFields = self.inventory.vertexInfoFields
self.vertexDataFields = []
self.cellInfoFields = []
@@ -79,7 +79,7 @@
def output_manager():
"""
- Factory associated with OutputDirichlet.
+ Factory associated with OutputManager.
"""
return OutputDirichlet()
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputFaultKin.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputFaultKin.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputFaultKin.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,54 +17,52 @@
##
## Factory: output_manager
-from OutputManager import OutputManager
+from OutputManagerSubMesh import OutputManagerSubMesh
# OutputFaultKin class
-class OutputFaultKin(OutputManager):
+class OutputFaultKin(OutputManagerSubMesh):
"""
Python object for managing output of finite-element information for
faults with kinematic ruptures.
+ Inventory
+
+ @class Inventory
+ Python object for managing OutputFaultKin facilities and properties.
+
+ \b Properties
+ @li \b vertex_info_fields Names of vertex info fields to output.
+ @li \b vertex_data_fields Names of vertex data fields to output.
+
+ \b Facilities
+ @li None
+
Factory: output_manager
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(OutputManager.Inventory):
- """
- Python object for managing OutputFaultKin facilities and properties.
- """
+ import pyre.inventory
- ## @class Inventory
- ## Python object for managing OutputFaultKin facilities and properties.
- ##
- ## \b Properties
- ## @li \b vertex_info_fields Names of vertex info fields to output.
- ## @li \b vertex_data_fields Names of vertex data fields to output.
- ##
- ## \b Facilities
- ## @li None
+ vertexInfoFields = pyre.inventory.list("vertex_info_fields",
+ default=["normal_dir",
+ "final_slip_rupture",
+ "slip_time_rupture"])
+ vertexInfoFields.meta['tip'] = "Names of vertex info fields to output."
- import pyre.inventory
+ vertexDataFields = pyre.inventory.list("vertex_data_fields",
+ default=["slip",
+ "traction_change"])
+ vertexDataFields.meta['tip'] = "Names of vertex data fields to output."
- vertexInfoFields = pyre.inventory.list("vertex_info_fields",
- default=["normal_dir",
- "final_slip_rupture",
- "slip_time_rupture"])
- vertexInfoFields.meta['tip'] = "Names of vertex info fields to output."
- vertexDataFields = pyre.inventory.list("vertex_data_fields",
- default=["slip",
- "traction_change"])
- vertexDataFields.meta['tip'] = "Names of vertex data fields to output."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="outputfaultkin"):
"""
Constructor.
"""
- OutputManager.__init__(self, name)
+ OutputManagerSubMesh.__init__(self, name)
return
@@ -74,7 +72,7 @@
"""
Set members based using inventory.
"""
- OutputManager._configure(self)
+ OutputManagerSubMesh._configure(self)
self.vertexInfoFields = self.inventory.vertexInfoFields
self.vertexDataFields = self.inventory.vertexDataFields
return
@@ -84,7 +82,7 @@
def output_manager():
"""
- Factory associated with OutputFaultKin.
+ Factory associated with OutputManager.
"""
return OutputFaultKin()
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputManager.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputManager.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputManager.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,76 +17,60 @@
##
## Factory: output_manager
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
# OutputManager class
-class OutputManager(Component):
+class OutputManager(PetscComponent):
"""
Python abstract base class for managing output of finite-element
information.
- Factory: output_manager
+ \b Properties
+ @li \b output_freq Flag indicating whether to use 'time_step' or 'skip'
+ to set frequency of solution output.
+ @li \b time_step Time step between solution output.
+ @li \b skip Number of time steps to skip between solution output.
+
+ \b Facilities
+ @li \b coordsys Coordinate system for output.
+ @li \b vertex_filter Filter for vertex data.
+ @li \b cell_filter Filter for cell data.
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing OutputManager facilities and properties.
- """
+ import pyre.inventory
- ## @class Inventory
- ## Python object for managing OutputManager facilities and properties.
- ##
- ## \b Properties
- ## @li \b output_freq Flag indicating whether to use 'time_step' or 'skip'
- ## to set frequency of solution output.
- ## @li \b time_step Time step between solution output.
- ## @li \b skip Number of time steps to skip between solution output.
- ##
- ## \b Facilities
- ## @li \b writer Writer for data.
- ## @li \b coordsys Coordinate system for output.
- ## @li \b vertex_filter Filter for vertex data.
- ## @li \b cell_filter Filter for cell data.
-
- import pyre.inventory
-
- outputFreq = pyre.inventory.str("output_freq", default="skip",
- validator=pyre.inventory.choice(["skip", "time_step"]))
- outputFreq.meta['tip'] = "Flag indicating whether to use 'time_step' " \
- "or 'skip' to set frequency of output."
-
- from pyre.units.time import s
- dt = pyre.inventory.dimensional("time_step", default=1.0*s)
- dt.meta['tip'] = "Time step between output."
-
- skip = pyre.inventory.int("skip", default=0,
- validator=pyre.inventory.greaterEqual(0))
- skip.meta['tip'] = "Number of time steps to skip between output."
-
- from DataWriterVTK import DataWriterVTK
- writer = pyre.inventory.facility("writer", factory=DataWriterVTK,
- family="data_writer")
- writer.meta['tip'] = "Writer for data."
-
- from spatialdata.geocoords.CSCart import CSCart
- coordsys = pyre.inventory.facility("coordsys", family="coordsys",
- factory=CSCart)
- coordsys.meta['tip'] = "Coordinate system for output."
+ outputFreq = pyre.inventory.str("output_freq", default="skip",
+ validator=pyre.inventory.choice(["skip", "time_step"]))
+ outputFreq.meta['tip'] = "Flag indicating whether to use 'time_step' " \
+ "or 'skip' to set frequency of output."
- from VertexFilter import VertexFilter
- vertexFilter = pyre.inventory.facility("vertex_filter",
- factory=VertexFilter,
- family="output_vertex_filter")
- vertexFilter.meta['tip'] = "Filter for vertex data."
-
- from CellFilter import CellFilter
- cellFilter = pyre.inventory.facility("cell_filter",
- factory=CellFilter,
- family="output_cell_filter")
- cellFilter.meta['tip'] = "Filter for cell data."
-
+ from pyre.units.time import s
+ dt = pyre.inventory.dimensional("time_step", default=1.0*s)
+ dt.meta['tip'] = "Time step between output."
+
+ skip = pyre.inventory.int("skip", default=0,
+ validator=pyre.inventory.greaterEqual(0))
+ skip.meta['tip'] = "Number of time steps to skip between output."
+
+ from spatialdata.geocoords.CSCart import CSCart
+ coordsys = pyre.inventory.facility("coordsys", family="coordsys",
+ factory=CSCart)
+ coordsys.meta['tip'] = "Coordinate system for output."
+
+ from VertexFilter import VertexFilter
+ vertexFilter = pyre.inventory.facility("vertex_filter",
+ factory=VertexFilter,
+ family="output_vertex_filter")
+ vertexFilter.meta['tip'] = "Filter for vertex data."
+
+ from CellFilter import CellFilter
+ cellFilter = pyre.inventory.facility("cell_filter",
+ factory=CellFilter,
+ family="output_cell_filter")
+ cellFilter.meta['tip'] = "Filter for cell data."
+
# PUBLIC METHODS /////////////////////////////////////////////////////
@@ -94,9 +78,8 @@
"""
Constructor.
"""
- Component.__init__(self, name, facility="outputmanager")
+ PetscComponent.__init__(self, name, facility="outputmanager")
self._loggingPrefix = "OutM "
- self.cppHandle = None
self._stepCur = 0
self._stepWrite = None
self._tWrite = None
@@ -105,12 +88,14 @@
self.vertexDataFields = []
self.cellInfoFields = []
self.cellDataFields = []
+
+ self._createModuleObj()
return
def preinitialize(self, dataProvider):
"""
- Do
+ Setup output manager.
"""
self._setupLogging()
self.dataProvider = dataProvider
@@ -146,8 +131,8 @@
self._logger.eventBegin(logEvent)
# Nondimensionalize time step
- lengthScale = normalizer.timeScale()
- self.dt = normalizer.nondimensionalize(self.dt, lengthScale)
+ timeScale = normalizer.timeScale()
+ self.dtN = normalizer.nondimensionalize(self.dt, timeScale)
# Initialize coordinate system
if self.coordsys is None:
@@ -156,7 +141,6 @@
self.cellFilter.initialize(quadrature)
self.writer.initialize(normalizer)
- self._sync()
self._logger.eventEnd(logEvent)
return
@@ -171,17 +155,12 @@
nsteps = numTimeSteps
if numTimeSteps > 0 and self.outputFreq == "skip" and self.skip > 0:
- nsteps = numTimeSteps / (1+self.skip)
+ nsteps = int(numTimeSteps / (1+self.skip))
elif numTimeSteps > 0 and self.outputFreq == "time_step":
- nsteps = 1 + int(totalTime / self.dt)
+ nsteps = int(1 + totalTime / self.dtN)
(mesh, label, labelId) = self.dataProvider.getDataMesh()
-
- assert(None != self.cppHandle)
- assert(None != mesh.cppHandle)
- assert(None != mesh.coordsys.cppHandle)
- self.cppHandle.open(mesh.cppHandle, mesh.coordsys.cppHandle,
- nsteps, label, labelId)
+ self._open(mesh, nsteps, label, labelId)
self._logger.eventEnd(logEvent)
return
@@ -194,8 +173,7 @@
logEvent = "%sclose" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- assert(None != self.cppHandle)
- self.cppHandle.close()
+ self._close()
self._logger.eventEnd(logEvent)
return
@@ -212,22 +190,18 @@
t = 0.0
self.open(totalTime=0.0, numTimeSteps=0)
(mesh, label, labelId) = self.dataProvider.getDataMesh()
- self.cppHandle.openTimeStep(t,
- mesh.cppHandle, mesh.coordsys.cppHandle,
- label, labelId)
+ self._openTimeStep(t, mesh, label, labelId)
for name in self.vertexInfoFields:
- (field, fieldType) = self.dataProvider.getVertexField(name)
- self.cppHandle.appendVertexField(t, name, field, fieldType,
- mesh.cppHandle)
+ field = self.dataProvider.getVertexField(name)
+ self._appendVertexField(t, field)
for name in self.cellInfoFields:
- (field, fieldType) = self.dataProvider.getCellField(name)
- self.cppHandle.appendCellField(t, name, field, fieldType,
- mesh.cppHandle, label, labelId)
+ field = self.dataProvider.getCellField(name)
+ self._appendCellField(t, field, label, labelId)
- self.cppHandle.closeTimeStep()
- self.close()
+ self._closeTimeStep()
+ self._close()
self._logger.eventEnd(logEvent)
return
@@ -245,21 +219,17 @@
len(self.cellDataFields) ) > 0:
(mesh, label, labelId) = self.dataProvider.getDataMesh()
- self.cppHandle.openTimeStep(t,
- mesh.cppHandle, mesh.coordsys.cppHandle,
- label, labelId)
+ self._openTimeStep(t, mesh, label, labelId)
for name in self.vertexDataFields:
- (field, fieldType) = self.dataProvider.getVertexField(name, fields)
- self.cppHandle.appendVertexField(t, name, field, fieldType,
- mesh.cppHandle)
+ field = self.dataProvider.getVertexField(name, fields)
+ self._appendVertexField(t, field)
for name in self.cellDataFields:
- (field, fieldType) = self.dataProvider.getCellField(name, fields)
- self.cppHandle.appendCellField(t, name, field, fieldType,
- mesh.cppHandle, label, labelId)
+ field = self.dataProvider.getCellField(name, fields)
+ self._appendCellField(t, field, label, labelId)
- self.cppHandle.closeTimeStep()
+ self._closeTimeStep()
self._logger.eventEnd(logEvent)
return
@@ -271,35 +241,17 @@
"""
Set members based using inventory.
"""
- Component._configure(self)
- self.outputFreq = self.inventory.outputFreq
- self.dt = self.inventory.dt
- self.skip = self.inventory.skip
- self.coordsys = self.inventory.coordsys
- self.writer = self.inventory.writer
- self.vertexFilter = self.inventory.vertexFilter
- self.cellFilter = self.inventory.cellFilter
+ PetscComponent._configure(self)
return
-
- def _sync(self):
+ def _createModuleObj(self):
"""
- Force synchronization between Python and C++.
+ Create handle to C++ object.
"""
- if None == self.cppHandle:
- import pylith.meshio.meshio as bindings
- self.cppHandle = bindings.OutputManager()
+ raise NotImplementedError, \
+ "Please implement _createModuleObj() in derived class."
- assert(self.coordsys.cppHandle != None)
- assert(self.writer.cppHandle != None)
-
- self.cppHandle.coordsys = self.coordsys.cppHandle
- self.cppHandle.writer = self.writer.cppHandle
- self.cppHandle.vertexFilter = self.vertexFilter.cppHandle
- self.cppHandle.cellFilter = self.cellFilter.cppHandle
- return
-
def _checkWrite(self, t):
"""
Check if we want to write data at time t.
@@ -318,7 +270,7 @@
self._stepWrite = self._stepCur
elif self.outputFreq == "time_step":
- if t >= self._tWrite + self.dt:
+ if t >= self._tWrite + self.dtN:
write = True
self._tWrite = t
@@ -382,7 +334,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Output")
+ logger.className("FE Output")
logger.initialize()
events = ["init",
@@ -399,13 +351,28 @@
return
-# FACTORIES ////////////////////////////////////////////////////////////
+ def _open(self):
+ raise NotImplementedError("Implement _open() in derived class.")
-def output_manager():
- """
- Factory associated with OutputManager.
- """
- return OutputManager()
+ def _openTimeStep(self):
+ raise NotImplementedError("Implement _openTimeStep() in derived class.")
+
+ def _appendVertexField(self):
+ raise NotImplementedError("Implement _appendVertexField() in derived class.")
+
+
+ def _appendCellField(self):
+ raise NotImplementedError("Implement _appendCellField() in derived class.")
+
+
+ def _closeTimeStep(self):
+ raise NotImplementedError("Implement _closeTimeStep() in derived class.")
+
+
+ def _close(self):
+ raise NotImplementedError("Implement _close() in derived class.")
+
+
# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/OutputManagerMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputManagerMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputManagerMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputManagerMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/OutputManagerMesh.py
+##
+## @brief Python abstract base class for managing output of
+## finite-element information.
+##
+## Factory: output_manager
+
+from OutputManager import OutputManager
+from meshio import MeshOutputManager as ModuleOutputManager
+
+# OutputManagerMesh class
+class OutputManagerMesh(OutputManager, ModuleOutputManager):
+ """
+ Python abstract base class for managing output of finite-element
+ information.
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b writer Writer for data.
+
+ Factory: output_manager
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ import pyre.inventory
+
+ from DataWriterVTKMesh import DataWriterVTKMesh
+ writer = pyre.inventory.facility("writer", factory=DataWriterVTKMesh,
+ family="data_writer")
+ writer.meta['tip'] = "Writer for data."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="outputmanagermesh"):
+ """
+ Constructor.
+ """
+ OutputManager.__init__(self, name)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ OutputManager._configure(self)
+ ModuleOutputManager.coordsys(self, self.inventory.coordsys)
+ ModuleOutputManager.writer(self, self.inventory.writer)
+ if None != self.vertexFilter.filter:
+ ModuleOutputManager.vertexFilter(self, self.inventory.vertexFilter)
+ if None != self.cellFilter.filter:
+ ModuleOutputManager.cellFilter(self, self.inventory.cellFilter)
+ return
+
+
+ def _createModuleObj(self):
+ """
+ Create handle to C++ object.
+ """
+ ModuleOutputManager.__init__(self)
+ return
+
+
+ def _open(self, mesh, nsteps, label, labelId):
+ """
+ Call C++ open();
+ """
+ if label != None and labelId != None:
+ ModuleOutputManager.open(self, mesh, nsteps, label, labelId)
+ else:
+ ModuleOutputManager.open(self, mesh, nsteps)
+ return
+
+
+ def _openTimeStep(self, t, mesh, label, labelId):
+ """
+ Call C++ openTimeStep();
+ """
+ if label != None and labelId != None:
+ ModuleOutputManager.openTimeStep(self, t, mesh, label, labelId)
+ else:
+ ModuleOutputManager.openTimeStep(self, t, mesh)
+ return
+
+
+ def _appendVertexField(self, t, field):
+ """
+ Call C++ appendVertexField();
+ """
+ ModuleOutputManager.appendVertexField(self, t, field)
+ return
+
+ def _appendCellField(self, t, field, label, labelId):
+ """
+ Call C++ appendCellField();
+ """
+ if label != None and labelId != None:
+ ModuleOutputManager.appendCellField(self, t, field, label, labelId)
+ else:
+ ModuleOutputManager.appendCellField(self, t, field)
+ return
+
+
+ def _closeTimeStep(self):
+ """
+ Call C++ closeTimeStep().
+ """
+ ModuleOutputManager.closeTimeStep(self)
+ return
+
+
+ def _close(self):
+ """
+ Call C++ close().
+ """
+ ModuleOutputManager.close(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_manager():
+ """
+ Factory associated with OutputManager.
+ """
+ return OutputManagerMesh()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/OutputManagerSubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/OutputManagerSubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputManagerSubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputManagerSubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/OutputManagerSubMesh.py
+##
+## @brief Python abstract base class for managing output of
+## finite-element information.
+##
+## Factory: output_manager
+
+from OutputManager import OutputManager
+from meshio import SubMeshOutputManager as ModuleOutputManager
+
+# OutputManagerSubMsh class
+class OutputManagerSubMesh(OutputManager, ModuleOutputManager):
+ """
+ Python abstract base class for managing output of finite-element
+ information.
+
+ \b Properties
+ @li None
+
+ \b Facilities
+ @li \b writer Writer for data.
+
+ Factory: output_manager
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ import pyre.inventory
+
+ from DataWriterVTKSubSubMesh import DataWriterVTKSubSubMesh
+ writer = pyre.inventory.facility("writer", factory=DataWriterVTKSubSubMesh,
+ family="data_writer")
+ writer.meta['tip'] = "Writer for data."
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="outputmanagersubmesh"):
+ """
+ Constructor.
+ """
+ OutputManager.__init__(self, name)
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ OutputManager._configure(self)
+ ModuleOutputManager.coordsys(self, self.inventory.coordsys)
+ ModuleOutputManager.writer(self, self.inventory.writer)
+ if None != self.vertexFilter.filter:
+ ModuleOutputManager.vertexFilter(self, self.inventory.vertexFilter)
+ if None != self.cellFilter.filter:
+ ModuleOutputManager.cellFilter(self, self.inventory.cellFilter)
+ return
+
+
+ def _createModuleObj(self):
+ """
+ Create handle to C++ object.
+ """
+ ModuleOutputManager.__init__(self)
+ return
+
+
+ def _open(self, mesh, nsteps, label, labelId):
+ """
+ Call C++ open();
+ """
+ if label != None and labelId != None:
+ ModuleOutputManager.open(self, mesh, nsteps, label, labelId)
+ else:
+ ModuleOutputManager.open(self, mesh, nsteps)
+ return
+
+
+ def _openTimeStep(self, t, mesh, label, labelId):
+ """
+ Call C++ openTimeStep();
+ """
+ if label != None and labelId != None:
+ ModuleOutputManager.openTimeStep(self, t, mesh, label, labelId)
+ else:
+ ModuleOutputManager.openTimeStep(self, t, mesh)
+ return
+
+
+ def _appendVertexField(self, t, field):
+ """
+ Call C++ appendVertexField();
+ """
+ ModuleOutputManager.appendVertexField(self, t, field)
+ return
+
+
+ def _appendCellField(self, t, field):
+ """
+ Call C++ appendCellField();
+ """
+ if label != None and labelId != None:
+ ModuleOutputManager.appendCellField(self, t, field, label, labelId)
+ else:
+ ModuleOutputManager.appendCellField(self, t, field)
+ return
+
+
+ def _closeTimeStep(self):
+ """
+ Call C++ closeTimeStep().
+ """
+ ModuleOutputManager.closeTimeStep(self)
+ return
+
+
+ def _close(self):
+ """
+ Call C++ close().
+ """
+ ModuleOutputManager.close(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_manager():
+ """
+ Factory associated with OutputManager.
+ """
+ return OutputManagerSubMesh()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputMatElastic.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputMatElastic.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputMatElastic.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,10 @@
##
## Factory: output_manager
-from OutputManager import OutputManager
+from OutputManagerMesh import OutputManagerMesh
# OutputMatElastic class
-class OutputMatElastic(OutputManager):
+class OutputMatElastic(OutputManagerMesh):
"""
Python object for managing output of finite-element information for
material state variables.
@@ -30,7 +30,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(OutputManager.Inventory):
+ class Inventory(OutputManagerMesh.Inventory):
"""
Python object for managing OutputMatElastic facilities and properties.
"""
@@ -64,7 +64,7 @@
"""
Constructor.
"""
- OutputManager.__init__(self, name)
+ OutputManagerMesh.__init__(self, name)
return
@@ -74,7 +74,7 @@
"""
Set members based using inventory.
"""
- OutputManager._configure(self)
+ OutputManagerMesh._configure(self)
self.vertexInfoFields = []
self.vertexDataFields = []
self.cellInfoFields = self.inventory.cellInfoFields
@@ -86,7 +86,7 @@
def output_manager():
"""
- Factory associated with OutputMatElastic.
+ Factory associated with OutputManager.
"""
return OutputMatElastic()
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputNeumann.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputNeumann.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputNeumann.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,10 @@
##
## Factory: output_manager
-from OutputManager import OutputManager
+from OutputManagerSubMesh import OutputManagerSubMesh
# OutputNeumann class
-class OutputNeumann(OutputManager):
+class OutputNeumann(OutputManagerSubMesh):
"""
Python object for managing output of finite-element information for
Neumann boundary conditions.
@@ -30,7 +30,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(OutputManager.Inventory):
+ class Inventory(OutputManagerSubMesh.Inventory):
"""
Python object for managing OutputNeumann facilities and properties.
"""
@@ -57,7 +57,7 @@
"""
Constructor.
"""
- OutputManager.__init__(self, name)
+ OutputManagerSubMesh.__init__(self, name)
return
@@ -67,7 +67,7 @@
"""
Set members based using inventory.
"""
- OutputManager._configure(self)
+ OutputManagerSubMesh._configure(self)
self.vertexInfoFields = []
self.vertexDataFields = []
self.cellInfoFields = self.inventory.cellInfoFields
@@ -79,7 +79,7 @@
def output_manager():
"""
- Factory associated with OutputNeumann.
+ Factory associated with OutputManager.
"""
return OutputNeumann()
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputSoln.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,56 +17,51 @@
##
## Factory: output_manager
-from OutputManager import OutputManager
+from OutputManagerMesh import OutputManagerMesh
# OutputSoln class
-class OutputSoln(OutputManager):
+class OutputSoln(OutputManagerMesh):
"""
Python object for managing output of finite-element solution
information.
- Factory: output_manager
+ @class Inventory
+ Python object for managing OutputSoln facilities and properties.
+
+ \b Properties
+ @li \b vertex_data_fields Names of vertex data fields to output.
+ @li \b cell_info_fields Names of cell info fields to output.
+
+ \b Facilities
+ @li None
+
+ Factory: mesh_output_manager
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(OutputManager.Inventory):
- """
- Python object for managing OutputSoln facilities and properties.
- """
+ import pyre.inventory
- ## @class Inventory
- ## Python object for managing OutputSoln facilities and properties.
- ##
- ## \b Properties
- ## @li \b vertex_data_fields Names of vertex data fields to output.
- ## @li \b cell_info_fields Names of cell info fields to output.
- ##
- ## \b Facilities
- ## @li None
+ vertexDataFields = pyre.inventory.list("vertex_data_fields",
+ default=["displacement"])
+ vertexDataFields.meta['tip'] = "Names of vertex data fields to output."
+
+ cellInfoFields = pyre.inventory.list("cell_info_fields", default=[])
+ cellInfoFields.meta['tip'] = "Names of cell info fields to output."
- import pyre.inventory
-
- vertexDataFields = pyre.inventory.list("vertex_data_fields",
- default=["displacements"])
- vertexDataFields.meta['tip'] = "Names of vertex data fields to output."
-
- cellInfoFields = pyre.inventory.list("cell_info_fields", default=[])
- cellInfoFields.meta['tip'] = "Names of cell info fields to output."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="outputsoln"):
"""
Constructor.
"""
- OutputManager.__init__(self, name)
+ OutputManagerMesh.__init__(self, name)
self.availableFields = \
{'vertex': \
{'info': [],
- 'data': ["displacements"]},
+ 'data': ["displacement"]},
'cell': \
- {'info': ["replaced_cells"],
+ {'info': [],
'data': []}}
return
@@ -75,7 +70,7 @@
"""
Do
"""
- OutputManager.preinitialize(self, dataProvider=self)
+ OutputManagerMesh.preinitialize(self, dataProvider=self)
return
@@ -87,7 +82,7 @@
self._logger.eventBegin(logEvent)
self.mesh = mesh
- OutputManager.initialize(self, normalizer)
+ OutputManagerMesh.initialize(self, normalizer)
self._logger.eventEnd(logEvent)
return
@@ -105,36 +100,20 @@
Get vertex field.
"""
field = None
- fieldType = None
- if name == "displacements":
- field = fields.getSolution()
- fieldType = 1 # vector field
+ if name == "displacement":
+ field = fields.solution()
else:
raise ValueError, "Vertex field '%s' not available." % name
- return (field, fieldType)
+ return field
- def getCellField(self, name):
- """
- Get vertex field.
- """
- field = None
- fieldType = None
- if name == "replaced_cells":
- field = self.mesh.getRealSection("replaced_cells")
- fieldType = 0 # scalar field
- else:
- raise ValueError, "Vertex field '%s' not available." % name
- return (field, fieldType)
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
def _configure(self):
"""
Set members based using inventory.
"""
- OutputManager._configure(self)
+ OutputManagerMesh._configure(self)
self.vertexDataFields = self.inventory.vertexDataFields
self.cellInfoFields = self.inventory.cellInfoFields
return
@@ -144,7 +123,7 @@
def output_manager():
"""
- Factory associated with OutputSoln.
+ Factory associated with OutputManager.
"""
return OutputSoln()
Modified: short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/OutputSolnSubset.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,43 +18,44 @@
## Factory: output_manager
from OutputManager import OutputManager
+from meshio import OutputSolnSubset as ModuleOutputSolnSubset
# OutputSolnSubset class
-class OutputSolnSubset(OutputManager):
+class OutputSolnSubset(OutputManager, ModuleOutputSolnSubset):
"""
Python object for managing output of finite-element solution
information over a subdomain.
+ @class Inventory
+ Python object for managing OutputSolnSubset facilities and properties.
+
+ \b Properties
+ @li \b vertex_data_fields Names of vertex data fields to output.
+ @li \b label Name identifier for subdomain.
+
+ \b Facilities
+ @li \b writer Writer for data.
+
Factory: output_manager
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(OutputManager.Inventory):
- """
- Python object for managing OutputSolnSubset facilities and properties.
- """
+ import pyre.inventory
- ## @class Inventory
- ## Python object for managing OutputSolnSubset facilities and properties.
- ##
- ## \b Properties
- ## @li \b vertex_data_fields Names of vertex data fields to output.
- ## @li \b label Name identifier for subdomain.
- ##
- ## \b Facilities
- ## @li None
+ vertexDataFields = pyre.inventory.list("vertex_data_fields",
+ default=["displacement"])
+ vertexDataFields.meta['tip'] = "Names of vertex data fields to output."
+
+ label = pyre.inventory.str("label", default="")
+ label.meta['tip'] = "Label identifier for subdomain."
- import pyre.inventory
+ from DataWriterVTKSubMesh import DataWriterVTKSubMesh
+ writer = pyre.inventory.facility("writer", factory=DataWriterVTKSubMesh,
+ family="data_writer")
+ writer.meta['tip'] = "Writer for data."
- vertexDataFields = pyre.inventory.list("vertex_data_fields",
- default=["displacements"])
- vertexDataFields.meta['tip'] = "Names of vertex data fields to output."
- label = pyre.inventory.str("label", default="")
- label.meta['tip'] = "Label identifier for subdomain."
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="outputsolnsubset"):
@@ -62,11 +63,10 @@
Constructor.
"""
OutputManager.__init__(self, name)
- self.cppHandle = None
self.availableFields = \
{'vertex': \
{'info': [],
- 'data': ["displacements"]},
+ 'data': ["displacement"]},
'cell': \
{'info': [],
'data': []}}
@@ -78,9 +78,6 @@
Do
"""
OutputManager.preinitialize(self, dataProvider=self)
- import meshio as bindings
- self.cppHandle = bindings.OutputSolnSubset()
- self.cppHandle.label = self.label
return
@@ -89,8 +86,7 @@
Verify compatibility of configuration.
"""
OutputManager.verifyConfiguration(self, mesh)
- assert(None != self.cppHandle);
- self.cppHandle.verifyConfiguration(mesh.cppHandle)
+ ModuleOutputSolnSubset.verifyConfiguration(self, mesh)
return
@@ -101,12 +97,7 @@
logEvent = "%sinit" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- from pylith.topology.Mesh import Mesh
- self.mesh = Mesh()
- self.mesh.initialize(mesh.coordsys)
- assert(None != self.cppHandle)
- self.cppHandle.mesh(self.mesh.cppHandle, mesh.cppHandle)
-
+ self.submesh = self.subdomainMesh(mesh)
OutputManager.initialize(self, normalizer)
self._logger.eventEnd(logEvent)
@@ -117,7 +108,7 @@
"""
Get mesh associated with data fields.
"""
- return (self.mesh, None, None)
+ return (self.submesh, None, None)
def getVertexField(self, name, fields):
@@ -126,12 +117,11 @@
"""
field = None
fieldType = None
- if name == "displacements":
- field = fields.getSolution()
- fieldType = 1 # vector field
+ if name == "displacement":
+ field = fields.solution()
else:
raise ValueError, "Vertex field '%s' not available." % name
- return (field, fieldType)
+ return field
# PRIVATE METHODS ////////////////////////////////////////////////////
@@ -141,16 +131,82 @@
Set members based using inventory.
"""
OutputManager._configure(self)
- self.vertexDataFields = self.inventory.vertexDataFields
- self.label = self.inventory.label
+ ModuleOutputSolnSubset.label(self, self.label)
+ ModuleOutputSolnSubset.coordsys(self, self.inventory.coordsys)
+ ModuleOutputSolnSubset.writer(self, self.inventory.writer)
+ if None != self.vertexFilter.filter:
+ ModuleOutputSolnSubset.vertexFilter(self, self.inventory.vertexFilter)
+ if None != self.cellFilter.filter:
+ ModuleOutputSolnSubset.cellFilter(self, self.inventory.cellFilter)
return
+ def _createModuleObj(self):
+ """
+ Create handle to C++ object.
+ """
+ ModuleOutputSolnSubset.__init__(self)
+ return
+
+
+ def _open(self, mesh, nsteps, label, labelId):
+ """
+ Call C++ open();
+ """
+ if label != None and labelId != None:
+ ModuleOutputSolnSubset.open(self, mesh, nsteps, label, labelId)
+ else:
+ ModuleOutputSolnSubset.open(self, mesh, nsteps)
+ return
+
+
+ def _openTimeStep(self, t, mesh, label, labelId):
+ """
+ Call C++ openTimeStep();
+ """
+ if label != None and labelId != None:
+ ModuleOutputSolnSubset.openTimeStep(self, t, mesh, label, labelId)
+ else:
+ ModuleOutputSolnSubset.openTimeStep(self, t, mesh)
+ return
+
+
+ def _appendVertexField(self, t, field):
+ """
+ Call C++ appendVertexField();
+ """
+ ModuleOutputSolnSubset.appendVertexField(self, t, field)
+ return
+
+ def _appendCellField(self, t, field):
+ """
+ Call C++ appendCellField();
+ """
+ ModuleOutputSolnSubset.appendCellField(self, t, field)
+ return
+
+
+ def _closeTimeStep(self):
+ """
+ Call C++ closeTimeStep().
+ """
+ ModuleOutputSolnSubset.closeTimeStep(self)
+ return
+
+
+ def _close(self):
+ """
+ Call C++ close().
+ """
+ ModuleOutputSolnSubset.close(self)
+ return
+
+
# FACTORIES ////////////////////////////////////////////////////////////
def output_manager():
"""
- Factory associated with OutputSolnSubset.
+ Factory associated with OutputManager.
"""
return OutputSolnSubset()
Modified: short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/VertexFilter.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,10 @@
##
## Factory: output_vertex_filter
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
# VertexFilter class
-class VertexFilter(Component):
+class VertexFilter(PetscComponent):
"""
Python abstract base class for filtering cell fields when writing
finite-element data.
@@ -30,31 +30,16 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing VertexFilter facilities and properties.
- """
+ # None
- ## @class Inventory
- ## Python object for managing VertexFilter facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li None
-
- import pyre.inventory
-
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="vertexfilter"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="vertexfilter")
- self.cppHandle = None
+ PetscComponent.__init__(self, name, facility="vertexfilter")
+ self.filter = None
return
@@ -69,27 +54,9 @@
"""
Initialize output manager.
"""
- self._createCppHandle()
return
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Set members based using inventory.
- """
- Component._configure(self)
- return
-
-
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- return
-
-
# FACTORIES ////////////////////////////////////////////////////////////
def output_vertex_filter():
Deleted: short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNorm.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,62 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file pyre/meshio/VertexFilterVecNorm.py
-##
-## @brief Python class for computing vector norm for each vertex for
-## field over vertices when writing finite-element data.
-##
-## Factory: output_vertex_filter
-
-from VertexFilter import VertexFilter
-
-# VertexFilterVecNorm class
-class VertexFilterVecNorm(VertexFilter):
- """
- Python class for computing vector norm for each vertex for field
- over vertices when writing finite-element data.
-
- Factory: output_vertex_filter
- """
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="vertexfiltervecnorm"):
- """
- Constructor.
- """
- VertexFilter.__init__(self, name)
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import meshio as bindings
- self.cppHandle = bindings.VertexFilterVecNorm()
- return
-
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def output_vertex_filter():
- """
- Factory associated with VertexFilter.
- """
- return VertexFilterVecNorm()
-
-
-# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/VertexFilterVecNormMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/VertexFilterVecNormMesh.py
+##
+## @brief Python class for computing vector norm for each vertex for
+## field over vertices when writing finite-element data.
+##
+## Factory: output_vertex_filter
+
+from VertexFilter import VertexFilter
+from meshio import MeshVertexFilterVecNorm as ModuleVertexFilterVecNorm
+
+# VertexFilterVecNormMesh class
+class VertexFilterVecNormMesh(VertexFilter, ModuleVertexFilterVecNorm):
+ """
+ Python class for computing vector norm for each vertex for field
+ over vertices when writing finite-element data.
+
+ Factory: output_vertex_filter
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="vertexfiltervecnormmesh"):
+ """
+ Constructor.
+ """
+ VertexFilter.__init__(self, name)
+ ModuleVertexFilterVecNorm.__init__(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_vertex_filter():
+ """
+ Factory associated with VertexFilter.
+ """
+ return VertexFilterVecNormMesh()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormSubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/meshio/VertexFilterVecNormSubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormSubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/meshio/VertexFilterVecNormSubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pyre/meshio/VertexFilterVecNormSubMesh.py
+##
+## @brief Python class for computing vector norm for each vertex for
+## field over vertices when writing finite-element data.
+##
+## Factory: output_vertex_filter
+
+from VertexFilter import VertexFilter
+from meshio import SubMeshVertexFilterVecNorm as ModuleVertexFilterVecNorm
+
+# VertexFilterVecNormSubMesh class
+class VertexFilterVecNormSubMesh(VertexFilter, ModuleVertexFilterVecNorm):
+ """
+ Python class for computing vector norm for each vertex for field
+ over vertices when writing finite-element data.
+
+ Factory: output_vertex_filter
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="vertexfiltervecnormsubmesh"):
+ """
+ Constructor.
+ """
+ VertexFilter.__init__(self, name)
+ ModuleVertexFilterVecNorm.__init__(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def output_vertex_filter():
+ """
+ Factory associated with VertexFilter.
+ """
+ return VertexFilterVecNormSubMesh()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/meshio/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/meshio/__init__.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/meshio/__init__.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,23 +15,30 @@
## @brief Python PyLith meshio module initialization
__all__ = ['CellFilter',
- 'CellFilterAvg',
+ 'CellFilterAvgMesh',
+ 'CellFilterAvgSubMesh',
'DataWriter',
'DataWriterVTK',
- 'MeshIO',
+ 'DataWriterVTKMesh',
+ 'DataWriterVTKSubMesh',
+ 'DataWriterVTKSubSubMesh',
+ 'MeshIOObj',
'MeshIOAscii',
'MeshIOCubit',
'MeshIOLagrit',
'OutputDirichlet',
'OutputFaultKin',
'OutputManager',
+ 'OutputManagerMesh',
+ 'OutputManagerSubMesh',
'OutputMatElastic',
'OutputNeumann'
'OutputSoln',
'OutputSolnSubset',
'SingleOutput',
'VertexFilter',
- 'VertexFilterVecNorm',
+ 'VertexFilterVecNormMesh',
+ 'VertexFilterVecNormSubMesh',
]
Copied: short/3D/PyLith/trunk/pylith/mpi (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/mpi)
Modified: short/3D/PyLith/trunk/pylith/problems/Explicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Explicit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/Explicit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,6 +18,7 @@
## Factory: pde_formulation
from Formulation import Formulation
+from pylith.utils.profiling import resourceUsageString
# Explicit class
class Explicit(Formulation):
@@ -46,8 +47,8 @@
"""
Formulation.__init__(self, name)
self._loggingPrefix = "TSEx "
- self.solnField = {'name': "dispT",
- 'label': "displacements"}
+ self.solnField = {'name': "disp(t)",
+ 'label': "displacement"}
return
@@ -69,19 +70,40 @@
Formulation.initialize(self, dimension, normalizer)
self._info.log("Creating other fields and matrices.")
- self.fields.addReal("dispTpdt")
- self.fields.addReal("dispTmdt")
- self.fields.addReal("residual")
- self.fields.createHistory(["dispTpdt", "dispT", "dispTmdt"])
- self.fields.copyLayout("dispT")
- self.jacobian = self.mesh.createMatrix(self.fields.getSolution())
+ self.fields.add("disp(t+dt)", "displacement")
+ self.fields.add("disp(t-dt)", "displacement")
+ self.fields.add("residual", "residual")
+ self.fields.createHistory(["disp(t+dt)", "disp(t)", "disp(t-dt)"])
+ self.fields.copyLayout("disp(t)")
+ self.fields.solveSolnName("disp(t+dt)")
+ self._debug.log(resourceUsageString())
- self.solver.initialize(self.mesh, self.fields.getSolution())
+ # Create Petsc vectors for fields involved in solve. Since we
+ # shift fields through the time history, all fields need a PETSc
+ # vector.
+ dispTpdt = self.fields.get("disp(t+dt)")
+ dispTpdt.createVector()
+ dispT = self.fields.get("disp(t)")
+ dispT.createVector()
+ dispTmdt = self.fields.get("disp(t-dt)")
+ dispTmdt.createVector()
+ residual = self.fields.get("residual")
+ residual.createVector()
+ self._info.log("Creating Jacobian matrix.")
+ from pylith.topology.Jacobian import Jacobian
+ self.jacobian = Jacobian(self.fields)
+ self.jacobian.zero() # TEMPORARY, to get correct memory usage
+ self._debug.log(resourceUsageString())
+
+ self._info.log("Initializing solver.")
+ self.solver.initialize(self.fields, self.jacobian, self)
+ self._debug.log(resourceUsageString())
+
# Solve for total displacement field
for constraint in self.constraints:
constraint.useSolnIncr(False)
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.useSolnIncr(False)
self._logger.eventEnd(logEvent)
@@ -95,12 +117,13 @@
logEvent = "%sprestep" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- dispTpdt = self.fields.getReal("dispTpdt")
+ dispTpdt = self.fields.get("disp(t+dt)")
for constraint in self.constraints:
constraint.setField(t+dt, dispTpdt)
needNewJacobian = False
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
+ integrator.timeStep(dt)
if integrator.needNewJacobian():
needNewJacobian = True
if needNewJacobian:
@@ -120,17 +143,10 @@
self._reformResidual(t, dt)
self._info.log("Solving equations.")
- residual = self.fields.getReal("residual")
- self.solver.solve(self.fields.getReal("dispTpdt"), self.jacobian, residual)
+ residual = self.fields.get("residual")
+ dispTpdt = self.fields.solveSoln()
+ self.solver.solve(dispTpdt, self.jacobian, residual)
- # BEGIN TEMPORARY
- #import pylith.topology.topology as bindings
- #bindings.sectionView(residual, "RHS");
- #bindings.sectionView(self.fields.getReal("dispTpdt"), "SOLUTION");
- #import pylith.utils.petsc as petscbindings
- #print "JACOBIAN"
- #petscbindings.mat_view(self.jacobian)
- # END TEMPORARY
self._logger.eventEnd(logEvent)
return
@@ -143,10 +159,14 @@
self._logger.eventBegin(logEvent)
self.fields.shiftHistory()
+
+ # :KLUDGE: only works for KSP solver
+ dispTpdt = self.fields.get("disp(t+dt)")
if not self.solver.guessZero:
- import pylith.topology.topology as bindings
- bindings.copyRealSection(self.fields.getReal("dispTpdt"),
- self.fields.getReal("dispT"))
+ dispT = self.fields.get("disp(t)")
+ dispTpdt.copy(dispT)
+ else:
+ dispTpdt.zero()
Formulation.poststep(self, t, dt)
Modified: short/3D/PyLith/trunk/pylith/problems/Formulation.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Formulation.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/Formulation.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,13 +10,15 @@
# ----------------------------------------------------------------------
#
+
## @file pylith/problems/Formulation.py
##
## @brief Python abstract base class for formulations of solving equations.
##
## Factory: pde_formulation
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
+from problems import Formulation as ModuleFormulation
from pylith.utils.profiling import resourceUsageString
from pyre.units.time import second
@@ -33,7 +35,7 @@
# Formulation class
-class Formulation(Component):
+class Formulation(PetscComponent, ModuleFormulation):
"""
Python abstract base class for formulations of solving equations.
@@ -45,7 +47,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
+ class Inventory(PetscComponent.Inventory):
"""
Python object for managing Formulation facilities and properties.
"""
@@ -55,39 +57,24 @@
##
## \b Properties
## @li \b view_jacobian Flag to output Jacobian matrix when it is reformed.
- ## @li \b jacobian_filename Filename for Jacobian matrix.
- ## @li \b jacobian_time_width String length of time stamp in Jacobian filename.
- ## @li \b jacobian_time_constant Value used to normalize time stamp in filename.
-
##
## \b Facilities
## @li \b time_step Time step size manager.
## @li \b solver Algebraic solver.
## @li \b output Output manager associated with solution.
+ ## @li \b jacobian_viewer Writer for Jacobian sparse matrix.
import pyre.inventory
viewJacobian = pyre.inventory.bool("view_jacobian", default=False)
viewJacobian.meta['tip'] = "Write Jacobian matrix to binary file."
- jacobianFilename = pyre.inventory.str("jacobian_filename",
- default="jacobian.mat")
- jacobianFilename.meta['tip'] = "Filename for Jacobian matrix."
-
- jacobianTimeWidth = pyre.inventory.int("jacobian_time_width", default=5)
- jacobianTimeWidth.meta['tip'] = "String length of time stamp in Jacobian filename."
-
- jacobianTimeConstant = pyre.inventory.dimensional("jacobian_time_constant",
- default=1.0*second,
- validator=pyre.inventory.greater(0.0*second))
- jacobianTimeConstant.meta['tip'] = "Values used to normalize time stamp in Jacobian filename."
-
from TimeStepUniform import TimeStepUniform
timeStep = pyre.inventory.facility("time_step", family="time_step",
factory=TimeStepUniform)
timeStep.meta['tip'] = "Time step size manager."
- from pylith.solver.SolverLinear import SolverLinear
+ from SolverLinear import SolverLinear
solver = pyre.inventory.facility("solver", family="solver",
factory=SolverLinear)
solver.meta['tip'] = "Algebraic solver."
@@ -98,17 +85,26 @@
factory=SingleOutput)
output.meta['tip'] = "Output managers associated with solution."
+ from pylith.topology.JacobianViewer import JacobianViewer
+ jacobianViewer = pyre.inventory.facility("jacobian_viewer",
+ family="jacobian_viewer",
+ factory=JacobianViewer)
+ jacobianViewer.meta['tip'] = "Writer for Jacobian sparse matrix."
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="formulation"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="pde_formulation")
- self.integrators = None
+ PetscComponent.__init__(self, name, facility="pde_formulation")
+ ModuleFormulation.__init__(self)
+ self.integratorsMesh = None
+ self.integratorsSubMesh = None
self.constraints = None
+ self.jacobian = None
self.fields = None
- self.solnField = None
+ self.solnName = None
return
@@ -124,7 +120,8 @@
self.timeStep.preinitialize()
self.mesh = mesh
- self.integrators = []
+ self.integratorsMesh = []
+ self.integratorsSubMesh = []
self.constraints = []
self.gravityField = gravityField
@@ -149,7 +146,7 @@
self.timeStep.verifyConfiguration()
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.verifyConfiguration()
for constraint in self.constraints:
constraint.verifyConfiguration()
@@ -172,8 +169,8 @@
numTimeSteps = self.timeStep.numTimeSteps()
totalTime = self.timeStep.totalTime
- from pylith.topology.FieldsManager import FieldsManager
- self.fields = FieldsManager(self.mesh)
+ from pylith.topology.SolutionFields import SolutionFields
+ self.fields = SolutionFields(self.mesh)
self._debug.log(resourceUsageString())
if self.gravityField != None:
@@ -181,9 +178,11 @@
self.gravityField.initialize()
self._info.log("Initializing integrators.")
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.gravityField = self.gravityField
integrator.initialize(totalTime, numTimeSteps, normalizer)
+ ModuleFormulation.meshIntegrators(self, self.integratorsMesh)
+ ModuleFormulation.submeshIntegrators(self, self.integratorsSubMesh)
self._debug.log(resourceUsageString())
self._info.log("Initializing constraints.")
@@ -200,14 +199,17 @@
self._info.log("Creating solution field.")
solnName = self.solnField['name']
- self.fields.addReal(solnName)
- self.fields.solutionField(solnName)
- self.fields.setFiberDimension(solnName, dimension)
+ self.fields.add(solnName, self.solnField['label'])
+ self.fields.solutionName(solnName)
+ solution = self.fields.solution()
+ solution.vectorFieldType(solution.VECTOR)
+ solution.newSection(solution.VERTICES_FIELD, dimension)
for constraint in self.constraints:
- constraint.setConstraintSizes(self.fields.getSolution())
- self.fields.allocate(solnName)
+ constraint.setConstraintSizes(solution)
+ solution.allocate()
for constraint in self.constraints:
- constraint.setConstraints(self.fields.getSolution())
+ constraint.setConstraints(solution)
+ solution.createScatter()
self._debug.log(resourceUsageString())
self._logger.eventEnd(logEvent)
@@ -218,14 +220,14 @@
"""
Get start time for simulation.
"""
- return 0.0*second
+ return 0.0
def getTotalTime(self):
"""
Get total time for simulation.
"""
- return self.timeStep.totalTime
+ return self.timeStep.totalTimeN # Nondimensionalized total time
def getTimeStep(self):
@@ -235,7 +237,8 @@
logEvent = "%stimestep" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- dt = self.timeStep.timeStep(self.integrators)
+ dt = self.timeStep.timeStep(self.mesh,
+ self.integratorsMesh + self.integratorsSubMesh)
self._logger.eventEnd(logEvent)
return dt
@@ -275,7 +278,7 @@
self._info.log("Writing solution fields.")
for output in self.output.components():
output.writeData(t+dt, self.fields)
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.poststep(t, dt, totalTime, self.fields)
for constraint in self.constraints:
constraint.poststep(t, dt, totalTime, self.fields)
@@ -293,7 +296,7 @@
self._info.log("Formulation finalize.")
self._debug.log(resourceUsageString())
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.finalize()
for constraint in self.constraints:
constraint.finalize()
@@ -311,14 +314,12 @@
"""
Set members based using inventory.
"""
- Component._configure(self)
+ PetscComponent._configure(self)
self.timeStep = self.inventory.timeStep
self.solver = self.inventory.solver
self.output = self.inventory.output
self.viewJacobian = self.inventory.viewJacobian
- self.jacobianFilename = self.inventory.jacobianFilename
- self.jacobianTimeWidth = self.inventory.jacobianTimeWidth
- self.jacobianTimeConstant = self.inventory.jacobianTimeConstant
+ self.jacobianViewer = self.inventory.jacobianViewer
import journal
self._debug = journal.debug(self.name)
@@ -340,7 +341,7 @@
"Could not use '%s' as an integrator for material '%s'. " \
"Functionality missing." % (integrator.name, material.label)
integrator.preinitialize(self.mesh, material)
- self.integrators.append(integrator)
+ self.integratorsMesh.append(integrator)
self._debug.log(resourceUsageString())
self._info.log("Added elasticity integrator for material '%s'." % \
@@ -362,7 +363,7 @@
foundType = False
if implementsIntegrator(bc):
foundType = True
- self.integrators.append(bc)
+ self.integratorsSubMesh.append(bc)
self._info.log("Added boundary condition '%s' as an integrator." % \
bc.label)
if implementsConstraint(bc):
@@ -391,7 +392,7 @@
foundType = False
if implementsIntegrator(ic):
foundType = True
- self.integrators.append(ic)
+ self.integratorsSubMesh.append(ic)
self._info.log("Added interface condition '%s' as an integrator." % \
ic.label)
if implementsConstraint(ic):
@@ -412,77 +413,33 @@
Reform Jacobian matrix for operator.
"""
self._debug.log(resourceUsageString())
+ self._info.log("Integrating Jacobian operator.")
self._logger.stagePush("Reform Jacobian")
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(self.jacobian)
- # Add in contributions that do not require assembly
- self._info.log("Reforming assembled portion of Jacobian of operator.")
- for integrator in self.integrators:
- integrator.timeStep(dt)
- integrator.integrateJacobianAssembled(self.jacobian, t+dt,
- self.fields)
- self._debug.log(resourceUsageString()) # TEMPORARY
- self._info.log("Flushing assembly of Jacobian of operator.")
- petsc.mat_assemble(self.jacobian, "flush_assembly")
+ self.updateSettings(self.jacobian, self.fields, t, dt)
+ self.reformJacobian()
- # Add in contributions that require assembly
- self._info.log("Reforming unassembled portion of Jacobian of operator.")
- for integrator in self.integrators:
- integrator.timeStep(dt)
- integrator.integrateJacobian(self.jacobian, t+dt, self.fields)
- self._debug.log(resourceUsageString()) # TEMPORARY
- self._info.log("Doing final assembly of Jacobian of operator.")
- petsc.mat_assemble(self.jacobian, "final_assembly")
self._logger.stagePop()
if self.viewJacobian:
- filename = self._createJacobianFilename(t+dt)
- petsc.mat_view_binary(self.jacobian, filename)
+ self.jacobianViewer.write(self.jacobian, t)
+
self._debug.log(resourceUsageString())
return
- def _createJacobianFilename(self, t):
- """
- Create filename by extracting basename and adding a time stamp.
- """
- base = self.jacobianFilename.lstrip().rstrip()
- baseLen = len(base)
- if base.endswith(".mat"):
- basename = base[0:baseLen-4]
- else:
- basename = base
- time = int(t.value/self.jacobianTimeConstant.value)
- timeStamp = repr(time).rjust(self.jacobianTimeWidth, '0')
- filename = basename + "_t" + timeStamp + ".mat"
- return filename
-
-
def _reformResidual(self, t, dt):
"""
Reform residual vector for operator.
"""
self._info.log("Integrating residual term in operator.")
self._logger.stagePush("Reform Residual")
- residual = self.fields.getReal("residual")
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(residual)
- # Add in contributions that require assembly
- for integrator in self.integrators:
- integrator.timeStep(dt)
- integrator.integrateResidual(residual, t, self.fields)
- self._info.log("Completing residual.")
- bindings.completeSection(self.mesh.cppHandle, residual)
+ self.updateSettings(self.jacobian, self.fields, t, dt)
+ self.reformResidual()
- # Add in contributions that do not require assembly
- self._info.log("Integrating assembled residual term in operator.")
- for integrator in self.integrators:
- integrator.timeStep(dt)
- integrator.integrateResidualAssembled(residual, t, self.fields)
-
self._logger.stagePop()
+ self._debug.log(resourceUsageString())
return
@@ -495,7 +452,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("PDE Formulation")
+ logger.className("PDE Formulation")
logger.initialize()
events = ["preinit",
@@ -519,6 +476,17 @@
return
+ def _cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ if not self.jacobian is None:
+ self.jacobian.cleanup()
+ if not self.fields is None:
+ self.fields.cleanup()
+ return
+
+
# FACTORIES ////////////////////////////////////////////////////////////
def pde_formulation():
Modified: short/3D/PyLith/trunk/pylith/problems/Implicit.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Implicit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/Implicit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -70,8 +70,8 @@
"""
Formulation.__init__(self, name)
self._loggingPrefix = "TSIm "
- self.solnField = {'name': "dispTBctpdt",
- 'label': "displacements"}
+ self.solnField = {'name': "disp(t), bc(t+dt)",
+ 'label': "displacement"}
self._stepCount = None
return
@@ -94,32 +94,33 @@
Formulation.initialize(self, dimension, normalizer)
self._info.log("Creating other fields.")
+ self.fields.add("dispIncr(t)", "displacement increment")
+ self.fields.add("residual", "residual")
+ self.fields.copyLayout("disp(t), bc(t+dt)")
+ self.fields.solveSolnName("dispIncr(t)")
self._debug.log(resourceUsageString())
- self.fields.addReal("dispIncr")
- self.fields.addReal("residual")
- self.fields.copyLayout("dispTBctpdt")
- self._debug.log(resourceUsageString())
self._info.log("Creating Jacobian matrix.")
- self.jacobian = self.mesh.createMatrix(self.fields.getSolution())
+ from pylith.topology.Jacobian import Jacobian
+ self.jacobian = Jacobian(self.fields)
+ self.jacobian.zero() # TEMPORARY, to get correct memory usage
+ self._debug.log(resourceUsageString())
- # BEGIN TEMPORARY
- # Access entries in matrix here to get correct memory usage
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(self.jacobian)
- # END TEMPORARY
+ # Create Petsc vectors for fields involved in solve
+ dispIncr = self.fields.get("dispIncr(t)")
+ dispIncr.createVector()
+ residual = self.fields.get("residual")
+ residual.createVector()
- self._debug.log(resourceUsageString())
-
self._info.log("Initializing solver.")
- self.solver.initialize(self.mesh, self.fields.getSolution())
+ self.solver.initialize(self.fields, self.jacobian, self)
self._debug.log(resourceUsageString())
# Initial time step solves for total displacement field, not increment
self._stepCount = 0
for constraint in self.constraints:
constraint.useSolnIncr(False)
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.useSolnIncr(False)
self._logger.eventEnd(logEvent)
@@ -130,7 +131,8 @@
"""
Get time at which time stepping should start.
"""
- dt = self.timeStep.currentStep()
+ dt = self.timeStep.timeStep(self.mesh,
+ self.integratorsMesh + self.integratorsSubMesh)
return -dt
@@ -144,7 +146,7 @@
# Set dispTBctpdt to the BC t time t+dt. Unconstrained DOF are
# unaffected and will be equal to their values at time t.
self._info.log("Setting constraints.")
- dispTBctpdt = self.fields.getReal("dispTBctpdt")
+ dispTBctpdt = self.fields.get("disp(t), bc(t+dt)")
for constraint in self.constraints:
constraint.setField(t+dt, dispTBctpdt)
@@ -155,13 +157,13 @@
"field solution.")
for constraint in self.constraints:
constraint.useSolnIncr(True)
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.useSolnIncr(True)
self._reformJacobian(t, dt)
### NONLINEAR: Might want to move logic into IntegrateJacobian() and set a flag instead
needNewJacobian = False
- for integrator in self.integrators:
+ for integrator in self.integratorsMesh + self.integratorsSubMesh:
integrator.timeStep(dt)
if integrator.needNewJacobian():
needNewJacobian = True
@@ -179,24 +181,24 @@
logEvent = "%sstep" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- dispIncr = self.fields.getReal("dispIncr")
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(dispIncr)
+ dispIncr = self.fields.solveSoln()
+ dispIncr.zero()
### NONLINEAR: This moves under SNES control as IntegrateResidual()
### NONLINEAR: Also move updateState() from Integrator.poststep() to this function
self._reformResidual(t+dt, dt)
self._info.log("Solving equations.")
- residual = self.fields.getReal("residual")
+ residual = self.fields.get("residual")
self._logger.stagePush("Solve")
+ #residual.view("RESIDUAL BEFORE SOLVE")
+ #self.jacobian.view()
self.solver.solve(dispIncr, self.jacobian, residual)
self._logger.stagePop()
# BEGIN TEMPORARY
- #import pylith.topology.topology as bindings
- #bindings.sectionView(self.fields.getReal("dispIncr"), "DISPINCR SOLUTION");
- #bindings.sectionView(self.fields.getReal("residual"), "RESIDUAL");
+ #dispIncr.view("DISPINCR SOLUTION")
+ #residual.view("RESIDUAL")
# END TEMPORARY
self._logger.eventEnd(logEvent)
@@ -215,10 +217,9 @@
# constrained DOF. We add in the displacement increments (only
# nonzero at unconstrained DOF) so that after poststep(),
# dispTBctpdt contains the displacement field at time t+dt.
- import pylith.topology.topology as bindings
- dispIncr = self.fields.getReal("dispIncr")
- dispTBctpdt = self.fields.getSolution()
- bindings.addRealSections(dispTBctpdt, dispTBctpdt, dispIncr)
+ dispIncr = self.fields.get("dispIncr(t)")
+ dispTBctpdt = self.fields.solution()
+ dispTBctpdt += dispIncr
Formulation.poststep(self, t, dt)
Modified: short/3D/PyLith/trunk/pylith/problems/Problem.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Problem.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/Problem.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
##
## Factory: problem.
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
# ITEM FACTORIES ///////////////////////////////////////////////////////
@@ -34,8 +34,8 @@
Factory for boundary condition items.
"""
from pyre.inventory import facility
- from pylith.bc.DirichletPoints import DirichletPoints
- return facility(name, family="boundary_condition", factory=DirichletPoints)
+ from pylith.bc.DirichletBC import DirichletBC
+ return facility(name, family="boundary_condition", factory=DirichletBC)
def faultFactory(name):
@@ -48,7 +48,7 @@
# Problem class
-class Problem(Component):
+class Problem(PetscComponent):
"""
Python abstract base class for crustal dynamics problems.
@@ -57,7 +57,7 @@
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
+ class Inventory(PetscComponent.Inventory):
"""
Python object for managing Problem facilities and properties.
"""
@@ -124,7 +124,7 @@
"""
Constructor.
"""
- Component.__init__(self, name, facility="problem")
+ PetscComponent.__init__(self, name, facility="problem")
self.mesh = None
return
@@ -155,28 +155,30 @@
# Check to make sure ids of materials and interfaces are unique
materialIds = {}
for material in self.materials.components():
- if material.quadrature.spaceDim != self.dimension:
+ if material.quadrature.spaceDim() != self.dimension:
raise ValueError, \
"Spatial dimension of problem is '%d' but quadrature " \
"for material '%s' is for spatial dimension '%d'." % \
- (self.dimension, material.label, material.quadrature.spaceDim)
- if material.id in materialIds.keys():
+ (self.dimension, material.label(), material.quadrature.spaceDim())
+ if material.id() in materialIds.keys():
raise ValueError, \
"ID values for materials '%s' and '%s' are both '%d'. " \
"Material id values must be unique." % \
- (material.label, materialIds[material.id], material.id)
- materialIds[material.id] = material.label
+ (material.label(), materialIds[material.id()], material.id())
+ materialIds[material.id()] = material.label()
for interface in self.interfaces.components():
- if interface.id in materialIds.keys():
+ if interface.id() in materialIds.keys():
raise ValueError, \
"ID values for material '%s' and interface '%s' are both '%d'. " \
"Material and interface id values must be unique." % \
- (materialIds[interface.id], interface.label, interface.id)
- materialIds[interface.id] = interface.label
+ (materialIds[interface.id()], interface.label(), interface.id())
+ materialIds[interface.id()] = interface.label()
# Check to make sure material-id for each cell matches the id of a material
- self.mesh.checkMaterialIds(materialIds.keys())
+ import numpy
+ idValues = numpy.array(materialIds.keys(), dtype=numpy.int32)
+ self.mesh.checkMaterialIds(idValues)
self._logger.eventEnd(logEvent)
return
@@ -221,7 +223,7 @@
"""
Set members based using inventory.
"""
- Component._configure(self)
+ PetscComponent._configure(self)
self.normalizer = self.inventory.normalizer
self.dimension = self.inventory.dimension
self.materials = self.inventory.materials
@@ -243,7 +245,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("Problem")
+ logger.className("Problem")
logger.initialize()
events = ["preinit",
Copied: short/3D/PyLith/trunk/pylith/problems/Solver.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/problems/Solver.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/Solver.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/problems/Solver.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/solver/Solver.py
+##
+## @brief Python PyLith abstract base class for solver.
+##
+## Factory: solver
+
+from pylith.utils.PetscComponent import PetscComponent
+
+# Solver class
+class Solver(PetscComponent):
+ """
+ Python abstract base class for solver.
+
+ Factory: solver.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(PetscComponent.Inventory):
+ """
+ Python object for managing Solver facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing Solver facilities and properties.
+ ##
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ guessZero = pyre.inventory.bool("initial_guess_zero", default=True)
+ guessZero.meta['tip'] = "Use zero for initial guess."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="solver"):
+ """
+ Constructor.
+ """
+ PetscComponent.__init__(self, name, facility="solver")
+ return
+
+
+ # PRIVATE METHODS /////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ PetscComponent._configure(self)
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def solver():
+ """
+ Factory associated with Solver.
+ """
+ return Solver()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/problems/SolverLinear.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/problems/SolverLinear.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/SolverLinear.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/problems/SolverLinear.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/solver/SolverLinear.py
+
+## @brief Python PyLith linear algebraic solver.
+
+from Solver import Solver
+from problems import SolverLinear as ModuleSolverLinear
+
+# SolverLinear class
+class SolverLinear(Solver, ModuleSolverLinear):
+ """
+ Python PyLith linear algebraic solver.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Solver.Inventory):
+ """
+ Python object for managing SolverLinear facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing SolverLinear facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b initial_guess_zero Use zero for initial guess.
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ guessZero = pyre.inventory.bool("initial_guess_zero", default=True)
+ guessZero.meta['tip'] = "Use zero for initial guess."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="solverlinear"):
+ """
+ Constructor.
+ """
+ Solver.__init__(self, name)
+ ModuleSolverLinear.__init__(self)
+ return
+
+
+ def initialize(self, fields, jacobian, formulation):
+ """
+ Initialize linear solver.
+ """
+ ModuleSolverLinear.initialize(self, fields, jacobian, formulation)
+ self.initialGuessZero(self.guessZero)
+ return
+
+
+ # PRIVATE METHODS /////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ Solver._configure(self)
+ self.guessZero = self.inventory.guessZero
+ return
+
+
+ def _cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def solver():
+ """
+ Factory associated with Solver.
+ """
+ return SolverLinear()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/problems/SolverNonlinear.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/problems/SolverNonlinear.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/SolverNonlinear.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/problems/SolverNonlinear.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/solver/SolverNonlinear.py
+
+## @brief Python PyLith nonlinear algebraic solver.
+
+from Solver import Solver
+from problems import SolverNonlinear as ModuleSolverNonlinear
+
+# SolverNonlinear class
+class SolverNonlinear(Solver, ModuleSolverNonlinear):
+ """
+ Python PyLith nonlinear algebraic solver.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Solver.Inventory):
+ """
+ Python object for managing SolverNonlinear facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing SolverNonlinear facilities and properties.
+ ##
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="solvernonlinear"):
+ """
+ Constructor.
+ """
+ Solver.__init__(self, name)
+ ModuleSolverNonlinear.__init__(self)
+ return
+
+
+ # PRIVATE METHODS /////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ Solver._configure(self)
+ return
+
+
+ def _cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def solver():
+ """
+ Factory associated with Solver.
+ """
+ return SolverNonlinear()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/problems/TimeDependent.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeDependent.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/TimeDependent.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -111,7 +111,6 @@
self._logger.eventBegin(logEvent)
self._info.log("Initializing problem.")
- self.normalizer.initialize()
self.checkpointTimer.initialize(self.normalizer)
self.formulation.initialize(self.dimension, self.normalizer)
Modified: short/3D/PyLith/trunk/pylith/problems/TimeStep.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStep.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStep.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,6 +38,8 @@
from pyre.units.time import second
self.totalTime = 0.0*second
self.dt = 0.0*second
+ self.totalTimeN = 0.0 # Nondimensionalized total time
+ self.dtN = 0.0 # Nondimenionalized time step
return
@@ -73,8 +75,8 @@
# Nondimensionalize time scales
timeScale = normalizer.timeScale()
- self.totalTime = normalizer.nondimensionalize(self.totalTime, timeScale)
- self.dt = normalizer.nondimensionalize(self.dt, timeScale)
+ self.totalTimeN = normalizer.nondimensionalize(self.totalTime, timeScale)
+ self.dtN = normalizer.nondimensionalize(self.dt, timeScale)
self._logger.eventEnd(logEvent)
return
@@ -88,19 +90,19 @@
return 0
- def timeStep(self, integrators):
+ def timeStep(self, mesh, integrators):
"""
Get stable time step for advancing forward in time.
"""
# Default is to use the current time step.
- return self.dt
+ return self.dtN
def currentStep(self):
"""
Get current time step size.
"""
- return self.dt
+ return self.dtN
# PRIVATE METHODS ////////////////////////////////////////////////////
@@ -122,7 +124,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("PDE TimeStep")
+ logger.className("PDE TimeStep")
logger.initialize()
events = ["preinit",
Modified: short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStepAdapt.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -79,6 +79,7 @@
TimeStep.__init__(self, name)
self._loggingPrefix = "DtAd "
self.skipped = 0
+ self.maxDtN = 0.0 # Nondimensionalized maximum time step
return
@@ -93,7 +94,7 @@
# Nondimensionalize time scales
timeScale = normalizer.timeScale()
- self.maxDt = normalizer.nondimensionalize(self.maxDt, timeScale)
+ self.maxDtN = normalizer.nondimensionalize(self.maxDt, timeScale)
self._logger.eventEnd(logEvent)
return
@@ -104,28 +105,28 @@
Get number of total time steps (or best guess if adaptive).
"""
# Guess using maximum time step
- nsteps = 1.0 + int(self.totalTime / self.maxDt)
+ nsteps = int(1.0 + self.totalTimeN / self.maxDtN)
return nsteps
- def timeStep(self, integrators):
+ def timeStep(self, mesh, integrators):
"""
Adjust stable time step for advancing forward in time.
"""
dtStable = 1.0e+30
for integrator in integrators:
- dt = integrator.stableTimeStep()
+ dt = integrator.stableTimeStep(mesh)
if dt < dtStable:
dtStable = dt
if self.skipped < self.adaptSkip and \
- self.dt != 0.0 and \
- self.dt < dtStable:
+ self.dtN != 0.0 and \
+ self.dtN < dtStable:
self.skipped += 1
else:
- self.dt = min(dtStable/self.stabilityFactor, self.maxDt)
+ self.dtN = min(dtStable/self.stabilityFactor, self.maxDtN)
self.skipped = 0
- return self.dt
+ return self.dtN
# PRIVATE METHODS ////////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStepUniform.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -71,15 +71,15 @@
"""
Get number of total time steps (or best guess if adaptive).
"""
- nsteps = 1.0 + int(self.totalTime / self.dt)
+ nsteps = int(1 + self.totalTimeN / self.dtN)
return nsteps
- def timeStep(self, integrators):
+ def timeStep(self, mesh, integrators):
"""
Adjust stable time step for advancing forward in time.
"""
- return self.dt
+ return self.dtN
# PRIVATE METHODS ////////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/TimeStepUser.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -115,11 +115,14 @@
# Nondimensionalize time steps
timeScale = normalizer.timeScale()
+ self.totalTimeN = normalizer.nondimensionalize(self.totalTime, timeScale)
for i in xrange(len(self.steps)):
- self.steps[i] = normalizer.nondimensionalize(self.steps[i], timeScale)
+ step = normalizer.nondimensionalize(self.steps[i], timeScale)
+ assert(step > 0.0)
+ self.steps[i] = step
# Set current time step
- self.dt = self.steps[self.index]
+ self.dtN = self.steps[self.index]
self._logger.eventEnd(logEvent)
return
@@ -129,11 +132,10 @@
"""
Get number of total time steps (or best guess if adaptive).
"""
- from pyre.units.time import second
t = 0.0
nsteps = 0
index = 0
- while t <= self.totalTime:
+ while t <= self.totalTimeN:
t += self.steps[index]
index += 1
if index >= len(self.steps):
@@ -145,16 +147,16 @@
return nsteps
- def timeStep(self, integrators):
+ def timeStep(self, mesh, integrators):
"""
Get time step for advancing forward in time.
"""
- self.dt = self.steps[self.index]
+ self.dtN = self.steps[self.index]
if self.index+1 < len(self.steps):
self.index += 1
elif self.loopSteps:
self.index = 0
- return self.dt
+ return self.dtN
# PRIVATE METHODS ////////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/pylith/problems/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/problems/__init__.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/problems/__init__.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,6 +18,9 @@
'Explicit',
'Implicit',
'Problem',
+ 'Solver',
+ 'SolverLinear',
+ 'SolverNonlinear',
'TimeDependent',
'TimeStep',
'TimeStepUniform',
Modified: short/3D/PyLith/trunk/pylith/topology/Distributor.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Distributor.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/topology/Distributor.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,61 +16,55 @@
##
## Factory: mesh_distributor.
-from pyre.components.Component import Component
+from pylith.utils.PetscComponent import PetscComponent
+from topology import Distributor as ModuleDistributor
# Distributor class
-class Distributor(Component):
+class Distributor(PetscComponent, ModuleDistributor):
"""
Python manager for distributing mesh among processors.
+ Inventory
+
+ \b Properties
+ @li \b partitioner Name of mesh partitioner {"parmetis", "chaco"}.
+ @li \b debug Write partition information to file.
+
+ \b Facilities
+ @li \b writer Data writer for for partition information.
+
Factory: mesh_distributor
"""
# INVENTORY //////////////////////////////////////////////////////////
- class Inventory(Component.Inventory):
- """
- Python object for managing Distributor facilities and properties.
- """
+ import pyre.inventory
+
+ partitioner = pyre.inventory.str("partitioner", default="chaco",
+ validator=pyre.inventory.choice(["chaco",
+ "parmetis"]))
+ partitioner.meta['tip'] = "Name of mesh partitioner."
+
+ debug = pyre.inventory.bool("debug", default=False)
+ debug.meta['tip'] = "Write partition information to file."
+
+ from pylith.meshio.DataWriterVTKMesh import DataWriterVTKMesh
+ dataWriter = pyre.inventory.facility("data_writer", factory=DataWriterVTKMesh,
+ family="output_data_writer")
+ dataWriter.meta['tip'] = "Data writer for partition information."
- ## @class Inventory
- ## Python object for managing Distributor facilities and properties.
- ##
- ## \b Properties
- ## @li \b partitioner Name of mesh partitioner {"parmetis", "chaco"}.
- ## @li \b debug Write partition information to file.
- ##
- ## \b Facilities
- ## @li \b writer Data writer for for partition information.
-
- import pyre.inventory
-
- partitioner = pyre.inventory.str("partitioner", default="chaco",
- validator=pyre.inventory.choice(["chaco",
- "parmetis"]))
- partitioner.meta['tip'] = "Name of mesh partitioner."
-
- debug = pyre.inventory.bool("debug", default=False)
- debug.meta['tip'] = "Write partition information to file."
-
- from pylith.meshio.DataWriterVTK import DataWriterVTK
- dataWriter = pyre.inventory.facility("data_writer", factory=DataWriterVTK,
- family="output_data_writer")
- dataWriter.meta['tip'] = "Data writer for partition information."
-
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="partitioner"):
"""
Constructor.
"""
- Component.__init__(self, name, facility="partitioner")
- self.cppHandle = None
- self.debug = False
+ PetscComponent.__init__(self, name, facility="partitioner")
+ ModuleDistributor.__init__(self)
return
- def distribute(self, mesh):
+ def distribute(self, mesh, normalizer):
"""
Distribute a Mesh
"""
@@ -78,18 +72,13 @@
logEvent = "%sdistribute" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- self._createCppHandle()
-
- from Mesh import Mesh
- newMesh = Mesh()
- newMesh.cppHandle = self.cppHandle.distribute(mesh.cppHandle,
- self.partitioner)
- newMesh.coordsys = mesh.coordsys
+ from pylith.topology.Mesh import Mesh
+ newMesh = Mesh(mesh.dimension())
+ ModuleDistributor.distribute(newMesh, mesh, self.partitioner)
if self.debug:
- self.dataWriter.initialize()
- self.cppHandle.write(self.dataWriter.cppHandle,
- newMesh.cppHandle, newMesh.coordsys.cppHandle)
+ self.dataWriter.initialize(normalizer)
+ ModuleDistributor.write(self.dataWriter, newMesh)
self._logger.eventEnd(logEvent)
return newMesh
@@ -101,23 +90,13 @@
"""
Set members based using inventory.
"""
- Component._configure(self)
+ PetscComponent._configure(self)
self.partitioner = self.inventory.partitioner
self.debug = self.inventory.debug
self.dataWriter = self.inventory.dataWriter
return
- def _createCppHandle(self):
- """
- Create handle to C++ object.
- """
- if None == self.cppHandle:
- import pylith.topology.topology as bindings
- self.cppHandle = bindings.Distributor()
- return
-
-
def _setupLogging(self):
"""
Setup event logging.
@@ -125,7 +104,7 @@
self._loggingPrefix = "Dist "
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Distribution")
+ logger.className("FE Distribution")
logger.initialize()
events = ["distribute"]
for event in events:
Deleted: short/3D/PyLith/trunk/pylith/topology/Field.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Field.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/topology/Field.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,211 +0,0 @@
-#!/usr/bin/env python
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-## @file pylith/topology/Field.py
-##
-## @brief Python object for managing a vector field over vertices or
-## cells of a finite-element mesh.
-##
-## Factory: vector_field
-
-# Field class
-class Field(object):
- """
- Python object for managing a vector field over vertices or cells of
- a finite-element mesh.
- """
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, mesh):
- """
- Constructor.
- """
- self.cppHandle = self._createCppHandle(mesh)
- return
-
-
- def setName(self, value):
- """
- Set name of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.name = value
- return
-
-
- def getName(self):
- """
- Get name of field.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.name
-
-
- def setVectorFieldType(self, value):
- """
- Set vector field type.
- """
- assert(None != self.cppHandle)
- self.cppHandle.vectorFieldType = value
- return
-
-
- def getVectorFieldType(self):
- """
- Get vector field type.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.VectorFieldType
- return
-
-
- def setSpaceDim(self, value):
- """
- Set spaceDim of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.spaceDim = value
- return
-
-
- def getSpaceDim(self, spaceDim):
- """
- Get spaceDim of field.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.spaceDim
-
-
- def setScale(self, value):
- """
- Set scale of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.scale = value
- return
-
-
- def getScale(self):
- """
- Get scale of field.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.scale
-
-
- def setAddDimensionOkay(self, value):
- """
- Set addDimensionOkay.
- """
- assert(None != self.cppHandle)
- self.cppHandle.addDimensionOkay = value
- return
-
-
- def getAddDimensionOkay(self):
- """
- Get addDimensionOkay.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.addDimensionOkay
-
-
- def copyLayout(self, field):
- """
- Copy layout of field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.copyLayout(field.cppHandle)
- return
-
-
- def clear(self):
- """
- Clear variables associated with section.
- """
- assert(None != self.cppHandle)
- self.cppHandle.clear()
- return
-
-
- def zero(self):
- """
- Zero section values.
- """
- assert(None != self.cppHandle)
- self.cppHandle.zero()
- return
-
-
- def complete(self):
- """
- Complete section by assembling over processors.
- """
- assert(None != self.cppHandle)
- self.cppHandle.complete()
- return
-
-
- def copy(self, field):
- """
- Copy field values and metadata.
- """
- assert(None != self.cppHandle)
- self.cppHandle.copy(field.cppHandle)
- return
-
-
- def add(self, field):
- """
- Add two fields, storing result in field.
- """
- assert(None != self.cppHandle)
- self.cppHandle.add(field.cppHandle)
- return
-
-
- def dimensionalize(self):
- """
- Add dimensions to field.
- """
- okay = self.cppHandle.addDimensionOkay
- if ~okay:
- name = self.cppHandle.name
- raise RuntimeError("Field '%s' is protected. Cannot dimensionalize." % \
- name)
- assert(None != self.cppHandle)
- self.cppHandle.dimensionalize()
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _createCppHandle(self):
- """
- Create handle to corresponding C++ object.
- """
- if None == self.cppHandle:
- import pylith.topology.topology as bindings
- self.cppHandle = bindings.Field()
- return
-
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def vector_field():
- """
- Factory associated with Mesh.
- """
- return Field()
-
-
-# End of file
Copied: short/3D/PyLith/trunk/pylith/topology/Field.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/topology/Field.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Field.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/topology/Field.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/Field.py
+##
+## @brief Python object for managing a vector field over vertices or
+## cells of a finite-element mesh.
+
+from topology import MeshField as ModuleMeshField
+from topology import SubMeshField as ModuleSubMeshField
+
+# ----------------------------------------------------------------------
+# MeshField class
+class MeshField(ModuleMeshField):
+ """
+ Python object for managing a vector field over vertices or cells of
+ a finite-element mesh.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, mesh):
+ """
+ Constructor.
+ """
+ ModuleMeshField.__init__(self, mesh)
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# ----------------------------------------------------------------------
+# SubMeshField class
+class SubMeshField(ModuleSubMeshField):
+ """
+ Python object for managing a vector field over vertices or cells of
+ a lower-dimension finite-element mesh.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, mesh):
+ """
+ Constructor.
+ """
+ ModuleSubMeshField.__init__(self, mesh)
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/topology/Fields.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/topology/Fields.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Fields.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/topology/Fields.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/Fields.py
+##
+## @brief Python object for managing vector fields over vertices or
+## cells of a finite-element mesh.
+
+from topology import MeshFields as ModuleMeshFields
+from topology import SubMeshFields as ModuleSubMeshFields
+
+# ----------------------------------------------------------------------
+# MeshFields class
+class MeshFields(ModuleMeshFields):
+ """
+ Python object for managing vector fields over vertices or cells of a
+ finite-element mesh.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, mesh):
+ """
+ Constructor.
+ """
+ ModuleMeshFields.__init__(self, mesh)
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# ----------------------------------------------------------------------
+# SubMeshFields class
+class SubMeshFields(ModuleSubMeshFields):
+ """
+ Python object for managing vector fields over vertices or cells of
+ a lower-dimension finite-element mesh.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, mesh):
+ """
+ Constructor.
+ """
+ ModuleSubMeshFields.__init__(self, mesh)
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/topology/Jacobian.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/topology/Jacobian.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Jacobian.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/topology/Jacobian.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/Jacobian.py
+##
+## @brief Python object for system Jacobian.
+
+from topology import Jacobian as ModuleJacobian
+
+# ----------------------------------------------------------------------
+# Jacobian class
+class Jacobian(ModuleJacobian):
+ """
+ Python object for system Jacobian.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, fields):
+ """
+ Constructor.
+
+ @param fields Solution fields.
+ """
+ ModuleJacobian.__init__(self, fields)
+ return
+
+
+ def cleanup(self):
+ """
+ Dellocate PETSC and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/topology/JacobianViewer.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/topology/JacobianViewer.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/JacobianViewer.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/topology/JacobianViewer.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+
+## @file pylith/topology/JacobianViewer.py
+##
+## @brief Python object for writing system Jacobian to file.
+##
+## Factory: jacobian_viewer
+
+from pyre.components.Component import Component
+
+# JacobianViewer class
+class JacobianViewer(Component):
+ """
+ Python abstract base class for formulations of solving equations.
+
+ In general, we use some explicit or implicit formulation of the PDEs
+ to create a linear form, [A]{u}={b} that we can solve.
+
+ Factory: pde_formulation.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Component.Inventory):
+ """
+ Python object for managing JacobianViewer facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing JacobianViewer facilities and properties.
+ ##
+ ## \b Properties
+ ## @li \b filename Filename for Jacobian matrix.
+ ## @li \b time_format C style format string for time stamp in filename.
+ ## @li \b time_constant Value used to normalize time stamp in filename.
+ ##
+ ## \b Facilities
+ ## @li None
+
+ import pyre.inventory
+
+ filename = pyre.inventory.str("filename", default="jacobian.mat")
+ filename.meta['tip'] = "Filename for Jacobian matrix."
+
+ timeFormat = pyre.inventory.str("time_format", default="%f")
+ timeFormat.meta['tip'] = "C style format string for time stamp in filename."
+
+ from pyre.units.time import second
+ timeConstant = pyre.inventory.dimensional("time_constant",
+ default=1.0*second,
+ validator=pyre.inventory.greater(0.0*second))
+ timeConstant.meta['tip'] = \
+ "Values used to normalize time stamp in filename."
+
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="formulation"):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name, facility="jacobian_viewer")
+ return
+
+
+ def view(self, jacobian, t):
+ """
+ Write Jacobian to binary file.
+ """
+ jacobian.write(self._filenameStamp(t))
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members based using inventory.
+ """
+ Component._configure(self)
+ self.filename = self.inventory.filename
+ self.timeFormat = self.inventory.timeFormat
+ self.timeConstant = self.inventory.timeConstant
+ return
+
+
+ def _filenameStamped(self, t):
+ """
+ Create filename by extracting basename and adding a time stamp.
+ """
+ timeStamp = self.timeFormat % (t.value/self.jacobianTimeConstant.value)
+ basename = self.filename
+ if basename.endswith(".mat"):
+ basename = base[0:len(base)-4]
+ filename = basename + "_t" + timeStamp + ".mat"
+ return filename
+
+
+# FACTORIES ////////////////////////////////////////////////////////////
+
+def jacobian_viewer():
+ """
+ Factory associated with JacobianViewer.
+ """
+ return JacobianViewer()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/topology/Mesh.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/Mesh.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/topology/Mesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,148 +13,55 @@
## @file pylith/topology/Mesh.py
##
## @brief Python Mesh for finite-element topology information.
-##
-## Factory: finite_element_mesh
-from pyre.components.Component import Component
+from topology import Mesh as ModuleMesh
# Mesh class
-class Mesh(Component):
+class Mesh(ModuleMesh):
"""
Python Mesh for finite-element topology information.
"""
# PUBLIC METHODS /////////////////////////////////////////////////////
- def __init__(self, name="mesh"):
+ def __init__(self, dim=None, comm=None):
"""
Constructor.
"""
- Component.__init__(self, name, facility="finite_element_mesh")
- self.cppHandle = None
- self.coordsys = None
- self.debug = False
+ if comm is None and dim is None:
+ ModuleMesh.__init__(self)
+ elif comm is None:
+ ModuleMesh.__init__(self, dim)
+ else:
+ ModuleMesh.__init__(self, dim, comm.handle)
return
- def initialize(self, coordsys):
+ def setComm(self, comm):
"""
- Initialize mesh.
+ Set communicator.
"""
- self._createCppHandle()
- self.coordsys = coordsys
+ ModuleMesh.comm(self, comm.handle)
return
- def setDebug(self, flag):
+ def getComm(self):
"""
- Set debugging flag.
+ Get communicator.
"""
- self.debug = flag
- self.cppHandle.debug = self.debug
- return
-
+ # Use Communicator object to wrap C++ MPI_Comm* returned by
+ # module.
+ from pylith.mpi.Communicator import Communicator
+ return Communicator(ModuleMesh.comm(self))
- def dimension(self):
- """
- Get dimension of mesh.
- """
- dim = None
- if not self.cppHandle is None:
- dim = self.cppHandle.dimension
- return dim
-
- def view(self):
- """
- View the mesh.
- """
- if not self.cppHandle is None:
- self.cppHandle.view()
- return
-
-
- def comm(self):
- """
- Get MPI communicator associated with mesh.
- """
- comm = None
- #if not self.cppHandle is None:
- # comm = self.cppHandle.comm
- import mpi
- comm = mpi.MPI_COMM_WORLD
- return comm
-
-
- def getRealSection(self, label):
- """
- Get real section from mesh.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.getRealSection(label)
-
-
- def createRealSection(self, label, fiberDim):
- """
- Create real section (but don't allocate).
- """
- assert(None != self.cppHandle)
- return self.cppHandle.createRealSection(label, fiberDim)
-
-
- def allocateRealSection(self, field):
- """
- Allocated (and zero) real section.
- """
- assert(None != self.cppHandle)
- self.cppHandle.allocateRealSection(field)
- return
-
-
- def createMatrix(self, field):
- """
- Create sparse matrix compatible with field.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.createMatrix(field)
-
-
def checkMaterialIds(self, materialIds):
"""
- Make sure material id for each cell matches id of a material.
+ Check material ids for consistency with mesh.
"""
- assert(None != self.cppHandle)
- self.cppHandle.checkMaterialIds(materialIds)
+ from topology import MeshOps_checkMaterialIds
+ MeshOps_checkMaterialIds(self, materialIds)
return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Set members based using inventory.
- """
- Component._configure(self)
- return
-
- def _createCppHandle(self):
- """
- Create handle to corresponding C++ object.
- """
- if None == self.cppHandle:
- import pylith.topology.topology as bindings
- self.cppHandle = bindings.Mesh()
- return
-
-# FACTORIES ////////////////////////////////////////////////////////////
-
-def finite_element_mesh():
- """
- Factory associated with Mesh.
- """
- return Mesh()
-
-
# End of file
Modified: short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/topology/MeshGenerator.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -109,7 +109,7 @@
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("Mesh Generator")
+ logger.className("Mesh Generator")
logger.initialize()
events = ["create",
Modified: short/3D/PyLith/trunk/pylith/topology/MeshImporter.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshImporter.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/topology/MeshImporter.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,16 +40,16 @@
## @li None
##
## \b Facilities
- ## @li \b importer Mesh importer.
+ ## @li \b reader Mesh reader.
## @li \b partitioner Mesh partitioner.
## @li \b refiner Mesh refiner.
import pyre.inventory
from pylith.meshio.MeshIOAscii import MeshIOAscii
- importer = pyre.inventory.facility("importer", family="mesh_io",
+ reader = pyre.inventory.facility("reader", family="mesh_io",
factory=MeshIOAscii)
- importer.meta['tip'] = "Mesh importer."
+ reader.meta['tip'] = "Mesh reader."
from Distributor import Distributor
distributor = pyre.inventory.facility("distributor",
@@ -85,10 +85,9 @@
logEvent = "%screate" % self._loggingPrefix
self._logger.eventBegin(logEvent)
- normalizer.initialize()
- mesh = self.importer.read(normalizer, self.debug, self.interpolate)
+ mesh = self.reader.read(normalizer, self.debug, self.interpolate)
if self.debug:
- mesh.view()
+ mesh.view("Finite-element mesh.")
self._debug.log(resourceUsageString())
self._info.log("Adjusting topology.")
self._adjustTopology(mesh, faults)
@@ -96,14 +95,12 @@
import mpi
if mpi.MPI_Comm_size(mpi.MPI_COMM_WORLD) > 1:
self._info.log("Distributing mesh.")
- mesh = self.distributor.distribute(mesh)
- if self.debug:
- mesh.view()
+ mesh = self.distributor.distribute(mesh, normalizer)
+ if self.debug:
+ mesh.view("Distributed mesh.")
# refine mesh (if necessary)
mesh = self.refiner.refine(mesh)
- if self.debug:
- mesh.view()
self._logger.eventEnd(logEvent)
return mesh
@@ -116,7 +113,7 @@
Set members based on inventory.
"""
MeshGenerator._configure(self)
- self.importer = self.inventory.importer
+ self.reader = self.inventory.reader
self.distributor = self.inventory.distributor
self.refiner = self.inventory.refiner
return
Modified: short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/topology/MeshRefiner.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -95,7 +95,7 @@
self._loggingPrefix = "Refin "
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("FE Refinement")
+ logger.className("FE Refinement")
logger.initialize()
events = ["refine"]
for event in events:
Copied: short/3D/PyLith/trunk/pylith/topology/SolutionFields.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/topology/SolutionFields.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/SolutionFields.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/topology/SolutionFields.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/SolutionFields.py
+##
+## @brief Python object for managing fields associated with problem
+## solution.
+
+from topology import SolutionFields as ModuleSolutionFields
+
+# ----------------------------------------------------------------------
+# SolutionFields class
+class SolutionFields(ModuleSolutionFields):
+ """
+ Python object for managing fields associated with problem solution.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, mesh):
+ """
+ Constructor.
+ """
+ ModuleSolutionFields.__init__(self, mesh)
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate PETSc and local data structures.
+ """
+ self.deallocate()
+ return
+
+
+# End of file
Copied: short/3D/PyLith/trunk/pylith/topology/SubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/topology/SubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/SubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/topology/SubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/topology/SubMesh.py
+##
+## @brief Python Mesh for lower-dimension finite-element topology
+## information.
+
+from topology import SubMesh as ModuleSubMesh
+
+# SubMesh class
+class SubMesh(ModuleSubMesh):
+ """
+ Python Mesh for lower-dimension finite-element topology information.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, mesh=None, label=None):
+ """
+ Constructor.
+ """
+ if mesh is None:
+ ModuleSubMesh.__init__(self)
+ else:
+ if label is None:
+ raise ValueError("SubMesh constructor with mesh requires label.")
+ ModuleSubMesh.__init__(self, mesh, label)
+ return
+
+
+ def comm(self):
+ """
+ Get communicator.
+ """
+ # Use Communicator object to wrap C++ MPI_Comm* returned by
+ # module.
+ from pylith.mpi.Communicator import Communicator
+ return Communicator(ModuleSubMesh.comm(self))
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/topology/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/topology/__init__.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/topology/__init__.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,8 +15,9 @@
## @brief Python PyLith finite-element topology module initialization
__all__ = ['Distributor',
- 'FieldsManager',
'Mesh',
+ 'SubMesh',
+ 'Field',
'MeshGenSimple',
'MeshGenerator',
'MeshImporter',
Modified: short/3D/PyLith/trunk/pylith/utils/CppData.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/CppData.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/utils/CppData.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -201,7 +201,11 @@
# Write array information
for array in self.arrays:
- fileOut.write(" static const %s %s[];\n\n" % \
+ if array['values'] is None:
+ fileOut.write(" static const %s* %s;\n\n" % \
+ (array['type'], array['name']))
+ else:
+ fileOut.write(" static const %s %s[];\n\n" % \
(array['type'], array['name']))
@@ -237,20 +241,27 @@
# Write array information
for array in self.arrays:
- cppformat = "const %s %s::%s::%s[] = {\n"
- fileOut.write(cppformat % \
- (array['type'],
- string.join(self.namespace, "::"), self.objname,
- array['name']))
- icol = 0
- for value in numpy.ravel(array['values']):
- cppformat = "%s," % array['format']
- fileOut.write(cppformat % value)
- icol += 1
- if icol == array['ncols']:
- fileOut.write("\n")
- icol = 0
- fileOut.write("};\n\n")
+ if array['values'] is None:
+ cppformat = "const %s* %s::%s::%s = 0;\n\n"
+ fileOut.write(cppformat % \
+ (array['type'],
+ string.join(self.namespace, "::"), self.objname,
+ array['name']))
+ else:
+ cppformat = "const %s %s::%s::%s[] = {\n"
+ fileOut.write(cppformat % \
+ (array['type'],
+ string.join(self.namespace, "::"), self.objname,
+ array['name']))
+ icol = 0
+ for value in numpy.ravel(array['values']):
+ cppformat = "%s," % array['format']
+ fileOut.write(cppformat % value)
+ icol += 1
+ if icol == array['ncols']:
+ fileOut.write("\n")
+ icol = 0
+ fileOut.write("};\n\n")
if self.parent != "":
self._writeLifecycle(fileOut)
Modified: short/3D/PyLith/trunk/pylith/utils/EventLogger.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/EventLogger.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/utils/EventLogger.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,8 +16,10 @@
##
## Each logger object manages the events for a single "logging class".
+from utils import EventLogger as ModuleEventLogger
+
# EventLogger class
-class EventLogger(object):
+class EventLogger(ModuleEventLogger):
"""
Python object for managing event logging using PETSc.
@@ -30,62 +32,25 @@
"""
Constructor.
"""
- self.cppHandle = None
- self._createCppHandle()
+ ModuleEventLogger.__init__(self)
self.events = {} # dict of events with counts for current logging.
return
- def setClassName(self, name):
- """
- Set name of logging class.
- """
- self._createCppHandle()
- self.cppHandle.className = name
- return
-
-
- def getClassName(self):
- """
- Set name of logging class.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.className
-
-
- def initialize(self):
- """
- Setup logging class.
- """
- assert(None != self.cppHandle)
- self.cppHandle.initialize()
- return
-
-
def registerEvent(self, name):
"""
Register event.
"""
self.events[name] = 0 # Set log count to 0
- assert(None != self.cppHandle)
- return self.cppHandle.registerEvent(name)
+ return ModuleEventLogger.registerEvent(self, name)
- def eventId(self, name):
- """
- Get event identifier.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.eventId(name)
-
-
def eventBegin(self, name):
"""
Log event begin.
"""
if self.events[name] == 0: # prevent double counting
- assert(None != self.cppHandle)
- self.cppHandle.eventBegin(self.cppHandle.eventId(name))
+ ModuleEventLogger.eventBegin(self, self.eventId(name))
self.events[name] += 1
return
@@ -97,55 +62,16 @@
if self.events[name] > 0:
self.events[name] -= 1
if 0 == self.events[name]: # prevent double counting
- assert(None != self.cppHandle)
- self.cppHandle.eventEnd(self.cppHandle.eventId(name))
-
+ ModuleEventLogger.eventEnd(self, self.eventId(name))
return
- def registerStage(self, name):
- """
- Register stage.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.registerStage(name)
-
-
- def stageId(self, name):
- """
- Get stage identifier.
- """
- assert(None != self.cppHandle)
- return self.cppHandle.stageId(name)
-
-
def stagePush(self, name):
"""
Log stage begin.
"""
- assert(None != self.cppHandle)
- self.cppHandle.stagePush(self.cppHandle.stageId(name))
+ ModuleEventLogger.stagePush(self, self.stageId(name))
return
- def stagePop(self):
- """
- Log stage end.
- """
- assert(None != self.cppHandle)
- self.cppHandle.stagePop()
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _createCppHandle(self):
- """
- Create handle to corresponding C++ object.
- """
- if None == self.cppHandle:
- import pylith.utils.utils as bindings
- self.cppHandle = bindings.EventLogger()
-
-
# End of file
Copied: short/3D/PyLith/trunk/pylith/utils/PetscComponent.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/pylith/utils/PetscComponent.py)
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/PetscComponent.py (rev 0)
+++ short/3D/PyLith/trunk/pylith/utils/PetscComponent.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# <LicenseText>
+#
+# ----------------------------------------------------------------------
+#
+
+## @file pylith/utils/PetscComponent.py
+##
+## @brief Python PetscComponent object for aid in deallocating data
+## structures before calling PetscFinalize().
+
+from pyre.components.Component import Component
+
+# PetscComponent class
+class PetscComponent(Component):
+ """
+ Python PetscComponent object for aid in deallocating data structures
+ before calling PetscFinalize().
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name, facility):
+ """
+ Constructor.
+ """
+ Component.__init__(self, name, facility)
+ return
+
+
+ def cleanup(self):
+ """
+ Deallocate data structures.
+ """
+ for component in self.components():
+ if isinstance(component, PetscComponent):
+ component.cleanup()
+ self._cleanup()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _cleanup(self):
+ """
+ Deallocate locally managed data structures.
+ """
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/pylith/utils/PetscManager.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/PetscManager.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/utils/PetscManager.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,7 @@
## Factory: petsc_manager
from pyre.components.Component import Component
+import pylith.utils.petsc as petsc
# PetscManager class
class PetscManager(Component):
@@ -45,14 +46,13 @@
Initialize PETSc.
"""
self._info.log("Initializing PETSc.")
- import pylith.utils.petsc as bindings
import sys
args = [sys.executable]
options = self._getOptions()
if len(options) > 0:
for arg in options:
args.append(arg)
- bindings.petsc_initialize(args)
+ petsc.initialize(args)
return
@@ -61,8 +61,7 @@
Finalize PETSc.
"""
self._info.log("Finalizing PETSc.")
- import pylith.utils.petsc as bindings
- bindings.petsc_finalize()
+ petsc.finalize()
return
Modified: short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/utils/VTKDataReader.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -28,7 +28,6 @@
"(https://svn.enthought.com/enthought/wiki/MayaVi)"
print " in order to enable verification of output."
has_vtk.flag = False
- has_vtk.flag = False
return has_vtk.flag
Modified: short/3D/PyLith/trunk/pylith/utils/__init__.py
===================================================================
--- short/3D/PyLith/trunk/pylith/utils/__init__.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/pylith/utils/__init__.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -12,6 +12,7 @@
__all__ = ['CheckpointTimer',
'CppData',
+ 'PetscComponent',
'PetscManager',
'testarray',
'importing']
Modified: short/3D/PyLith/trunk/tests/1d/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/tests/1d/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/1d/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,8 +11,7 @@
#
SUBDIRS = \
- line2 \
- line3
+ line2
# End of file
Modified: short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/1d/line2/TestAxial.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
# Local version of PyLithApp
-from pylith.PyLithApp import PyLithApp
+from pylith.apps.PyLithApp import PyLithApp
class AxialPlaneStrainApp(PyLithApp):
def __init__(self):
PyLithApp.__init__(self, name="axialextension")
@@ -75,7 +75,7 @@
# Check vertices
nverticesE = 5
- spaceDimE = 2
+ spaceDimE = 3
(nvertices, spaceDim) = data['vertices'].shape
self.assertEqual(nverticesE, nvertices)
self.assertEqual(spaceDimE, spaceDim)
@@ -91,6 +91,7 @@
diff = numpy.abs(1.0 - data['cell_fields']['mu']/muE)
okay = diff < tolerance
if numpy.sum(okay) != ncells:
+ print "Expected Lame's constant mu: ",muE
print "Lame's constant mu: ",data['cell_fields']['mu']
self.assertEqual(ncells, numpy.sum(okay))
@@ -99,6 +100,7 @@
diff = numpy.abs(1.0 - data['cell_fields']['lambda']/lambdaE)
okay = diff < tolerance
if numpy.sum(okay) != ncells:
+ print "Expected Lame's constant lambda: ",lambdaE
print "Lame's constant lambda: ",data['cell_fields']['lambda']
self.assertEqual(ncells, numpy.sum(okay))
@@ -106,6 +108,7 @@
diff = numpy.abs(1.0 - data['cell_fields']['density']/densityE)
okay = diff < tolerance
if numpy.sum(okay) != ncells:
+ print "Expected density: ",densityE
print "Density: ",data['cell_fields']['density']
self.assertEqual(ncells, numpy.sum(okay))
return
@@ -140,21 +143,21 @@
dispE = numpy.zeros( (nvertices, spaceDim), dtype=numpy.float64)
dispE[:,0] = -0.2 + 0.1 * vertices[:,0]
- disp = data['vertex_fields']['displacements']
+ disp = data['vertex_fields']['displacement']
# Check x displacements
diff = numpy.abs(disp[:,0] - dispE[:,0])
okay = diff < tolerance
if numpy.sum(okay) != nvertices:
+ print "Displacement field expected: ",dispE
print "Displacement field: ",disp
self.assertEqual(nvertices, numpy.sum(okay))
# Check y displacements
- mask = dispE[:,1] > 0.0
- diff = mask * numpy.abs(1.0 - disp[:,1] / dispE[:,1]) + \
- ~mask * numpy.abs(disp[:,1] - dispE[:,1])
+ diff = numpy.abs(disp[:,1] - dispE[:,1])
okay = diff < tolerance
if numpy.sum(okay) != nvertices:
+ print "Displacement field expected: ",dispE
print "Displacement field: ",disp
self.assertEqual(nvertices, numpy.sum(okay))
@@ -162,17 +165,18 @@
diff = numpy.abs(disp[:,2] - dispE[:,2])
okay = diff < tolerance
if numpy.sum(okay) != nvertices:
+ print "Displacement field expected: ",dispE
print "Displacement field: ",disp
self.assertEqual(nvertices, numpy.sum(okay))
return
- def test_elastic_statevars(self):
- """
- Check elastic state variables.
- """
- return
+ #def test_elastic_statevars(self):
+ # """
+ # Check elastic state variables.
+ # """
+ # return
# End of file
Modified: short/3D/PyLith/trunk/tests/1d/line2/axialextension.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/axialextension.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/1d/line2/axialextension.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,18 +1,21 @@
# -*- Python -*-
[axialextension]
+[axialextension.launcher]
+command = mpiexec -n ${nodes}
+
# ----------------------------------------------------------------------
# journal
# ----------------------------------------------------------------------
[axialextension.journal.info]
-#timedependent = 1
-#implicit = 1
-#petsc = 1
-#solverlinear = 1
-#meshiocubit = 1
-#implicitelasticity = 1
-#quadrature2d = 1
-#fiatsimplex = 1
+timedependent = 1
+implicit = 1
+petsc = 1
+solverlinear = 1
+meshiocubit = 1
+implicitelasticity = 1
+quadrature = 1
+fiatsimplex = 1
# ----------------------------------------------------------------------
# mesh_generator
@@ -20,7 +23,7 @@
[axialextension.mesh_generator]
#debug = 1
-[axialextension.mesh_generator.importer]
+[axialextension.mesh_generator.reader]
filename = bar.mesh
coordsys.space_dim = 1
@@ -31,6 +34,8 @@
dimension = 1
bc = [bc]
+#formulation.solver = pylith.problems.SolverNonlinear
+
[axialextension.timedependent.formulation.time_step]
total_time = 0.0*s
@@ -44,8 +49,7 @@
[axialextension.timedependent.materials.elastic]
label = Elastic material
id = 1
-db.iohandler.filename = matprops.spatialdb
-quadrature = pylith.feassemble.quadrature.Quadrature1D
+properties_db.iohandler.filename = matprops.spatialdb
quadrature.cell.shape = line
# ----------------------------------------------------------------------
@@ -69,7 +73,9 @@
#ksp_monitor = true
#ksp_view = true
#log_summary = true
-# start_in_debugger = true
+#start_in_debugger = true
+snes_monitor = true
+snes_view = true
# ----------------------------------------------------------------------
# output
@@ -78,5 +84,5 @@
filename = axialextension.vtk
[axialextension.timedependent.materials.elastic.output]
-cell_filter = pylith.meshio.CellFilterAvg
+cell_filter = pylith.meshio.CellFilterAvgMesh
writer.filename = axialextension-statevars-elastic.vtk
Modified: short/3D/PyLith/trunk/tests/1d/line2/testpylith.py
===================================================================
--- short/3D/PyLith/trunk/tests/1d/line2/testpylith.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/1d/line2/testpylith.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env nemesis
#
# ======================================================================
#
Modified: short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/TestAxialPlaneStrain.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
from pylith.utils.VTKDataReader import VTKDataReader
# Local version of PyLithApp
-from pylith.PyLithApp import PyLithApp
+from pylith.apps.PyLithApp import PyLithApp
class AxialPlaneStrainApp(PyLithApp):
def __init__(self):
PyLithApp.__init__(self, name="axialplanestrain")
Modified: short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,7 +18,7 @@
import unittest
# Local application
-from pylith.PyLithApp import PyLithApp
+from pylith.apps.PyLithApp import PyLithApp
class DislocationApp(PyLithApp):
def __init__(self):
PyLithApp.__init__(self, name="dislocation")
Modified: short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation2.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation2.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/TestDislocation2.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,7 +18,7 @@
import unittest
# Local application
-from pylith.PyLithApp import PyLithApp
+from pylith.apps.PyLithApp import PyLithApp
class DislocationApp(PyLithApp):
def __init__(self):
PyLithApp.__init__(self, name="dislocation2")
Modified: short/3D/PyLith/trunk/tests/2d/tri3/TestShearPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/TestShearPlaneStrain.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/TestShearPlaneStrain.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,7 +20,7 @@
from pylith.utils.VTKDataReader import VTKDataReader
# Local version of PyLithApp
-from pylith.PyLithApp import PyLithApp
+from pylith.apps.PyLithApp import PyLithApp
class ShearPlaneStrainApp(PyLithApp):
def __init__(self):
PyLithApp.__init__(self, name="shearplanestrain")
Modified: short/3D/PyLith/trunk/tests/2d/tri3/axialplanestrain.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/axialplanestrain.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/axialplanestrain.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,9 +19,9 @@
# ----------------------------------------------------------------------
[axialplanestrain.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOCubit
+reader = pylith.meshio.MeshIOCubit
-[axialplanestrain.mesh_generator.importer]
+[axialplanestrain.mesh_generator.reader]
filename = box_tri3_100m.exo
coordsys.space_dim = 2
@@ -45,8 +45,7 @@
[axialplanestrain.timedependent.materials.elastic]
label = Elastic material
id = 1
-db.iohandler.filename = matprops.spatialdb
-quadrature = pylith.feassemble.quadrature.Quadrature2D
+properties_db.iohandler.filename = matprops.spatialdb
quadrature.cell.shape = triangle
# ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/tests/2d/tri3/dislocation.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/dislocation.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/dislocation.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,7 +11,7 @@
#solverlinear = 1
#meshiocubit = 1
#implicitelasticity = 1
-#quadrature2d = 1
+#quadrature = 1
#fiatsimplex = 1
# ----------------------------------------------------------------------
@@ -19,9 +19,9 @@
# ----------------------------------------------------------------------
[dislocation.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOCubit
+reader = pylith.meshio.MeshIOCubit
-[dislocation.mesh_generator.importer]
+[dislocation.mesh_generator.reader]
filename = box_tri3_100m.exo
coordsys.space_dim = 2
@@ -46,8 +46,7 @@
[dislocation.timedependent.materials.elastic]
label = Elastic material
id = 1
-db.iohandler.filename = matprops.spatialdb
-quadrature = pylith.feassemble.quadrature.Quadrature2D
+properties_db.iohandler.filename = matprops.spatialdb
quadrature.cell.shape = triangle
# ----------------------------------------------------------------------
@@ -78,7 +77,6 @@
[dislocation.timedependent.interfaces.fault]
id = 2
label = 10
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell.shape = line
mat_db.iohandler.filename = matprops.spatialdb
Modified: short/3D/PyLith/trunk/tests/2d/tri3/dislocation2.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/dislocation2.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/dislocation2.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,7 +11,7 @@
#solverlinear = 1
#meshiocubit = 1
#implicitelasticity = 1
-#quadrature2d = 1
+#quadrature = 1
#fiatsimplex = 1
# ----------------------------------------------------------------------
@@ -19,9 +19,9 @@
# ----------------------------------------------------------------------
[dislocation2.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOCubit
+reader = pylith.meshio.MeshIOCubit
-[dislocation2.mesh_generator.importer]
+[dislocation2.mesh_generator.reader]
filename = box_tri3_100m.exo
coordsys.space_dim = 2
@@ -46,8 +46,7 @@
[dislocation2.timedependent.materials.elastic]
label = Elastic material
id = 1
-db.iohandler.filename = matprops.spatialdb
-quadrature = pylith.feassemble.quadrature.Quadrature2D
+properties_db.iohandler.filename = matprops.spatialdb
quadrature.cell.shape = triangle
# ----------------------------------------------------------------------
@@ -71,7 +70,6 @@
[dislocation2.timedependent.interfaces.fault_pos]
id = 2
label = 11
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell.shape = line
mat_db.iohandler.filename = matprops.spatialdb
@@ -83,7 +81,6 @@
[dislocation2.timedependent.interfaces.fault_neg]
id = 3
label = 12
-quadrature = pylith.feassemble.quadrature.Quadrature1Din2D
quadrature.cell.shape = line
mat_db.iohandler.filename = matprops.spatialdb
Modified: short/3D/PyLith/trunk/tests/2d/tri3/shearplanestrain.cfg
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/shearplanestrain.cfg 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/shearplanestrain.cfg 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,9 +19,9 @@
# ----------------------------------------------------------------------
[shearplanestrain.mesh_generator]
#debug = 1
-importer = pylith.meshio.MeshIOCubit
+reader = pylith.meshio.MeshIOCubit
-[shearplanestrain.mesh_generator.importer]
+[shearplanestrain.mesh_generator.reader]
filename = box_tri3_100m.exo
coordsys.space_dim = 2
@@ -45,8 +45,7 @@
[shearplanestrain.timedependent.materials.elastic]
label = Elastic material
id = 1
-db.iohandler.filename = matprops.spatialdb
-quadrature = pylith.feassemble.quadrature.Quadrature2D
+properties_db.iohandler.filename = matprops.spatialdb
quadrature.cell.shape = triangle
# ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/tests/2d/tri3/testpylith.py
===================================================================
--- short/3D/PyLith/trunk/tests/2d/tri3/testpylith.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/2d/tri3/testpylith.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,11 +26,11 @@
from TestShearPlaneStrain import TestShearPlaneStrain
suite.addTest(unittest.makeSuite(TestShearPlaneStrain))
- from TestDislocation import TestDislocation
- suite.addTest(unittest.makeSuite(TestDislocation))
+ #from TestDislocation import TestDislocation
+ #suite.addTest(unittest.makeSuite(TestDislocation))
- from TestDislocation2 import TestDislocation2
- suite.addTest(unittest.makeSuite(TestDislocation2))
+ #from TestDislocation2 import TestDislocation2
+ #suite.addTest(unittest.makeSuite(TestDislocation2))
return suite
Modified: short/3D/PyLith/trunk/tests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/tests/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/tests/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,6 +11,7 @@
#
SUBDIRS = \
+ petsc \
1d \
2d \
3d
Copied: short/3D/PyLith/trunk/tests/petsc (from rev 14862, short/3D/PyLith/branches/pylith-swig/tests/petsc)
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,44 +21,43 @@
# Primary source files
testbc_SOURCES = \
- TestAbsorbingDampers.cc \
- TestAbsorbingDampersLine2.cc \
- TestAbsorbingDampersTri3.cc \
- TestAbsorbingDampersQuad4.cc \
- TestAbsorbingDampersTet4.cc \
- TestAbsorbingDampersHex8.cc \
TestBoundaryCondition.cc \
- TestBoundaryMesh.cc \
- TestBoundaryMeshTri3.cc \
- TestBoundaryMeshQuad4.cc \
- TestBoundaryMeshTet4.cc \
- TestBoundaryMeshHex8.cc \
+ TestDirichletBC.cc \
+ TestDirichletBCLine2.cc \
+ TestDirichletBCLine2b.cc \
+ TestDirichletBCTri3.cc \
+ TestDirichletBCQuad4.cc \
+ TestDirichletBCTet4.cc \
+ TestDirichletBCHex8.cc \
+ TestDirichletBCMulti.cc \
+ TestDirichletBCMultiTri3.cc \
+ TestDirichletBCMultiTet4.cc \
TestDirichletBoundary.cc \
TestDirichletBoundaryTri3.cc \
TestDirichletBoundaryQuad4.cc \
TestDirichletBoundaryTet4.cc \
TestDirichletBoundaryHex8.cc \
- TestDirichletBoundaryMulti.cc \
- TestDirichletBoundaryMultiTri3.cc \
- TestDirichletBoundaryMultiTet4.cc \
- TestDirichletPoints.cc \
- TestDirichletPointsLine2.cc \
- TestDirichletPointsLine2b.cc \
- TestDirichletPointsTri3.cc \
- TestDirichletPointsQuad4.cc \
- TestDirichletPointsTet4.cc \
- TestDirichletPointsHex8.cc \
- TestDirichletPointsMulti.cc \
- TestDirichletPointsMultiTri3.cc \
- TestDirichletPointsMultiTet4.cc \
TestNeumann.cc \
TestNeumannLine2.cc \
TestNeumannTri3.cc \
TestNeumannQuad4.cc \
TestNeumannTet4.cc \
TestNeumannHex8.cc \
+ TestAbsorbingDampers.cc \
+ TestAbsorbingDampersLine2.cc \
+ TestAbsorbingDampersTri3.cc \
+ TestAbsorbingDampersQuad4.cc \
+ TestAbsorbingDampersTet4.cc \
+ TestAbsorbingDampersHex8.cc \
+ TestBoundaryMesh.cc \
+ TestBoundaryMeshTri3.cc \
+ TestBoundaryMeshQuad4.cc \
+ TestBoundaryMeshTet4.cc \
+ TestBoundaryMeshHex8.cc \
test_bc.cc
+
+
noinst_HEADERS = \
TestAbsorbingDampers.hh \
TestAbsorbingDampersLine2.hh \
@@ -77,19 +76,16 @@
TestDirichletBoundaryQuad4.hh \
TestDirichletBoundaryTet4.hh \
TestDirichletBoundaryHex8.hh \
- TestDirichletBoundaryMulti.hh \
- TestDirichletBoundaryMultiTri3.hh \
- TestDirichletBoundaryMultiTet4.hh \
- TestDirichletPoints.hh \
- TestDirichletPointsLine2.hh \
- TestDirichletPointsLine2b.hh \
- TestDirichletPointsTri3.hh \
- TestDirichletPointsQuad4.hh \
- TestDirichletPointsTet4.hh \
- TestDirichletPointsHex8.hh \
- TestDirichletPointsMulti.hh \
- TestDirichletPointsMultiTri3.hh \
- TestDirichletPointsMultiTet4.hh \
+ TestDirichletBC.hh \
+ TestDirichletBCLine2.hh \
+ TestDirichletBCLine2b.hh \
+ TestDirichletBCTri3.hh \
+ TestDirichletBCQuad4.hh \
+ TestDirichletBCTet4.hh \
+ TestDirichletBCHex8.hh \
+ TestDirichletBCMulti.hh \
+ TestDirichletBCMultiTri3.hh \
+ TestDirichletBCMultiTet4.hh \
TestNeumann.hh \
TestNeumannLine2.hh \
TestNeumannTri3.hh \
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,27 +18,37 @@
#include "data/AbsorbingDampersData.hh" // USES AbsorbingDampersData
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
-#include <stdexcept> // USES std::runtime_error
+#include <stdexcept> // USES std::runtime_erro
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestAbsorbingDampers );
// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::RealSection RealSection;
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
+typedef pylith::topology::SubMesh::RealSection SubRealSection;
+typedef pylith::topology::SubMesh::RestrictVisitor RestrictVisitor;
+
+// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::bc::TestAbsorbingDampers::setUp(void)
{ // setUp
_data = 0;
- _quadrature = 0;
+ _quadrature = new feassemble::Quadrature<topology::SubMesh>();
+ CPPUNIT_ASSERT(0 != _quadrature);
} // setUp
// ----------------------------------------------------------------------
@@ -63,41 +73,42 @@
void
pylith::bc::TestAbsorbingDampers::testInitialize(void)
{ // testInitialize
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
AbsorbingDampers bc;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &bc, &fields);
CPPUNIT_ASSERT(0 != _data);
-
- const ALE::Obj<SubMesh>& boundaryMesh = bc._boundaryMesh;
+ const topology::SubMesh& boundaryMesh = *bc._boundaryMesh;
+ const ALE::Obj<SieveSubMesh>& submesh = boundaryMesh.sieveMesh();
+
// Check boundary mesh
- CPPUNIT_ASSERT(!boundaryMesh.isNull());
+ CPPUNIT_ASSERT(!submesh.isNull());
- const int cellDim = boundaryMesh->getDimension();
- const ALE::Obj<sieve_type>& sieve = boundaryMesh->getSieve();
- const ALE::Obj<SubMesh::label_sequence>& cells = boundaryMesh->heightStratum(1);
- const int numVertices = boundaryMesh->depthStratum(0)->size();
+ const int cellDim = boundaryMesh.dimension();
+ const int numCorners = _data->numCorners;
+ const int spaceDim = _data->spaceDim;
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells = submesh->heightStratum(1);
+ const int numVertices = submesh->depthStratum(0)->size();
const int numCells = cells->size();
+ const int boundaryDepth = submesh->depth()-1; // depth of boundary cells
CPPUNIT_ASSERT_EQUAL(_data->cellDim, cellDim);
CPPUNIT_ASSERT_EQUAL(_data->numVertices, numVertices);
CPPUNIT_ASSERT_EQUAL(_data->numCells, numCells);
- //boundaryMesh->view("BOUNDARY MESH");
-
- const int boundaryDepth = boundaryMesh->depth()-1; // depth of bndry cells
- ALE::ISieveVisitor::PointRetriever<Mesh::sieve_type> pV(sieve->getMaxConeSize());
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = submesh->getSieve();
+ ALE::ISieveVisitor::PointRetriever<SieveSubMesh::sieve_type> pV(sieve->getMaxConeSize());
int dp = 0;
- for(SubMesh::label_sequence::iterator c_iter = cells->begin();
+ for(SieveSubMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cells->end();
++c_iter) {
- const int numCorners = boundaryMesh->getNumCellCorners(*c_iter, boundaryDepth);
+ const int numCorners = submesh->getNumCellCorners(*c_iter, boundaryDepth);
CPPUNIT_ASSERT_EQUAL(_data->numCorners, numCorners);
sieve->cone(*c_iter, pV);
- const Mesh::point_type *cone = pV.getPoints();
+ const SieveSubMesh::point_type *cone = pV.getPoints();
for(int p = 0; p < pV.getSize(); ++p, ++dp) {
CPPUNIT_ASSERT_EQUAL(_data->cells[dp], cone[p]);
}
@@ -105,21 +116,27 @@
} // for
// Check damping constants
- const int sizeE = _data->numCells * _data->numQuadPts * _data->spaceDim;
- const double* valsE = _data->dampingConsts;
+ const int numQuadPts = _data->numQuadPts;
+ const int fiberDim = numQuadPts * spaceDim;
+ double_array dampersCell(fiberDim);
+ int index = 0;
+ const ALE::Obj<SubRealSection>& dampersSection = bc._dampingConsts->section();
- const int size = bc._dampingConsts->sizeWithBC();
- const double* vals = bc._dampingConsts->restrictSpace();
-
- //bc._dampingConsts->view("DAMPING CONSTS");
-
- CPPUNIT_ASSERT_EQUAL(sizeE, size);
const double tolerance = 1.0e-06;
- for (int i=0; i < size; ++i)
- if (fabs(valsE[i]) > 1.0)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, vals[i]/valsE[i], tolerance);
- else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(valsE[i], vals[i], tolerance);
+ for(SieveSubMesh::label_sequence::iterator c_iter = cells->begin();
+ c_iter != cells->end();
+ ++c_iter) {
+ dampersSection->restrictPoint(*c_iter,
+ &dampersCell[0], dampersCell.size());
+ for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
+ for (int iDim =0; iDim < spaceDim; ++iDim) {
+ const double dampersCellData = _data->dampingConsts[index];
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
+ dampersCell[iQuad*spaceDim+iDim]/dampersCellData,
+ tolerance);
+ ++index;
+ } // for
+ } // for
} // testInitialize
// ----------------------------------------------------------------------
@@ -129,26 +146,31 @@
{ // testIntegrateResidual
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
AbsorbingDampers bc;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &bc, &fields);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((mesh)->getDimension());
- cs.initialize();
+ const topology::SubMesh& boundaryMesh = *bc._boundaryMesh;
+ const ALE::Obj<SieveSubMesh>& submesh = boundaryMesh.sieveMesh();
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
- const double t = 1.0;
- bc.integrateResidual(residual, t, &fields, mesh, &cs);
+ topology::Field<topology::Mesh>& residual = fields.get("residual");
+ const double t = 0.0;
+ bc.integrateResidual(residual, t, &fields);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CPPUNIT_ASSERT(!sieveMesh->depthStratum(0).isNull());
+
const double* valsE = _data->valsResidual;
- const int totalNumVertices = mesh->depthStratum(0)->size();
+ const int totalNumVertices = sieveMesh->depthStratum(0)->size();
const int sizeE = _data->spaceDim * totalNumVertices;
- const double* vals = residual->restrictSpace();
- const int size = residual->sizeWithBC();
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ CPPUNIT_ASSERT(!residualSection.isNull());
+
+ const double* vals = residualSection->restrictSpace();
+ const int size = residualSection->sizeWithBC();
CPPUNIT_ASSERT_EQUAL(sizeE, size);
//residual->view("RESIDUAL");
@@ -168,44 +190,45 @@
{ // testIntegrateJacobian
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
AbsorbingDampers bc;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &bc, &fields);
- bc._needNewJacobian = true;
- const ALE::Obj<pylith::real_section_type>& dispTpdt =
- fields.getReal("dispTpdt");
- CPPUNIT_ASSERT(!dispTpdt.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
- PetscMat jacobian;
- //mesh->getFactory()->getGlobalOrder(mesh, "default", dispTpdt)->view("Global Order");
- PetscErrorCode err = MeshCreateMatrix(mesh, dispTpdt, MATMPIBAIJ, &jacobian);
- CPPUNIT_ASSERT(0 == err);
+ const topology::SubMesh& boundaryMesh = *bc._boundaryMesh;
+ const ALE::Obj<SieveSubMesh>& submesh = boundaryMesh.sieveMesh();
+ topology::Field<topology::Mesh>& solution = fields.solution();
+ const ALE::Obj<RealSection>& solutionSection = solution.section();
+ CPPUNIT_ASSERT(!solutionSection.isNull());
+
+ topology::Jacobian jacobian(fields);
+
const double t = 1.0;
- bc.integrateJacobian(&jacobian, t, &fields, mesh);
+ bc.integrateJacobian(&jacobian, t, &fields);
CPPUNIT_ASSERT_EQUAL(false, bc.needNewJacobian());
+ jacobian.assemble("final_assembly");
- err = MatAssemblyBegin(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
- err = MatAssemblyEnd(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
+ CPPUNIT_ASSERT(!sieveMesh->depthStratum(0).isNull());
const double* valsE = _data->valsJacobian;
- const int totalNumVertices = mesh->depthStratum(0)->size();
+ const int totalNumVertices = sieveMesh->depthStratum(0)->size();
const int nrowsE = totalNumVertices * _data->spaceDim;
const int ncolsE = totalNumVertices * _data->spaceDim;
+ const PetscMat jacobianMat = jacobian.matrix();
int nrows = 0;
int ncols = 0;
- MatGetSize(jacobian, &nrows, &ncols);
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(jacobian, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
@@ -239,10 +262,9 @@
// ----------------------------------------------------------------------
void
-pylith::bc::TestAbsorbingDampers::_initialize(
- ALE::Obj<Mesh>* mesh,
- AbsorbingDampers* const bc,
- topology::FieldsManager* fields) const
+pylith::bc::TestAbsorbingDampers::_initialize(topology::Mesh* mesh,
+ AbsorbingDampers* const bc,
+ topology::SolutionFields* fields) const
{ // _initialize
CPPUNIT_ASSERT(0 != mesh);
CPPUNIT_ASSERT(0 != bc);
@@ -254,73 +276,81 @@
// Setup mesh
meshio::MeshIOAscii iohandler;
iohandler.filename(_data->meshFilename);
- //iohandler.debug(true);
iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
- (*mesh)->view("Absorbing mesh");
+ // Set coordinate system
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
+ cs.setSpaceDim(mesh->dimension());
cs.initialize();
+ mesh->coordsys(&cs);
- // Setup quadrature
- _quadrature->initialize(_data->basis, _data->basisDerivRef, _data->quadPts,
- _data->quadWts, _data->cellDim, _data->numBasis,
- _data->numQuadPts, _data->spaceDim);
+ // Set up quadrature
+ _quadrature->initialize(_data->basis, _data->numQuadPts, _data->numBasis,
+ _data->basisDerivRef, _data->numQuadPts,
+ _data->numBasis, _data->cellDim,
+ _data->quadPts, _data->numQuadPts, _data->cellDim,
+ _data->quadWts, _data->numQuadPts,
+ _data->spaceDim);
+ // Set up database
spatialdata::spatialdb::SimpleDB db("TestAbsorbingDampers");
spatialdata::spatialdb::SimpleIOAscii dbIO;
dbIO.filename(_data->spatialDBFilename);
db.ioHandler(&dbIO);
db.queryType(spatialdata::spatialdb::SimpleDB::NEAREST);
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
+ const double upDir[] = { 0.0, 0.0, 1.0 };
bc->quadrature(_quadrature);
bc->timeStep(_data->dt);
bc->label(_data->label);
bc->db(&db);
- bc->initialize(*mesh, &cs, upDir);
+ bc->initialize(*mesh, upDir);
//bc->_boundaryMesh->view("BOUNDARY MESH");
// Setup fields
CPPUNIT_ASSERT(0 != fields);
- fields->addReal("residual");
- fields->addReal("dispTpdt");
- fields->addReal("dispT");
- fields->addReal("dispTmdt");
- fields->solutionField("dispTpdt");
- const char* history[] = { "dispTpdt", "dispT", "dispTmdt" };
+ fields->add("residual", "residual");
+ fields->add("disp(t+dt)", "displacement");
+ fields->add("disp(t)", "displacement");
+ fields->add("disp(t-dt)", "displacement");
+ fields->solutionName("disp(t+dt)");
+ const char* history[] = { "disp(t+dt)", "disp(t)", "disp(t-dt)" };
const int historySize = 3;
fields->createHistory(history, historySize);
- const ALE::Obj<real_section_type>& residual = fields->getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
- residual->setChart((*mesh)->getSieve()->getChart());
- residual->setFiberDimension((*mesh)->depthStratum(0), _data->spaceDim);
- (*mesh)->allocate(residual);
- residual->zero();
+ topology::Field<topology::Mesh>& residual = fields->get("residual");
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ residual.newSection(vertices, _data->spaceDim);
+ residual.allocate();
+ residual.zero();
fields->copyLayout("residual");
-
- const int totalNumVertices = (*mesh)->depthStratum(0)->size();
- const int numMeshCells = (*mesh)->heightStratum(0)->size();
+
+ const int totalNumVertices = sieveMesh->depthStratum(0)->size();
+ const int numMeshCells = sieveMesh->heightStratum(0)->size();
const int fieldSize = _data->spaceDim * totalNumVertices;
- const ALE::Obj<real_section_type>& dispTpdt = fields->getReal("dispTpdt");
- const ALE::Obj<real_section_type>& dispT = fields->getReal("dispT");
- const ALE::Obj<real_section_type>& dispTmdt = fields->getReal("dispTmdt");
- CPPUNIT_ASSERT(!dispTpdt.isNull());
- CPPUNIT_ASSERT(!dispT.isNull());
- CPPUNIT_ASSERT(!dispTmdt.isNull());
+ const ALE::Obj<RealSection>& dispTpdtSection =
+ fields->get("disp(t+dt)").section();
+ const ALE::Obj<RealSection>& dispTSection =
+ fields->get("disp(t)").section();
+ const ALE::Obj<RealSection>& dispTmdtSection =
+ fields->get("disp(t-dt)").section();
+ CPPUNIT_ASSERT(!dispTpdtSection.isNull());
+ CPPUNIT_ASSERT(!dispTSection.isNull());
+ CPPUNIT_ASSERT(!dispTmdtSection.isNull());
const int offset = numMeshCells;
for (int iVertex=0; iVertex < totalNumVertices; ++iVertex) {
- dispTpdt->updatePoint(iVertex+offset,
- &_data->fieldTpdt[iVertex*_data->spaceDim]);
- dispT->updatePoint(iVertex+offset,
- &_data->fieldT[iVertex*_data->spaceDim]);
- dispTmdt->updatePoint(iVertex+offset,
- &_data->fieldTmdt[iVertex*_data->spaceDim]);
+ dispTpdtSection->updatePoint(iVertex+offset,
+ &_data->fieldTpdt[iVertex*_data->spaceDim]);
+ dispTSection->updatePoint(iVertex+offset,
+ &_data->fieldT[iVertex*_data->spaceDim]);
+ dispTmdtSection->updatePoint(iVertex+offset,
+ &_data->fieldTmdt[iVertex*_data->spaceDim]);
} // for
} catch (const ALE::Exception& err) {
throw std::runtime_error(err.msg());
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampers.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,24 +23,16 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/bc/bcfwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
/// Namespace for pylith package
namespace pylith {
namespace bc {
class TestAbsorbingDampers;
-
- class AbsorbingDampers;
class AbsorbingDampersData;
} // bc
-
- namespace feassemble {
- class Quadrature; // HOLDSA Quadrature
- } // feassemble
-
- namespace topology {
- class FieldsManager; // USES FieldsManager
- } // topology
} // pylith
/// C++ unit testing for AbsorbingDampers.
@@ -77,21 +69,20 @@
protected :
AbsorbingDampersData* _data; ///< Data for testing
- feassemble::Quadrature* _quadrature; ///< Data used in testing
+ feassemble::Quadrature<topology::SubMesh>* _quadrature; ///< Used in testing.
// PRIVATE METHODS ////////////////////////////////////////////////////
private :
/** Initialize AbsorbingDampers boundary condition.
*
- * @param mesh PETSc mesh to initialize
- * @param bc AbsorbingDampers boundary condition to initialize.
- * @param cs Mesh coordinate system.
+ * @param mesh Finite-element mesh to initialize
+ * @param bc Neumann boundary condition to initialize.
* @param fields Solution fields.
*/
- void _initialize(ALE::Obj<Mesh>* mesh,
+ void _initialize(topology::Mesh* mesh,
AbsorbingDampers* const bc,
- topology::FieldsManager* fields) const;
+ topology::SolutionFields* fields) const;
}; // class TestAbsorbingDampers
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/AbsorbingDampersDataHex8.hh" // USES AbsorbingDampersDataHex8
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryQuad3D.hh" // USES GeometryQuad3D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestAbsorbingDampersHex8::setUp(void)
{ // setUp
+ TestAbsorbingDampers::setUp();
_data = new AbsorbingDampersDataHex8();
- _quadrature = new feassemble::Quadrature2Din3D();
+ feassemble::GeometryQuad3D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryQuad3D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/AbsorbingDampersDataLine2.hh" // USES AbsorbingDampersDataLine2
-#include "pylith/feassemble/Quadrature0D.hh" // USES Quadrature1D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryPoint1D.hh" // USES GeometryPoint0D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestAbsorbingDampersLine2::setUp(void)
{ // setUp
+ TestAbsorbingDampers::setUp();
_data = new AbsorbingDampersDataLine2();
- _quadrature = new feassemble::Quadrature0D();
+ feassemble::GeometryPoint1D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryPoint1D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/AbsorbingDampersDataQuad4.hh" // USES AbsorbingDampersDataQuad4
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestAbsorbingDampersQuad4::setUp(void)
{ // setUp
+ TestAbsorbingDampers::setUp();
_data = new AbsorbingDampersDataQuad4();
- _quadrature = new feassemble::Quadrature1Din2D();
+ feassemble::GeometryLine2D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/AbsorbingDampersDataTet4.hh" // USES AbsorbingDampersDataTet4
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri3D.hh" // USES GeometryTri3D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestAbsorbingDampersTet4::setUp(void)
{ // setUp
+ TestAbsorbingDampers::setUp();
_data = new AbsorbingDampersDataTet4();
- _quadrature = new feassemble::Quadrature2Din3D();
+ feassemble::GeometryTri3D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryTri3D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestAbsorbingDampersTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/AbsorbingDampersDataTri3.hh" // USES AbsorbingDampersDataTri3
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestAbsorbingDampersTri3::setUp(void)
{ // setUp
+ TestAbsorbingDampers::setUp();
_data = new AbsorbingDampersDataTri3();
- _quadrature = new feassemble::Quadrature1Din2D();
+ feassemble::GeometryLine2D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryCondition.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryCondition.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryCondition.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,7 +14,7 @@
#include "TestBoundaryCondition.hh" // Implementation of class methods
-#include "pylith/bc/DirichletPoints.hh" // USES DirichletPoints
+#include "pylith/bc/DirichletBC.hh" // USES DirichletBC
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -28,11 +28,11 @@
void
pylith::bc::TestBoundaryCondition::testLabel(void)
{ // testLabel
- const std::string label = "the_database";
- DirichletPoints bc;
+ const std::string& label = "the_database";
+ DirichletBC bc;
bc.label(label.c_str());
- CPPUNIT_ASSERT_EQUAL(label, bc.label());
+ CPPUNIT_ASSERT_EQUAL(label, std::string(bc.label()));
} // testLabel
// ----------------------------------------------------------------------
@@ -40,9 +40,9 @@
void
pylith::bc::TestBoundaryCondition::testDB(void)
{ // testDB
- const std::string label = "my db";
+ const std::string& label = "my db";
spatialdata::spatialdb::SimpleDB db(label.c_str());
- DirichletPoints bc;
+ DirichletBC bc;
bc.db(&db);
CPPUNIT_ASSERT(0 != bc._db);
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryMesh.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestBoundaryMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,12 +16,16 @@
#include "data/BoundaryMeshData.hh" // USES BoundaryMeshData
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultsCohesiveKin
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-#include <Selection.hh> // USES submesh algorithms
+// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
// ----------------------------------------------------------------------
// Setup testing data.
@@ -46,49 +50,52 @@
{ // testSubmesh
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
-
+ topology::Mesh mesh;
meshio::MeshIOAscii iohandler;
iohandler.filename(_data->filename);
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const char* label = _data->bcLabel;
- const ALE::Obj<SubMesh>& subMesh =
- ALE::Selection<Mesh>::submeshV<SubMesh>(mesh, mesh->getIntSection(label));
- CPPUNIT_ASSERT(!subMesh.isNull());
+ // Set coordinate system
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(mesh.dimension());
+ cs.initialize();
+ mesh.coordsys(&cs);
- //subMesh->view("SUBMESH WITHOUT FAULT");
+ // Create submesh
+ topology::SubMesh submesh(mesh, _data->bcLabel);
+ CPPUNIT_ASSERT(!submesh.sieveMesh().isNull());
- const ALE::Obj<SubMesh::label_sequence>& vertices = subMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
-
+ // Check vertices
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ submesh.sieveMesh()->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
CPPUNIT_ASSERT_EQUAL(_data->numVerticesNoFault, int(vertices->size()));
int ipt = 0;
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++ipt)
CPPUNIT_ASSERT_EQUAL(_data->verticesNoFault[ipt], *v_iter);
- const ALE::Obj<SubMesh::label_sequence>& cells = subMesh->heightStratum(1);
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
- const ALE::Obj<sieve_type>& sieve = subMesh->getSieve();
+ // Check cells
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ submesh.sieveMesh()->heightStratum(1);
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
+ const ALE::Obj<SieveSubMesh::sieve_type>& sieve =
+ submesh.sieveMesh()->getSieve();
assert(!sieve.isNull());
+ CPPUNIT_ASSERT_EQUAL(_data->numCells, int(cells->size()));
- CPPUNIT_ASSERT_EQUAL(_data->numCells, (int) cells->size());
+ ALE::ISieveVisitor::NConeRetriever<SieveSubMesh::sieve_type> ncV(*sieve, (int) pow(sieve->getMaxConeSize(), submesh.sieveMesh()->depth()));
- ALE::ISieveVisitor::NConeRetriever<sieve_type> ncV(*sieve, (int) pow(sieve->getMaxConeSize(), subMesh->depth()));
-
int icell = 0;
int index = 0;
- for (SubMesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveSubMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter, ++icell) {
- ALE::ISieveTraversal<sieve_type>::orientedClosure(*sieve, *c_iter, ncV);
- const int coneSize = ncV.getSize();
- const Mesh::point_type *cone = ncV.getPoints();
-
+ ALE::ISieveTraversal<SieveSubMesh::sieve_type>::orientedClosure(*sieve, *c_iter, ncV);
+ const int coneSize = ncV.getSize();
+ const SieveSubMesh::point_type *cone = ncV.getPoints();
CPPUNIT_ASSERT_EQUAL(_data->numCorners, coneSize);
for(int v = 0; v < coneSize; ++v, ++index)
@@ -104,55 +111,58 @@
{ // testSubmeshFault
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
-
+ topology::Mesh mesh;
meshio::MeshIOAscii iohandler;
iohandler.filename(_data->filename);
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
+ // Set coordinate system
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(mesh.dimension());
+ cs.initialize();
+ mesh.coordsys(&cs);
+
+ // Adjust topology
faults::FaultCohesiveKin fault;
fault.label(_data->faultLabel);
fault.id(_data->faultId);
- fault.adjustTopology(mesh, _flipFault);
+ fault.adjustTopology(&mesh, _flipFault);
- const char* label = _data->bcLabel;
- const ALE::Obj<SubMesh>& subMesh =
- ALE::Selection<Mesh>::submeshV<SubMesh>(mesh, mesh->getIntSection(label));
- CPPUNIT_ASSERT(!subMesh.isNull());
+ // Create submesh
+ topology::SubMesh submesh(mesh, _data->bcLabel);
+ CPPUNIT_ASSERT(!submesh.sieveMesh().isNull());
- //subMesh->view("Submesh for mesh w/fault");
- const ALE::Obj<SubMesh::label_sequence>& vertices = subMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
-
+ // Check vertices
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ submesh.sieveMesh()->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
CPPUNIT_ASSERT_EQUAL(_data->numVerticesFault, int(vertices->size()));
int ipt = 0;
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++ipt)
CPPUNIT_ASSERT_EQUAL(_data->verticesFault[ipt], *v_iter);
-
- const ALE::Obj<SubMesh::label_sequence>& cells = subMesh->depthStratum(1);
- const SubMesh::label_sequence::iterator cellsEnd = cells->end();
- const ALE::Obj<sieve_type>& sieve = subMesh->getSieve();
+
+ // Check cells
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells =
+ submesh.sieveMesh()->heightStratum(1);
+ const SieveSubMesh::label_sequence::iterator cellsEnd = cells->end();
+ const ALE::Obj<SieveSubMesh::sieve_type>& sieve =
+ submesh.sieveMesh()->getSieve();
assert(!sieve.isNull());
- const int depth = 1;
- typedef ALE::SieveAlg<Mesh> SieveAlg;
-
CPPUNIT_ASSERT_EQUAL(_data->numCells, int(cells->size()));
- ALE::ISieveVisitor::NConeRetriever<sieve_type> ncV(*sieve, (int) pow(sieve->getMaxConeSize(), subMesh->depth()));
+ ALE::ISieveVisitor::NConeRetriever<SieveSubMesh::sieve_type> ncV(*sieve, (int) pow(sieve->getMaxConeSize(), submesh.sieveMesh()->depth()));
int icell = 0;
int index = 0;
- for (SubMesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveSubMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter, ++icell) {
- ALE::ISieveTraversal<sieve_type>::orientedClosure(*sieve, *c_iter, ncV);
- const int coneSize = ncV.getSize();
- const Mesh::point_type *cone = ncV.getPoints();
-
+ ALE::ISieveTraversal<SieveSubMesh::sieve_type>::orientedClosure(*sieve, *c_iter, ncV);
+ const int coneSize = ncV.getSize();
+ const SieveSubMesh::point_type *cone = ncV.getPoints();
CPPUNIT_ASSERT_EQUAL(_data->numCorners, coneSize);
for(int v = 0; v < coneSize; ++v, ++index)
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBC.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,343 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBC.hh" // Implementation of class methods
+
+#include "pylith/bc/DirichletBC.hh" // USES DirichletBC
+
+#include "data/DirichletData.hh" // USES DirichletData
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
+#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
+#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBC );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBC::setUp(void)
+{ // setUp
+ _data = 0;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::bc::TestDirichletBC::tearDown(void)
+{ // tearDown
+ delete _data; _data = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::bc::TestDirichletBC::testConstructor(void)
+{ // testConstructor
+ DirichletBC bc;
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test fixedDOF()
+void
+pylith::bc::TestDirichletBC::testFixedDOF(void)
+{ // testfixedDOF
+ DirichletBC bc;
+
+ const size_t numDOF = 4;
+ const int fixedDOF[] = { 0, 2, 3, 5 };
+ bc.fixedDOF(fixedDOF, numDOF);
+
+ CPPUNIT_ASSERT_EQUAL(numDOF, bc._fixedDOF.size());
+ for (int i=0; i < numDOF; ++i)
+ CPPUNIT_ASSERT_EQUAL(fixedDOF[i], bc._fixedDOF[i]);
+} // testFixedDOF
+
+// ----------------------------------------------------------------------
+// Test initialize().
+void
+pylith::bc::TestDirichletBC::testInitialize(void)
+{ // testInitialize
+ topology::Mesh mesh;
+ DirichletBC bc;
+ _initialize(&mesh, &bc);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ const int numFixedDOF = _data->numFixedDOF;
+ const size_t numPoints = _data->numConstrainedPts;
+
+ // Check points
+ const int offset = numCells;
+ if (numFixedDOF > 0) {
+ CPPUNIT_ASSERT_EQUAL(numPoints, bc._points.size());
+ for (int i=0; i < numPoints; ++i)
+ CPPUNIT_ASSERT_EQUAL(_data->constrainedPoints[i]+offset, bc._points[i]);
+ } // if
+
+ // Check values
+ const size_t size = numPoints * numFixedDOF;
+ CPPUNIT_ASSERT_EQUAL(size, bc._valuesInitial.size());
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valuesInitial[i], bc._valuesInitial[i],
+ tolerance);
+
+ CPPUNIT_ASSERT_EQUAL(size, bc._valuesRate.size());
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valueRate, bc._valuesRate[i],
+ tolerance);
+} // testInitialize
+
+// ----------------------------------------------------------------------
+// Test setConstraintSizes().
+void
+pylith::bc::TestDirichletBC::testSetConstraintSizes(void)
+{ // testSetConstraintSizes
+ topology::Mesh mesh;
+ DirichletBC bc;
+ _initialize(&mesh, &bc);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const int fiberDim = _data->numDOF;
+ topology::Field<topology::Mesh> field(mesh);
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<RealSection>& fieldSection = field.section();
+ CPPUNIT_ASSERT(!fieldSection.isNull());
+
+ bc.setConstraintSizes(field);
+
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ const int offset = numCells;
+ int iConstraint = 0;
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
+ CPPUNIT_ASSERT_EQUAL(_data->numDOF,
+ fieldSection->getFiberDimension(*v_iter));
+ CPPUNIT_ASSERT_EQUAL(0,
+ fieldSection->getConstraintDimension(*v_iter));
+ } else {
+ CPPUNIT_ASSERT_EQUAL(_data->numDOF,
+ fieldSection->getFiberDimension(*v_iter));
+ CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF,
+ fieldSection->getConstraintDimension(*v_iter));
+ ++iConstraint;
+ } // if/else
+ } // for
+} // testSetConstraintSizes
+
+// ----------------------------------------------------------------------
+// Test setConstraints().
+void
+pylith::bc::TestDirichletBC::testSetConstraints(void)
+{ // testSetConstraints
+ topology::Mesh mesh;
+ DirichletBC bc;
+ _initialize(&mesh, &bc);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const int fiberDim = _data->numDOF;
+ topology::Field<topology::Mesh> field(mesh);
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<RealSection>& fieldSection = field.section();
+ CPPUNIT_ASSERT(!fieldSection.isNull());
+
+ bc.setConstraintSizes(field);
+ field.allocate();
+ bc.setConstraints(field);
+
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ const int offset = numCells;
+ int iConstraint = 0;
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ const int* fixedDOF = fieldSection->getConstraintDof(*v_iter);
+ if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
+ CPPUNIT_ASSERT_EQUAL(0, fieldSection->getConstraintDimension(*v_iter));
+ //CPPUNIT_ASSERT(0 == fixedDOF);
+ } else {
+ CPPUNIT_ASSERT(0 != fixedDOF);
+ CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF,
+ fieldSection->getConstraintDimension(*v_iter));
+ for (int iDOF=0; iDOF < _data->numFixedDOF; ++iDOF)
+ CPPUNIT_ASSERT_EQUAL(_data->fixedDOF[iDOF], fixedDOF[iDOF]);
+ ++iConstraint;
+ } // if/else
+ } // for
+} // testSetConstraints
+
+// ----------------------------------------------------------------------
+// Test setField().
+void
+pylith::bc::TestDirichletBC::testSetField(void)
+{ // testSetField
+ topology::Mesh mesh;
+ DirichletBC bc;
+ _initialize(&mesh, &bc);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const int fiberDim = _data->numDOF;
+ topology::Field<topology::Mesh> field(mesh);
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<RealSection>& fieldSection = field.section();
+ CPPUNIT_ASSERT(!fieldSection.isNull());
+
+ bc.setConstraintSizes(field);
+ field.allocate();
+ bc.setConstraints(field);
+
+ const double tolerance = 1.0e-06;
+
+ // All values should be zero.
+ field.zero();
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ const int fiberDim = fieldSection->getFiberDimension(*v_iter);
+ const RealSection::value_type* values =
+ sieveMesh->restrictClosure(fieldSection, *v_iter);
+ for (int i=0; i < fiberDim; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
+ } // for
+
+ // Only unconstrained values should be zero.
+ const double t = 1.0;
+ bc.setField(t, field);
+
+ // Create list of unconstrained DOF at constrained DOF
+ const int numFreeDOF = _data->numDOF - _data->numFixedDOF;
+ int_array freeDOF(numFreeDOF);
+ int index = 0;
+ for (int iDOF=0; iDOF < _data->numDOF; ++iDOF) {
+ bool free = true;
+ for (int iFixed=0; iFixed < _data->numFixedDOF; ++iFixed)
+ if (iDOF == _data->fixedDOF[iFixed])
+ free = false;
+ if (free)
+ freeDOF[index] = iDOF;
+ } // for
+
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ const int offset = numCells;
+ const int numFixedDOF = _data->numFixedDOF;
+ int iConstraint = 0;
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ const int fiberDim = fieldSection->getFiberDimension(*v_iter);
+ const RealSection::value_type* values =
+ sieveMesh->restrictClosure(fieldSection, *v_iter);
+
+ if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
+ // unconstrained point
+ for (int i=0; i < fiberDim; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
+ } else {
+ // constrained point
+
+ // check unconstrained DOF
+ for (int iDOF=0; iDOF < numFreeDOF; ++iDOF)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[freeDOF[iDOF]], tolerance);
+
+ // check constrained DOF
+ for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
+ const int index = iConstraint * numFixedDOF + iDOF;
+ const double valueE = (t > _data->tRef) ?
+ _data->valuesInitial[index] + (t-_data->tRef)*_data->valueRate :
+ _data->valuesInitial[index];
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[_data->fixedDOF[iDOF]],
+ tolerance);
+ } // for
+ ++iConstraint;
+ } // if/else
+ } // for
+} // testSetField
+
+// ----------------------------------------------------------------------
+void
+pylith::bc::TestDirichletBC::_initialize(topology::Mesh* mesh,
+ DirichletBC* const bc) const
+{ // _initialize
+ CPPUNIT_ASSERT(0 != _data);
+ CPPUNIT_ASSERT(0 != bc);
+
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename(_data->meshFilename);
+ iohandler.read(mesh);
+
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
+
+ spatialdata::spatialdb::SimpleDB db("TestDirichletBC initial");
+ spatialdata::spatialdb::SimpleIOAscii dbIO;
+ dbIO.filename(_data->dbFilename);
+ db.ioHandler(&dbIO);
+ db.queryType(spatialdata::spatialdb::SimpleDB::NEAREST);
+
+ spatialdata::spatialdb::UniformDB dbRate("TestDirichletBC rate");
+ const char* names[] = { "dof-0", "dof-1", "dof-2" };
+ const double values[] = { _data->valueRate,
+ _data->valueRate,
+ _data->valueRate };
+ const int numValues = 3;
+ dbRate.setData(names, values, numValues);
+
+ const double upDir[] = { 0.0, 0.0, 1.0 };
+
+ bc->label(_data->label);
+ bc->db(&db);
+ bc->dbRate(&dbRate);
+ bc->referenceTime(_data->tRef);
+ bc->fixedDOF(_data->fixedDOF, _data->numFixedDOF);
+ bc->initialize(*mesh, upDir);
+} // _initialize
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBC.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBC.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBC.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC.
+ */
+
+#if !defined(pylith_bc_testdirichletbc_hh)
+#define pylith_bc_testdirichletbc_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/bc/bcfwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBC;
+ class DirichletData;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC.
+class pylith::bc::TestDirichletBC : public CppUnit::TestFixture
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDirichletBC );
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testFixedDOF );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test fixedDOF().
+ void testFixedDOF(void);
+
+ /// Test initialize().
+ void testInitialize(void);
+
+ /// Test setConstraintSizes().
+ void testSetConstraintSizes(void);
+
+ /// Test setConstraints().
+ void testSetConstraints(void);
+
+ /// Test setField().
+ void testSetField(void);
+
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ DirichletData* _data; ///< Data for testing
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Initialize DirichletBC boundary condition.
+ *
+ * @param mesh Finite-element mesh to initialize.
+ * @param bc DirichletBC boundary condition to initialize.
+ */
+ void _initialize(topology::Mesh* mesh,
+ DirichletBC* const bc) const;
+
+}; // class TestDirichletBC
+
+#endif // pylith_bc_dirichletbc_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCHex8.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCHex8.hh" // Implementation of class methods
+
+#include "data/DirichletDataHex8.hh" // USES DirichletDataHex8
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCHex8 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCHex8::setUp(void)
+{ // setUp
+ _data = new DirichletDataHex8();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCHex8.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCHex8.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbchex8_hh)
+#define pylith_bc_testdirichletbchex8_hh
+
+#include "TestDirichletBC.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCHex8;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 3-D hex cells.
+class pylith::bc::TestDirichletBCHex8 : public TestDirichletBC
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUB_SUITE( TestDirichletBCHex8, TestDirichletBC );
+ CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCHex8
+
+#endif // pylith_bc_dirichletbchex8_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCLine2.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCLine2.hh" // Implementation of class methods
+
+#include "data/DirichletDataLine2.hh" // USES DirichletDataLine2
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCLine2 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCLine2::setUp(void)
+{ // setUp
+ _data = new DirichletDataLine2();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCLine2.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCLine2.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbcline2_hh)
+#define pylith_bc_testdirichletbcline2_hh
+
+#include "TestDirichletBC.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCLine2;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 1-D line cells.
+class pylith::bc::TestDirichletBCLine2 : public TestDirichletBC
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUB_SUITE( TestDirichletBCLine2, TestDirichletBC );
+ CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCLine2
+
+#endif // pylith_bc_dirichletbcline2_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCLine2b.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCLine2b.hh" // Implementation of class methods
+
+#include "data/DirichletDataLine2b.hh" // USES DirichletDataLine2b
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCLine2b );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCLine2b::setUp(void)
+{ // setUp
+ _data = new DirichletDataLine2b();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCLine2b.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCLine2b.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCLine2b.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbcline2b_hh)
+#define pylith_bc_testdirichletbcline2b_hh
+
+#include "TestDirichletBC.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCLine2b;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 1-D line cells.
+class pylith::bc::TestDirichletBCLine2b : public TestDirichletBC
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUB_SUITE( TestDirichletBCLine2b, TestDirichletBC );
+ CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCLine2b
+
+#endif // pylith_bc_dirichletbcline2b_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCMulti.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,277 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCMulti.hh" // Implementation of class methods
+
+#include "pylith/bc/DirichletBC.hh" // USES DirichletBC
+
+#include "data/DirichletDataMulti.hh" // USES DirichletData
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
+#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
+#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCMulti::setUp(void)
+{ // setUp
+ _data = 0;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::bc::TestDirichletBCMulti::tearDown(void)
+{ // tearDown
+ delete _data; _data = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test setConstraintSizes().
+void
+pylith::bc::TestDirichletBCMulti::testSetConstraintSizes(void)
+{ // testSetConstraintSizes
+ topology::Mesh mesh;
+ DirichletBC bcA;
+ DirichletBC bcB;
+ DirichletBC bcC;
+ _initialize(&mesh, &bcA, &bcB, &bcC);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const int fiberDim = _data->numDOF;
+ topology::Field<topology::Mesh> field(mesh);
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<RealSection>& fieldSection = field.section();
+ CPPUNIT_ASSERT(!fieldSection.isNull());
+
+ bcA.setConstraintSizes(field);
+ bcB.setConstraintSizes(field);
+ bcC.setConstraintSizes(field);
+
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ const int offset = numCells;
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ CPPUNIT_ASSERT_EQUAL(_data->numDOF,
+ fieldSection->getFiberDimension(*v_iter));
+
+ CPPUNIT_ASSERT_EQUAL(_data->constraintSizes[*v_iter-offset],
+ fieldSection->getConstraintDimension(*v_iter));
+ } // for
+} // testSetConstraintSizes
+
+// ----------------------------------------------------------------------
+// Test setConstraints().
+void
+pylith::bc::TestDirichletBCMulti::testSetConstraints(void)
+{ // testSetConstraints
+ topology::Mesh mesh;
+ DirichletBC bcA;
+ DirichletBC bcB;
+ DirichletBC bcC;
+ _initialize(&mesh, &bcA, &bcB, &bcC);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const int fiberDim = _data->numDOF;
+ topology::Field<topology::Mesh> field(mesh);
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<RealSection>& fieldSection = field.section();
+ CPPUNIT_ASSERT(!fieldSection.isNull());
+
+ bcA.setConstraintSizes(field);
+ bcB.setConstraintSizes(field);
+ bcC.setConstraintSizes(field);
+ field.allocate();
+ bcA.setConstraints(field);
+ bcB.setConstraints(field);
+ bcC.setConstraints(field);
+
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ const int offset = numCells;
+ int index = 0;
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ const int numConstrainedDOF = _data->constraintSizes[*v_iter-offset];
+ if (numConstrainedDOF > 0) {
+ const int* fixedDOF = fieldSection->getConstraintDof(*v_iter);
+ for (int iDOF=0; iDOF < numConstrainedDOF; ++iDOF)
+ CPPUNIT_ASSERT_EQUAL(_data->constrainedDOF[index++], fixedDOF[iDOF]);
+ } // if
+ } // for
+} // testSetConstraints
+
+// ----------------------------------------------------------------------
+// Test setField().
+void
+pylith::bc::TestDirichletBCMulti::testSetField(void)
+{ // testSetField
+ topology::Mesh mesh;
+ DirichletBC bcA;
+ DirichletBC bcB;
+ DirichletBC bcC;
+ _initialize(&mesh, &bcA, &bcB, &bcC);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const int fiberDim = _data->numDOF;
+ topology::Field<topology::Mesh> field(mesh);
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<RealSection>& fieldSection = field.section();
+ CPPUNIT_ASSERT(!fieldSection.isNull());
+
+ bcA.setConstraintSizes(field);
+ bcB.setConstraintSizes(field);
+ bcC.setConstraintSizes(field);
+ field.allocate();
+ bcA.setConstraints(field);
+ bcB.setConstraints(field);
+ bcC.setConstraints(field);
+
+ const double tolerance = 1.0e-06;
+
+ // All values should be zero.
+ field.zero();
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ const int fiberDim = fieldSection->getFiberDimension(*v_iter);
+ const RealSection::value_type* values =
+ sieveMesh->restrictClosure(fieldSection, *v_iter);
+ for (int i=0; i < fiberDim; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
+ } // for
+
+ // Only unconstrained values should be zero.
+ // Expected values set in _data->field
+ const double t = 10.0;
+ bcA.setField(t, field);
+ bcB.setField(t, field);
+ bcC.setField(t, field);
+
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter = vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ const int fiberDim = fieldSection->getFiberDimension(*v_iter);
+ const RealSection::value_type* values =
+ sieveMesh->restrictClosure(fieldSection, *v_iter);
+ for (int iDOF=0; iDOF < fiberDim; ++iDOF)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->field[i++], values[iDOF], tolerance);
+ } // for
+} // testSetField
+
+// ----------------------------------------------------------------------
+void
+pylith::bc::TestDirichletBCMulti::_initialize(topology::Mesh* mesh,
+ DirichletBC* const bcA,
+ DirichletBC* const bcB,
+ DirichletBC* const bcC) const
+{ // _initialize
+ CPPUNIT_ASSERT(0 != _data);
+ CPPUNIT_ASSERT(0 != bcA);
+ CPPUNIT_ASSERT(0 != bcB);
+ CPPUNIT_ASSERT(0 != bcC);
+
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename(_data->meshFilename);
+ iohandler.read(mesh);
+
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
+
+ // Setup boundary condition A
+ spatialdata::spatialdb::SimpleDB db("TestDirichletBCMulti initial");
+ spatialdata::spatialdb::SimpleIOAscii dbIO;
+ dbIO.filename(_data->dbFilenameA);
+ db.ioHandler(&dbIO);
+
+ spatialdata::spatialdb::SimpleDB dbRate("TestDirichletBCMulti rate");
+ spatialdata::spatialdb::SimpleIOAscii dbIORate;
+ dbIORate.filename(_data->dbFilenameARate);
+ dbRate.ioHandler(&dbIORate);
+
+ const double upDir[] = { 0.0, 0.0, 1.0 };
+
+ bcA->label(_data->labelA);
+ bcA->db(&db);
+ bcA->dbRate(&dbRate);
+ bcA->referenceTime(_data->tRefA);
+ bcA->fixedDOF(_data->fixedDOFA, _data->numFixedDOFA);
+ bcA->initialize(*mesh, upDir);
+
+ // Setup boundary condition B
+ dbIO.filename(_data->dbFilenameB);
+ db.ioHandler(&dbIO);
+
+ dbIORate.filename(_data->dbFilenameBRate);
+ dbRate.ioHandler(&dbIORate);
+
+ bcB->label(_data->labelB);
+ bcB->db(&db);
+ bcB->dbRate(&dbRate);
+ bcB->referenceTime(_data->tRefB);
+ bcB->fixedDOF(_data->fixedDOFB, _data->numFixedDOFB);
+ bcB->initialize(*mesh, upDir);
+
+ // Setup boundary condition C
+ if (_data->numFixedDOFC > 0.0) {
+ dbIO.filename(_data->dbFilenameC);
+ db.ioHandler(&dbIO);
+
+ dbIORate.filename(_data->dbFilenameCRate);
+ dbRate.ioHandler(&dbIORate);
+
+ bcC->label(_data->labelC);
+ bcC->db(&db);
+ bcC->dbRate(&dbRate);
+ bcC->referenceTime(_data->tRefC);
+ bcC->fixedDOF(_data->fixedDOFC, _data->numFixedDOFC);
+ bcC->initialize(*mesh, upDir);
+ } // if
+} // _initialize
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCMulti.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMulti.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCMulti.hh
+ *
+ * @brief C++ TestDirichletBCMulti object.
+ *
+ * C++ unit testing for DirichletBCMulti.
+ */
+
+#if !defined(pylith_bc_testdirichletbcmulti_hh)
+#define pylith_bc_testdirichletbcmulti_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/bc/bcfwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCMulti;
+ class DirichletDataMulti;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBCMulti.
+class pylith::bc::TestDirichletBCMulti : public CppUnit::TestFixture
+{ // class TestDirichletBCMulti
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test setConstraintSizes().
+ void testSetConstraintSizes(void);
+
+ /// Test setConstraints().
+ void testSetConstraints(void);
+
+ /// Test setField().
+ void testSetField(void);
+
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ DirichletDataMulti* _data; ///< Data for testing
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Initialize DirichletBCMulti boundary condition.
+ *
+ * @param mesh Finite-element mesh to initialize.
+ * @param bcA DirichletBC boundary condition A to initialize.
+ * @param bcB DirichletBC boundary condition B to initialize.
+ * @param bcC DirichletBC boundary condition C to initialize.
+ */
+ void _initialize(topology::Mesh* mesh,
+ DirichletBC* const bcA,
+ DirichletBC* const bcB,
+ DirichletBC* const bcC) const;
+
+}; // class TestDirichletBCMulti
+
+#endif // pylith_bc_dirichletbcmulti_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCMultiTet4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCMultiTet4.hh" // Implementation of class methods
+
+#include "data/DirichletDataMultiTet4.hh" // USES DirichletDataMultiTet4
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCMultiTet4 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCMultiTet4::setUp(void)
+{ // setUp
+ _data = new DirichletDataMultiTet4();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCMultiTet4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCMultiTet4.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbcmultitet4_hh)
+#define pylith_bc_testdirichletbcmultitet4_hh
+
+#include "TestDirichletBCMulti.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCMultiTet4;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 2-D tri cells.
+class pylith::bc::TestDirichletBCMultiTet4 : public TestDirichletBCMulti
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDirichletBCMultiTet4 );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCMultiTet4
+
+#endif // pylith_bc_dirichletbcmultitet4_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCMultiTri3.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCMultiTri3.hh" // Implementation of class methods
+
+#include "data/DirichletDataMultiTri3.hh" // USES DirichletDataMultiTri3
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCMultiTri3 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCMultiTri3::setUp(void)
+{ // setUp
+ _data = new DirichletDataMultiTri3();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCMultiTri3.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCMultiTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCMultiTri3.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbcmultitri3_hh)
+#define pylith_bc_testdirichletbcmultitri3_hh
+
+#include "TestDirichletBCMulti.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCMultiTri3;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 2-D tri cells.
+class pylith::bc::TestDirichletBCMultiTri3 : public TestDirichletBCMulti
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDirichletBCMultiTri3 );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCMultiTri3
+
+#endif // pylith_bc_dirichletbcmultitri3_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCQuad4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCQuad4.hh" // Implementation of class methods
+
+#include "data/DirichletDataQuad4.hh" // USES DirichletDataQuad4
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCQuad4 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCQuad4::setUp(void)
+{ // setUp
+ _data = new DirichletDataQuad4();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCQuad4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCQuad4.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbcquad4_hh)
+#define pylith_bc_testdirichletbcquad4_hh
+
+#include "TestDirichletBC.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCQuad4;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 2-D quad cells.
+class pylith::bc::TestDirichletBCQuad4 : public TestDirichletBC
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUB_SUITE( TestDirichletBCQuad4, TestDirichletBC );
+ CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCQuad4
+
+#endif // pylith_bc_dirichletbcquad4_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCTet4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCTet4.hh" // Implementation of class methods
+
+#include "data/DirichletDataTet4.hh" // USES DirichletDataTet4
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCTet4 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCTet4::setUp(void)
+{ // setUp
+ _data = new DirichletDataTet4();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCTet4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCTet4.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbctet4_hh)
+#define pylith_bc_testdirichletbcet4_hh
+
+#include "TestDirichletBC.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCTet4;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 3-D tet cells.
+class pylith::bc::TestDirichletBCTet4 : public TestDirichletBC
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUB_SUITE( TestDirichletBCTet4, TestDirichletBC );
+ CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCTet4
+
+#endif // pylith_bc_dirichletbctet4_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCTri3.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDirichletBCTri3.hh" // Implementation of class methods
+
+#include "data/DirichletDataTri3.hh" // USES DirichletDataTri3
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBCTri3 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::bc::TestDirichletBCTri3::setUp(void)
+{ // setUp
+ _data = new DirichletDataTri3();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/bc/TestDirichletBCTri3.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBCTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,56 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/bc/TestDirichletBCTri3.hh
+ *
+ * @brief C++ TestDirichletBC object.
+ *
+ * C++ unit testing for DirichletBC for mesh with 1-D line cells.
+ */
+
+#if !defined(pylith_bc_testdirichletbctri3_hh)
+#define pylith_bc_testdirichletbctri3_hh
+
+#include "TestDirichletBC.hh" // ISA TestDirichletBC
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace bc {
+ class TestDirichletBCTri3;
+ } // bc
+} // pylith
+
+/// C++ unit testing for DirichletBC for mesh with 2-D tri cells.
+class pylith::bc::TestDirichletBCTri3 : public TestDirichletBC
+{ // class TestDirichletBC
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUB_SUITE( TestDirichletBCTri3, TestDirichletBC );
+ CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testSetConstraintSizes );
+ CPPUNIT_TEST( testSetConstraints );
+ CPPUNIT_TEST( testSetField );
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDirichletBCTri3
+
+#endif // pylith_bc_dirichletbctri3_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,8 +17,10 @@
#include "pylith/bc/DirichletBoundary.hh" // USES DirichletBoundary
#include "data/DirichletData.hh" // USES DirichletData
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -29,6 +31,9 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBoundary );
// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::bc::TestDirichletBoundary::setUp(void)
@@ -53,47 +58,30 @@
} // testConstructor
// ----------------------------------------------------------------------
-// Test fixedDOF()
-void
-pylith::bc::TestDirichletBoundary::testFixedDOF(void)
-{ // testfixedDOF
- DirichletBoundary bc;
-
- const size_t numDOF = 4;
- const int dof[] = { 0, 2, 3, 5 };
- int_array fixedDOF(dof, numDOF);
- bc.fixedDOF(fixedDOF);
-
- CPPUNIT_ASSERT_EQUAL(numDOF, bc._fixedDOF.size());
- for (int i=0; i < numDOF; ++i)
- CPPUNIT_ASSERT_EQUAL(fixedDOF[i], bc._fixedDOF[i]);
-} // testFixedDOF
-
-#include <iostream>
-// ----------------------------------------------------------------------
// Test initialize().
void
pylith::bc::TestDirichletBoundary::testInitialize(void)
{ // testInitialize
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
DirichletBoundary bc;
_initialize(&mesh, &bc);
CPPUNIT_ASSERT(0 != _data);
- const int numCells = mesh->heightStratum(0)->size();
+ const int numCells = mesh.sieveMesh()->heightStratum(0)->size();
const int numFixedDOF = _data->numFixedDOF;
const size_t numBoundary = _data->numConstrainedPts;
// Check vertices in boundary mesh
- const ALE::Obj<SubMesh::label_sequence>& vertices =
- bc._boundaryMesh->depthStratum(0);
- const SubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = bc._boundaryMesh->sieveMesh();
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
const int offset = numCells;
if (numFixedDOF > 0) {
int i = 0;
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++i) {
CPPUNIT_ASSERT_EQUAL(_data->constrainedPoints[i]+offset, *v_iter);
@@ -101,191 +89,24 @@
CPPUNIT_ASSERT_EQUAL(int(numBoundary), i);
} // if
- // Check initial and rate values
- int i = 0;
- for (SubMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter) {
- CPPUNIT_ASSERT_EQUAL(2*numFixedDOF,
- bc._values->getFiberDimension(*v_iter));
+ // Check values
+ const size_t size = numBoundary * numFixedDOF;
+ CPPUNIT_ASSERT_EQUAL(size, bc._valuesInitial.size());
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valuesInitial[i], bc._valuesInitial[i],
+ tolerance);
- const real_section_type::value_type* values =
- bc._values->restrictPoint(*v_iter);
-
- const double tolerance = 1.0e-06;
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF, ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valuesInitial[i], values[iDOF],
- tolerance);
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valueRate, values[numFixedDOF+iDOF],
- tolerance);
- } // for
+ CPPUNIT_ASSERT_EQUAL(size, bc._valuesRate.size());
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valueRate, bc._valuesRate[i],
+ tolerance);
} // testInitialize
// ----------------------------------------------------------------------
-// Test setConstraintSizes().
void
-pylith::bc::TestDirichletBoundary::testSetConstraintSizes(void)
-{ // testSetConstraintSizes
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bc;
- _initialize(&mesh, &bc);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bc.setConstraintSizes(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int iConstraint = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, field->getConstraintDimension(*v_iter));
- } else {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF,
- field->getConstraintDimension(*v_iter));
- ++iConstraint;
- } // if/else
- } // for
-} // testSetConstraintSizes
-
-// ----------------------------------------------------------------------
-// Test setConstraints().
-void
-pylith::bc::TestDirichletBoundary::testSetConstraints(void)
-{ // testSetConstraints
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bc;
- _initialize(&mesh, &bc);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bc.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bc.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int iConstraint = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int* fixedDOF = field->getConstraintDof(*v_iter);
- if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
- CPPUNIT_ASSERT_EQUAL(0, field->getConstraintDimension(*v_iter));
- //CPPUNIT_ASSERT(0 == fixedDOF);
- } else {
- CPPUNIT_ASSERT(0 != fixedDOF);
- CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF,
- field->getConstraintDimension(*v_iter));
- for (int iDOF=0; iDOF < _data->numFixedDOF; ++iDOF)
- CPPUNIT_ASSERT_EQUAL(_data->fixedDOF[iDOF], fixedDOF[iDOF]);
- ++iConstraint;
- } // if/else
- } // for
-} // testSetConstraints
-
-// ----------------------------------------------------------------------
-// Test setField().
-void
-pylith::bc::TestDirichletBoundary::testSetField(void)
-{ // testSetField
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bc;
- _initialize(&mesh, &bc);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bc.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bc.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
- const double tolerance = 1.0e-06;
-
- // All values should be zero.
- field->zero();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int i=0; i < fiberDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
- } // for
-
- // Only unconstrained values should be zero.
- const double t = 1.0;
- bc.setField(t, field, mesh);
-
- // Create list of unconstrained DOF at constrained DOF
- const int numFreeDOF = _data->numDOF - _data->numFixedDOF;
- int_array freeDOF(numFreeDOF);
- int index = 0;
- for (int iDOF=0; iDOF < _data->numDOF; ++iDOF) {
- bool free = true;
- for (int iFixed=0; iFixed < _data->numFixedDOF; ++iFixed)
- if (iDOF == _data->fixedDOF[iFixed])
- free = false;
- if (free)
- freeDOF[index] = iDOF;
- } // for
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- const int numFixedDOF = _data->numFixedDOF;
- int iConstraint = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
-
- if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
- // unconstrained point
- for (int i=0; i < fiberDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
- } else {
- // constrained point
-
- // check unconstrained DOF
- for (int iDOF=0; iDOF < numFreeDOF; ++iDOF)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[freeDOF[iDOF]], tolerance);
-
- // check constrained DOF
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
- const int index = iConstraint * numFixedDOF + iDOF;
- const double valueE = (t > _data->tRef) ?
- _data->valuesInitial[index] + (t-_data->tRef)*_data->valueRate :
- _data->valuesInitial[index];
- CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[_data->fixedDOF[iDOF]],
- tolerance);
- } // for
- ++iConstraint;
- } // if/else
- } // for
-} // testSetField
-
-// ----------------------------------------------------------------------
-void
-pylith::bc::TestDirichletBoundary::_initialize(ALE::Obj<Mesh>* mesh,
- DirichletBoundary* const bc) const
+pylith::bc::TestDirichletBoundary::_initialize(topology::Mesh* mesh,
+ DirichletBoundary* const bc) const
{ // _initialize
CPPUNIT_ASSERT(0 != _data);
CPPUNIT_ASSERT(0 != bc);
@@ -293,11 +114,11 @@
meshio::MeshIOAscii iohandler;
iohandler.filename(_data->meshFilename);
iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
+ cs.setSpaceDim(mesh->dimension());
cs.initialize();
+ mesh->coordsys(&cs);
spatialdata::spatialdb::SimpleDB db("TestDirichletBoundary initial");
spatialdata::spatialdb::SimpleIOAscii dbIO;
@@ -313,16 +134,14 @@
const int numValues = 3;
dbRate.setData(names, values, numValues);
- int_array fixedDOF(_data->fixedDOF, _data->numFixedDOF);
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
+ const double upDir[] = { 0.0, 0.0, 1.0 };
bc->label(_data->label);
bc->db(&db);
bc->dbRate(&dbRate);
bc->referenceTime(_data->tRef);
- bc->fixedDOF(fixedDOF);
- bc->initialize(*mesh, &cs, upDir);
+ bc->fixedDOF(_data->fixedDOF, _data->numFixedDOF);
+ bc->initialize(*mesh, upDir);
} // _initialize
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundary.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,16 +23,19 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/bc/bcfwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // forward declarations
/// Namespace for pylith package
namespace pylith {
namespace bc {
class TestDirichletBoundary;
-
- class DirichletBoundary;
class DirichletData;
} // bc
+
+ namespace topology {
+ class Mesh; // USES Mesh
+ } // topology
} // pylith
/// C++ unit testing for DirichletBoundary.
@@ -42,7 +45,6 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestDirichletBoundary );
CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testFixedDOF );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -57,21 +59,9 @@
/// Test constructor.
void testConstructor(void);
- /// Test fixedDOF().
- void testFixedDOF(void);
-
/// Test initialize().
void testInitialize(void);
- /// Test setConstraintSizes().
- void testSetConstraintSizes(void);
-
- /// Test setConstraints().
- void testSetConstraints(void);
-
- /// Test setField().
- void testSetField(void);
-
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
@@ -85,7 +75,7 @@
* @param mesh PETSc mesh to initialize
* @param bc DirichletBoundary boundary condition to initialize.
*/
- void _initialize(ALE::Obj<Mesh>* mesh,
+ void _initialize(topology::Mesh* mesh,
DirichletBoundary* const bc) const;
}; // class TestDirichletBoundary
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryHex8.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -37,9 +37,6 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUB_SUITE( TestDirichletBoundaryHex8, TestDirichletBoundary );
CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,253 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletBoundaryMulti.hh" // Implementation of class methods
-
-#include "pylith/bc/DirichletBoundary.hh" // USES DirichletBoundary
-
-#include "data/DirichletDataMulti.hh" // USES DirichletData
-#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
-#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
-#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletBoundaryMulti::setUp(void)
-{ // setUp
- _data = 0;
-} // setUp
-
-// ----------------------------------------------------------------------
-// Tear down testing data.
-void
-pylith::bc::TestDirichletBoundaryMulti::tearDown(void)
-{ // tearDown
- delete _data; _data = 0;
-} // tearDown
-
-// ----------------------------------------------------------------------
-// Test setConstraintSizes().
-void
-pylith::bc::TestDirichletBoundaryMulti::testSetConstraintSizes(void)
-{ // testSetConstraintSizes
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bcA;
- DirichletBoundary bcB;
- DirichletBoundary bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
-
- CPPUNIT_ASSERT_EQUAL(_data->constraintSizes[*v_iter-offset],
- field->getConstraintDimension(*v_iter));
- } // for
-} // testSetConstraintSizes
-
-// ----------------------------------------------------------------------
-// Test setConstraints().
-void
-pylith::bc::TestDirichletBoundaryMulti::testSetConstraints(void)
-{ // testSetConstraints
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bcA;
- DirichletBoundary bcB;
- DirichletBoundary bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bcA.setConstraints(field, mesh);
- bcB.setConstraints(field, mesh);
- bcC.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int index = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int numConstrainedDOF = _data->constraintSizes[*v_iter-offset];
- if (numConstrainedDOF > 0) {
- const int* fixedDOF = field->getConstraintDof(*v_iter);
- for (int iDOF=0; iDOF < numConstrainedDOF; ++iDOF)
- CPPUNIT_ASSERT_EQUAL(_data->constrainedDOF[index++], fixedDOF[iDOF]);
- } // if
- } // for
-} // testSetConstraints
-
-// ----------------------------------------------------------------------
-// Test setField().
-void
-pylith::bc::TestDirichletBoundaryMulti::testSetField(void)
-{ // testSetField
- ALE::Obj<Mesh> mesh;
- DirichletBoundary bcA;
- DirichletBoundary bcB;
- DirichletBoundary bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bcA.setConstraints(field, mesh);
- bcB.setConstraints(field, mesh);
- bcC.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
- const double tolerance = 1.0e-06;
-
- // All values should be zero.
- field->zero();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int i=0; i < fiberDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
- } // for
-
- // Only unconstrained values should be zero.
- // Expected values set in _data->field
- const double t = 10.0;
- bcA.setField(t, field, mesh);
- bcB.setField(t, field, mesh);
- bcC.setField(t, field, mesh);
-
- int i = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int iDOF=0; iDOF < fiberDim; ++iDOF)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->field[i++], values[iDOF], tolerance);
- } // for
-} // testSetField
-
-// ----------------------------------------------------------------------
-void
-pylith::bc::TestDirichletBoundaryMulti::_initialize(ALE::Obj<Mesh>* mesh,
- DirichletBoundary* const bcA,
- DirichletBoundary* const bcB,
- DirichletBoundary* const bcC) const
-{ // _initialize
- CPPUNIT_ASSERT(0 != _data);
- CPPUNIT_ASSERT(0 != bcA);
- CPPUNIT_ASSERT(0 != bcB);
- CPPUNIT_ASSERT(0 != bcC);
-
- meshio::MeshIOAscii iohandler;
- iohandler.filename(_data->meshFilename);
- iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
- cs.initialize();
-
- // Setup boundary condition A
- spatialdata::spatialdb::SimpleDB db("TestDirichletBoundaryMulti initial");
- spatialdata::spatialdb::SimpleIOAscii dbIO;
- dbIO.filename(_data->dbFilenameA);
- db.ioHandler(&dbIO);
-
- spatialdata::spatialdb::SimpleDB dbRate("TestDirichletBoundaryMulti rate");
- spatialdata::spatialdb::SimpleIOAscii dbIORate;
- dbIORate.filename(_data->dbFilenameARate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFA(_data->fixedDOFA, _data->numFixedDOFA);
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
-
- bcA->label(_data->labelA);
- bcA->db(&db);
- bcA->dbRate(&dbRate);
- bcA->referenceTime(_data->tRefA);
- bcA->fixedDOF(fixedDOFA);
- bcA->initialize(*mesh, &cs, upDir);
-
- // Setup boundary condition B
- dbIO.filename(_data->dbFilenameB);
- db.ioHandler(&dbIO);
-
- dbIORate.filename(_data->dbFilenameBRate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFB(_data->fixedDOFB, _data->numFixedDOFB);
-
- bcB->label(_data->labelB);
- bcB->db(&db);
- bcB->dbRate(&dbRate);
- bcB->referenceTime(_data->tRefB);
- bcB->fixedDOF(fixedDOFB);
- bcB->initialize(*mesh, &cs, upDir);
-
- // Setup boundary condition C
- if (_data->numFixedDOFC > 0) {
- dbIO.filename(_data->dbFilenameC);
- db.ioHandler(&dbIO);
-
- dbIORate.filename(_data->dbFilenameCRate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFC(_data->fixedDOFC, _data->numFixedDOFC);
-
- bcC->label(_data->labelC);
- bcC->db(&db);
- bcC->dbRate(&dbRate);
- bcC->referenceTime(_data->tRefC);
- bcC->fixedDOF(fixedDOFC);
- bcC->initialize(*mesh, &cs, upDir);
- } // if
-} // _initialize
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMulti.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,85 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletBoundaryMulti.hh
- *
- * @brief C++ TestDirichletBoundaryMulti object.
- *
- * C++ unit testing for DirichletBoundaryMulti.
- */
-
-#if !defined(pylith_bc_testdirichletboundarymulti_hh)
-#define pylith_bc_testdirichletboundarymulti_hh
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletBoundaryMulti;
-
- class DirichletBoundary;
- class DirichletDataMulti;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletBoundaryMulti.
-class pylith::bc::TestDirichletBoundaryMulti : public CppUnit::TestFixture
-{ // class TestDirichletBoundaryMulti
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
- /// Tear down testing data.
- void tearDown(void);
-
- /// Test setConstraintSizes().
- void testSetConstraintSizes(void);
-
- /// Test setConstraints().
- void testSetConstraints(void);
-
- /// Test setField().
- void testSetField(void);
-
- // PROTECTED MEMBERS //////////////////////////////////////////////////
-protected :
-
- DirichletDataMulti* _data; ///< Data for testing
-
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
-
- /** Initialize DirichletBoundaryMulti boundary condition.
- *
- * @param mesh PETSc mesh to initialize
- * @param bcA DirichletBoundary boundary condition A to initialize.
- * @param bcB DirichletBoundary boundary condition B to initialize.
- * @param bcC DirichletBoundary boundary condition C to initialize.
- */
- void _initialize(ALE::Obj<Mesh>* mesh,
- DirichletBoundary* const bcA,
- DirichletBoundary* const bcB,
- DirichletBoundary* const bcC) const;
-
-}; // class TestDirichletBoundaryMulti
-
-#endif // pylith_bc_dirichletboundarymulti_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletBoundaryMultiTet4.hh" // Implementation of class methods
-
-#include "data/DirichletDataMultiTet4.hh" // USES DirichletDataMultiTet4
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBoundaryMultiTet4 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletBoundaryMultiTet4::setUp(void)
-{ // setUp
- _data = new DirichletDataMultiTet4();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletBoundaryMultiTet4.hh
- *
- * @brief C++ TestDirichletBoundary object.
- *
- * C++ unit testing for DirichletBoundary for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletboundarymultitet4_hh)
-#define pylith_bc_testdirichletboundarymultitet4_hh
-
-#include "TestDirichletBoundaryMulti.hh" // ISA TestDirichletBoundary
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletBoundaryMultiTet4;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletBoundary for mesh with 2-D tri cells.
-class pylith::bc::TestDirichletBoundaryMultiTet4 : public TestDirichletBoundaryMulti
-{ // class TestDirichletBoundary
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDirichletBoundaryMultiTet4 );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletBoundaryMultiTet4
-
-#endif // pylith_bc_dirichletboundarymultitet4_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletBoundaryMultiTri3.hh" // Implementation of class methods
-
-#include "data/DirichletDataMultiTri3.hh" // USES DirichletDataMultiTri3
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletBoundaryMultiTri3 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletBoundaryMultiTri3::setUp(void)
-{ // setUp
- _data = new DirichletDataMultiTri3();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletBoundaryMultiTri3.hh
- *
- * @brief C++ TestDirichletBoundary object.
- *
- * C++ unit testing for DirichletBoundary for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletboundarymultitri3_hh)
-#define pylith_bc_testdirichletboundarymultitri3_hh
-
-#include "TestDirichletBoundaryMulti.hh" // ISA TestDirichletBoundary
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletBoundaryMultiTri3;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletBoundary for mesh with 2-D tri cells.
-class pylith::bc::TestDirichletBoundaryMultiTri3 : public TestDirichletBoundaryMulti
-{ // class TestDirichletBoundary
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDirichletBoundaryMultiTri3 );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletBoundaryMultiTri3
-
-#endif // pylith_bc_dirichletboundarymultitri3_hh
-
-
-// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryQuad4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -37,9 +37,6 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUB_SUITE( TestDirichletBoundaryQuad4, TestDirichletBoundary );
CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -37,9 +37,6 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUB_SUITE( TestDirichletBoundaryTet4, TestDirichletBoundary );
CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletBoundaryTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -37,9 +37,6 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUB_SUITE( TestDirichletBoundaryTri3, TestDirichletBoundary );
CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,314 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPoints.hh" // Implementation of class methods
-
-#include "pylith/bc/DirichletPoints.hh" // USES DirichletPoints
-
-#include "data/DirichletData.hh" // USES DirichletData
-#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
-#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
-#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPoints );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPoints::setUp(void)
-{ // setUp
- _data = 0;
-} // setUp
-
-// ----------------------------------------------------------------------
-// Tear down testing data.
-void
-pylith::bc::TestDirichletPoints::tearDown(void)
-{ // tearDown
- delete _data; _data = 0;
-} // tearDown
-
-// ----------------------------------------------------------------------
-// Test constructor.
-void
-pylith::bc::TestDirichletPoints::testConstructor(void)
-{ // testConstructor
- DirichletPoints bc;
-} // testConstructor
-
-// ----------------------------------------------------------------------
-// Test fixedDOF()
-void
-pylith::bc::TestDirichletPoints::testFixedDOF(void)
-{ // testfixedDOF
- DirichletPoints bc;
-
- const size_t numDOF = 4;
- const int dof[] = { 0, 2, 3, 5 };
- int_array fixedDOF(dof, numDOF);
- bc.fixedDOF(fixedDOF);
-
- CPPUNIT_ASSERT_EQUAL(numDOF, bc._fixedDOF.size());
- for (int i=0; i < numDOF; ++i)
- CPPUNIT_ASSERT_EQUAL(fixedDOF[i], bc._fixedDOF[i]);
-} // testFixedDOF
-
-// ----------------------------------------------------------------------
-// Test initialize().
-void
-pylith::bc::TestDirichletPoints::testInitialize(void)
-{ // testInitialize
- ALE::Obj<Mesh> mesh;
- DirichletPoints bc;
- _initialize(&mesh, &bc);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
-
- const int numFixedDOF = _data->numFixedDOF;
- const size_t numPoints = _data->numConstrainedPts;
-
- // Check points
- const int offset = numCells;
- if (numFixedDOF > 0) {
- CPPUNIT_ASSERT_EQUAL(numPoints, bc._points.size());
- for (int i=0; i < numPoints; ++i)
- CPPUNIT_ASSERT_EQUAL(_data->constrainedPoints[i]+offset, bc._points[i]);
- } // if
-
- // Check values
- const size_t size = numPoints * numFixedDOF;
- CPPUNIT_ASSERT_EQUAL(size, bc._valuesInitial.size());
- const double tolerance = 1.0e-06;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valuesInitial[i], bc._valuesInitial[i],
- tolerance);
-
- CPPUNIT_ASSERT_EQUAL(size, bc._valuesRate.size());
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->valueRate, bc._valuesRate[i],
- tolerance);
-} // testInitialize
-
-// ----------------------------------------------------------------------
-// Test setConstraintSizes().
-void
-pylith::bc::TestDirichletPoints::testSetConstraintSizes(void)
-{ // testSetConstraintSizes
- ALE::Obj<Mesh> mesh;
- DirichletPoints bc;
- _initialize(&mesh, &bc);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bc.setConstraintSizes(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int iConstraint = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, field->getConstraintDimension(*v_iter));
- } else {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF,
- field->getConstraintDimension(*v_iter));
- ++iConstraint;
- } // if/else
- } // for
-} // testSetConstraintSizes
-
-// ----------------------------------------------------------------------
-// Test setConstraints().
-void
-pylith::bc::TestDirichletPoints::testSetConstraints(void)
-{ // testSetConstraints
- ALE::Obj<Mesh> mesh;
- DirichletPoints bc;
- _initialize(&mesh, &bc);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bc.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bc.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int iConstraint = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int* fixedDOF = field->getConstraintDof(*v_iter);
- if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
- CPPUNIT_ASSERT_EQUAL(0, field->getConstraintDimension(*v_iter));
- //CPPUNIT_ASSERT(0 == fixedDOF);
- } else {
- CPPUNIT_ASSERT(0 != fixedDOF);
- CPPUNIT_ASSERT_EQUAL(_data->numFixedDOF,
- field->getConstraintDimension(*v_iter));
- for (int iDOF=0; iDOF < _data->numFixedDOF; ++iDOF)
- CPPUNIT_ASSERT_EQUAL(_data->fixedDOF[iDOF], fixedDOF[iDOF]);
- ++iConstraint;
- } // if/else
- } // for
-} // testSetConstraints
-
-// ----------------------------------------------------------------------
-// Test setField().
-void
-pylith::bc::TestDirichletPoints::testSetField(void)
-{ // testSetField
- ALE::Obj<Mesh> mesh;
- DirichletPoints bc;
- _initialize(&mesh, &bc);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bc.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bc.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
- const double tolerance = 1.0e-06;
-
- // All values should be zero.
- field->zero();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int i=0; i < fiberDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
- } // for
-
- // Only unconstrained values should be zero.
- const double t = 1.0;
- bc.setField(t, field, mesh);
-
- // Create list of unconstrained DOF at constrained DOF
- const int numFreeDOF = _data->numDOF - _data->numFixedDOF;
- int_array freeDOF(numFreeDOF);
- int index = 0;
- for (int iDOF=0; iDOF < _data->numDOF; ++iDOF) {
- bool free = true;
- for (int iFixed=0; iFixed < _data->numFixedDOF; ++iFixed)
- if (iDOF == _data->fixedDOF[iFixed])
- free = false;
- if (free)
- freeDOF[index] = iDOF;
- } // for
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- const int numFixedDOF = _data->numFixedDOF;
- int iConstraint = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
-
- if (*v_iter != _data->constrainedPoints[iConstraint] + offset) {
- // unconstrained point
- for (int i=0; i < fiberDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
- } else {
- // constrained point
-
- // check unconstrained DOF
- for (int iDOF=0; iDOF < numFreeDOF; ++iDOF)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[freeDOF[iDOF]], tolerance);
-
- // check constrained DOF
- for (int iDOF=0; iDOF < numFixedDOF; ++iDOF) {
- const int index = iConstraint * numFixedDOF + iDOF;
- const double valueE = (t > _data->tRef) ?
- _data->valuesInitial[index] + (t-_data->tRef)*_data->valueRate :
- _data->valuesInitial[index];
- CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[_data->fixedDOF[iDOF]],
- tolerance);
- } // for
- ++iConstraint;
- } // if/else
- } // for
-} // testSetField
-
-// ----------------------------------------------------------------------
-void
-pylith::bc::TestDirichletPoints::_initialize(ALE::Obj<Mesh>* mesh,
- DirichletPoints* const bc) const
-{ // _initialize
- CPPUNIT_ASSERT(0 != _data);
- CPPUNIT_ASSERT(0 != bc);
-
- meshio::MeshIOAscii iohandler;
- iohandler.filename(_data->meshFilename);
- iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
- cs.initialize();
-
- spatialdata::spatialdb::SimpleDB db("TestDirichletPoints initial");
- spatialdata::spatialdb::SimpleIOAscii dbIO;
- dbIO.filename(_data->dbFilename);
- db.ioHandler(&dbIO);
- db.queryType(spatialdata::spatialdb::SimpleDB::NEAREST);
-
- spatialdata::spatialdb::UniformDB dbRate("TestDirichletPoints rate");
- const char* names[] = { "dof-0", "dof-1", "dof-2" };
- const double values[] = { _data->valueRate,
- _data->valueRate,
- _data->valueRate };
- const int numValues = 3;
- dbRate.setData(names, values, numValues);
-
- int_array fixedDOF(_data->fixedDOF, _data->numFixedDOF);
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
-
- bc->label(_data->label);
- bc->db(&db);
- bc->dbRate(&dbRate);
- bc->referenceTime(_data->tRef);
- bc->fixedDOF(fixedDOF);
- bc->initialize(*mesh, &cs, upDir);
-} // _initialize
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPoints.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,96 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPoints.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints.
- */
-
-#if !defined(pylith_bc_testdirichletpoints_hh)
-#define pylith_bc_testdirichletpoints_hh
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPoints;
-
- class DirichletPoints;
- class DirichletData;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints.
-class pylith::bc::TestDirichletPoints : public CppUnit::TestFixture
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDirichletPoints );
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testFixedDOF );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
- /// Tear down testing data.
- void tearDown(void);
-
- /// Test constructor.
- void testConstructor(void);
-
- /// Test fixedDOF().
- void testFixedDOF(void);
-
- /// Test initialize().
- void testInitialize(void);
-
- /// Test setConstraintSizes().
- void testSetConstraintSizes(void);
-
- /// Test setConstraints().
- void testSetConstraints(void);
-
- /// Test setField().
- void testSetField(void);
-
- // PROTECTED MEMBERS //////////////////////////////////////////////////
-protected :
-
- DirichletData* _data; ///< Data for testing
-
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
-
- /** Initialize DirichletPoints boundary condition.
- *
- * @param mesh PETSc mesh to initialize
- * @param bc DirichletPoints boundary condition to initialize.
- */
- void _initialize(ALE::Obj<Mesh>* mesh,
- DirichletPoints* const bc) const;
-
-}; // class TestDirichletPoints
-
-#endif // pylith_bc_dirichletpoints_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsHex8.hh" // Implementation of class methods
-
-#include "data/DirichletDataHex8.hh" // USES DirichletDataHex8
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsHex8 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsHex8::setUp(void)
-{ // setUp
- _data = new DirichletDataHex8();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,56 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsHex8.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointshex8_hh)
-#define pylith_bc_testdirichletpointshex8_hh
-
-#include "TestDirichletPoints.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsHex8;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 3-D hex cells.
-class pylith::bc::TestDirichletPointsHex8 : public TestDirichletPoints
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUB_SUITE( TestDirichletPointsHex8, TestDirichletPoints );
- CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsHex8
-
-#endif // pylith_bc_dirichletpointshex8_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsLine2.hh" // Implementation of class methods
-
-#include "data/DirichletDataLine2.hh" // USES DirichletDataLine2
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsLine2 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsLine2::setUp(void)
-{ // setUp
- _data = new DirichletDataLine2();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,56 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsLine2.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointsline2_hh)
-#define pylith_bc_testdirichletpointsline2_hh
-
-#include "TestDirichletPoints.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsLine2;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 1-D line cells.
-class pylith::bc::TestDirichletPointsLine2 : public TestDirichletPoints
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUB_SUITE( TestDirichletPointsLine2, TestDirichletPoints );
- CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsLine2
-
-#endif // pylith_bc_dirichletpointsline2_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsLine2b.hh" // Implementation of class methods
-
-#include "data/DirichletDataLine2b.hh" // USES DirichletDataLine2b
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsLine2b );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsLine2b::setUp(void)
-{ // setUp
- _data = new DirichletDataLine2b();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsLine2b.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,56 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsLine2b.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointsline2b_hh)
-#define pylith_bc_testdirichletpointsline2b_hh
-
-#include "TestDirichletPoints.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsLine2b;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 1-D line cells.
-class pylith::bc::TestDirichletPointsLine2b : public TestDirichletPoints
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUB_SUITE( TestDirichletPointsLine2b, TestDirichletPoints );
- CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsLine2b
-
-#endif // pylith_bc_dirichletpointsline2b_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,253 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsMulti.hh" // Implementation of class methods
-
-#include "pylith/bc/DirichletPoints.hh" // USES DirichletPoints
-
-#include "data/DirichletDataMulti.hh" // USES DirichletData
-#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
-#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
-#include "spatialdata/spatialdb/UniformDB.hh" // USES UniformDB
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsMulti::setUp(void)
-{ // setUp
- _data = 0;
-} // setUp
-
-// ----------------------------------------------------------------------
-// Tear down testing data.
-void
-pylith::bc::TestDirichletPointsMulti::tearDown(void)
-{ // tearDown
- delete _data; _data = 0;
-} // tearDown
-
-// ----------------------------------------------------------------------
-// Test setConstraintSizes().
-void
-pylith::bc::TestDirichletPointsMulti::testSetConstraintSizes(void)
-{ // testSetConstraintSizes
- ALE::Obj<Mesh> mesh;
- DirichletPoints bcA;
- DirichletPoints bcB;
- DirichletPoints bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- CPPUNIT_ASSERT_EQUAL(_data->numDOF, field->getFiberDimension(*v_iter));
-
- CPPUNIT_ASSERT_EQUAL(_data->constraintSizes[*v_iter-offset],
- field->getConstraintDimension(*v_iter));
- } // for
-} // testSetConstraintSizes
-
-// ----------------------------------------------------------------------
-// Test setConstraints().
-void
-pylith::bc::TestDirichletPointsMulti::testSetConstraints(void)
-{ // testSetConstraints
- ALE::Obj<Mesh> mesh;
- DirichletPoints bcA;
- DirichletPoints bcB;
- DirichletPoints bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bcA.setConstraints(field, mesh);
- bcB.setConstraints(field, mesh);
- bcC.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
-
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
- int index = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int numConstrainedDOF = _data->constraintSizes[*v_iter-offset];
- if (numConstrainedDOF > 0) {
- const int* fixedDOF = field->getConstraintDof(*v_iter);
- for (int iDOF=0; iDOF < numConstrainedDOF; ++iDOF)
- CPPUNIT_ASSERT_EQUAL(_data->constrainedDOF[index++], fixedDOF[iDOF]);
- } // if
- } // for
-} // testSetConstraints
-
-// ----------------------------------------------------------------------
-// Test setField().
-void
-pylith::bc::TestDirichletPointsMulti::testSetField(void)
-{ // testSetField
- ALE::Obj<Mesh> mesh;
- DirichletPoints bcA;
- DirichletPoints bcB;
- DirichletPoints bcC;
- _initialize(&mesh, &bcA, &bcB, &bcC);
-
- const ALE::Obj<real_section_type>& field = mesh->getRealSection("field");
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, _data->numDOF);
- bcA.setConstraintSizes(field, mesh);
- bcB.setConstraintSizes(field, mesh);
- bcC.setConstraintSizes(field, mesh);
- mesh->allocate(field);
- bcA.setConstraints(field, mesh);
- bcB.setConstraints(field, mesh);
- bcC.setConstraints(field, mesh);
-
- CPPUNIT_ASSERT(0 != _data);
- const double tolerance = 1.0e-06;
-
- // All values should be zero.
- field->zero();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int i=0; i < fiberDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[i], tolerance);
- } // for
-
- // Only unconstrained values should be zero.
- // Expected values set in _data->field
- const double t = 10.0;
- bcA.setField(t, field, mesh);
- bcB.setField(t, field, mesh);
- bcC.setField(t, field, mesh);
-
- int i = 0;
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- const int fiberDim = field->getFiberDimension(*v_iter);
- const real_section_type::value_type* values =
- mesh->restrictClosure(field, *v_iter);
- for (int iDOF=0; iDOF < fiberDim; ++iDOF)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->field[i++], values[iDOF], tolerance);
- } // for
-} // testSetField
-
-// ----------------------------------------------------------------------
-void
-pylith::bc::TestDirichletPointsMulti::_initialize(ALE::Obj<Mesh>* mesh,
- DirichletPoints* const bcA,
- DirichletPoints* const bcB,
- DirichletPoints* const bcC) const
-{ // _initialize
- CPPUNIT_ASSERT(0 != _data);
- CPPUNIT_ASSERT(0 != bcA);
- CPPUNIT_ASSERT(0 != bcB);
- CPPUNIT_ASSERT(0 != bcC);
-
- meshio::MeshIOAscii iohandler;
- iohandler.filename(_data->meshFilename);
- iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
- cs.initialize();
-
- // Setup boundary condition A
- spatialdata::spatialdb::SimpleDB db("TestDirichletPointsMulti initial");
- spatialdata::spatialdb::SimpleIOAscii dbIO;
- dbIO.filename(_data->dbFilenameA);
- db.ioHandler(&dbIO);
-
- spatialdata::spatialdb::SimpleDB dbRate("TestDirichletPointsMulti rate");
- spatialdata::spatialdb::SimpleIOAscii dbIORate;
- dbIORate.filename(_data->dbFilenameARate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFA(_data->fixedDOFA, _data->numFixedDOFA);
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
-
- bcA->label(_data->labelA);
- bcA->db(&db);
- bcA->dbRate(&dbRate);
- bcA->referenceTime(_data->tRefA);
- bcA->fixedDOF(fixedDOFA);
- bcA->initialize(*mesh, &cs, upDir);
-
- // Setup boundary condition B
- dbIO.filename(_data->dbFilenameB);
- db.ioHandler(&dbIO);
-
- dbIORate.filename(_data->dbFilenameBRate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFB(_data->fixedDOFB, _data->numFixedDOFB);
-
- bcB->label(_data->labelB);
- bcB->db(&db);
- bcB->dbRate(&dbRate);
- bcB->referenceTime(_data->tRefB);
- bcB->fixedDOF(fixedDOFB);
- bcB->initialize(*mesh, &cs, upDir);
-
- // Setup boundary condition C
- if (_data->numFixedDOFC > 0.0) {
- dbIO.filename(_data->dbFilenameC);
- db.ioHandler(&dbIO);
-
- dbIORate.filename(_data->dbFilenameCRate);
- dbRate.ioHandler(&dbIORate);
-
- int_array fixedDOFC(_data->fixedDOFC, _data->numFixedDOFC);
-
- bcC->label(_data->labelC);
- bcC->db(&db);
- bcC->dbRate(&dbRate);
- bcC->referenceTime(_data->tRefC);
- bcC->fixedDOF(fixedDOFC);
- bcC->initialize(*mesh, &cs, upDir);
- } // if
-} // _initialize
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMulti.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,85 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsMulti.hh
- *
- * @brief C++ TestDirichletPointsMulti object.
- *
- * C++ unit testing for DirichletPointsMulti.
- */
-
-#if !defined(pylith_bc_testdirichletpointsmulti_hh)
-#define pylith_bc_testdirichletpointsmulti_hh
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsMulti;
-
- class DirichletPoints;
- class DirichletDataMulti;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPointsMulti.
-class pylith::bc::TestDirichletPointsMulti : public CppUnit::TestFixture
-{ // class TestDirichletPointsMulti
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
- /// Tear down testing data.
- void tearDown(void);
-
- /// Test setConstraintSizes().
- void testSetConstraintSizes(void);
-
- /// Test setConstraints().
- void testSetConstraints(void);
-
- /// Test setField().
- void testSetField(void);
-
- // PROTECTED MEMBERS //////////////////////////////////////////////////
-protected :
-
- DirichletDataMulti* _data; ///< Data for testing
-
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
-
- /** Initialize DirichletPointsMulti boundary condition.
- *
- * @param mesh PETSc mesh to initialize
- * @param bcA DirichletPoints boundary condition A to initialize.
- * @param bcB DirichletPoints boundary condition B to initialize.
- * @param bcC DirichletPoints boundary condition C to initialize.
- */
- void _initialize(ALE::Obj<Mesh>* mesh,
- DirichletPoints* const bcA,
- DirichletPoints* const bcB,
- DirichletPoints* const bcC) const;
-
-}; // class TestDirichletPointsMulti
-
-#endif // pylith_bc_dirichletpointsmulti_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsMultiTet4.hh" // Implementation of class methods
-
-#include "data/DirichletDataMultiTet4.hh" // USES DirichletDataMultiTet4
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsMultiTet4 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsMultiTet4::setUp(void)
-{ // setUp
- _data = new DirichletDataMultiTet4();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsMultiTet4.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointsmultitet4_hh)
-#define pylith_bc_testdirichletpointsmultitet4_hh
-
-#include "TestDirichletPointsMulti.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsMultiTet4;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 2-D tri cells.
-class pylith::bc::TestDirichletPointsMultiTet4 : public TestDirichletPointsMulti
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDirichletPointsMultiTet4 );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsMultiTet4
-
-#endif // pylith_bc_dirichletpointsmultitet4_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsMultiTri3.hh" // Implementation of class methods
-
-#include "data/DirichletDataMultiTri3.hh" // USES DirichletDataMultiTri3
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsMultiTri3 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsMultiTri3::setUp(void)
-{ // setUp
- _data = new DirichletDataMultiTri3();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsMultiTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,55 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsMultiTri3.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointsmultitri3_hh)
-#define pylith_bc_testdirichletpointsmultitri3_hh
-
-#include "TestDirichletPointsMulti.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsMultiTri3;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 2-D tri cells.
-class pylith::bc::TestDirichletPointsMultiTri3 : public TestDirichletPointsMulti
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDirichletPointsMultiTri3 );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsMultiTri3
-
-#endif // pylith_bc_dirichletpointsmultitri3_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsQuad4.hh" // Implementation of class methods
-
-#include "data/DirichletDataQuad4.hh" // USES DirichletDataQuad4
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsQuad4 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsQuad4::setUp(void)
-{ // setUp
- _data = new DirichletDataQuad4();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,56 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsQuad4.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointsquad4_hh)
-#define pylith_bc_testdirichletpointsquad4_hh
-
-#include "TestDirichletPoints.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsQuad4;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 2-D quad cells.
-class pylith::bc::TestDirichletPointsQuad4 : public TestDirichletPoints
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUB_SUITE( TestDirichletPointsQuad4, TestDirichletPoints );
- CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsQuad4
-
-#endif // pylith_bc_dirichletpointsquad4_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsTet4.hh" // Implementation of class methods
-
-#include "data/DirichletDataTet4.hh" // USES DirichletDataTet4
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsTet4 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsTet4::setUp(void)
-{ // setUp
- _data = new DirichletDataTet4();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,56 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsTet4.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointstet4_hh)
-#define pylith_bc_testdirichletpointset4_hh
-
-#include "TestDirichletPoints.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsTet4;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 3-D tet cells.
-class pylith::bc::TestDirichletPointsTet4 : public TestDirichletPoints
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUB_SUITE( TestDirichletPointsTet4, TestDirichletPoints );
- CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsTet4
-
-#endif // pylith_bc_dirichletpointstet4_hh
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestDirichletPointsTri3.hh" // Implementation of class methods
-
-#include "data/DirichletDataTri3.hh" // USES DirichletDataTri3
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestDirichletPointsTri3 );
-
-// ----------------------------------------------------------------------
-// Setup testing data.
-void
-pylith::bc::TestDirichletPointsTri3::setUp(void)
-{ // setUp
- _data = new DirichletDataTri3();
-} // setUp
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestDirichletPointsTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,56 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/bc/TestDirichletPointsTri3.hh
- *
- * @brief C++ TestDirichletPoints object.
- *
- * C++ unit testing for DirichletPoints for mesh with 1-D line cells.
- */
-
-#if !defined(pylith_bc_testdirichletpointstri3_hh)
-#define pylith_bc_testdirichletpointstri3_hh
-
-#include "TestDirichletPoints.hh" // ISA TestDirichletPoints
-
-/// Namespace for pylith package
-namespace pylith {
- namespace bc {
- class TestDirichletPointsTri3;
- } // bc
-} // pylith
-
-/// C++ unit testing for DirichletPoints for mesh with 2-D tri cells.
-class pylith::bc::TestDirichletPointsTri3 : public TestDirichletPoints
-{ // class TestDirichletPoints
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUB_SUITE( TestDirichletPointsTri3, TestDirichletPoints );
- CPPUNIT_TEST( testInitialize );
- CPPUNIT_TEST( testSetConstraintSizes );
- CPPUNIT_TEST( testSetConstraints );
- CPPUNIT_TEST( testSetField );
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Setup testing data.
- void setUp(void);
-
-}; // class TestDirichletPointsTri3
-
-#endif // pylith_bc_dirichletpointstri3_hh
-
-
-// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -18,10 +18,11 @@
#include "data/NeumannData.hh" // USES NeumannData
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -33,12 +34,20 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::bc::TestNeumann );
// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+typedef pylith::topology::SubMesh::RealSection RealSection;
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
+typedef pylith::topology::SubMesh::RealSection SubRealSection;
+typedef pylith::topology::SubMesh::RestrictVisitor RestrictVisitor;
+
+// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::bc::TestNeumann::setUp(void)
{ // setUp
_data = 0;
- _quadrature = 0;
+ _quadrature = new feassemble::Quadrature<topology::SubMesh>();
+ CPPUNIT_ASSERT(0 != _quadrature);
} // setUp
// ----------------------------------------------------------------------
@@ -63,35 +72,36 @@
void
pylith::bc::TestNeumann::testInitialize(void)
{ // testInitialize
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
Neumann bc;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &bc, &fields);
CPPUNIT_ASSERT(0 != _data);
- const ALE::Obj<SubMesh>& boundaryMesh = bc._boundaryMesh;
+ const topology::SubMesh& boundaryMesh = *bc._boundaryMesh;
+ const ALE::Obj<SieveSubMesh>& submesh = boundaryMesh.sieveMesh();
// Check boundary mesh
- CPPUNIT_ASSERT(!boundaryMesh.isNull());
+ CPPUNIT_ASSERT(!submesh.isNull());
- const int cellDim = boundaryMesh->getDimension();
- const ALE::Obj<SubMesh::label_sequence>& cells = boundaryMesh->heightStratum(1);
- const int numBoundaryVertices = boundaryMesh->depthStratum(0)->size();
+ const int cellDim = boundaryMesh.dimension();
+ const int numCorners = _data->numCorners;
+ const int spaceDim = _data->spaceDim;
+ const ALE::Obj<SieveSubMesh::label_sequence>& cells = submesh->heightStratum(1);
+ const int numBoundaryVertices = submesh->depthStratum(0)->size();
const int numBoundaryCells = cells->size();
CPPUNIT_ASSERT_EQUAL(_data->cellDim, cellDim);
CPPUNIT_ASSERT_EQUAL(_data->numBoundaryVertices, numBoundaryVertices);
CPPUNIT_ASSERT_EQUAL(_data->numBoundaryCells, numBoundaryCells);
- // boundaryMesh->view("BOUNDARY MESH");
-
- const int boundaryDepth = boundaryMesh->depth()-1; // depth of boundary cells
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
+ const int boundaryDepth = submesh->depth()-1; // depth of boundary cells
+ const ALE::Obj<SubRealSection>& coordinates =
+ submesh->getRealSection("coordinates");
+ RestrictVisitor coordsVisitor(*coordinates, numCorners*spaceDim);
// coordinates->view("Mesh coordinates from TestNeumann::testInitialize");
- const int spaceDim = _data->spaceDim;
const int numBasis = bc._quadrature->numBasis();
const int cellVertSize = _data->numCorners * spaceDim;
double_array cellVertices(cellVertSize);
@@ -100,16 +110,17 @@
// check cell vertices
int iCell = 0;
- for(SubMesh::label_sequence::iterator c_iter = cells->begin();
+ for(SieveSubMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cells->end();
++c_iter) {
- const int numCorners = boundaryMesh->getNumCellCorners(*c_iter, boundaryDepth);
+ const int numCorners = submesh->getNumCellCorners(*c_iter, boundaryDepth);
CPPUNIT_ASSERT_EQUAL(_data->numCorners, numCorners);
- boundaryMesh->restrictClosure(coordinates, *c_iter, &cellVertices[0],
- cellVertices.size());
+ coordsVisitor.clear();
+ submesh->restrictClosure(*c_iter, coordsVisitor);
double vert =0.0;
double vertE =0.0;
+ const double* cellVertices = coordsVisitor.getValues();
// std::cout << "c_iter " << *c_iter << " vertex coords:" << std::endl;
for(int iVert = 0; iVert < numCorners; ++iVert) {
for(int iDim = 0; iDim < spaceDim; ++iDim) {
@@ -131,27 +142,21 @@
const int fiberDim = numQuadPts * spaceDim;
double_array tractionsCell(fiberDim);
int index = 0;
+ const ALE::Obj<SubRealSection>& tractionSection = bc._tractions->section();
- for(SubMesh::label_sequence::iterator c_iter = cells->begin();
+ for(SieveSubMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cells->end();
++c_iter) {
-
- bc._boundaryMesh->restrictClosure(bc._tractions, *c_iter,
- &tractionsCell[0], tractionsCell.size());
-
- // std::cout << "Tractions at quadrature points: " << std::endl;
- // std::cout << "Computed Expected" << std::endl;
- for (int iQuad=0; iQuad < numQuadPts; ++iQuad) {
+ tractionSection->restrictPoint(*c_iter,
+ &tractionsCell[0], tractionsCell.size());
+ for (int iQuad=0; iQuad < numQuadPts; ++iQuad)
for (int iDim =0; iDim < spaceDim; ++iDim) {
const double tractionsCellData = _data->tractionsCell[index];
- // std::cout << " " << tractionsCell[iQuad*spaceDim+iDim] << " " << tractionsCellData << std::endl;
CPPUNIT_ASSERT_DOUBLES_EQUAL(tractionsCellData,
tractionsCell[iQuad*spaceDim+iDim],
tolerance);
++index;
} // for
- // std::cout << std::endl;
- } // for
} // for
} // testInitialize
@@ -163,32 +168,31 @@
{ // testIntegrateResidual
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
Neumann bc;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &bc, &fields);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(mesh->getDimension());
- cs.initialize();
+ topology::Field<topology::Mesh>& residual = fields.get("residual");
+ const double t = 0.0;
+ bc.integrateResidual(residual, t, &fields);
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CPPUNIT_ASSERT(!sieveMesh->depthStratum(0).isNull());
- const int spaceDim = _data->spaceDim;
-
- const double t = 0.0;
- bc.integrateResidual(residual, t, &fields, mesh, &cs);
-
const double* valsE = _data->valsResidual;
- const int totalNumVertices = mesh->depthStratum(0)->size();
+ const int totalNumVertices = sieveMesh->depthStratum(0)->size();
const int sizeE = _data->spaceDim * totalNumVertices;
- const double* vals = residual->restrictSpace();
- const int size = residual->sizeWithBC();
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ CPPUNIT_ASSERT(!residualSection.isNull());
+
+ const double* vals = residualSection->restrictSpace();
+ const int size = residualSection->sizeWithBC();
CPPUNIT_ASSERT_EQUAL(sizeE, size);
- //residual->view("RESIDUAL");
+ //residual.view("RESIDUAL");
const double tolerance = 1.0e-06;
// std::cout << "computed residuals: " << std::endl;
@@ -198,18 +202,18 @@
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, vals[i]/valsE[i], tolerance);
else
CPPUNIT_ASSERT_DOUBLES_EQUAL(valsE[i], vals[i], tolerance);
-
} // testIntegrateResidual
// ----------------------------------------------------------------------
void
-pylith::bc::TestNeumann::_initialize(ALE::Obj<Mesh>* mesh,
+pylith::bc::TestNeumann::_initialize(topology::Mesh* mesh,
Neumann* const bc,
- topology::FieldsManager* fields) const
+ topology::SolutionFields* fields) const
{ // _initialize
CPPUNIT_ASSERT(0 != _data);
CPPUNIT_ASSERT(0 != mesh);
CPPUNIT_ASSERT(0 != bc);
+ CPPUNIT_ASSERT(0 != fields);
CPPUNIT_ASSERT(0 != _quadrature);
try {
@@ -217,17 +221,20 @@
meshio::MeshIOAscii iohandler;
iohandler.filename(_data->meshFilename);
iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
// Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
+ cs.setSpaceDim(mesh->dimension());
cs.initialize();
+ mesh->coordsys(&cs);
// Set up quadrature
- _quadrature->initialize(_data->basis, _data->basisDerivRef, _data->quadPts,
- _data->quadWts, _data->cellDim, _data->numBasis,
- _data->numQuadPts, _data->spaceDim);
+ _quadrature->initialize(_data->basis, _data->numQuadPts, _data->numBasis,
+ _data->basisDerivRef, _data->numQuadPts,
+ _data->numBasis, _data->cellDim,
+ _data->quadPts, _data->numQuadPts, _data->cellDim,
+ _data->quadWts, _data->numQuadPts,
+ _data->spaceDim);
// Set up database
spatialdata::spatialdb::SimpleDB db("TestNeumann");
@@ -236,29 +243,30 @@
db.ioHandler(&dbIO);
db.queryType(spatialdata::spatialdb::SimpleDB::LINEAR);
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
+ const double upDir[] = { 0.0, 0.0, 1.0 };
bc->quadrature(_quadrature);
bc->label(_data->label);
bc->db(&db);
- bc->initialize(*mesh, &cs, upDir);
+ bc->initialize(*mesh, upDir);
// Set up fields
CPPUNIT_ASSERT(0 != fields);
- fields->addReal("residual");
- fields->addReal("dispTBctpdt");
+ fields->add("residual", "residual");
+ fields->add("disp(t), bc(t+dt)", "displacement");
+ fields->solutionName("disp(t), bc(t+dt)");
- const ALE::Obj<real_section_type>& residual = fields->getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
- residual->setChart((*mesh)->getSieve()->getChart());
- residual->setFiberDimension((*mesh)->depthStratum(0), _data->spaceDim);
- (*mesh)->allocate(residual);
- residual->zero();
+ topology::Field<topology::Mesh>& residual = fields->get("residual");
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ residual.newSection(vertices, _data->spaceDim);
+ residual.allocate();
+ residual.zero();
+
fields->copyLayout("residual");
- const ALE::Obj<real_section_type>& dispTBctpdt =
- fields->getReal("dispTBctpdt");
- CPPUNIT_ASSERT(!dispTBctpdt.isNull());
} catch (const ALE::Exception& err) {
throw std::runtime_error(err.msg());
} // catch
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumann.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,24 +23,16 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/bc/bcfwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
/// Namespace for pylith package
namespace pylith {
namespace bc {
class TestNeumann;
-
- class Neumann; // USES Neumann
class NeumannData; // HOLDSA NeumannData
} // bc
-
- namespace feassemble {
- class Quadrature; // HOLDSA Quadrature
- } // feassemble
-
- namespace topology {
- class FieldsManager; // USES FieldsManager
- } // topology
} // pylith
/// C++ unit testing for Neumann.
@@ -74,20 +66,20 @@
protected :
NeumannData* _data; ///< Data for testing
- feassemble::Quadrature* _quadrature; ///< Data used in testing.
+ feassemble::Quadrature<topology::SubMesh>* _quadrature; ///< Used in testing.
// PRIVATE METHODS ////////////////////////////////////////////////////
private :
/** Initialize Neumann boundary condition.
*
- * @param mesh PETSc mesh to initialize
+ * @param mesh Finite-element mesh to initialize
* @param bc Neumann boundary condition to initialize.
* @param fields Solution fields.
*/
- void _initialize(ALE::Obj<Mesh>* mesh,
+ void _initialize(topology::Mesh* mesh,
Neumann* const bc,
- topology::FieldsManager* fields) const;
+ topology::SolutionFields* fields) const;
}; // class TestNeumann
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/NeumannDataHex8.hh" // USES NeumannDataHex8
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryQuad3D.hh" // USES GeometryQuad3D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestNeumannHex8::setUp(void)
{ // setUp
+ TestNeumann::setUp();
_data = new NeumannDataHex8();
- _quadrature = new feassemble::Quadrature2Din3D();
+ feassemble::GeometryQuad3D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryQuad3D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/NeumannDataLine2.hh" // USES NeumannDataLine2
-#include "pylith/feassemble/Quadrature0D.hh" // USES Quadrature0D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryPoint1D.hh" // USES GeometryPoint1D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestNeumannLine2::setUp(void)
{ // setUp
+ TestNeumann::setUp();
_data = new NeumannDataLine2();
- _quadrature = new feassemble::Quadrature0D();
+ feassemble::GeometryPoint1D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryPoint1D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/NeumannDataQuad4.hh" // USES NeumannDataQuad4
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestNeumannQuad4::setUp(void)
{ // setUp
+ TestNeumann::setUp();
_data = new NeumannDataQuad4();
- _quadrature = new feassemble::Quadrature1Din2D();
+ feassemble::GeometryLine2D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/NeumannDataTet4.hh" // USES NeumannDataTet4
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri3D.hh" // USES GeometryTri3D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestNeumannTet4::setUp(void)
{ // setUp
+ TestNeumann::setUp();
_data = new NeumannDataTet4();
- _quadrature = new feassemble::Quadrature2Din3D();
+ feassemble::GeometryTri3D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryTri3D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/bc/TestNeumannTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/NeumannDataTri3.hh" // USES NeumannDataTri3
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -27,10 +28,10 @@
void
pylith::bc::TestNeumannTri3::setUp(void)
{ // setUp
+ TestNeumann::setUp();
_data = new NeumannDataTri3();
- _quadrature = new feassemble::Quadrature1Din2D();
+ feassemble::GeometryLine2D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
- feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,13 +21,13 @@
# Primary source files
testfaults_SOURCES = \
+ TestFault.cc \
+ TestFaultCohesive.cc \
+ TestStepSlipFn.cc \
+ TestConstRateSlipFn.cc \
TestBruneSlipFn.cc \
TestLiuCosSlipFn.cc \
- TestConstRateSlipFn.cc \
- TestStepSlipFn.cc \
TestEqKinSrc.cc \
- TestFault.cc \
- TestFaultCohesive.cc \
TestFaultCohesiveKin.cc \
TestFaultCohesiveKinLine2.cc \
TestFaultCohesiveKinTri3.cc \
@@ -47,7 +47,6 @@
test_faults.cc
-
noinst_HEADERS = \
TestBruneSlipFn.hh \
TestLiuCosSlipFn.hh \
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,8 +17,11 @@
#include "pylith/faults/BruneSlipFn.hh" // USES BruneSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -38,11 +41,11 @@
const int faultId;
const char* finalSlipFilename;
const char* slipTimeFilename;
- const char* peakRateFilename;
+ const char* riseTimeFilename;
const int* constraintPts;
const double* finalSlipE;
const double* slipTimeE;
- const double* peakRateE;
+ const double* riseTimeE;
const int numConstraintPts;
}; // DataStruct
} // _TestBruneSlipFn
@@ -50,6 +53,11 @@
} // pylith
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Test constructor.
void
pylith::faults::TestBruneSlipFn::testConstructor(void)
@@ -72,7 +80,7 @@
CPPUNIT_ASSERT_EQUAL(std::string(label),
std::string(slipfn._dbFinalSlip->label()));
CPPUNIT_ASSERT(0 == slipfn._dbSlipTime);
- CPPUNIT_ASSERT(0 == slipfn._dbPeakRate);
+ CPPUNIT_ASSERT(0 == slipfn._dbRiseTime);
} // testDbFinalSlip
// ----------------------------------------------------------------------
@@ -90,26 +98,26 @@
CPPUNIT_ASSERT_EQUAL(std::string(label),
std::string(slipfn._dbSlipTime->label()));
CPPUNIT_ASSERT(0 == slipfn._dbFinalSlip);
- CPPUNIT_ASSERT(0 == slipfn._dbPeakRate);
+ CPPUNIT_ASSERT(0 == slipfn._dbRiseTime);
} // testDbSlipTime
// ----------------------------------------------------------------------
-// Test dbPeakRate().
+// Test dbRiseTime().
void
-pylith::faults::TestBruneSlipFn::testDbPeakRate(void)
-{ // testDbPeakRate
+pylith::faults::TestBruneSlipFn::testDbRiseTime(void)
+{ // testDbRiseTime
const char* label = "database ABCDE";
BruneSlipFn slipfn;
spatialdata::spatialdb::SimpleDB db(label);
- slipfn.dbPeakRate(&db);
+ slipfn.dbRiseTime(&db);
- CPPUNIT_ASSERT(0 != slipfn._dbPeakRate);
+ CPPUNIT_ASSERT(0 != slipfn._dbRiseTime);
CPPUNIT_ASSERT_EQUAL(std::string(label),
- std::string(slipfn._dbPeakRate->label()));
+ std::string(slipfn._dbRiseTime->label()));
CPPUNIT_ASSERT(0 == slipfn._dbFinalSlip);
CPPUNIT_ASSERT(0 == slipfn._dbSlipTime);
-} // testDbPeakRate
+} // testDbRiseTime
// ----------------------------------------------------------------------
// Test initialize() in 1-D.
@@ -121,11 +129,11 @@
const int faultId = 2;
const char* finalSlipFilename = "data/line2_finalslip.spatialdb";
const char* slipTimeFilename = "data/line2_sliptime.spatialdb";
- const char* peakRateFilename = "data/line2_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/line2_risetime.spatialdb";
const int constraintPts[] = { 3 };
const double finalSlipE[] = { 2.3 };
const double slipTimeE[] = { 1.2 };
- const double peakRateE[] = { 1.4 };
+ const double riseTimeE[] = { 1.4 };
const int numConstraintPts = 1;
_TestBruneSlipFn::DataStruct data = {meshFilename,
@@ -133,11 +141,11 @@
faultId,
finalSlipFilename,
slipTimeFilename,
- peakRateFilename,
+ riseTimeFilename,
constraintPts,
finalSlipE,
slipTimeE,
- peakRateE,
+ riseTimeE,
numConstraintPts};
_testInitialize(data);
} // testInitialize1D
@@ -152,12 +160,12 @@
const int faultId = 2;
const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
- const char* peakRateFilename = "data/tri3_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/tri3_risetime.spatialdb";
const int constraintPts[] = { 3, 4 };
const double finalSlipE[] = { 2.3, 0.1,
2.4, 0.2};
const double slipTimeE[] = { 1.2, 1.3 };
- const double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const int numConstraintPts = 2;
_TestBruneSlipFn::DataStruct data = {meshFilename,
@@ -165,11 +173,11 @@
faultId,
finalSlipFilename,
slipTimeFilename,
- peakRateFilename,
+ riseTimeFilename,
constraintPts,
finalSlipE,
slipTimeE,
- peakRateE,
+ riseTimeE,
numConstraintPts};
_testInitialize(data);
} // testInitialize2D
@@ -184,13 +192,13 @@
const int faultId = 2;
const char* finalSlipFilename = "data/tet4_finalslip.spatialdb";
const char* slipTimeFilename = "data/tet4_sliptime.spatialdb";
- const char* peakRateFilename = "data/tet4_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/tet4_risetime.spatialdb";
const int constraintPts[] = { 3, 4, 5 };
const double finalSlipE[] = { 2.3, -0.7, 0.1,
2.4, -0.8, 0.2,
2.5, -0.9, 0.3 };
const double slipTimeE[] = { 1.2, 1.3, 1.4 };
- const double peakRateE[] = { 1.5, 1.6, 1.7 };
+ const double riseTimeE[] = { 1.5, 1.6, 1.7 };
const int numConstraintPts = 3;
_TestBruneSlipFn::DataStruct data = {meshFilename,
@@ -198,11 +206,11 @@
faultId,
finalSlipFilename,
slipTimeFilename,
- peakRateFilename,
+ riseTimeFilename,
constraintPts,
finalSlipE,
slipTimeE,
- peakRateE,
+ riseTimeE,
numConstraintPts};
_testInitialize(data);
} // testInitialize3D
@@ -215,46 +223,49 @@
const double finalSlipE[] = { 2.3, 0.1,
0.0, 0.0};
const double slipTimeE[] = { 1.2, 1.3 };
- const double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 5.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
BruneSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t = 2.134;
- slipfn.slip(slip, originTime+t, faultMesh);
+ slipfn.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
for (int iDim=0; iDim < spaceDim; ++iDim)
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
+ const double peakRate = slipMag / riseTimeE[iPoint] * 1.745;
const double tau =
- (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRateE[iPoint]) : 1.0;
+ (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRate) : 1.0;
const double t0 = slipTimeE[iPoint];
const double slipNorm = 1.0 - exp(-(t-t0)/tau) * (1.0 + (t-t0)/tau);
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -272,51 +283,54 @@
const double finalSlipE[] = { 2.3, 0.1,
0.0, 0.0};
const double slipTimeE[] = { 1.2, 1.3 };
- const double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 1.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
BruneSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t0 = 1.234;
const double t1 = 3.635;
- slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ slipfn.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
for (int iDim=0; iDim < spaceDim; ++iDim)
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
+ const double peakRate = slipMag / riseTimeE[iPoint] * 1.745;
const double tau =
- (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRateE[iPoint]) : 1.0;
+ (slipMag > 0.0) ? slipMag / (exp(1.0) * peakRate) : 1.0;
const double tRef = slipTimeE[iPoint];
const double slipNorm0 =
(t0 > tRef) ? 1.0 - exp(-(t0-tRef)/tau) * (1.0 + (t0-tRef)/tau) : 0.0;
const double slipNorm1 =
(t1 > tRef) ? 1.0 - exp(-(t1-tRef)/tau) * (1.0 + (t1-tRef)/tau) : 0.0;
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -334,66 +348,72 @@
{ // testSlipTH
const double t = 0.734;
const double finalSlip = 4.64;
- const double peakRate = 3.23;
+ const double riseTime = 3.23;
+ const double peakRate = finalSlip / riseTime * 1.745;
const double tau = finalSlip / (exp(1.0) * peakRate);
const double slipE = finalSlip * (1.0 - exp(-t/tau) * (1.0 + t/tau));
- double slip = BruneSlipFn::_slipFn(t, finalSlip, peakRate);
+ double slip = BruneSlipFn::_slipFn(t, finalSlip, riseTime);
const double tolerance = 1.0e-06;
CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE, slip, tolerance);
- slip = BruneSlipFn::_slipFn(-0.5, finalSlip, peakRate);
+ slip = BruneSlipFn::_slipFn(-0.5, finalSlip, riseTime);
CPPUNIT_ASSERT_EQUAL(0.0, slip);
- slip = BruneSlipFn::_slipFn(1.0e+10, finalSlip, peakRate);
+ slip = BruneSlipFn::_slipFn(1.0e+10, finalSlip, riseTime);
CPPUNIT_ASSERT_DOUBLES_EQUAL(finalSlip, slip, tolerance);
} // testSlipTH
// ----------------------------------------------------------------------
// Initialize BruneSlipFn.
void
-pylith::faults::TestBruneSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
+pylith::faults::TestBruneSlipFn::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
BruneSlipFn* slipfn,
const double originTime)
{ // _initialize
- assert(0 != slipfn);
+ CPPUNIT_ASSERT(0 != mesh);
+ CPPUNIT_ASSERT(0 != faultMesh);
+ CPPUNIT_ASSERT(0 != slipfn);
const char* meshFilename = "data/tri3.mesh";
const char* faultLabel = "fault";
const int faultId = 2;
const char* finalSlipFilename = "data/tri3_finalslipB.spatialdb";
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
- const char* peakRateFilename = "data/tri3_peakrate.spatialdb";
+ const char* riseTimeFilename = "data/tri3_risetime.spatialdb";
- ALE::Obj<Mesh> mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
- meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh->isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- (*faultMesh)->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -406,19 +426,19 @@
ioSlipTime.filename(slipTimeFilename);
dbSlipTime.ioHandler(&ioSlipTime);
- spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
- spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
- ioPeakRate.filename(peakRateFilename);
- dbPeakRate.ioHandler(&ioPeakRate);
+ spatialdata::spatialdb::SimpleDB dbRiseTime("rise time");
+ spatialdata::spatialdb::SimpleIOAscii ioRiseTime;
+ ioRiseTime.filename(riseTimeFilename);
+ dbRiseTime.ioHandler(&ioRiseTime);
spatialdata::units::Nondimensional normalizer;
// setup BruneSlipFn
slipfn->dbFinalSlip(&dbFinalSlip);
slipfn->dbSlipTime(&dbSlipTime);
- slipfn->dbPeakRate(&dbPeakRate);
+ slipfn->dbRiseTime(&dbRiseTime);
- slipfn->initialize(*faultMesh, &cs, normalizer, originTime);
+ slipfn->initialize(*faultMesh, normalizer, originTime);
} // _initialize
// ----------------------------------------------------------------------
@@ -429,34 +449,38 @@
typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
// Setup mesh
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(data.meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
+ const int spaceDim = mesh.dimension();
cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh.coordsys(&cs);
// Create fault mesh
- ALE::Obj<Mesh> faultMesh =
- new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
const bool useLagrangeConstraints = true;
- CohesiveTopology::createFault(faultMesh, faultBd,
- mesh,
- mesh->getIntSection(data.faultLabel));
- CohesiveTopology::create(faultMesh, faultBd, mesh,
- mesh->getIntSection(data.faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(&faultMesh, faultBoundary,
+ mesh, sieveMesh->getIntSection(data.faultLabel));
+ CohesiveTopology::create(&mesh, faultMesh, faultBoundary,
+ sieveMesh->getIntSection(data.faultLabel),
data.faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh.isNull());
- // Need to copy coordinates from mesh to fault mesh since we are
+ // Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- faultMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -469,51 +493,61 @@
ioSlipTime.filename(data.slipTimeFilename);
dbSlipTime.ioHandler(&ioSlipTime);
- spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
- spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
- ioPeakRate.filename(data.peakRateFilename);
- dbPeakRate.ioHandler(&ioPeakRate);
+ spatialdata::spatialdb::SimpleDB dbRiseTime("rise time");
+ spatialdata::spatialdb::SimpleIOAscii ioRiseTime;
+ ioRiseTime.filename(data.riseTimeFilename);
+ dbRiseTime.ioHandler(&ioRiseTime);
- spatialdata::units::Nondimensional normalizer;
-
// setup BruneSlipFn
BruneSlipFn slipfn;
slipfn.dbFinalSlip(&dbFinalSlip);
slipfn.dbSlipTime(&dbSlipTime);
- slipfn.dbPeakRate(&dbPeakRate);
+ slipfn.dbRiseTime(&dbRiseTime);
+ spatialdata::units::Nondimensional normalizer;
const double originTime = 5.353;
- slipfn.initialize(faultMesh, &cs, normalizer, originTime);
+ slipfn.initialize(faultMesh, normalizer, originTime);
- const double tolerance = 1.0e-06;
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ CPPUNIT_ASSERT(0 != slipfn._parameters);
+ const ALE::Obj<RealSection>& finalSlipSection =
+ slipfn._parameters->get("final slip").section();
+ CPPUNIT_ASSERT(!finalSlipSection.isNull());
+ const ALE::Obj<RealSection>& slipTimeSection =
+ slipfn._parameters->get("slip time").section();
+ CPPUNIT_ASSERT(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& riseTimeSection =
+ slipfn._parameters->get("rise time").section();
+ CPPUNIT_ASSERT(!riseTimeSection.isNull());
+ const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
- const int fiberDim = slipfn._parameters->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(spaceDim+2, fiberDim);
-
- const real_section_type::value_type* vals =
- slipfn._parameters->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vals);
-
+ CPPUNIT_ASSERT_EQUAL(spaceDim, finalSlipSection->getFiberDimension(*v_iter));
+ const double* finalSlipVertex = finalSlipSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != finalSlipVertex);
for (int iDim=0; iDim < spaceDim; ++iDim)
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.finalSlipE[iPoint*spaceDim+iDim],
- vals[iDim],
+ finalSlipVertex[iDim],
tolerance);
- const double peakRate = vals[spaceDim ];
- const double slipTime = vals[spaceDim+1];
+ CPPUNIT_ASSERT_EQUAL(1, slipTimeSection->getFiberDimension(*v_iter));
+ const double* slipTimeVertex = slipTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
+ slipTimeVertex[0], tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.peakRateE[iPoint], peakRate, tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
- slipTime, tolerance);
+ CPPUNIT_ASSERT_EQUAL(1, riseTimeSection->getFiberDimension(*v_iter));
+ const double* riseTimeVertex = riseTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != riseTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.riseTimeE[iPoint],
+ riseTimeVertex[0], tolerance);
} // for
} // _testInitialize
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestBruneSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_testbruneslipfn_hh)
#define pylith_faults_testbruneslipfn_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES BruneSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,7 +30,6 @@
namespace pylith {
namespace faults {
class TestBruneSlipFn;
- class BruneSlipFn;
namespace _TestBruneSlipFn {
struct DataStruct;
@@ -47,7 +47,7 @@
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testDbFinalSlip );
CPPUNIT_TEST( testDbSlipTime );
- CPPUNIT_TEST( testDbPeakRate );
+ CPPUNIT_TEST( testDbRiseTime );
CPPUNIT_TEST( testInitialize1D );
CPPUNIT_TEST( testInitialize2D );
CPPUNIT_TEST( testInitialize3D );
@@ -69,8 +69,8 @@
/// Test dbSlipTime().
void testDbSlipTime(void);
- /// Test dbPeakRate().
- void testDbPeakRate(void);
+ /// Test dbRiseTime().
+ void testDbRiseTime(void);
/// Test initialize() in 1-D.
void testInitialize1D(void);
@@ -95,12 +95,14 @@
/** Initialize BruneSlipFn.
*
- * @param faultMesh Fault mesh.
- * @param slipfn Brune slip function.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
+ * @param slipfn Step slip function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
BruneSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,8 +17,11 @@
#include "pylith/faults/ConstRateSlipFn.hh" // USES ConstRateSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -48,6 +51,11 @@
} // pylith
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Test constructor.
void
pylith::faults::TestConstRateSlipFn::testConstructor(void)
@@ -183,35 +191,38 @@
const double slipTimeE[] = { 1.2, 1.3 };
const double originTime = 5.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
ConstRateSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t = 1.234;
- slipfn.slip(slip, originTime+t, faultMesh);
+ slipfn.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
const double t0 = slipTimeE[iPoint];
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -232,36 +243,38 @@
const double slipTimeE[] = { 1.2, 1.3 };
const double originTime = 1.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
ConstRateSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t0 = 1.234;
const double t1 = 3.635;
- slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ slipfn.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
-
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -276,11 +289,14 @@
// ----------------------------------------------------------------------
// Initialize ConstRateSlipFn.
void
-pylith::faults::TestConstRateSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
- ConstRateSlipFn* slipfn,
+pylith::faults::TestConstRateSlipFn::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
+ ConstRateSlipFn* slipfn,
const double originTime)
{ // _initialize
- assert(0 != slipfn);
+ CPPUNIT_ASSERT(0 != mesh);
+ CPPUNIT_ASSERT(0 != faultMesh);
+ CPPUNIT_ASSERT(0 != slipfn);
const char* meshFilename = "data/tri3.mesh";
const char* faultLabel = "fault";
@@ -288,33 +304,35 @@
const char* slipRateFilename = "data/tri3_sliprate.spatialdb";
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
- ALE::Obj<Mesh> mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
- meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh->isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- (*faultMesh)->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbSlipRate("slip rate");
@@ -333,7 +351,7 @@
slipfn->dbSlipRate(&dbSlipRate);
slipfn->dbSlipTime(&dbSlipTime);
- slipfn->initialize(*faultMesh, &cs, normalizer, originTime);
+ slipfn->initialize(*faultMesh, normalizer, originTime);
} // _initialize
// ----------------------------------------------------------------------
@@ -344,33 +362,38 @@
typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
// Setup mesh
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(data.meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
+ const int spaceDim = mesh.dimension();
cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh.coordsys(&cs);
// Create fault mesh
- ALE::Obj<Mesh> faultMesh = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
const bool useLagrangeConstraints = true;
- CohesiveTopology::createFault(faultMesh, faultBd,
- mesh,
- mesh->getIntSection(data.faultLabel));
- CohesiveTopology::create(faultMesh, faultBd, mesh,
- mesh->getIntSection(data.faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(&faultMesh, faultBoundary,
+ mesh, sieveMesh->getIntSection(data.faultLabel));
+ CohesiveTopology::create(&mesh, faultMesh, faultBoundary,
+ sieveMesh->getIntSection(data.faultLabel),
data.faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh.isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- faultMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbSlipRate("slip rate");
@@ -389,37 +412,40 @@
slipfn.dbSlipTime(&dbSlipTime);
spatialdata::units::Nondimensional normalizer;
-
const double originTime = 5.353;
- slipfn.initialize(faultMesh, &cs, normalizer, originTime);
+ slipfn.initialize(faultMesh, normalizer, originTime);
- const double tolerance = 1.0e-06;
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ CPPUNIT_ASSERT(0 != slipfn._parameters);
+ const ALE::Obj<RealSection>& slipRateSection =
+ slipfn._parameters->get("slip rate").section();
+ CPPUNIT_ASSERT(!slipRateSection.isNull());
+ const ALE::Obj<RealSection>& slipTimeSection =
+ slipfn._parameters->get("slip time").section();
+ CPPUNIT_ASSERT(!slipTimeSection.isNull());
+ const double tolerance = 1.0e-06;\
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
- const int fiberDim = slipfn._parameters->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(spaceDim+1, fiberDim);
-
- const real_section_type::value_type* vals =
- slipfn._parameters->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vals);
-
+ CPPUNIT_ASSERT_EQUAL(spaceDim, slipRateSection->getFiberDimension(*v_iter));
+ const double* slipRateVertex = slipRateSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipRateVertex);
for (int iDim=0; iDim < spaceDim; ++iDim)
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipRateE[iPoint*spaceDim+iDim],
- vals[iDim],
+ slipRateVertex[iDim],
tolerance);
- const double slipTime = vals[spaceDim];
-
+ CPPUNIT_ASSERT_EQUAL(1, slipTimeSection->getFiberDimension(*v_iter));
+ const double* slipTimeVertex = slipTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipTimeVertex);
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
- slipTime, tolerance);
+ slipTimeVertex[0], tolerance);
} // for
} // _testInitialize
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestConstRateSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_testconstrateslipfn_hh)
#define pylith_faults_testconstrateslipfn_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES ConstRateSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,7 +30,6 @@
namespace pylith {
namespace faults {
class TestConstRateSlipFn;
- class ConstRateSlipFn;
namespace _TestConstRateSlipFn {
struct DataStruct;
@@ -87,12 +87,14 @@
/** Initialize ConstRateSlipFn.
*
- * @param faultMesh Fault mesh.
- * @param slipfn ConstRate slip function.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
+ * @param slipfn Step slip function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
ConstRateSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,10 +16,13 @@
#include "pylith/faults/EqKinSrc.hh" // USES EqKinSrc
+
#include "pylith/faults/BruneSlipFn.hh" // USES BruneSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -30,6 +33,11 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestEqKinSrc );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Test constructor.
void
pylith::faults::TestEqKinSrc::testConstructor(void)
@@ -55,11 +63,12 @@
void
pylith::faults::TestEqKinSrc::testInitialize(void)
{ // testInitialize
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
EqKinSrc eqsrc;
BruneSlipFn slipfn;
const double originTime = 2.45;
- _initialize(&faultMesh, &eqsrc, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &eqsrc, &slipfn, originTime);
// Don't have access to details of slip time function, so we can't
// check parameters. Have to rely on test of slip() for verification
@@ -74,46 +83,51 @@
const double finalSlipE[] = { 2.3, 0.1,
2.4, 0.2};
const double slipTimeE[] = { 1.2, 1.3 };
- const double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 2.42;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
EqKinSrc eqsrc;
BruneSlipFn slipfn;
- _initialize(&faultMesh, &eqsrc, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &eqsrc, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t = 2.134;
- eqsrc.slip(slip, originTime+t, faultMesh);
+ eqsrc.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
for (int iDim=0; iDim < spaceDim; ++iDim)
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
- const double tau = slipMag / (exp(1.0) * peakRateE[iPoint]);
+ const double peakRate = slipMag / riseTimeE[iPoint] * 1.745;
+ const double tau = slipMag / (exp(1.0) * peakRate);
const double t0 = slipTimeE[iPoint];
const double slipNorm = 1.0 - exp(-(t-t0)/tau) * (1.0 + (t-t0)/tau);
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -131,50 +145,54 @@
const double finalSlipE[] = { 2.3, 0.1,
2.4, 0.2};
const double slipTimeE[] = { 1.2, 1.3 };
- const double peakRateE[] = { 1.4, 1.5 };
+ const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = -4.29;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
EqKinSrc eqsrc;
BruneSlipFn slipfn;
- _initialize(&faultMesh, &eqsrc, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &eqsrc, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t0 = 1.234;
const double t1 = 2.525;
- eqsrc.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ eqsrc.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
for (int iDim=0; iDim < spaceDim; ++iDim)
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
- const double tau = slipMag / (exp(1.0) * peakRateE[iPoint]);
+ const double peakRate = slipMag / riseTimeE[iPoint] * 1.745;
+ const double tau = slipMag / (exp(1.0) * peakRate);
const double tRef = slipTimeE[iPoint];
const double slipNorm0 =
(t0 > tRef) ? 1.0 - exp(-(t0-tRef)/tau) * (1.0 + (t0-tRef)/tau) : 0.0;
const double slipNorm1 =
(t1 > tRef) ? 1.0 - exp(-(t1-tRef)/tau) * (1.0 + (t1-tRef)/tau) : 0.0;
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -188,45 +206,53 @@
// ----------------------------------------------------------------------
// Initialize EqKinSrc.
void
-pylith::faults::TestEqKinSrc::_initialize(ALE::Obj<Mesh>* faultMesh,
+pylith::faults::TestEqKinSrc::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
EqKinSrc* eqsrc,
BruneSlipFn* slipfn,
const double originTime)
{ // _initialize
+ CPPUNIT_ASSERT(0 != mesh);
+ CPPUNIT_ASSERT(0 != faultMesh);
+ CPPUNIT_ASSERT(0 != eqsrc);
+ CPPUNIT_ASSERT(0 != slipfn);
+
const char* meshFilename = "data/tri3.mesh";
const char* faultLabel = "fault";
const int faultId = 2;
const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
- const char* peakRateFilename = "data/tri3_peakrate.spatialdb";
+ const char* peakRateFilename = "data/tri3_risetime.spatialdb";
- ALE::Obj<Mesh> mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
- meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh->isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- (*faultMesh)->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -239,21 +265,21 @@
ioSlipTime.filename(slipTimeFilename);
dbSlipTime.ioHandler(&ioSlipTime);
- spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
- spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
- ioPeakRate.filename(peakRateFilename);
- dbPeakRate.ioHandler(&ioPeakRate);
+ spatialdata::spatialdb::SimpleDB dbRiseTime("rise time");
+ spatialdata::spatialdb::SimpleIOAscii ioRiseTime;
+ ioRiseTime.filename(peakRateFilename);
+ dbRiseTime.ioHandler(&ioRiseTime);
spatialdata::units::Nondimensional normalizer;
// setup EqKinSrc
slipfn->dbFinalSlip(&dbFinalSlip);
slipfn->dbSlipTime(&dbSlipTime);
- slipfn->dbPeakRate(&dbPeakRate);
+ slipfn->dbRiseTime(&dbRiseTime);
eqsrc->originTime(originTime);
eqsrc->slipfn(slipfn);
- eqsrc->initialize(*faultMesh, &cs, normalizer);
+ eqsrc->initialize(*faultMesh, normalizer);
} // _initialize
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestEqKinSrc.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_testeqkinsrc_hh)
#define pylith_faults_testeqkinsrc_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES EqKinSrc, BruneSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,12 +30,6 @@
namespace pylith {
namespace faults {
class TestEqKinSrc;
- class EqKinSrc;
- class BruneSlipFn;
-
- namespace _TestEqKinSrc {
- struct DataStruct;
- } // _TestEqKinSrc
} // faults
} // pylith
@@ -79,13 +74,15 @@
/** Initialize EqKinSrc.
*
- * @param faultMesh Fault mesh.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
* @param eqsrc Earthquake source.
* @param slipfn Slip time function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
EqKinSrc* eqsrc,
BruneSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -30,7 +30,7 @@
FaultCohesiveKin fault;
fault.id(id);
- CPPUNIT_ASSERT(id == fault.id());
+ CPPUNIT_ASSERT_EQUAL(id, fault.id());
} // testID
// ----------------------------------------------------------------------
@@ -42,7 +42,7 @@
FaultCohesiveKin fault;
fault.label(label.c_str());
- CPPUNIT_ASSERT_EQUAL(label, fault.label());
+ CPPUNIT_ASSERT_EQUAL(label, std::string(fault.label()));
} // testLabel
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFault.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,7 +26,6 @@
/// Namespace for pylith package
namespace pylith {
namespace faults {
- class Fault;
class TestFault;
} // faults
} // pylith
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,10 +17,9 @@
#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultsCohesiveKin
#include "pylith/faults/FaultCohesiveDyn.hh" // USES FaultsCohesiveDyn
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/utils/array.hh" // USES int_array, double_array
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
#include "data/CohesiveDataLine2.hh" // USES CohesiveDataLine2
#include "data/CohesiveDataTri3.hh" // USES CohesiveDataTri3
@@ -66,6 +65,9 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestFaultCohesive );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
void
pylith::faults::TestFaultCohesive::testUseFaultMesh(void)
{ // testUseFaultMesh
@@ -482,7 +484,7 @@
const CohesiveData& data,
const bool flipFault)
{ // _testAdjustTopology
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
meshio::MeshIOAscii iohandler;
iohandler.filename(data.filename);
iohandler.debug(false);
@@ -492,27 +494,31 @@
CPPUNIT_ASSERT(0 != fault);
fault->id(1);
fault->label("fault");
- fault->adjustTopology(mesh, flipFault);
+ fault->adjustTopology(&mesh, flipFault);
//mesh->view(data.filename);
- CPPUNIT_ASSERT_EQUAL(data.cellDim, mesh->getDimension());
+ CPPUNIT_ASSERT_EQUAL(data.cellDim, mesh.dimension());
// Check vertices
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<Mesh::real_section_type>& coordsField =
- mesh->getRealSection("coordinates");
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const ALE::Obj<topology::Mesh::RealSection>& coordsSection =
+ sieveMesh->getRealSection("coordinates");
+ CPPUNIT_ASSERT(!coordsSection.isNull());
const int numVertices = vertices->size();
CPPUNIT_ASSERT_EQUAL(data.numVertices, numVertices);
CPPUNIT_ASSERT_EQUAL(data.spaceDim,
- coordsField->getFiberDimension(*vertices->begin()));
+ coordsSection->getFiberDimension(*vertices->begin()));
int i = 0;
const int spaceDim = data.spaceDim;
- for(Mesh::label_sequence::iterator v_iter =
+ for (SieveMesh::label_sequence::iterator v_iter =
vertices->begin();
v_iter != vertices->end();
++v_iter) {
- const Mesh::real_section_type::value_type *vertexCoords =
- coordsField->restrictPoint(*v_iter);
+ const double* vertexCoords = coordsSection->restrictPoint(*v_iter);
const double tolerance = 1.0e-06;
for (int iDim=0; iDim < spaceDim; ++iDim)
if (data.vertices[i] < 1.0)
@@ -524,22 +530,24 @@
} // for
// check cells
- const ALE::Obj<sieve_type>& sieve = mesh->getSieve();
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = sieveMesh->getSieve();
+ CPPUNIT_ASSERT(!sieve.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells = sieveMesh->heightStratum(0);
+ CPPUNIT_ASSERT(!cells.isNull());
const int numCells = cells->size();
CPPUNIT_ASSERT_EQUAL(data.numCells, numCells);
- ALE::ISieveVisitor::PointRetriever<Mesh::sieve_type> pV(sieve->getMaxConeSize());
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> pV(sieve->getMaxConeSize());
int iCell = 0;
i = 0;
- for(Mesh::label_sequence::iterator c_iter = cells->begin();
+ for(SieveMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cells->end();
++c_iter) {
- const int numCorners = mesh->getNumCellCorners(*c_iter);
+ const int numCorners = sieveMesh->getNumCellCorners(*c_iter);
CPPUNIT_ASSERT_EQUAL(data.numCorners[iCell++], numCorners);
sieve->cone(*c_iter, pV);
- const Mesh::point_type *cone = pV.getPoints();
+ const SieveMesh::point_type *cone = pV.getPoints();
for(int p = 0; p < pV.getSize(); ++p, ++i) {
CPPUNIT_ASSERT_EQUAL(data.cells[i], cone[p]);
}
@@ -547,41 +555,44 @@
} // for
// check materials
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- mesh->getLabel("material-id");
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->getLabel("material-id");
+ CPPUNIT_ASSERT(!labelMaterials.isNull());
const int idDefault = -999;
const int size = numCells;
int_array materialIds(size);
i = 0;
- for(Mesh::label_sequence::iterator c_iter = cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cells->end();
++c_iter)
- materialIds[i++] = mesh->getValue(labelMaterials, *c_iter, idDefault);
+ materialIds[i++] = sieveMesh->getValue(labelMaterials, *c_iter, idDefault);
for (int iCell=0; iCell < numCells; ++iCell)
CPPUNIT_ASSERT_EQUAL(data.materialIds[iCell], materialIds[iCell]);
// Check groups
const ALE::Obj<std::set<std::string> >& groupNames =
- mesh->getIntSections();
+ sieveMesh->getIntSections();
+ CPPUNIT_ASSERT(!groupNames.isNull());
int iGroup = 0;
int index = 0;
for (std::set<std::string>::const_iterator name=groupNames->begin();
name != groupNames->end();
++name, ++iGroup) {
- const ALE::Obj<int_section_type>& groupField = mesh->getIntSection(*name);
+ const ALE::Obj<topology::Mesh::IntSection>& groupField =
+ sieveMesh->getIntSection(*name);
CPPUNIT_ASSERT(!groupField.isNull());
- const int_section_type::chart_type& chart = groupField->getChart();
- Mesh::point_type firstPoint;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
+ const topology::Mesh::IntSection::chart_type& chart = groupField->getChart();
+ SieveMesh::point_type firstPoint;
+ for (topology::Mesh::IntSection::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
if (groupField->getFiberDimension(*c_iter)) {firstPoint = *c_iter; break;}
}
std::string groupType =
- (mesh->height(firstPoint) == 0) ? "cell" : "vertex";
+ (sieveMesh->height(firstPoint) == 0) ? "cell" : "vertex";
const int numPoints = groupField->size();
int_array points(numPoints);
int i = 0;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
+ for (topology::Mesh::IntSection::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
if (groupField->getFiberDimension(*c_iter)) points[i++] = *c_iter;
}
@@ -602,7 +613,7 @@
const bool flipFaultA,
const bool flipFaultB)
{ // _testAdjustTopology
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
meshio::MeshIOAscii iohandler;
iohandler.filename(data.filename);
iohandler.debug(false);
@@ -612,60 +623,67 @@
CPPUNIT_ASSERT(0 != faultA);
faultA->id(1);
faultA->label("faultA");
- faultA->adjustTopology(mesh, flipFaultA);
+ faultA->adjustTopology(&mesh, flipFaultA);
CPPUNIT_ASSERT(0 != faultB);
faultB->id(2);
faultB->label("faultB");
- faultB->adjustTopology(mesh, flipFaultB);
+ faultB->adjustTopology(&mesh, flipFaultB);
- //mesh->view(data.filename);
- CPPUNIT_ASSERT_EQUAL(data.cellDim, mesh->getDimension());
+ //sieveMesh->view(data.filename);
+ CPPUNIT_ASSERT_EQUAL(data.cellDim, mesh.dimension());
// Check vertices
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<Mesh::real_section_type>& coordsField =
- mesh->getRealSection("coordinates");
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const ALE::Obj<topology::Mesh::RealSection>& coordsSection =
+ sieveMesh->getRealSection("coordinates");
+ CPPUNIT_ASSERT(!coordsSection.isNull());
const int numVertices = vertices->size();
CPPUNIT_ASSERT_EQUAL(data.numVertices, numVertices);
CPPUNIT_ASSERT_EQUAL(data.spaceDim,
- coordsField->getFiberDimension(*vertices->begin()));
+ coordsSection->getFiberDimension(*vertices->begin()));
int i = 0;
const int spaceDim = data.spaceDim;
- for(Mesh::label_sequence::iterator v_iter =
+ for(SieveMesh::label_sequence::iterator v_iter =
vertices->begin();
v_iter != vertices->end();
++v_iter) {
- const Mesh::real_section_type::value_type *vertexCoords =
- coordsField->restrictPoint(*v_iter);
+ const double* coordsVertex = coordsSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != coordsVertex);
const double tolerance = 1.0e-06;
for (int iDim=0; iDim < spaceDim; ++iDim)
if (data.vertices[i] < 1.0)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.vertices[i++], vertexCoords[iDim],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.vertices[i++], coordsVertex[iDim],
tolerance);
else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, vertexCoords[iDim]/data.vertices[i++],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, coordsVertex[iDim]/data.vertices[i++],
tolerance);
} // for
// check cells
- const ALE::Obj<sieve_type>& sieve = mesh->getSieve();
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = sieveMesh->getSieve();
+ CPPUNIT_ASSERT(!sieve.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells = sieveMesh->heightStratum(0);
+ CPPUNIT_ASSERT(!cells.isNull());
const int numCells = cells->size();
CPPUNIT_ASSERT_EQUAL(data.numCells, numCells);
- ALE::ISieveVisitor::PointRetriever<Mesh::sieve_type> pV(sieve->getMaxConeSize());
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> pV(sieve->getMaxConeSize());
int iCell = 0;
i = 0;
- //mesh->view(data.filename);
- for(Mesh::label_sequence::iterator c_iter = cells->begin();
+ //sieveMesh->view(data.filename);
+ for(SieveMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cells->end();
++c_iter) {
- const int numCorners = mesh->getNumCellCorners(*c_iter);
+ const int numCorners = sieveMesh->getNumCellCorners(*c_iter);
CPPUNIT_ASSERT_EQUAL(data.numCorners[iCell++], numCorners);
sieve->cone(*c_iter, pV);
- const Mesh::point_type *cone = pV.getPoints();
+ const SieveMesh::point_type *cone = pV.getPoints();
for(int p = 0; p < pV.getSize(); ++p, ++i) {
CPPUNIT_ASSERT_EQUAL(data.cells[i], cone[p]);
}
@@ -673,41 +691,44 @@
} // for
// check materials
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- mesh->getLabel("material-id");
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->getLabel("material-id");
+ CPPUNIT_ASSERT(!labelMaterials.isNull());
const int idDefault = -999;
const int size = numCells;
int_array materialIds(size);
i = 0;
- for(Mesh::label_sequence::iterator c_iter = cells->begin();
+ for(SieveMesh::label_sequence::iterator c_iter = cells->begin();
c_iter != cells->end();
++c_iter)
- materialIds[i++] = mesh->getValue(labelMaterials, *c_iter, idDefault);
+ materialIds[i++] = sieveMesh->getValue(labelMaterials, *c_iter, idDefault);
for (int iCell=0; iCell < numCells; ++iCell)
CPPUNIT_ASSERT_EQUAL(data.materialIds[iCell], materialIds[iCell]);
// Check groups
const ALE::Obj<std::set<std::string> >& groupNames =
- mesh->getIntSections();
+ sieveMesh->getIntSections();
+ CPPUNIT_ASSERT(!groupNames.isNull());
int iGroup = 0;
int index = 0;
for (std::set<std::string>::const_iterator name=groupNames->begin();
name != groupNames->end();
++name, ++iGroup) {
- const ALE::Obj<int_section_type>& groupField = mesh->getIntSection(*name);
+ const ALE::Obj<topology::Mesh::IntSection>& groupField =
+ sieveMesh->getIntSection(*name);
CPPUNIT_ASSERT(!groupField.isNull());
- const int_section_type::chart_type& chart = groupField->getChart();
- Mesh::point_type firstPoint;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
+ const topology::Mesh::IntSection::chart_type& chart = groupField->getChart();
+ SieveMesh::point_type firstPoint;
+ for(topology::Mesh::IntSection::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
if (groupField->getFiberDimension(*c_iter)) {firstPoint = *c_iter; break;}
}
std::string groupType =
- (mesh->height(firstPoint) == 0) ? "cell" : "vertex";
+ (sieveMesh->height(firstPoint) == 0) ? "cell" : "vertex";
const int numPoints = groupField->size();
int_array points(numPoints);
int i = 0;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
+ for(topology::Mesh::IntSection::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
if (groupField->getFiberDimension(*c_iter)) points[i++] = *c_iter;
}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesive.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,12 +23,11 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievefwd.hh" // USES PETSc Mesh
+#include "pylith/faults/faultsfwd.hh" // USES PETSc Mesh
/// Namespace for pylith package
namespace pylith {
namespace faults {
- class Fault;
class TestFaultCohesive;
class CohesiveData;
} // faults
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,10 +20,12 @@
#include "pylith/faults/EqKinSrc.hh" // USES EqKinSrc
#include "pylith/faults/BruneSlipFn.hh" // USES BruneSlipFn
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -35,12 +37,18 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestFaultCohesiveKin );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
+
+// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::faults::TestFaultCohesiveKin::setUp(void)
{ // setUp
_data = 0;
- _quadrature = 0;
+ _quadrature = new feassemble::Quadrature<topology::SubMesh>();
+ CPPUNIT_ASSERT(0 != _quadrature);
const int nsrcs = 1;
_eqsrcs.resize(nsrcs);
_eqsrcs[0] = new EqKinSrc();
@@ -87,7 +95,7 @@
const char* names[] = {"one", "two"};
sources[0] = &eqsrcA;
sources[1] = &eqsrcB;
- fault.eqsrcs(names, sources, nsrcs);
+ fault.eqsrcs(names, nsrcs, sources, nsrcs);
CPPUNIT_ASSERT(&eqsrcA == fault._eqSrcs["one"]);
CPPUNIT_ASSERT(&eqsrcB == fault._eqSrcs["two"]);
delete[] sources; sources = 0;
@@ -129,76 +137,88 @@
void
pylith::faults::TestFaultCohesiveKin::testInitialize(void)
{ // testInitialize
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
FaultCohesiveKin fault;
- _initialize(&mesh, &fault);
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &fault, &fields);
- //mesh->view(_data->meshFilename);
-
- Mesh::renumbering_type& renumbering = fault._faultMesh->getRenumbering();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- fault._faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = fault._faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ SieveSubMesh::renumbering_type& renumbering =
+ faultSieveMesh->getRenumbering();
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
int iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++iVertex) {
- CPPUNIT_ASSERT(renumbering.find(_data->constraintVertices[iVertex]) != renumbering.end());
+ CPPUNIT_ASSERT(renumbering.find(_data->constraintVertices[iVertex]) !=
+ renumbering.end());
CPPUNIT_ASSERT_EQUAL(renumbering[_data->constraintVertices[iVertex]],
*v_iter);
} // for
CPPUNIT_ASSERT_EQUAL(_data->numConstraintVert, iVertex);
// Check orientation
+ //fault._fields->get("orientation").view("ORIENTATION"); // DEBUGGING
+ const ALE::Obj<RealSection>& orientationSection =
+ fault._fields->get("orientation").section();
+ CPPUNIT_ASSERT(!orientationSection.isNull());
const int cellDim = _data->cellDim;
const int spaceDim = _data->spaceDim;
const int orientationSize = spaceDim*spaceDim;
iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const int fiberDim = fault._orientation->getFiberDimension(*v_iter);
+ const int fiberDim = orientationSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(orientationSize, fiberDim);
- const real_section_type::value_type* vertexOrient =
- fault._orientation->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vertexOrient);
+ const double* orientationVertex =
+ orientationSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != orientationVertex);
const double tolerance = 1.0e-06;
for (int i=0; i < orientationSize; ++i) {
const int index = iVertex*orientationSize+i;
CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->orientation[index],
- vertexOrient[i], tolerance);
+ orientationVertex[i], tolerance);
} // for
} // for
// Check area
+ const ALE::Obj<RealSection>& areaSection =
+ fault._fields->get("area").section();
+ CPPUNIT_ASSERT(!areaSection.isNull());
iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const int fiberDim = fault._area->getFiberDimension(*v_iter);
+ const int fiberDim = areaSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(1, fiberDim);
- const real_section_type::value_type* vertexArea =
- fault._area->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vertexArea);
+ const double* areaVertex = areaSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != areaVertex);
const double tolerance = 1.0e-06;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->area[iVertex], vertexArea[0],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->area[iVertex], areaVertex[0],
tolerance);
} // for
// Check pseudoStiffness
+ const ALE::Obj<RealSection>& stiffnessSection =
+ fault._fields->get("pseudostiffness").section();
+ CPPUNIT_ASSERT(!stiffnessSection.isNull());
iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const int fiberDim = fault._pseudoStiffness->getFiberDimension(*v_iter);
+ const int fiberDim = stiffnessSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(1, fiberDim);
- const real_section_type::value_type* vertexStiffness =
- fault._pseudoStiffness->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vertexStiffness);
+ const double* stiffnessVertex = stiffnessSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != stiffnessVertex);
const double tolerance = 1.0e-06;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->pseudoStiffness, vertexStiffness[0],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(_data->pseudoStiffness, stiffnessVertex[0],
tolerance);
} // for
} // testInitialize
@@ -208,49 +228,39 @@
void
pylith::faults::TestFaultCohesiveKin::testIntegrateResidual(void)
{ // testIntegrateResidual
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
FaultCohesiveKin fault;
- _initialize(&mesh, &fault);
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &fault, &fields);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((mesh)->getDimension());
- cs.initialize();
-
- // Setup fields
- topology::FieldsManager fields(mesh);
- fields.addReal("residual");
- fields.addReal("solution");
- fields.solutionField("solution");
-
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
const int spaceDim = _data->spaceDim;
- residual->setChart(mesh->getSieve()->getChart());
- residual->setFiberDimension(mesh->depthStratum(0), spaceDim);
- mesh->allocate(residual);
- residual->zero();
- fields.copyLayout("residual");
+ topology::Field<topology::Mesh>& residual = fields.get("residual");
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ CPPUNIT_ASSERT(!residualSection.isNull());
- const ALE::Obj<real_section_type>& solution = fields.getReal("solution");
- CPPUNIT_ASSERT(!solution.isNull());
+ const ALE::Obj<RealSection>& solutionSection =
+ fields.get("solution").section();
+ CPPUNIT_ASSERT(!solutionSection.isNull());
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::label_sequence::iterator vBegin = vertices->begin();
- const Mesh::label_sequence::iterator vEnd = vertices->end();
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
int iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
- ++v_iter, ++iVertex) {
- solution->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
- } // for
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter, ++iVertex)
+ solutionSection->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
const double t = 2.134;
const double dt = 0.01;
fault.timeStep(dt);
{ // Integrate residual with solution (as opposed to solution increment).
fault.useSolnIncr(false);
- fault.integrateResidual(residual, t, &fields, mesh, &cs);
+ fault.integrateResidual(residual, t, &fields);
//residual->view("RESIDUAL"); // DEBUGGING
@@ -259,13 +269,12 @@
iVertex = 0;
const int fiberDimE = spaceDim;
const double tolerance = 1.0e-06;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const int fiberDim = residual->getFiberDimension(*v_iter);
+ const int fiberDim = residualSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(fiberDimE, fiberDim);
- const real_section_type::value_type* vals =
- residual->restrictPoint(*v_iter);
+ const double* vals = residualSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
const bool isConstraint = _isConstraintVertex(*v_iter);
@@ -287,25 +296,24 @@
} // for
} // Integrate residual with solution (as opposed to solution increment).
- residual->zero();
+ residual.zero();
{ // Integrate residual with solution increment.
fault.useSolnIncr(true);
- fault.integrateResidual(residual, t, &fields, mesh, &cs);
+ fault.integrateResidual(residual, t, &fields);
- //residual->view("RESIDUAL"); // DEBUGGING
+ //residual.view("RESIDUAL"); // DEBUGGING
// Check values
const double* valsE = _data->valsResidualIncr;
iVertex = 0;
const int fiberDimE = spaceDim;
const double tolerance = 1.0e-06;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const int fiberDim = residual->getFiberDimension(*v_iter);
+ const int fiberDim = residualSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(fiberDimE, fiberDim);
- const real_section_type::value_type* vals =
- residual->restrictPoint(*v_iter);
+ const double* vals = residualSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
const bool isConstraint = _isConstraintVertex(*v_iter);
@@ -333,67 +341,52 @@
void
pylith::faults::TestFaultCohesiveKin::testIntegrateJacobian(void)
{ // testIntegrateJacobian
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
FaultCohesiveKin fault;
- _initialize(&mesh, &fault);
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &fault, &fields);
- // Setup fields
- topology::FieldsManager fields(mesh);
- fields.addReal("residual");
- fields.addReal("solution");
- fields.solutionField("solution");
-
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
- const int spaceDim = _data->spaceDim;
- residual->setChart(mesh->getSieve()->getChart());
- residual->setFiberDimension(mesh->depthStratum(0), spaceDim);
- mesh->allocate(residual);
- residual->zero();
- fields.copyLayout("residual");
+ const ALE::Obj<RealSection>& solutionSection = fields.get("solution").section();
+ CPPUNIT_ASSERT(!solutionSection.isNull());
- const ALE::Obj<real_section_type>& solution = fields.getReal("solution");
- CPPUNIT_ASSERT(!solution.isNull());
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const int spaceDim = _data->spaceDim;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices = sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::label_sequence::iterator vBegin = vertices->begin();
- const Mesh::label_sequence::iterator vEnd = vertices->end();
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
int iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
++v_iter, ++iVertex) {
- solution->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
+ solutionSection->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
} // for
- PetscMat jacobian;
- PetscErrorCode err = MeshCreateMatrix(mesh, solution, MATMPIBAIJ, &jacobian);
- CPPUNIT_ASSERT(0 == err);
+ topology::Jacobian jacobian(fields);
const double t = 2.134;
- fault.integrateJacobian(&jacobian, t, &fields, mesh);
+ fault.integrateJacobian(&jacobian, t, &fields);
CPPUNIT_ASSERT_EQUAL(false, fault.needNewJacobian());
- err = MatAssemblyBegin(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
- err = MatAssemblyEnd(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
+ jacobian.assemble("final_assembly");
//MatView(jacobian, PETSC_VIEWER_STDOUT_WORLD); // DEBUGGING
const double* valsE = _data->valsJacobian;
- const int nrowsE = solution->sizeWithBC();
+ const int nrowsE = solutionSection->sizeWithBC();
const int ncolsE = nrowsE;
int nrows = 0;
int ncols = 0;
- MatGetSize(jacobian, &nrows, &ncols);
+ PetscMat jacobianMat = jacobian.matrix();
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(jacobian, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
@@ -428,49 +421,37 @@
void
pylith::faults::TestFaultCohesiveKin::testIntegrateResidualAssembled(void)
{ // testIntegrateResidualAssembled
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
FaultCohesiveKin fault;
- _initialize(&mesh, &fault);
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &fault, &fields);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((mesh)->getDimension());
- cs.initialize();
-
- // Setup fields
- topology::FieldsManager fields(mesh);
- fields.addReal("residual");
- fields.addReal("solution");
- fields.solutionField("solution");
-
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
const int spaceDim = _data->spaceDim;
- residual->setChart(mesh->getSieve()->getChart());
- residual->setFiberDimension(mesh->depthStratum(0), spaceDim);
- mesh->allocate(residual);
- residual->zero();
- fields.copyLayout("residual");
+ topology::Field<topology::Mesh>& residual = fields.get("residual");
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ CPPUNIT_ASSERT(!residualSection.isNull());
- const ALE::Obj<real_section_type>& solution = fields.getReal("solution");
- CPPUNIT_ASSERT(!solution.isNull());
+ const ALE::Obj<RealSection>& solutionSection = fields.get("solution").section();
+ CPPUNIT_ASSERT(!solutionSection.isNull());
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices = sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::label_sequence::iterator vBegin = vertices->begin();
- const Mesh::label_sequence::iterator vEnd = vertices->end();
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
int iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
- ++v_iter, ++iVertex) {
- solution->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
- } // for
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter, ++iVertex)
+ solutionSection->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
const double t = 2.134;
const double dt = 0.01;
fault.timeStep(dt);
{ // Integrate residual with solution (as opposed to solution increment).
fault.useSolnIncr(false);
- fault.integrateResidualAssembled(residual, t, &fields, mesh, &cs);
+ fault.integrateResidualAssembled(residual, t, &fields);
//residual->view("RESIDUAL"); // DEBUGGING
@@ -479,13 +460,12 @@
iVertex = 0;
const int fiberDimE = spaceDim;
const double tolerance = 1.0e-06;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const int fiberDim = residual->getFiberDimension(*v_iter);
+ const int fiberDim = residualSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(fiberDimE, fiberDim);
- const real_section_type::value_type* vals =
- residual->restrictPoint(*v_iter);
+ const double* vals = residualSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
const bool isConstraint = _isConstraintVertex(*v_iter);
@@ -507,10 +487,10 @@
} // for
} // Integrate residual with solution (as opposed to solution increment).
- residual->zero();
+ residual.zero();
{ // Integrate residual with solution increment.
fault.useSolnIncr(true);
- fault.integrateResidualAssembled(residual, t, &fields, mesh, &cs);
+ fault.integrateResidualAssembled(residual, t, &fields);
//residual->view("RESIDUAL"); // DEBUGGING
@@ -519,13 +499,12 @@
iVertex = 0;
const int fiberDimE = spaceDim;
const double tolerance = 1.0e-06;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const int fiberDim = residual->getFiberDimension(*v_iter);
+ const int fiberDim = residualSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(fiberDimE, fiberDim);
- const real_section_type::value_type* vals =
- residual->restrictPoint(*v_iter);
+ const double* vals = residualSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
const bool isConstraint = _isConstraintVertex(*v_iter);
@@ -553,67 +532,52 @@
void
pylith::faults::TestFaultCohesiveKin::testIntegrateJacobianAssembled(void)
{ // testIntegrateJacobianAssembled
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
FaultCohesiveKin fault;
- _initialize(&mesh, &fault);
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &fault, &fields);
- // Setup fields
- topology::FieldsManager fields(mesh);
- fields.addReal("residual");
- fields.addReal("solution");
- fields.solutionField("solution");
-
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
const int spaceDim = _data->spaceDim;
- residual->setChart(mesh->getSieve()->getChart());
- residual->setFiberDimension(mesh->depthStratum(0), spaceDim);
- mesh->allocate(residual);
- residual->zero();
- fields.copyLayout("residual");
+ const ALE::Obj<RealSection>& solutionSection = fields.get("solution").section();
+ CPPUNIT_ASSERT(!solutionSection.isNull());
- const ALE::Obj<real_section_type>& solution = fields.getReal("solution");
- CPPUNIT_ASSERT(!solution.isNull());
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices = sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::label_sequence::iterator vBegin = vertices->begin();
- const Mesh::label_sequence::iterator vEnd = vertices->end();
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
int iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vBegin;
- v_iter != vEnd;
- ++v_iter, ++iVertex) {
- solution->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
- } // for
-
- PetscMat jacobian;
- PetscErrorCode err = MeshCreateMatrix(mesh, solution, MATMPIBAIJ, &jacobian);
- CPPUNIT_ASSERT(0 == err);
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
+ v_iter != verticesEnd;
+ ++v_iter, ++iVertex)
+ solutionSection->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
+ topology::Jacobian jacobian(fields);
+
const double t = 2.134;
- fault.integrateJacobian(&jacobian, t, &fields, mesh);
+ fault.integrateJacobian(&jacobian, t, &fields);
CPPUNIT_ASSERT_EQUAL(false, fault.needNewJacobian());
- err = MatAssemblyBegin(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
- err = MatAssemblyEnd(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
+ jacobian.assemble("final_assembly");
//MatView(jacobian, PETSC_VIEWER_STDOUT_WORLD); // DEBUGGING
const double* valsE = _data->valsJacobian;
- const int nrowsE = solution->sizeWithBC();
+ const int nrowsE = solutionSection->sizeWithBC();
const int ncolsE = nrowsE;
+ PetscMat jacobianMat = jacobian.matrix();
+
int nrows = 0;
int ncols = 0;
- MatGetSize(jacobian, &nrows, &ncols);
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(jacobian, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
@@ -649,69 +613,62 @@
} // testIntegrateJacobianAssembled
// ----------------------------------------------------------------------
-// Test updateState().
+// Test updateStateVars().
void
-pylith::faults::TestFaultCohesiveKin::testUpdateState(void)
-{ // testUpdateState
- ALE::Obj<Mesh> mesh;
+pylith::faults::TestFaultCohesiveKin::testUpdateStateVars(void)
+{ // testUpdateStateVars
+ topology::Mesh mesh;
FaultCohesiveKin fault;
- _initialize(&mesh, &fault);
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &fault, &fields);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((mesh)->getDimension());
- cs.initialize();
-
- // Setup fields
- topology::FieldsManager fields(mesh);
- fields.addReal("residual");
- fields.addReal("solution");
- fields.solutionField("solution");
-
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
const int spaceDim = _data->spaceDim;
- residual->setChart(mesh->getSieve()->getChart());
- residual->setFiberDimension(mesh->depthStratum(0), spaceDim);
- mesh->allocate(residual);
- residual->zero();
- fields.copyLayout("residual");
-
- const ALE::Obj<real_section_type>& solution = fields.getReal("solution");
+ const ALE::Obj<RealSection>& solutionSection = fields.get("solution").section();
+ CPPUNIT_ASSERT(!solutionSection.isNull());
{ // setup solution
- CPPUNIT_ASSERT(!solution.isNull());
- solution->zero();
+ solutionSection->zero();
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices = sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
int iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
- ++v_iter, ++iVertex) {
- solution->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
- } // for
+ ++v_iter, ++iVertex)
+ solutionSection->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
} // setup solution
+ topology::Field<topology::Mesh>& residual = fields.get("residual");
const double t = 2.134;
const double dt = 0.01;
fault.useSolnIncr(false);
fault.timeStep(dt);
- fault.integrateResidualAssembled(residual, t, &fields, mesh, &cs);
- fault.updateState(t, &fields, mesh);
+ fault.integrateResidualAssembled(residual, t, &fields);
+ fault.updateStateVars(t, &fields);
- const ALE::Obj<Mesh::label_sequence>& vertices =
- fault._faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- Mesh::renumbering_type& renumbering = fault._faultMesh->getRenumbering();
+ CPPUNIT_ASSERT(0 != fault._faultMesh);
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = fault._faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveSubMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveSubMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ SieveSubMesh::renumbering_type& renumbering = faultSieveMesh->getRenumbering();
// Compute expected cumulative slip using eqsrcs
- ALE::Obj<real_section_type> cumSlipE =
- new real_section_type(fault._faultMesh->comm(), fault._faultMesh->debug());
- CPPUNIT_ASSERT(!cumSlipE.isNull());
- cumSlipE->setChart(fault._faultMesh->getSieve()->getChart());
- cumSlipE->setFiberDimension(vertices, spaceDim);
- fault._faultMesh->allocate(cumSlipE);
+ topology::Field<topology::SubMesh> cumSlipE(*fault._faultMesh);
+ cumSlipE.newSection(topology::FieldBase::VERTICES_FIELD, spaceDim);
+ cumSlipE.allocate();
+ const ALE::Obj<RealSection> cumSlipESection = cumSlipE.section();
+ CPPUNIT_ASSERT(!cumSlipESection.isNull());
+ const ALE::Obj<RealSection> cumSlipSection =
+ fault._fields->get("cumulative slip").section();
+ CPPUNIT_ASSERT(!cumSlipSection.isNull());
+
const FaultCohesiveKin::srcs_type::const_iterator srcsEnd = fault._eqSrcs.end();
for (FaultCohesiveKin::srcs_type::iterator s_iter=fault._eqSrcs.begin();
s_iter != srcsEnd;
@@ -719,17 +676,17 @@
EqKinSrc* src = s_iter->second;
assert(0 != src);
if (t >= src->originTime())
- src->slip(cumSlipE, t, fault._faultMesh);
+ src->slip(&cumSlipE, t);
} // for
int iVertex = 0;
const double tolerance = 1.0e-06;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveSubMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++iVertex) {
- const Mesh::point_type meshVertex = _data->constraintVertices[iVertex];
+ const SieveSubMesh::point_type meshVertex = _data->constraintVertices[iVertex];
bool found = false;
- for(Mesh::renumbering_type::const_iterator r_iter = renumbering.begin();
+ for(SieveSubMesh::renumbering_type::const_iterator r_iter = renumbering.begin();
r_iter != renumbering.end();
++r_iter) {
if (r_iter->second == *v_iter) {
@@ -740,14 +697,12 @@
CPPUNIT_ASSERT(found);
// Check _cumSlip
- int fiberDim = fault._cumSlip->getFiberDimension(*v_iter);
+ int fiberDim = cumSlipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* slipV =
- fault._cumSlip->restrictPoint(*v_iter);
+ const double* slipV = cumSlipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != slipV);
- const real_section_type::value_type* slipE =
- cumSlipE->restrictPoint(*v_iter);
+ const double* slipE = cumSlipESection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != slipE);
for (int iDim=0; iDim < spaceDim; ++iDim) {
@@ -757,93 +712,99 @@
CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE[iDim], slipV[iDim], tolerance);
} // for
} // for
-} // testUpdateState
+} // testUpdateStateVars
// ----------------------------------------------------------------------
// Test calcTractionsChange().
void
pylith::faults::TestFaultCohesiveKin::testCalcTractionsChange(void)
{ // testCalcTractionsChange
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
FaultCohesiveKin fault;
- _initialize(&mesh, &fault);
-
- // Setup fields
- topology::FieldsManager fields(mesh);
- fields.addReal("solution");
- fields.solutionField("solution");
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &fault, &fields);
const int spaceDim = _data->spaceDim;
- const ALE::Obj<real_section_type>& solution = fields.getReal("solution");
+ const ALE::Obj<RealSection>& solutionSection = fields.get("solution").section();
+ CPPUNIT_ASSERT(!solutionSection.isNull());
{ // setup solution
- CPPUNIT_ASSERT(!solution.isNull());
- solution->setChart(mesh->getSieve()->getChart());
- solution->setFiberDimension(mesh->depthStratum(0), spaceDim);
- mesh->allocate(solution);
- solution->zero();
- fields.copyLayout("solution");
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
CPPUNIT_ASSERT(!vertices.isNull());
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const SieveMesh::label_sequence::iterator verticesBegin = vertices->begin();
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
int iVertex = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++iVertex) {
- solution->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
+ solutionSection->updatePoint(*v_iter, &_data->fieldT[iVertex*spaceDim]);
} // for
} // setup solution
- ALE::Obj<real_section_type> tractions =
- new real_section_type(fault._faultMesh->comm(), fault._faultMesh->debug());
- CPPUNIT_ASSERT(!tractions.isNull());
- Mesh::renumbering_type& renumbering = fault._faultMesh->getRenumbering();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- fault._faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- tractions->setChart(fault._faultMesh->getSieve()->getChart());
- tractions->setFiberDimension(vertices, spaceDim);
- fault._faultMesh->allocate(tractions);
+ CPPUNIT_ASSERT(0 != fault._faultMesh);
+ topology::Field<topology::SubMesh> tractions(*fault._faultMesh);
+ tractions.newSection(topology::FieldBase::VERTICES_FIELD, spaceDim);
+ tractions.allocate();
+ tractions.zero();
+ const ALE::Obj<RealSection>& tractionsSection = tractions.section();
+ CPPUNIT_ASSERT(!tractionsSection.isNull());
+
const double t = 0;
- fault.updateState(t, &fields, mesh);
- fault._calcTractionsChange(&tractions, mesh, solution);
+ fault.updateStateVars(t, &fields);
+ fault._calcTractionsChange(&tractions, fields.get("solution"));
int iVertex = 0;
const double tolerance = 1.0e-06;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = fault._faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const SieveSubMesh::label_sequence::iterator verticesBegin =
+ vertices->begin();
+ const SieveSubMesh::label_sequence::iterator verticesEnd = vertices->end();
+ SieveSubMesh::renumbering_type& renumbering =
+ faultSieveMesh->getRenumbering();
+ const SieveMesh::renumbering_type::const_iterator renumberingBegin =
+ renumbering.begin();
+ const SieveMesh::renumbering_type::const_iterator renumberingEnd =
+ renumbering.end();
+ for (SieveMesh::label_sequence::iterator v_iter=verticesBegin;
v_iter != verticesEnd;
++v_iter, ++iVertex) {
- Mesh::point_type meshVertex = -1;
+ SieveMesh::point_type meshVertex = -1;
bool found = false;
- for(Mesh::renumbering_type::const_iterator r_iter = renumbering.begin(); r_iter != renumbering.end(); ++r_iter) {
+ for (SieveMesh::renumbering_type::const_iterator r_iter = renumberingBegin;
+ r_iter != renumberingEnd;
+ ++r_iter) {
if (r_iter->second == *v_iter) {
meshVertex = r_iter->first;
- found = true;
+ found = true;
break;
- }
- }
+ } // if
+ } // for
CPPUNIT_ASSERT(found);
- int fiberDim = tractions->getFiberDimension(*v_iter);
+ int fiberDim = tractionsSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vertexTractions =
- tractions->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vertexTractions);
+ const double* tractionsVertex = tractionsSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != tractionsVertex);
- fiberDim = solution->getFiberDimension(meshVertex);
+ fiberDim = solutionSection->getFiberDimension(meshVertex);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vertexSolution =
- solution->restrictPoint(meshVertex);
- CPPUNIT_ASSERT(0 != vertexSolution);
+ const double* solutionVertex = solutionSection->restrictPoint(meshVertex);
+ CPPUNIT_ASSERT(0 != solutionVertex);
const double scale = _data->pseudoStiffness / _data->area[iVertex];
for (int iDim=0; iDim < spaceDim; ++iDim) {
- const double tractionE = vertexSolution[iDim] * scale;
+ const double tractionE = solutionVertex[iDim] * scale;
if (tractionE > 1.0)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, vertexTractions[iDim]/tractionE,
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, tractionsVertex[iDim]/tractionE,
tolerance);
else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(tractionE, vertexTractions[iDim],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(tractionE, tractionsVertex[iDim],
tolerance);
} // for
} // for
@@ -852,89 +813,99 @@
// ----------------------------------------------------------------------
// Initialize FaultCohesiveKin interface condition.
void
-pylith::faults::TestFaultCohesiveKin::_initialize(ALE::Obj<Mesh>* mesh,
- FaultCohesiveKin* const fault) const
+pylith::faults::TestFaultCohesiveKin::_initialize(
+ topology::Mesh* const mesh,
+ FaultCohesiveKin* const fault,
+ topology::SolutionFields* const fields) const
{ // _initialize
- CPPUNIT_ASSERT(0 != _data);
CPPUNIT_ASSERT(0 != mesh);
CPPUNIT_ASSERT(0 != fault);
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _data);
CPPUNIT_ASSERT(0 != _quadrature);
- try {
- meshio::MeshIOAscii iohandler;
- iohandler.filename(_data->meshFilename);
- iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
-
- //(*mesh)->setDebug(true); // DEBUGGING
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((*mesh)->getDimension());
- cs.initialize();
-
- _quadrature->initialize(_data->basis, _data->basisDeriv, _data->quadPts,
- _data->quadWts, _data->cellDim, _data->numBasis,
- _data->numQuadPts, _data->spaceDim);
-
- // Setup earthquake source
- spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
- spatialdata::spatialdb::SimpleIOAscii ioFinalSlip;
- ioFinalSlip.filename(_data->finalSlipFilename);
- dbFinalSlip.ioHandler(&ioFinalSlip);
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename(_data->meshFilename);
+ iohandler.read(mesh);
- spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
- spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
- ioSlipTime.filename(_data->slipTimeFilename);
- dbSlipTime.ioHandler(&ioSlipTime);
+ //(*mesh)->setDebug(true); // DEBUGGING
- spatialdata::spatialdb::SimpleDB dbPeakRate("peak rate");
- spatialdata::spatialdb::SimpleIOAscii ioPeakRate;
- ioPeakRate.filename(_data->peakRateFilename);
- dbPeakRate.ioHandler(&ioPeakRate);
-
- const int nsrcs = _eqsrcs.size();
- CPPUNIT_ASSERT(nsrcs == _slipfns.size());
- EqKinSrc** sources = new EqKinSrc*[nsrcs];
- char** names = new char*[nsrcs];
- for (int i=0; i < nsrcs; ++i) {
- _slipfns[i]->dbFinalSlip(&dbFinalSlip);
- _slipfns[i]->dbSlipTime(&dbSlipTime);
- _slipfns[i]->dbPeakRate(&dbPeakRate);
-
- _eqsrcs[i]->slipfn(_slipfns[i]);
- sources[i] = _eqsrcs[i];
- names[i] = new char[2];
- names[i][0] = 'a' + i;
- names[i][1] = '\0';
- } // for
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
- fault->id(_data->id);
- fault->label(_data->label);
- fault->quadrature(_quadrature);
+ _quadrature->initialize(_data->basis, _data->numQuadPts, _data->numBasis,
+ _data->basisDeriv,
+ _data->numQuadPts, _data->numBasis, _data->cellDim,
+ _data->quadPts, _data->numQuadPts, _data->cellDim,
+ _data->quadWts, _data->numQuadPts,
+ _data->spaceDim);
+
+ // Setup earthquake source
+ spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
+ spatialdata::spatialdb::SimpleIOAscii ioFinalSlip;
+ ioFinalSlip.filename(_data->finalSlipFilename);
+ dbFinalSlip.ioHandler(&ioFinalSlip);
+
+ spatialdata::spatialdb::SimpleDB dbSlipTime("slip time");
+ spatialdata::spatialdb::SimpleIOAscii ioSlipTime;
+ ioSlipTime.filename(_data->slipTimeFilename);
+ dbSlipTime.ioHandler(&ioSlipTime);
+
+ spatialdata::spatialdb::SimpleDB dbRiseTime("rise time");
+ spatialdata::spatialdb::SimpleIOAscii ioRiseTime;
+ ioRiseTime.filename(_data->riseTimeFilename);
+ dbRiseTime.ioHandler(&ioRiseTime);
+
+ const int nsrcs = _eqsrcs.size();
+ CPPUNIT_ASSERT(nsrcs == _slipfns.size());
+ EqKinSrc** sources = new EqKinSrc*[nsrcs];
+ char** names = new char*[nsrcs];
+ for (int i=0; i < nsrcs; ++i) {
+ _slipfns[i]->dbFinalSlip(&dbFinalSlip);
+ _slipfns[i]->dbSlipTime(&dbSlipTime);
+ _slipfns[i]->dbRiseTime(&dbRiseTime);
- fault->eqsrcs(const_cast<const char**>(names), sources, nsrcs);
- fault->adjustTopology(*mesh, _flipFault);
-
- const double upDirVals[] = { 0.0, 0.0, 1.0 };
- double_array upDir(upDirVals, 3);
-
- const double normalDirVals[] = { 1.0, 0.0, 0.0 };
- double_array normalDir(normalDirVals, 3);
-
- spatialdata::spatialdb::SimpleDB dbMatProp("material properties");
- spatialdata::spatialdb::SimpleIOAscii ioMatProp;
- ioMatProp.filename(_data->matPropsFilename);
- dbMatProp.ioHandler(&ioMatProp);
-
- fault->initialize(*mesh, &cs, upDir, normalDir, &dbMatProp);
-
- delete[] sources; sources = 0;
- for (int i=0; i < nsrcs; ++i)
- delete[] names[i];
- delete[] names; names = 0;
- } catch (const ALE::Exception& err) {
- throw std::runtime_error(err.msg());
- } // catch
+ _eqsrcs[i]->slipfn(_slipfns[i]);
+ sources[i] = _eqsrcs[i];
+ names[i] = new char[2];
+ names[i][0] = 'a' + i;
+ names[i][1] = '\0';
+ } // for
+
+ fault->id(_data->id);
+ fault->label(_data->label);
+ fault->quadrature(_quadrature);
+
+ fault->eqsrcs(const_cast<const char**>(names), nsrcs, sources, nsrcs);
+ fault->adjustTopology(mesh, _flipFault);
+
+ const double upDir[] = { 0.0, 0.0, 1.0 };
+ const double normalDir[] = { 1.0, 0.0, 0.0 };
+
+ spatialdata::spatialdb::SimpleDB dbMatProp("material properties");
+ spatialdata::spatialdb::SimpleIOAscii ioMatProp;
+ ioMatProp.filename(_data->matPropsFilename);
+ dbMatProp.ioHandler(&ioMatProp);
+
+ fault->initialize(*mesh, upDir, normalDir, &dbMatProp);
+
+ delete[] sources; sources = 0;
+ for (int i=0; i < nsrcs; ++i)
+ delete[] names[i];
+ delete[] names; names = 0;
+
+ // Setup fields
+ fields->add("residual", "residual");
+ fields->add("solution", "displacement");
+ fields->solutionName("solution");
+
+ const int spaceDim = _data->spaceDim;
+ topology::Field<topology::Mesh>& residual = fields->get("residual");
+ residual.newSection(topology::FieldBase::VERTICES_FIELD, spaceDim);
+ residual.allocate();
+ fields->copyLayout("residual");
} // _initialize
// ----------------------------------------------------------------------
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKin.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,7 +23,9 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/faults/faultsfwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
+#include "pylith/feassemble/feassemblefwd.hh" // HOLDSA Quadrature
#include <vector> // HASA std::vector
@@ -32,15 +34,8 @@
namespace faults {
class TestFaultCohesiveKin;
- class FaultCohesiveKin; // USES FaultCohesiveKin
- class CohesiveKinData; // HOLDSA CohesiveKinData
- class EqKinSrc; // HOLDSA EqKinSrc
- class BruneSlipFn; // HOLDSA BruneSlipFn
+ class CohesiveKinData;
} // faults
-
- namespace feassemble {
- class Quadrature; // HOLDSA Quadrature
- } // feassemble
} // pylith
/// C++ unit testing for FaultCohesiveKin
@@ -62,7 +57,7 @@
protected :
CohesiveKinData* _data; ///< Data for testing
- feassemble::Quadrature* _quadrature; ///< Data used in testing
+ feassemble::Quadrature<topology::SubMesh>* _quadrature; ///< Fault quad.
std::vector<EqKinSrc*> _eqsrcs; ///< Array of Kinematic earthquake sources.
std::vector<BruneSlipFn*> _slipfns; ///< Slip time function.
bool _flipFault; ///< If true, flip fault orientation.
@@ -106,8 +101,8 @@
/// Test integrateJacobianAssembled().
void testIntegrateJacobianAssembled(void);
- /// Test updateState().
- void testUpdateState(void);
+ /// Test updateStateVars().
+ void testUpdateStateVars(void);
/// Test _calcTractionsChange().
void testCalcTractionsChange(void);
@@ -119,9 +114,11 @@
*
* @param mesh PETSc mesh to initialize
* @param fault Cohesive fault interface condition to initialize.
+ * @param fields Solution fields.
*/
- void _initialize(ALE::Obj<Mesh>* mesh,
- FaultCohesiveKin* const fault) const;
+ void _initialize(topology::Mesh* const mesh,
+ FaultCohesiveKin* const fault,
+ topology::SolutionFields* const fields) const;
/** Determine if vertex is a Lagrange multiplier constraint vertex.
*
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataHex8.hh" // USES CohesiveKinDataHex8
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryQuad3D.hh" // USES GeometryQuad3D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataHex8();
- _quadrature = new feassemble::Quadrature2Din3D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryQuad3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataLine2.hh" // USES CohesiveKinDataLine2
-#include "pylith/feassemble/Quadrature0D.hh" // USES Quadrature0D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryPoint1D.hh" // USES GeometryPoint1D
// ----------------------------------------------------------------------
@@ -29,8 +30,8 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataLine2();
- _quadrature = new feassemble::Quadrature0D();
- CPPUNIT_ASSERT(0 != _quadrature);
+
+ assert(0 != _quadrature);
feassemble::GeometryPoint1D geometry;
_quadrature->refGeometry(&geometry);
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataQuad4.hh" // USES CohesiveKinDataQuad4
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataQuad4();
- _quadrature = new feassemble::Quadrature1Din2D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataQuad4e.hh" // USES CohesiveKinDataQuad4e
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataQuad4e();
- _quadrature = new feassemble::Quadrature1Din2D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinQuad4e.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcs.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcs.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcs.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -27,7 +27,6 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = 0;
- _quadrature = 0;
// Cleanup previous allocation
int nsrcs = _eqsrcs.size();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinSrcsDataHex8.hh" // USES CohesiveKinDataHex8
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryQuad3D.hh" // USES GeometryQuad3D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKinSrcs::setUp();
_data = new CohesiveKinSrcsDataHex8();
- _quadrature = new feassemble::Quadrature2Din3D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryQuad3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinSrcsDataLine2.hh" // USES CohesiveKinDataSrcsLine2
-#include "pylith/feassemble/Quadrature0D.hh" // USES Quadrature0D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryPoint1D.hh" // USES GeometryPoint1D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKinSrcs::setUp();
_data = new CohesiveKinSrcsDataLine2();
- _quadrature = new feassemble::Quadrature0D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryPoint1D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinSrcsDataQuad4.hh" // USES CohesiveKinDataQuad4
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKinSrcs::setUp();
_data = new CohesiveKinSrcsDataQuad4();
- _quadrature = new feassemble::Quadrature1Din2D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinSrcsDataTet4.hh" // USES CohesiveKinDataTet4
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryTri3D.hh" // USES GeometryTri3D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKinSrcs::setUp();
_data = new CohesiveKinSrcsDataTet4();
- _quadrature = new feassemble::Quadrature2Din3D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryTri3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinSrcsTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinSrcsDataTri3.hh" // USES CohesiveKinSrcsDataTri3
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKinSrcs::setUp();
_data = new CohesiveKinSrcsDataTri3();
- _quadrature = new feassemble::Quadrature1Din2D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataTet4.hh" // USES CohesiveKinDataTet4
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryTri3D.hh" // USES GeometryTri3D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataTet4();
- _quadrature = new feassemble::Quadrature2Din3D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryTri3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataTet4e.hh" // USES CohesiveKinDataTet4e
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryTri3D.hh" // USES GeometryTri3D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataTet4e();
- _quadrature = new feassemble::Quadrature2Din3D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryTri3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4e.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataTet4f.hh" // USES CohesiveKinDataTet4f
-#include "pylith/feassemble/Quadrature2Din3D.hh" // USES Quadrature2Din3D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryTri3D.hh" // USES GeometryTri3D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataTet4f();
- _quadrature = new feassemble::Quadrature2Din3D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryTri3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTet4f.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataTri3.hh" // USES CohesiveKinDataTri3
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataTri3();
- _quadrature = new feassemble::Quadrature1Din2D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/CohesiveKinDataTri3d.hh" // USES CohesiveKinDataTri3d
-#include "pylith/feassemble/Quadrature1Din2D.hh" // USES Quadrature1Din2D
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature<SubMesh>
#include "pylith/feassemble/GeometryLine2D.hh" // USES GeometryLine2D
// ----------------------------------------------------------------------
@@ -29,7 +30,7 @@
{ // setUp
TestFaultCohesiveKin::setUp();
_data = new CohesiveKinDataTri3d();
- _quadrature = new feassemble::Quadrature1Din2D();
+
CPPUNIT_ASSERT(0 != _quadrature);
feassemble::GeometryLine2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestFaultCohesiveKinTri3d.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,7 +40,7 @@
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testCalcTractionsChange );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,8 +17,11 @@
#include "pylith/faults/LiuCosSlipFn.hh" // USES LiuCosSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -29,6 +32,11 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::faults::TestLiuCosSlipFn );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
namespace pylith {
namespace faults {
namespace _TestLiuCosSlipFn {
@@ -218,29 +226,32 @@
const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 5.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
LiuCosSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t = 2.134;
- slipfn.slip(slip, originTime+t, faultMesh);
+ slipfn.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
@@ -248,13 +259,13 @@
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
- const double slipNorm =
- _slipFn(t - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag;
+ const double slipNorm = (slipMag > 0.0) ?
+ _slipFn(t - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag :
+ 0.0;
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -275,30 +286,33 @@
const double riseTimeE[] = { 1.4, 1.5 };
const double originTime = 1.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
LiuCosSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
const double t0 = 1.234;
const double t1 = 3.635;
- slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ slipfn.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
double slipMag = 0.0;
@@ -306,15 +320,16 @@
slipMag += pow(finalSlipE[iPoint*spaceDim+iDim], 2);
slipMag = sqrt(slipMag);
- const double slipNorm0 =
- _slipFn(t0 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag;
- const double slipNorm1 =
- _slipFn(t1 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag;
+ const double slipNorm0 = (slipMag > 0.0) ?
+ _slipFn(t0 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag :
+ 0.0;
+ const double slipNorm1 = (slipMag > 0.0) ?
+ _slipFn(t1 - slipTimeE[iPoint], slipMag, riseTimeE[iPoint]) / slipMag :
+ 0.0;
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim) {
@@ -351,9 +366,10 @@
// ----------------------------------------------------------------------
// Initialize LiuCosSlipFn.
void
-pylith::faults::TestLiuCosSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
- LiuCosSlipFn* slipfn,
- const double originTime)
+pylith::faults::TestLiuCosSlipFn::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
+ LiuCosSlipFn* slipfn,
+ const double originTime)
{ // _initialize
assert(0 != slipfn);
@@ -364,33 +380,35 @@
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
const char* riseTimeFilename = "data/tri3_risetime.spatialdb";
- ALE::Obj<Mesh> mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
- meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh->isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- (*faultMesh)->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -415,7 +433,7 @@
slipfn->dbSlipTime(&dbSlipTime);
slipfn->dbRiseTime(&dbRiseTime);
- slipfn->initialize(*faultMesh, &cs, normalizer, originTime);
+ slipfn->initialize(*faultMesh, normalizer, originTime);
} // _initialize
// ----------------------------------------------------------------------
@@ -426,33 +444,38 @@
typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
// Setup mesh
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(data.meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
+ const int spaceDim = mesh.dimension();
cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh.coordsys(&cs);
// Create fault mesh
- ALE::Obj<Mesh> faultMesh = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
const bool useLagrangeConstraints = true;
- CohesiveTopology::createFault(faultMesh, faultBd,
- mesh,
- mesh->getIntSection(data.faultLabel));
- CohesiveTopology::create(faultMesh, faultBd, mesh,
- mesh->getIntSection(data.faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(&faultMesh, faultBoundary,
+ mesh, sieveMesh->getIntSection(data.faultLabel));
+ CohesiveTopology::create(&mesh, faultMesh, faultBoundary,
+ sieveMesh->getIntSection(data.faultLabel),
data.faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh.isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- faultMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -477,39 +500,49 @@
slipfn.dbRiseTime(&dbRiseTime);
spatialdata::units::Nondimensional normalizer;
-
const double originTime = 5.353;
- slipfn.initialize(faultMesh, &cs, normalizer, originTime);
+ slipfn.initialize(faultMesh, normalizer, originTime);
- const double tolerance = 1.0e-06;
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ CPPUNIT_ASSERT(0 != slipfn._parameters);
+ const ALE::Obj<RealSection>& finalSlipSection =
+ slipfn._parameters->get("final slip").section();
+ CPPUNIT_ASSERT(!finalSlipSection.isNull());
+ const ALE::Obj<RealSection>& slipTimeSection =
+ slipfn._parameters->get("slip time").section();
+ CPPUNIT_ASSERT(!slipTimeSection.isNull());
+ const ALE::Obj<RealSection>& riseTimeSection =
+ slipfn._parameters->get("rise time").section();
+ CPPUNIT_ASSERT(!riseTimeSection.isNull());
+ const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
- const int fiberDim = slipfn._parameters->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(spaceDim+2, fiberDim);
-
- const real_section_type::value_type* vals =
- slipfn._parameters->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vals);
-
+ CPPUNIT_ASSERT_EQUAL(spaceDim, finalSlipSection->getFiberDimension(*v_iter));
+ const double* finalSlipVertex = finalSlipSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != finalSlipVertex);
for (int iDim=0; iDim < spaceDim; ++iDim)
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.finalSlipE[iPoint*spaceDim+iDim],
- vals[iDim],
+ finalSlipVertex[iDim],
tolerance);
- const double riseTime = vals[spaceDim ];
- const double slipTime = vals[spaceDim+1];
+ CPPUNIT_ASSERT_EQUAL(1, slipTimeSection->getFiberDimension(*v_iter));
+ const double* slipTimeVertex = slipTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
+ slipTimeVertex[0], tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.riseTimeE[iPoint], riseTime, tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
- slipTime, tolerance);
+ CPPUNIT_ASSERT_EQUAL(1, riseTimeSection->getFiberDimension(*v_iter));
+ const double* riseTimeVertex = riseTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != riseTimeVertex);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(data.riseTimeE[iPoint],
+ riseTimeVertex[0], tolerance);
} // for
} // _testInitialize
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestLiuCosSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_testliucosslipfn_hh)
#define pylith_faults_testliucosslipfn_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES LiuCosSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,7 +30,6 @@
namespace pylith {
namespace faults {
class TestLiuCosSlipFn;
- class LiuCosSlipFn;
namespace _TestLiuCosSlipFn {
struct DataStruct;
@@ -95,12 +95,14 @@
/** Initialize LiuCosSlipFn.
*
- * @param faultMesh Fault mesh.
- * @param slipfn LiuCos slip function.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
+ * @param slipfn Step slip function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
LiuCosSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,8 +17,11 @@
#include "pylith/faults/StepSlipFn.hh" // USES StepSlipFn
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -48,6 +51,11 @@
} // pylith
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::SieveSubMesh SieveSubMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Test constructor.
void
pylith::faults::TestStepSlipFn::testConstructor(void)
@@ -105,14 +113,14 @@
const int numConstraintPts = 1;
_TestStepSlipFn::DataStruct data = {meshFilename,
- faultLabel,
- faultId,
- finalSlipFilename,
- slipTimeFilename,
- constraintPts,
- finalSlipE,
- slipTimeE,
- numConstraintPts};
+ faultLabel,
+ faultId,
+ finalSlipFilename,
+ slipTimeFilename,
+ constraintPts,
+ finalSlipE,
+ slipTimeE,
+ numConstraintPts};
_testInitialize(data);
} // testInitialize1D
@@ -133,14 +141,14 @@
const int numConstraintPts = 2;
_TestStepSlipFn::DataStruct data = {meshFilename,
- faultLabel,
- faultId,
- finalSlipFilename,
- slipTimeFilename,
- constraintPts,
- finalSlipE,
- slipTimeE,
- numConstraintPts};
+ faultLabel,
+ faultId,
+ finalSlipFilename,
+ slipTimeFilename,
+ constraintPts,
+ finalSlipE,
+ slipTimeE,
+ numConstraintPts};
_testInitialize(data);
} // testInitialize2D
@@ -162,14 +170,14 @@
const int numConstraintPts = 3;
_TestStepSlipFn::DataStruct data = {meshFilename,
- faultLabel,
- faultId,
- finalSlipFilename,
- slipTimeFilename,
- constraintPts,
- finalSlipE,
- slipTimeE,
- numConstraintPts};
+ faultLabel,
+ faultId,
+ finalSlipFilename,
+ slipTimeFilename,
+ constraintPts,
+ finalSlipE,
+ slipTimeE,
+ numConstraintPts};
_testInitialize(data);
} // testInitialize3D
@@ -182,37 +190,41 @@
0.0, 0.0};
const double originTime = 5.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
StepSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t = 1.234;
- slipfn.slip(slip, originTime+t, faultMesh);
+ slipfn.slip(&slip, originTime+t);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
+
for (int iDim=0; iDim < fiberDim; ++iDim)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE[iPoint*spaceDim+iDim], vals[iDim],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(slipE[iPoint*spaceDim+iDim], vals[iDim],
tolerance);
} // for
} // testSlip
@@ -226,36 +238,38 @@
2.4, 0.2};
const double originTime = 1.064;
- ALE::Obj<Mesh> faultMesh;
+ topology::Mesh mesh;
+ topology::SubMesh faultMesh;
StepSlipFn slipfn;
- _initialize(&faultMesh, &slipfn, originTime);
+ _initialize(&mesh, &faultMesh, &slipfn, originTime);
- const int spaceDim = faultMesh->getDimension() + 1;
- const ALE::Obj<Mesh::label_sequence>& vertices = faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> slip =
- new real_section_type(faultMesh->comm(), faultMesh->debug());
- slip->setChart(real_section_type::chart_type(*std::min_element(vertices->begin(),
- vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- slip->setFiberDimension(vertices, spaceDim);
- faultMesh->allocate(slip);
- CPPUNIT_ASSERT(!slip.isNull());
+ const spatialdata::geocoords::CoordSys* cs = faultMesh.coordsys();
+ CPPUNIT_ASSERT(0 != cs);
+ const int spaceDim = cs->spaceDim();
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+ topology::Field<topology::SubMesh> slip(faultMesh);
+ slip.newSection(vertices, spaceDim);
+ slip.allocate();
+
const double t0 = 1.234;
- const double t1 = 3.635;
- slipfn.slipIncr(slip, originTime+t0, originTime+t1, faultMesh);
+ const double t1 = 2.525;
+ slipfn.slipIncr(&slip, originTime+t0, originTime+t1);
const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ const ALE::Obj<RealSection>& slipSection = slip.section();
+ CPPUNIT_ASSERT(!slipSection.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
-
- const int fiberDim = slip->getFiberDimension(*v_iter);
+ const int fiberDim = slipSection->getFiberDimension(*v_iter);
CPPUNIT_ASSERT_EQUAL(spaceDim, fiberDim);
- const real_section_type::value_type* vals =
- slip->restrictPoint(*v_iter);
+ const double* vals = slipSection->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vals);
for (int iDim=0; iDim < fiberDim; ++iDim)
@@ -267,11 +281,14 @@
// ----------------------------------------------------------------------
// Initialize StepSlipFn.
void
-pylith::faults::TestStepSlipFn::_initialize(ALE::Obj<Mesh>* faultMesh,
- StepSlipFn* slipfn,
- const double originTime)
+pylith::faults::TestStepSlipFn::_initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
+ StepSlipFn* slipfn,
+ const double originTime)
{ // _initialize
- assert(0 != slipfn);
+ CPPUNIT_ASSERT(0 != mesh);
+ CPPUNIT_ASSERT(0 != faultMesh);
+ CPPUNIT_ASSERT(0 != slipfn);
const char* meshFilename = "data/tri3.mesh";
const char* faultLabel = "fault";
@@ -279,33 +296,35 @@
const char* finalSlipFilename = "data/tri3_finalslip.spatialdb";
const char* slipTimeFilename = "data/tri3_sliptime.spatialdb";
- ALE::Obj<Mesh> mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
- meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+ meshIO.read(mesh);
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
// Create fault mesh
const bool useLagrangeConstraints = true;
- (*faultMesh) = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
- CohesiveTopology::createFault(*faultMesh, faultBd,
- mesh,
- mesh->getIntSection(faultLabel));
- CohesiveTopology::create(*faultMesh, faultBd, mesh,
- mesh->getIntSection(faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(faultMesh, faultBoundary,
+ *mesh, sieveMesh->getIntSection(faultLabel));
+ CohesiveTopology::create(mesh, *faultMesh, faultBoundary,
+ sieveMesh->getIntSection(faultLabel),
faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh->isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- (*faultMesh)->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -324,7 +343,7 @@
slipfn->dbFinalSlip(&dbFinalSlip);
slipfn->dbSlipTime(&dbSlipTime);
- slipfn->initialize(*faultMesh, &cs, normalizer, originTime);
+ slipfn->initialize(*faultMesh, normalizer, originTime);
} // _initialize
// ----------------------------------------------------------------------
@@ -332,36 +351,41 @@
void
pylith::faults::TestStepSlipFn::_testInitialize(const _TestStepSlipFn::DataStruct& data)
{ // _testInitialize
- typedef std::set<Mesh::point_type>::const_iterator vert_iterator;
+ typedef std::set<SieveMesh::point_type>::const_iterator vert_iterator;
// Setup mesh
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
meshio::MeshIOAscii meshIO;
meshIO.filename(data.meshFilename);
meshIO.debug(false);
meshIO.interpolate(false);
meshIO.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
- const int spaceDim = mesh->getDimension();
+
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
+ const int spaceDim = mesh.dimension();
cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh.coordsys(&cs);
// Create fault mesh
- ALE::Obj<Mesh> faultMesh = new Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
- ALE::Obj<ALE::Mesh> faultBd = NULL;
+ topology::SubMesh faultMesh;
const bool useLagrangeConstraints = true;
- CohesiveTopology::createFault(faultMesh, faultBd,
- mesh,
- mesh->getIntSection(data.faultLabel));
- CohesiveTopology::create(faultMesh, faultBd, mesh,
- mesh->getIntSection(data.faultLabel),
+ ALE::Obj<ALE::Mesh> faultBoundary = 0;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CohesiveTopology::createFault(&faultMesh, faultBoundary,
+ mesh, sieveMesh->getIntSection(data.faultLabel));
+ CohesiveTopology::create(&mesh, faultMesh, faultBoundary,
+ sieveMesh->getIntSection(data.faultLabel),
data.faultId,
useLagrangeConstraints);
- CPPUNIT_ASSERT(!faultMesh.isNull());
// Need to copy coordinates from mesh to fault mesh since we are not
// using create() instead of createParallel().
- faultMesh->setRealSection("coordinates",
- mesh->getRealSection("coordinates"));
+ const ALE::Obj<SieveSubMesh>& faultSieveMesh = faultMesh.sieveMesh();
+ CPPUNIT_ASSERT(!faultSieveMesh.isNull());
+ faultSieveMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
// Setup databases
spatialdata::spatialdb::SimpleDB dbFinalSlip("final slip");
@@ -382,34 +406,38 @@
spatialdata::units::Nondimensional normalizer;
const double originTime = 5.353;
- slipfn.initialize(faultMesh, &cs, normalizer, originTime);
+ slipfn.initialize(faultMesh, normalizer, originTime);
- const double tolerance = 1.0e-06;
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ faultSieveMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- const ALE::Obj<Mesh::label_sequence>& vertices =
- faultMesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ CPPUNIT_ASSERT(0 != slipfn._parameters);
+ const ALE::Obj<RealSection>& finalSlipSection =
+ slipfn._parameters->get("final slip").section();
+ CPPUNIT_ASSERT(!finalSlipSection.isNull());
+ const ALE::Obj<RealSection>& slipTimeSection =
+ slipfn._parameters->get("slip time").section();
+ CPPUNIT_ASSERT(!slipTimeSection.isNull());
+ const double tolerance = 1.0e-06;
int iPoint = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++iPoint) {
- const int fiberDim = slipfn._parameters->getFiberDimension(*v_iter);
- CPPUNIT_ASSERT_EQUAL(spaceDim+1, fiberDim);
-
- const real_section_type::value_type* vals =
- slipfn._parameters->restrictPoint(*v_iter);
- CPPUNIT_ASSERT(0 != vals);
-
+ CPPUNIT_ASSERT_EQUAL(spaceDim, finalSlipSection->getFiberDimension(*v_iter));
+ const double* finalSlipVertex = finalSlipSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != finalSlipVertex);
for (int iDim=0; iDim < spaceDim; ++iDim)
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.finalSlipE[iPoint*spaceDim+iDim],
- vals[iDim],
+ finalSlipVertex[iDim],
tolerance);
- const double slipTime = vals[spaceDim];
-
+ CPPUNIT_ASSERT_EQUAL(1, slipTimeSection->getFiberDimension(*v_iter));
+ const double* slipTimeVertex = slipTimeSection->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT(0 != slipTimeVertex);
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.slipTimeE[iPoint]+originTime,
- slipTime, tolerance);
+ slipTimeVertex[0], tolerance);
} // for
} // _testInitialize
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/TestStepSlipFn.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,8 @@
#if !defined(pylith_faults_teststepslipfn_hh)
#define pylith_faults_teststepslipfn_hh
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include "pylith/faults/faultsfwd.hh" // USES StepSlipFn
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh
#include <cppunit/extensions/HelperMacros.h>
@@ -29,11 +30,10 @@
namespace pylith {
namespace faults {
class TestStepSlipFn;
- class StepSlipFn;
namespace _TestStepSlipFn {
struct DataStruct;
- } // _StepSlipTimeFn
+ } // _BruneSlipTimeFn
} // faults
} // pylith
@@ -87,12 +87,14 @@
/** Initialize StepSlipFn.
*
- * @param faultMesh Fault mesh.
+ * @param mesh Finite-element mesh of domain.
+ * @param faultMesh Finite-element mesh of fault.
* @param slipfn Step slip function.
* @param originTime Origin time for earthquake rupture.
*/
static
- void _initialize(ALE::Obj<Mesh>* faultMesh,
+ void _initialize(topology::Mesh* mesh,
+ topology::SubMesh* faultMesh,
StepSlipFn* slipfn,
const double originTime);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,7 +29,7 @@
label(0),
finalSlipFilename(0),
slipTimeFilename(0),
- peakRateFilename(0),
+ riseTimeFilename(0),
matPropsFilename(0),
fieldT(0),
orientation(0),
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -55,7 +55,7 @@
char* label; ///< Label for fault
char* finalSlipFilename; ///< Name of db for final slip
char* slipTimeFilename; ///< Name of db for slip time
- char* peakRateFilename; ///< Name of db for peak rate
+ char* riseTimeFilename; ///< Name of db for rise time
char* matPropsFilename; ///< Name of db for bulk material properties
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -98,8 +98,8 @@
const char* pylith::faults::CohesiveKinDataHex8::_slipTimeFilename =
"data/hex8_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataHex8::_peakRateFilename =
- "data/hex8_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataHex8::_riseTimeFilename =
+ "data/hex8_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataHex8::_matPropsFilename =
"data/bulkprops_3d.spatialdb";
@@ -1415,7 +1415,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -63,8 +63,8 @@
const char* pylith::faults::CohesiveKinDataLine2::_slipTimeFilename =
"data/line2_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataLine2::_peakRateFilename =
- "data/line2_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataLine2::_riseTimeFilename =
+ "data/line2_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataLine2::_matPropsFilename =
"data/bulkprops_1d.spatialdb";
@@ -138,7 +138,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -86,8 +86,8 @@
const char* pylith::faults::CohesiveKinDataQuad4::_slipTimeFilename =
"data/quad4_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataQuad4::_peakRateFilename =
- "data/quad4_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataQuad4::_riseTimeFilename =
+ "data/quad4_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataQuad4::_matPropsFilename =
"data/bulkprops_2d.spatialdb";
@@ -372,7 +372,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -105,8 +105,8 @@
const char* pylith::faults::CohesiveKinDataQuad4e::_slipTimeFilename =
"data/quad4e_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataQuad4e::_peakRateFilename =
- "data/quad4e_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataQuad4e::_riseTimeFilename =
+ "data/quad4e_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataQuad4e::_matPropsFilename =
"data/bulkprops_2d.spatialdb";
@@ -659,7 +659,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataQuad4e.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -74,8 +74,8 @@
const char* pylith::faults::CohesiveKinDataTet4::_slipTimeFilename =
"data/tet4_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataTet4::_peakRateFilename =
- "data/tet4_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataTet4::_riseTimeFilename =
+ "data/tet4_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataTet4::_matPropsFilename =
"data/bulkprops_3d.spatialdb";
@@ -528,7 +528,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -74,8 +74,8 @@
const char* pylith::faults::CohesiveKinDataTet4e::_slipTimeFilename =
"data/tet4e_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataTet4e::_peakRateFilename =
- "data/tet4e_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataTet4e::_riseTimeFilename =
+ "data/tet4e_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataTet4e::_matPropsFilename =
"data/bulkprops_3d.spatialdb";
@@ -764,7 +764,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4e.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -74,8 +74,8 @@
const char* pylith::faults::CohesiveKinDataTet4f::_slipTimeFilename =
"data/tet4_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataTet4f::_peakRateFilename =
- "data/tet4_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataTet4f::_riseTimeFilename =
+ "data/tet4_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataTet4f::_matPropsFilename =
"data/bulkprops_3d.spatialdb";
@@ -528,7 +528,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTet4f.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -89,8 +89,8 @@
const char* pylith::faults::CohesiveKinDataTri3::_slipTimeFilename =
"data/tri3_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataTri3::_peakRateFilename =
- "data/tri3_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataTri3::_riseTimeFilename =
+ "data/tri3_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataTri3::_matPropsFilename =
"data/bulkprops_2d.spatialdb";
@@ -299,7 +299,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -104,8 +104,8 @@
const char* pylith::faults::CohesiveKinDataTri3d::_slipTimeFilename =
"data/tri3d_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinDataTri3d::_peakRateFilename =
- "data/tri3d_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinDataTri3d::_riseTimeFilename =
+ "data/tri3d_risetime.spatialdb";
const char* pylith::faults::CohesiveKinDataTri3d::_matPropsFilename =
"data/bulkprops_2d.spatialdb";
@@ -487,7 +487,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinDataTri3d.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -98,8 +98,8 @@
const char* pylith::faults::CohesiveKinSrcsDataHex8::_slipTimeFilename =
"data/hex8_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinSrcsDataHex8::_peakRateFilename =
- "data/hex8_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinSrcsDataHex8::_riseTimeFilename =
+ "data/hex8_risetime.spatialdb";
const char* pylith::faults::CohesiveKinSrcsDataHex8::_matPropsFilename =
"data/bulkprops_3d.spatialdb";
@@ -1415,7 +1415,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -63,8 +63,8 @@
const char* pylith::faults::CohesiveKinSrcsDataLine2::_slipTimeFilename =
"data/line2_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinSrcsDataLine2::_peakRateFilename =
- "data/line2_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinSrcsDataLine2::_riseTimeFilename =
+ "data/line2_risetime.spatialdb";
const char* pylith::faults::CohesiveKinSrcsDataLine2::_matPropsFilename =
"data/bulkprops_1d.spatialdb";
@@ -138,7 +138,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -86,8 +86,8 @@
const char* pylith::faults::CohesiveKinSrcsDataQuad4::_slipTimeFilename =
"data/quad4_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinSrcsDataQuad4::_peakRateFilename =
- "data/quad4_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinSrcsDataQuad4::_riseTimeFilename =
+ "data/quad4_risetime.spatialdb";
const char* pylith::faults::CohesiveKinSrcsDataQuad4::_matPropsFilename =
"data/bulkprops_2d.spatialdb";
@@ -372,7 +372,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -74,8 +74,8 @@
const char* pylith::faults::CohesiveKinSrcsDataTet4::_slipTimeFilename =
"data/tet4_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinSrcsDataTet4::_peakRateFilename =
- "data/tet4_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinSrcsDataTet4::_riseTimeFilename =
+ "data/tet4_risetime.spatialdb";
const char* pylith::faults::CohesiveKinSrcsDataTet4::_matPropsFilename =
"data/bulkprops_3d.spatialdb";
@@ -528,7 +528,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -100,8 +100,8 @@
const char* pylith::faults::CohesiveKinSrcsDataTri3::_slipTimeFilename =
"data/tri3_sliptime.spatialdb";
-const char* pylith::faults::CohesiveKinSrcsDataTri3::_peakRateFilename =
- "data/tri3_peakrate.spatialdb";
+const char* pylith::faults::CohesiveKinSrcsDataTri3::_riseTimeFilename =
+ "data/tri3_risetime.spatialdb";
const char* pylith::faults::CohesiveKinSrcsDataTri3::_matPropsFilename =
"data/bulkprops_2d.spatialdb";
@@ -310,7 +310,7 @@
label = const_cast<char*>(_label);
finalSlipFilename = const_cast<char*>(_finalSlipFilename);
slipTimeFilename = const_cast<char*>(_slipTimeFilename);
- peakRateFilename = const_cast<char*>(_peakRateFilename);
+ riseTimeFilename = const_cast<char*>(_riseTimeFilename);
matPropsFilename = const_cast<char*>(_matPropsFilename);
fieldT = const_cast<double*>(_fieldT);
orientation = const_cast<double*>(_orientation);
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/CohesiveKinSrcsDataTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,7 +53,7 @@
static const char* _label; ///< Label for fault
static const char* _finalSlipFilename; ///< Name of db for final slip
static const char* _slipTimeFilename; ///< Name of db for slip time
- static const char* _peakRateFilename; ///< Name of db for peak rate
+ static const char* _riseTimeFilename; ///< Name of db for rise time
static const char* _matPropsFilename; ///< Name of db for bulk mat properties.
//@}
Modified: short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,7 +17,6 @@
line2.mesh \
line2_finalslip.spatialdb \
line2_sliptime.spatialdb \
- line2_peakrate.spatialdb \
line2_sliprate.spatialdb \
line2_risetime.spatialdb \
tri3.mesh \
@@ -29,12 +28,11 @@
tri3_finalslip.spatialdb \
tri3_finalslipB.spatialdb \
tri3_sliptime.spatialdb \
- tri3_peakrate.spatialdb \
tri3_sliprate.spatialdb \
tri3_risetime.spatialdb \
tri3d_finalslip.spatialdb \
tri3d_sliptime.spatialdb \
- tri3d_peakrate.spatialdb \
+ tri3d_risetime.spatialdb \
quad4.mesh \
quad4b.mesh \
quad4c.mesh \
@@ -45,10 +43,10 @@
quad4h.mesh \
quad4_finalslip.spatialdb \
quad4_sliptime.spatialdb \
- quad4_peakrate.spatialdb \
+ quad4_risetime.spatialdb \
quad4e_finalslip.spatialdb \
quad4e_sliptime.spatialdb \
- quad4e_peakrate.spatialdb \
+ quad4e_risetime.spatialdb \
tet4.mesh \
tet4b.mesh \
tet4c.mesh \
@@ -61,12 +59,11 @@
tet4j.mesh \
tet4_finalslip.spatialdb \
tet4_sliptime.spatialdb \
- tet4_peakrate.spatialdb \
- tet4_sliprate.spatialdb \
tet4_risetime.spatialdb \
+ tet4_sliprate.spatialdb \
tet4e_finalslip.spatialdb \
tet4e_sliptime.spatialdb \
- tet4e_peakrate.spatialdb \
+ tet4e_risetime.spatialdb \
hex8.mesh \
hex8b.mesh \
hex8c.mesh \
@@ -78,7 +75,7 @@
hex8i.mesh \
hex8_finalslip.spatialdb \
hex8_sliptime.spatialdb \
- hex8_peakrate.spatialdb \
+ hex8_risetime.spatialdb \
tri3traction.mesh \
quad4traction.mesh \
tet4traction.mesh \
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,17 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 4
- data-dim = 2
- space-dim = 3
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 3
- }
-}
-0.0 -1.0 -1.0 1.5
-0.0 1.0 -1.0 1.6
-0.0 -1.0 1.0 1.7
-0.0 1.0 1.0 1.8
Copied: short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/data/hex8_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/hex8_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,17 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = rise-time
+ value-units = s
+ num-locs = 4
+ data-dim = 2
+ space-dim = 3
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 3
+ }
+}
+0.0 -1.0 -1.0 1.5
+0.0 1.0 -1.0 1.6
+0.0 -1.0 1.0 1.7
+0.0 1.0 1.0 1.8
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/line2_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,14 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 1
- data-dim = 0
- space-dim = 1
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 1
- }
-}
-0.0 1.4
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,15 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 2
- data-dim = 1
- space-dim = 2
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 2
- }
-}
-0.0 +1.0 1.4
-0.0 -1.0 1.5
Copied: short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/data/quad4_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = rise-time
+ value-units = s
+ num-locs = 2
+ data-dim = 1
+ space-dim = 2
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 2
+ }
+}
+0.0 +1.0 1.4
+0.0 -1.0 1.5
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,16 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 3
- data-dim = 1
- space-dim = 2
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 2
- }
-}
-0.0 +1.0 1.4
-0.0 -1.0 1.5
-0.0 +3.0 1.6
Copied: short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/data/quad4e_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/quad4e_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,16 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = rise-time
+ value-units = s
+ num-locs = 3
+ data-dim = 1
+ space-dim = 2
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 2
+ }
+}
+0.0 +1.0 1.4
+0.0 -1.0 1.5
+0.0 +3.0 1.6
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,16 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 3
- data-dim = 2
- space-dim = 3
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 3
- }
-}
-0.0 -1.0 0.0 1.5
-0.0 0.0 1.0 1.6
-0.0 1.0 0.0 1.7
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,17 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 4
- data-dim = 2
- space-dim = 3
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 3
- }
-}
-0.0 -1.0 0.0 1.5
-0.0 0.0 1.0 1.6
-0.0 1.0 0.0 1.7
-0.0 0.0 -1.0 1.8
Copied: short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/data/tet4e_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tet4e_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,17 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = rise-time
+ value-units = s
+ num-locs = 4
+ data-dim = 2
+ space-dim = 3
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 3
+ }
+}
+0.0 -1.0 0.0 1.5
+0.0 0.0 1.0 1.6
+0.0 1.0 0.0 1.7
+0.0 0.0 -1.0 1.8
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,15 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 2
- data-dim = 1
- space-dim = 2
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 2
- }
-}
-0.0 +1.0 1.4
-0.0 -1.0 1.5
Deleted: short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_peakrate.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_peakrate.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_peakrate.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,16 +0,0 @@
-#SPATIAL.ascii 1
-SimpleDB {
- num-values = 1
- value-names = slip-rate
- value-units = m/s
- num-locs = 3
- data-dim = 2
- space-dim = 2
- cs-data = cartesian {
- to-meters = 1.0
- space-dim = 2
- }
-}
- 0.0 +1.0 1.4
- 0.0 -1.0 1.5
--2.0 +1.0 1.6
Copied: short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_risetime.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/faults/data/tri3d_risetime.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_risetime.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/faults/data/tri3d_risetime.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,16 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = rise-time
+ value-units = s
+ num-locs = 3
+ data-dim = 1
+ space-dim = 2
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 2
+ }
+}
+ 0.0 +1.0 1.4
+ 0.0 -1.0 1.5
+-2.0 +1.0 1.6
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,6 +22,30 @@
# Primary source files
testfeassemble_SOURCES = \
TestCellGeometry.cc \
+ TestGeometryPoint1D.cc \
+ TestGeometryPoint2D.cc \
+ TestGeometryPoint3D.cc \
+ TestGeometryLine1D.cc \
+ TestGeometryLine2D.cc \
+ TestGeometryLine3D.cc \
+ TestGeometryTri2D.cc \
+ TestGeometryTri3D.cc \
+ TestGeometryQuad2D.cc \
+ TestGeometryQuad3D.cc \
+ TestGeometryTet3D.cc \
+ TestGeometryHex3D.cc \
+ TestQuadratureRefCell.cc \
+ TestQuadratureEngine.cc \
+ TestQuadrature0D.cc \
+ TestQuadrature1D.cc \
+ TestQuadrature1Din2D.cc \
+ TestQuadrature1Din3D.cc \
+ TestQuadrature2D.cc \
+ TestQuadrature2Din3D.cc \
+ TestQuadrature3D.cc \
+ TestQuadrature.cc \
+ TestIntegrator.cc \
+ TestIntegratorElasticity.cc \
TestElasticityExplicit.cc \
TestElasticityExplicit1DLinear.cc \
TestElasticityExplicit1DQuadratic.cc \
@@ -42,29 +66,10 @@
TestElasticityImplicitGrav2DQuadratic.cc \
TestElasticityImplicitGrav3DLinear.cc \
TestElasticityImplicitGrav3DQuadratic.cc \
- TestGeometryPoint1D.cc \
- TestGeometryPoint2D.cc \
- TestGeometryPoint3D.cc \
- TestGeometryLine1D.cc \
- TestGeometryLine2D.cc \
- TestGeometryLine3D.cc \
- TestGeometryTri2D.cc \
- TestGeometryTri3D.cc \
- TestGeometryQuad2D.cc \
- TestGeometryQuad3D.cc \
- TestGeometryTet3D.cc \
- TestGeometryHex3D.cc \
- TestIntegrator.cc \
- TestIntegratorElasticity.cc \
- TestQuadrature.cc \
- TestQuadrature0D.cc \
- TestQuadrature1D.cc \
- TestQuadrature1Din2D.cc \
- TestQuadrature2D.cc \
- TestQuadrature2Din3D.cc \
- TestQuadrature3D.cc \
test_feassemble.cc
+
+
noinst_HEADERS = \
TestCellGeometry.hh \
TestElasticityExplicit.hh \
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestCellGeometry.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestCellGeometry.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestCellGeometry.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,12 +23,13 @@
#include <cppunit/extensions/HelperMacros.h>
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
+
/// Namespace for pylith package
namespace pylith {
namespace feassemble {
class TestCellGeometry;
- class CellGeometry;
class CellGeomData;
} // feassemble
} // pylith
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,7 +19,9 @@
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -35,12 +37,16 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityExplicit );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::feassemble::TestElasticityExplicit::setUp(void)
{ // setUp
+ _quadrature = new Quadrature<topology::Mesh>();
_data = 0;
- _quadrature = 0;
_material = 0;
_gravityField = 0;
} // setUp
@@ -80,17 +86,6 @@
} // testTimeStep
// ----------------------------------------------------------------------
-// Test StableTimeStep().
-void
-pylith::feassemble::TestElasticityExplicit::testStableTimeStep(void)
-{ // testStableTimeStep
- ElasticityExplicit integrator;
-
- const double stableTimeStep = integrator.stableTimeStep();
- CPPUNIT_ASSERT_EQUAL(1.0e+30, stableTimeStep);
-} // testStableTimeStep
-
-// ----------------------------------------------------------------------
// Test material().
void
pylith::feassemble::TestElasticityExplicit::testMaterial(void)
@@ -148,22 +143,18 @@
} // testUseSolnIncr
// ----------------------------------------------------------------------
-// Test updateState().
+// Test initialize().
void
-pylith::feassemble::TestElasticityExplicit::testUpdateState(void)
-{ // testUpdateState
+pylith::feassemble::TestElasticityExplicit::testInitialize(void)
+{ // testInitialize
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
ElasticityExplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
- const ALE::Obj<real_section_type>& dispT = fields.getReal("dispT");
- CPPUNIT_ASSERT(!dispT.isNull());
- const double t = 1.0;
- integrator.updateState(t, &fields, mesh);
-} // testUpdateState
+} // testInitialize
// ----------------------------------------------------------------------
// Test integrateResidual().
@@ -172,25 +163,22 @@
{ // testIntegrateResidual
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
ElasticityExplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((mesh)->getDimension());
- cs.initialize();
-
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
+ topology::Field<topology::Mesh>& residual = fields.get("residual");
const double t = 1.0;
- integrator.integrateResidual(residual, t, &fields, mesh, &cs);
+ integrator.integrateResidual(residual, t, &fields);
const double* valsE = _data->valsResidual;
const int sizeE = _data->spaceDim * _data->numVertices;
- const double* vals = residual->restrictSpace();
- const int size = residual->sizeWithBC();
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ CPPUNIT_ASSERT(!residualSection.isNull());
+ const double* vals = residualSection->restrictSpace();
+ const int size = residualSection->sizeWithBC();
CPPUNIT_ASSERT_EQUAL(sizeE, size);
const double tolerance = 1.0e-06;
@@ -208,42 +196,34 @@
{ // testIntegrateJacobian
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
ElasticityExplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
integrator._needNewJacobian = true;
- const ALE::Obj<pylith::real_section_type>& dispTpdt =
- fields.getReal("dispTpdt");
- CPPUNIT_ASSERT(!dispTpdt.isNull());
+ topology::Jacobian jacobian(fields);
- PetscMat jacobian;
- PetscErrorCode err = MeshCreateMatrix(mesh, dispTpdt, MATMPIBAIJ, &jacobian);
- CPPUNIT_ASSERT(0 == err);
-
const double t = 1.0;
- integrator.integrateJacobian(&jacobian, t, &fields, mesh);
+ integrator.integrateJacobian(&jacobian, t, &fields);
CPPUNIT_ASSERT_EQUAL(false, integrator.needNewJacobian());
+ jacobian.assemble("final_assembly");
- err = MatAssemblyBegin(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
- err = MatAssemblyEnd(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
-
const double* valsE = _data->valsJacobian;
const int nrowsE = _data->numVertices * _data->spaceDim;
const int ncolsE = _data->numVertices * _data->spaceDim;
+ const PetscMat jacobianMat = jacobian.matrix();
+
int nrows = 0;
int ncols = 0;
- MatGetSize(jacobian, &nrows, &ncols);
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(jacobian, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
@@ -268,12 +248,42 @@
} // testIntegrateJacobian
// ----------------------------------------------------------------------
+// Test updateStateVars().
+void
+pylith::feassemble::TestElasticityExplicit::testUpdateStateVars(void)
+{ // testUpdateStateVars
+ CPPUNIT_ASSERT(0 != _data);
+
+ topology::Mesh mesh;
+ ElasticityExplicit integrator;
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &integrator, &fields);
+
+ const double t = 1.0;
+ integrator.updateStateVars(t, &fields);
+} // testUpdateStateVars
+
+// ----------------------------------------------------------------------
+// Test StableTimeStep().
+void
+pylith::feassemble::TestElasticityExplicit::testStableTimeStep(void)
+{ // testStableTimeStep
+ topology::Mesh mesh;
+ ElasticityExplicit integrator;
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &integrator, &fields);
+
+ const double stableTimeStep = integrator.stableTimeStep(mesh);
+ CPPUNIT_ASSERT_EQUAL(1.0e+30, stableTimeStep);
+} // testStableTimeStep
+
+// ----------------------------------------------------------------------
// Initialize elasticity integrator.
void
pylith::feassemble::TestElasticityExplicit::_initialize(
- ALE::Obj<Mesh>* mesh,
+ topology::Mesh* mesh,
ElasticityExplicit* const integrator,
- topology::FieldsManager* fields)
+ topology::SolutionFields* fields)
{ // _initialize
CPPUNIT_ASSERT(0 != mesh);
CPPUNIT_ASSERT(0 != integrator);
@@ -285,37 +295,51 @@
spatialdata::geocoords::CSCart cs;
cs.setSpaceDim(_data->spaceDim);
cs.initialize();
- *mesh = new Mesh(PETSC_COMM_WORLD, _data->cellDim);
- CPPUNIT_ASSERT(!mesh->isNull());
- ALE::Obj<sieve_type> sieve = new sieve_type((*mesh)->comm());
+ mesh->coordsys(&cs);
+ mesh->createSieveMesh(_data->cellDim);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ ALE::Obj<SieveMesh::sieve_type> sieve =
+ new SieveMesh::sieve_type(mesh->comm());
CPPUNIT_ASSERT(!sieve.isNull());
+
+ // Cells and vertices
const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
+ ALE::SieveBuilder<ALE::Mesh>::buildTopology(s,
+ _data->cellDim, _data->numCells,
+ const_cast<int*>(_data->cells),
+ _data->numVertices,
+ interpolate, _data->numBasis);
+ std::map<ALE::Mesh::point_type,ALE::Mesh::point_type> renumbering;
+ ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
+ sieveMesh->setSieve(sieve);
+ sieveMesh->stratify();
+ ALE::SieveBuilder<SieveMesh>::buildCoordinates(sieveMesh, _data->spaceDim,
+ _data->vertices);
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, _data->cellDim,
- _data->numCells, const_cast<int*>(_data->cells),
- _data->numVertices, interpolate, _data->numBasis);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- (*mesh)->setSieve(sieve);
- (*mesh)->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates((*mesh), _data->spaceDim,
- _data->vertices);
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- (*mesh)->createLabel("material-id");
+ // Material ids
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
+ CPPUNIT_ASSERT(!cells.isNull());
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->createLabel("material-id");
+ CPPUNIT_ASSERT(!labelMaterials.isNull());
int i = 0;
- const ALE::Obj<Mesh::label_sequence>& cells = (*mesh)->heightStratum(0);
- CPPUNIT_ASSERT(!cells.isNull());
- for(Mesh::label_sequence::iterator c_iter = cells->begin();
- c_iter != cells->end();
- ++c_iter)
- (*mesh)->setValue(labelMaterials, *c_iter, _data->matId);
- (*mesh)->getFactory()->clear(); // clear numberings
+ for(SieveMesh::label_sequence::iterator e_iter=cells->begin();
+ e_iter != cells->end();
+ ++e_iter)
+ sieveMesh->setValue(labelMaterials, *e_iter, _data->matId);
// Setup quadrature
- _quadrature->initialize(_data->basis, _data->basisDerivRef, _data->quadPts,
- _data->quadWts, _data->cellDim, _data->numBasis,
- _data->numQuadPts, _data->spaceDim);
+ _quadrature->initialize(_data->basis, _data->numQuadPts, _data->numBasis,
+ _data->basisDerivRef, _data->numQuadPts,
+ _data->numBasis, _data->cellDim,
+ _data->quadPts, _data->numQuadPts, _data->cellDim,
+ _data->quadWts, _data->numQuadPts,
+ _data->spaceDim);
// Setup gravityField
_gravityField = 0;
@@ -323,55 +347,57 @@
// Setup material
spatialdata::spatialdb::SimpleIOAscii iohandler;
iohandler.filename(_data->matDBFilename);
- spatialdata::spatialdb::SimpleDB db;
- db.ioHandler(&iohandler);
+ spatialdata::spatialdb::SimpleDB dbProperties;
+ dbProperties.ioHandler(&iohandler);
spatialdata::units::Nondimensional normalizer;
_material->id(_data->matId);
_material->label(_data->matLabel);
- _material->db(&db);
+ _material->dbProperties(&dbProperties);
_material->normalizer(normalizer);
- _material->initialize(*mesh, &cs, _quadrature);
integrator->quadrature(_quadrature);
integrator->gravityField(_gravityField);
integrator->timeStep(_data->dt);
integrator->material(_material);
+ integrator->initialize(*mesh);
// Setup fields
CPPUNIT_ASSERT(0 != fields);
- fields->addReal("residual");
- fields->addReal("dispTpdt");
- fields->addReal("dispT");
- fields->addReal("dispTmdt");
- const char* history[] = { "dispTpdt", "dispT", "dispTmdt" };
+ fields->add("residual", "residual");
+ fields->add("disp(t+dt)", "displacement");
+ fields->add("disp(t)", "displacement");
+ fields->add("disp(t-dt)", "displacement");
+ fields->solutionName("disp(t+dt)");
+ const char* history[] = { "disp(t+dt)", "disp(t)", "disp(t-dt)" };
const int historySize = 3;
fields->createHistory(history, historySize);
- const ALE::Obj<real_section_type>& residual = fields->getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
- residual->setChart((*mesh)->getSieve()->getChart());
- residual->setFiberDimension((*mesh)->depthStratum(0), _data->spaceDim);
- (*mesh)->allocate(residual);
- residual->zero();
+ topology::Field<topology::Mesh>& residual = fields->get("residual");
+ residual.newSection(topology::FieldBase::VERTICES_FIELD, _data->spaceDim);
+ residual.allocate();
+ residual.zero();
fields->copyLayout("residual");
const int fieldSize = _data->spaceDim * _data->numVertices;
- const ALE::Obj<real_section_type>& dispTpdt = fields->getReal("dispTpdt");
- const ALE::Obj<real_section_type>& dispT = fields->getReal("dispT");
- const ALE::Obj<real_section_type>& dispTmdt = fields->getReal("dispTmdt");
- CPPUNIT_ASSERT(!dispTpdt.isNull());
- CPPUNIT_ASSERT(!dispT.isNull());
- CPPUNIT_ASSERT(!dispTmdt.isNull());
+ topology::Field<topology::Mesh>& dispTpdt = fields->get("disp(t+dt)");
+ topology::Field<topology::Mesh>& dispT = fields->get("disp(t)");
+ topology::Field<topology::Mesh>& dispTmdt = fields->get("disp(t-dt)");
+ const ALE::Obj<RealSection>& dispTpdtSection = dispTpdt.section();
+ const ALE::Obj<RealSection>& dispTSection = dispT.section();
+ const ALE::Obj<RealSection>& dispTmdtSection = dispTmdt.section();
+ CPPUNIT_ASSERT(!dispTpdtSection.isNull());
+ CPPUNIT_ASSERT(!dispTSection.isNull());
+ CPPUNIT_ASSERT(!dispTmdtSection.isNull());
const int offset = _data->numCells;
for (int iVertex=0; iVertex < _data->numVertices; ++iVertex) {
- dispTpdt->updatePoint(iVertex+offset,
- &_data->fieldTpdt[iVertex*_data->spaceDim]);
- dispT->updatePoint(iVertex+offset,
- &_data->fieldT[iVertex*_data->spaceDim]);
- dispTmdt->updatePoint(iVertex+offset,
- &_data->fieldTmdt[iVertex*_data->spaceDim]);
+ dispTpdtSection->updatePoint(iVertex+offset,
+ &_data->fieldTpdt[iVertex*_data->spaceDim]);
+ dispTSection->updatePoint(iVertex+offset,
+ &_data->fieldT[iVertex*_data->spaceDim]);
+ dispTmdtSection->updatePoint(iVertex+offset,
+ &_data->fieldTmdt[iVertex*_data->spaceDim]);
} // for
} // _initialize
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,35 +23,20 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SolutionFields
+#include "pylith/materials/materialsfwd.hh" // USES ElasticMaterial
-#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // USES GravityField
/// Namespace for pylith package
namespace pylith {
namespace feassemble {
class TestElasticityExplicit;
-
- class ElasticityExplicit; // USES ElasticityExplicit
- class IntegratorData; // HOLDSA IntegratorData
- class Quadrature; // HOLDSA Quadrature
+ class IntegratorData;
} // feassemble
-
- namespace materials {
- class ElasticMaterial; // HOLDSA ElasticMaterial
- } // materials
-
- namespace topology {
- class FieldsManager; // USES FieldsManager
- } // topology
} // pylith
-namespace spatialdata {
- namespace spatialdb {
- class GravityField; // HOLDSA GravityField
- } // spatialdb
-} // spatialdata
-
/// C++ unit testing for ElasticityExplicit
class pylith::feassemble::TestElasticityExplicit : public CppUnit::TestFixture
{ // class TestElasticityExplicit
@@ -61,11 +46,14 @@
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testTimeStep );
- CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST( testMaterial );
CPPUNIT_TEST( testNeedNewJacobian );
CPPUNIT_TEST( testUseSolnIncr );
+ // Testing of initialize(), integrateResidual(),
+ // integrateJacobian(), and updateStateVars() handled by derived
+ // classes.
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -83,9 +71,6 @@
/// Test timeStep().
void testTimeStep(void);
- /// Test StableTimeStep().
- void testStableTimeStep(void);
-
/// Test material().
void testMaterial(void);
@@ -95,8 +80,8 @@
/// Test useSolnIncr().
void testUseSolnIncr(void);
- /// Test updateState().
- void testUpdateState(void);
+ /// Test initialize().
+ void testInitialize(void);
/// Test integrateResidual().
void testIntegrateResidual(void);
@@ -104,12 +89,18 @@
/// Test integrateJacobian().
void testIntegrateJacobian(void);
+ /// Test updateStateVars().
+ void testUpdateStateVars(void);
+
+ /// Test StableTimeStep().
+ void testStableTimeStep(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
IntegratorData* _data; ///< Data for testing.
materials::ElasticMaterial* _material; ///< Elastic material.
- Quadrature* _quadrature; ///< Quadrature information.
+ Quadrature<topology::Mesh>* _quadrature; ///< Quadrature information.
spatialdata::spatialdb::GravityField* _gravityField; ///< Gravity field.
// PRIVATE METHODS ////////////////////////////////////////////////////
@@ -117,13 +108,13 @@
/** Initialize elasticity integrator.
*
- * @param mesh PETSc mesh to initialize.
+ * @param mesh Finite-element mesh to initialize.
* @param integrator ElasticityIntegrator to initialize.
* @param fields Solution fields.
*/
- void _initialize(ALE::Obj<Mesh>* mesh,
+ void _initialize(topology::Mesh* mesh,
ElasticityExplicit* const integrator,
- topology::FieldsManager* const fields);
+ topology::SolutionFields* const fields);
}; // class TestElasticityExplicit
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityExplicitData1DLinear.hh"
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityExplicit1DLinear::setUp(void)
{ // setUp
+ TestElasticityExplicit::setUp();
+
_data = new ElasticityExplicitData1DLinear();
- _quadrature = new Quadrature1D();
GeometryLine1D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityExplicit1DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityExplicitData1DQuadratic.hh"
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature1D
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityExplicit1DQuadratic::setUp(void)
{ // setUp
+ TestElasticityExplicit::setUp();
+
_data = new ElasticityExplicitData1DQuadratic();
- _quadrature = new Quadrature1D();
GeometryLine1D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit1DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityExplicit1DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityExplicitData2DLinear.hh"
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature2D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D
#include "pylith/materials/ElasticPlaneStrain.hh" // USES ElasticPlaneStrain
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityExplicit2DLinear::setUp(void)
{ // setUp
+ TestElasticityExplicit::setUp();
+
_data = new ElasticityExplicitData2DLinear();
- _quadrature = new Quadrature2D();
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTri2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityExplicit2DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityExplicitData2DQuadratic.hh"
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature2D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D
#include "pylith/materials/ElasticPlaneStrain.hh" // USES ElasticPlaneStrain
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityExplicit2DQuadratic::setUp(void)
{ // setUp
+ TestElasticityExplicit::setUp();
+
_data = new ElasticityExplicitData2DQuadratic();
- _quadrature = new Quadrature2D();
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTri2D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit2DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityExplicit2DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityExplicitData3DLinear.hh"
-#include "pylith/feassemble/Quadrature3D.hh" // USES Quadrature3D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTet3D.hh" // USES GeometryTet3D
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityExplicit3DLinear::setUp(void)
{ // setUp
+ TestElasticityExplicit::setUp();
+
_data = new ElasticityExplicitData3DLinear();
- _quadrature = new Quadrature3D();
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTet3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityExplicit3DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityExplicitData3DQuadratic.hh"
-#include "pylith/feassemble/Quadrature3D.hh" // USES Quadrature3D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTet3D.hh" // USES GeometryTet3D
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityExplicit3DQuadratic::setUp(void)
{ // setUp
+ TestElasticityExplicit::setUp();
+
_data = new ElasticityExplicitData3DQuadratic();
- _quadrature = new Quadrature3D();
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTet3D geometry;
_quadrature->refGeometry(&geometry);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityExplicit3DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityExplicit3DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,7 +20,9 @@
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
@@ -34,12 +36,16 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestElasticityImplicit );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::feassemble::TestElasticityImplicit::setUp(void)
{ // setUp
+ _quadrature = new Quadrature<topology::Mesh>();
_data = 0;
- _quadrature = 0;
_material = 0;
_gravityField = 0;
} // setUp
@@ -79,24 +85,6 @@
} // testTimeStep
// ----------------------------------------------------------------------
-// Test StableTimeStep().
-void
-pylith::feassemble::TestElasticityImplicit::testStableTimeStep(void)
-{ // testStableTimeStep
- ElasticityImplicit integrator;
-
- materials::ElasticIsotropic3D material;
- const int id = 3;
- const std::string label("my material");
- material.id(id);
- material.label(label.c_str());
- integrator.material(&material);
-
- const double stableTimeStep = integrator.stableTimeStep();
- CPPUNIT_ASSERT_EQUAL(pylith::PYLITH_MAXDOUBLE, stableTimeStep);
-} // testStableTimeStep
-
-// ----------------------------------------------------------------------
// Test material().
void
pylith::feassemble::TestElasticityImplicit::testMaterial(void)
@@ -146,23 +134,18 @@
} // testUseSolnIncr
// ----------------------------------------------------------------------
-// Test updateState().
+// Test initialize().
void
-pylith::feassemble::TestElasticityImplicit::testUpdateState(void)
-{ // testUpdateState
+pylith::feassemble::TestElasticityImplicit::testInitialize(void)
+{ // testInitialize
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
ElasticityImplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
- const ALE::Obj<real_section_type>& dispTBctpdt =
- fields.getReal("dispTBctpdt");
- CPPUNIT_ASSERT(!dispTBctpdt.isNull());
- const double t = 1.0;
- integrator.updateState(t, &fields, mesh);
-} // testUpdateState
+} // testInitialize
// ----------------------------------------------------------------------
// Test integrateResidual().
@@ -171,25 +154,22 @@
{ // testIntegrateResidual
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
ElasticityImplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim((mesh)->getDimension());
- cs.initialize();
-
- const ALE::Obj<real_section_type>& residual = fields.getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
+ topology::Field<topology::Mesh>& residual = fields.get("residual");
const double t = 1.0;
- integrator.integrateResidual(residual, t, &fields, mesh, &cs);
+ integrator.integrateResidual(residual, t, &fields);
const double* valsE = _data->valsResidual;
const int sizeE = _data->spaceDim * _data->numVertices;
- const double* vals = residual->restrictSpace();
- const int size = residual->sizeWithBC();
+ const ALE::Obj<RealSection>& residualSection = residual.section();
+ CPPUNIT_ASSERT(!residualSection.isNull());
+ const double* vals = residualSection->restrictSpace();
+ const int size = residualSection->sizeWithBC();
CPPUNIT_ASSERT_EQUAL(sizeE, size);
const double tolerance = 1.0e-06;
@@ -207,44 +187,36 @@
{ // testIntegrateJacobian
CPPUNIT_ASSERT(0 != _data);
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
ElasticityImplicit integrator;
- topology::FieldsManager fields(mesh);
+ topology::SolutionFields fields(mesh);
_initialize(&mesh, &integrator, &fields);
integrator._needNewJacobian = true;
- const ALE::Obj<pylith::real_section_type>& dispTBctpdt =
- fields.getReal("dispTBctpdt");
- CPPUNIT_ASSERT(!dispTBctpdt.isNull());
+ topology::Jacobian jacobian(fields);
- PetscMat jacobian;
- PetscErrorCode err = MeshCreateMatrix(mesh, dispTBctpdt, MATMPIBAIJ, &jacobian);
- CPPUNIT_ASSERT(0 == err);
-
const double t = 1.0;
//mesh->getSieve()->setDebug(10);
- integrator.integrateJacobian(&jacobian, t, &fields, mesh);
+ integrator.integrateJacobian(&jacobian, t, &fields);
CPPUNIT_ASSERT_EQUAL(false, integrator.needNewJacobian());
//mesh->getSieve()->setDebug(0);
+ jacobian.assemble("final_assembly");
- err = MatAssemblyBegin(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
- err = MatAssemblyEnd(jacobian, MAT_FINAL_ASSEMBLY);
- CPPUNIT_ASSERT(0 == err);
-
const double* valsE = _data->valsJacobian;
const int nrowsE = _data->numVertices * _data->spaceDim;
const int ncolsE = _data->numVertices * _data->spaceDim;
+ const PetscMat jacobianMat = jacobian.matrix();
+
int nrows = 0;
int ncols = 0;
- MatGetSize(jacobian, &nrows, &ncols);
+ MatGetSize(jacobianMat, &nrows, &ncols);
CPPUNIT_ASSERT_EQUAL(nrowsE, nrows);
CPPUNIT_ASSERT_EQUAL(ncolsE, ncols);
PetscMat jDense;
PetscMat jSparseAIJ;
- MatConvert(jacobian, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
+ MatConvert(jacobianMat, MATSEQAIJ, MAT_INITIAL_MATRIX, &jSparseAIJ);
MatConvert(jSparseAIJ, MATSEQDENSE, MAT_INITIAL_MATRIX, &jDense);
double_array vals(nrows*ncols);
@@ -269,12 +241,43 @@
} // testIntegrateJacobian
// ----------------------------------------------------------------------
+// Test updateStateVars().
+void
+pylith::feassemble::TestElasticityImplicit::testUpdateStateVars(void)
+{ // testUpdateStateVars
+ CPPUNIT_ASSERT(0 != _data);
+
+ topology::Mesh mesh;
+ ElasticityImplicit integrator;
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &integrator, &fields);
+
+ const double t = 1.0;
+ integrator.updateStateVars(t, &fields);
+} // testUpdateStateVars
+
+// ----------------------------------------------------------------------
+// Test StableTimeStep().
+void
+pylith::feassemble::TestElasticityImplicit::testStableTimeStep(void)
+{ // testStableTimeStep
+
+ topology::Mesh mesh;
+ ElasticityImplicit integrator;
+ topology::SolutionFields fields(mesh);
+ _initialize(&mesh, &integrator, &fields);
+
+ const double stableTimeStep = integrator.stableTimeStep(mesh);
+ CPPUNIT_ASSERT_EQUAL(pylith::PYLITH_MAXDOUBLE, stableTimeStep);
+} // testStableTimeStep
+
+// ----------------------------------------------------------------------
// Initialize elasticity integrator.
void
pylith::feassemble::TestElasticityImplicit::_initialize(
- ALE::Obj<Mesh>* mesh,
+ topology::Mesh* mesh,
ElasticityImplicit* const integrator,
- topology::FieldsManager* fields)
+ topology::SolutionFields* fields)
{ // _initialize
CPPUNIT_ASSERT(0 != mesh);
CPPUNIT_ASSERT(0 != integrator);
@@ -286,82 +289,93 @@
spatialdata::geocoords::CSCart cs;
cs.setSpaceDim(_data->spaceDim);
cs.initialize();
- *mesh = new Mesh(PETSC_COMM_WORLD, _data->cellDim);
- CPPUNIT_ASSERT(!mesh->isNull());
- ALE::Obj<sieve_type> sieve = new sieve_type((*mesh)->comm());
+ mesh->coordsys(&cs);
+ mesh->createSieveMesh(_data->cellDim);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ ALE::Obj<SieveMesh::sieve_type> sieve =
+ new SieveMesh::sieve_type(mesh->comm());
CPPUNIT_ASSERT(!sieve.isNull());
+
+ // Cells and vertices
const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
+ ALE::SieveBuilder<ALE::Mesh>::buildTopology(s,
+ _data->cellDim, _data->numCells,
+ const_cast<int*>(_data->cells),
+ _data->numVertices,
+ interpolate, _data->numBasis);
+ std::map<ALE::Mesh::point_type,ALE::Mesh::point_type> renumbering;
+ ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
+ sieveMesh->setSieve(sieve);
+ sieveMesh->stratify();
+ ALE::SieveBuilder<SieveMesh>::buildCoordinates(sieveMesh, _data->spaceDim,
+ _data->vertices);
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, _data->cellDim,
- _data->numCells, const_cast<int*>(_data->cells),
- _data->numVertices, interpolate, _data->numBasis);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering, false);
- (*mesh)->setSieve(sieve);
- (*mesh)->stratify();
- //std::cout << "Mesh chart: " << (*mesh)->getSieve()->getChart() << std::endl;
- ALE::SieveBuilder<Mesh>::buildCoordinates((*mesh), _data->spaceDim,
- _data->vertices);
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- (*mesh)->createLabel("material-id");
+ // Material ids
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
+ CPPUNIT_ASSERT(!cells.isNull());
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->createLabel("material-id");
+ CPPUNIT_ASSERT(!labelMaterials.isNull());
int i = 0;
- const ALE::Obj<Mesh::label_sequence>& cells = (*mesh)->heightStratum(0);
- CPPUNIT_ASSERT(!cells.isNull());
- for(Mesh::label_sequence::iterator c_iter = cells->begin();
- c_iter != cells->end();
- ++c_iter)
- (*mesh)->setValue(labelMaterials, *c_iter, _data->matId);
- (*mesh)->getFactory()->clear(); // clear numberings
+ for(SieveMesh::label_sequence::iterator e_iter=cells->begin();
+ e_iter != cells->end();
+ ++e_iter)
+ sieveMesh->setValue(labelMaterials, *e_iter, _data->matId);
// Setup quadrature
- _quadrature->initialize(_data->basis, _data->basisDerivRef, _data->quadPts,
- _data->quadWts, _data->cellDim, _data->numBasis,
- _data->numQuadPts, _data->spaceDim);
- // Setup gravityField
- // _gravityField = 0;
+ _quadrature->initialize(_data->basis, _data->numQuadPts, _data->numBasis,
+ _data->basisDerivRef, _data->numQuadPts,
+ _data->numBasis, _data->cellDim,
+ _data->quadPts, _data->numQuadPts, _data->cellDim,
+ _data->quadWts, _data->numQuadPts,
+ _data->spaceDim);
// Setup material
spatialdata::spatialdb::SimpleIOAscii iohandler;
iohandler.filename(_data->matDBFilename);
- spatialdata::spatialdb::SimpleDB db;
- db.ioHandler(&iohandler);
+ spatialdata::spatialdb::SimpleDB dbProperties;
+ dbProperties.ioHandler(&iohandler);
spatialdata::units::Nondimensional normalizer;
_material->id(_data->matId);
_material->label(_data->matLabel);
- _material->db(&db);
+ _material->dbProperties(&dbProperties);
_material->normalizer(normalizer);
- _material->initialize(*mesh, &cs, _quadrature);
integrator->quadrature(_quadrature);
integrator->gravityField(_gravityField);
integrator->timeStep(_data->dt);
integrator->material(_material);
+ integrator->initialize(*mesh);
// Setup fields
CPPUNIT_ASSERT(0 != fields);
- fields->addReal("residual");
- fields->addReal("dispTBctpdt");
+ fields->add("residual", "residual");
+ fields->add("disp(t), bc(t+dt)", "displacement");
+ fields->add("dispIncr(t->t+dt)", "displacement increment");
+ fields->solutionName("dispIncr(t->t+dt)");
- const ALE::Obj<real_section_type>& residual = fields->getReal("residual");
- CPPUNIT_ASSERT(!residual.isNull());
- residual->setChart((*mesh)->getSieve()->getChart());
- residual->setFiberDimension((*mesh)->depthStratum(0), _data->spaceDim);
- (*mesh)->allocate(residual);
- residual->zero();
- //residual->view("Residual");
+ topology::Field<topology::Mesh>& residual = fields->get("residual");
+ residual.newSection(topology::FieldBase::VERTICES_FIELD, _data->spaceDim);
+ residual.allocate();
+ residual.zero();
fields->copyLayout("residual");
const int fieldSize = _data->spaceDim * _data->numVertices;
- const ALE::Obj<real_section_type>& dispTBctpdt =
- fields->getReal("dispTBctpdt");
- CPPUNIT_ASSERT(!dispTBctpdt.isNull());
+ topology::Field<topology::Mesh>& dispTBctpdt =
+ fields->get("disp(t), bc(t+dt)");
+ const ALE::Obj<RealSection>& dispTBctpdtSection = dispTBctpdt.section();
+ CPPUNIT_ASSERT(!dispTBctpdtSection.isNull());
const int offset = _data->numCells;
for (int iVertex=0; iVertex < _data->numVertices; ++iVertex) {
- dispTBctpdt->updatePoint(iVertex+offset,
- &_data->fieldTpdt[iVertex*_data->spaceDim]);
+ dispTBctpdtSection->updatePoint(iVertex+offset,
+ &_data->fieldTpdt[iVertex*_data->spaceDim]);
} // for
} // _initialize
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,35 +23,20 @@
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SolutionFields
+#include "pylith/materials/materialsfwd.hh" // USES ElasticMaterial
-#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
+#include "spatialdata/spatialdb/spatialdbfwd.hh" // USES GravityField
/// Namespace for pylith package
namespace pylith {
namespace feassemble {
class TestElasticityImplicit;
-
- class ElasticityImplicit; // USES ElasticityImplicit
- class IntegratorData; // HOLDSA IntegratorData
- class Quadrature; // HOLDSA Quadrature
+ class IntegratorData;
} // feassemble
-
- namespace materials {
- class ElasticMaterial; // HOLDSA ElasticMaterial
- } // materials
-
- namespace topology {
- class FieldsManager; // USES FieldsManager
- } // topology
} // pylith
-namespace spatialdata {
- namespace spatialdb {
- class GravityField; // HOLDSA GravityField
- } // spatialdb
-} // spatialdata
-
/// C++ unit testing for ElasticityImplicit
class pylith::feassemble::TestElasticityImplicit : public CppUnit::TestFixture
{ // class TestElasticityImplicit
@@ -61,11 +46,14 @@
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testTimeStep );
- CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST( testMaterial );
CPPUNIT_TEST( testNeedNewJacobian );
CPPUNIT_TEST( testUseSolnIncr );
+ // Testing of initialize(), integrateResidual(),
+ // integrateJacobian(), and updateStateVars() handled by derived
+ // classes.
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -95,8 +83,8 @@
/// Test useSolnIncr().
void testUseSolnIncr(void);
- /// Test updateState().
- void testUpdateState(void);
+ /// Test initialize().
+ void testInitialize(void);
/// Test integrateResidual().
void testIntegrateResidual(void);
@@ -104,12 +92,15 @@
/// Test integrateJacobian().
void testIntegrateJacobian(void);
+ /// Test updateStateVars().
+ void testUpdateStateVars(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
IntegratorData* _data; ///< Data for testing.
materials::ElasticMaterial* _material; ///< Elastic material.
- Quadrature* _quadrature; ///< Quadrature information.
+ Quadrature<topology::Mesh>* _quadrature; ///< Quadrature information.
spatialdata::spatialdb::GravityField* _gravityField; ///< Gravity field.
// PRIVATE METHODS ////////////////////////////////////////////////////
@@ -117,13 +108,13 @@
/** Initialize elasticity integrator.
*
- * @param mesh PETSc mesh to initialize.
+ * @param mesh Finite-element mesh to initialize.
* @param integrator ElasticityIntegrator to initialize.
* @param fields Solution fields.
*/
- void _initialize(ALE::Obj<Mesh>* mesh,
+ void _initialize(topology::Mesh* mesh,
ElasticityImplicit* const integrator,
- topology::FieldsManager* const fields);
+ topology::SolutionFields* const fields);
}; // class TestElasticityImplicit
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitData1DLinear.hh"
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityImplicit1DLinear::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitData1DLinear();
- _quadrature = new Quadrature1D();
_gravityField = 0;
GeometryLine1D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicit1DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitData1DQuadratic.hh"
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityImplicit1DQuadratic::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitData1DQuadratic();
- _quadrature = new Quadrature1D();
_gravityField = 0;
GeometryLine1D geometry;
CPPUNIT_ASSERT(0 != _quadrature);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit1DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicit1DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitData2DLinear.hh"
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature2D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D
#include "pylith/materials/ElasticPlaneStrain.hh" // USES ElasticPlaneStrain
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityImplicit2DLinear::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitData2DLinear();
- _quadrature = new Quadrature2D();
_gravityField = 0;
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTri2D geometry;
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicit2DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitData2DQuadratic.hh"
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature2D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D
#include "pylith/materials/ElasticPlaneStrain.hh" // USES ElasticPlaneStrain
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityImplicit2DQuadratic::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitData2DQuadratic();
- _quadrature = new Quadrature2D();
_gravityField = 0;
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTri2D geometry;
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit2DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicit2DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitData3DLinear.hh"
-#include "pylith/feassemble/Quadrature3D.hh" // USES Quadrature3D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTet3D.hh" // USES GeometryTet3D
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityImplicit3DLinear::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitData3DLinear();
- _quadrature = new Quadrature3D();
_gravityField = 0;
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTet3D geometry;
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicit3DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitData3DQuadratic.hh"
-#include "pylith/feassemble/Quadrature3D.hh" // USES Quadrature3D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTet3D.hh" // USES GeometryTet3D
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
@@ -28,8 +29,9 @@
void
pylith::feassemble::TestElasticityImplicit3DQuadratic::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitData3DQuadratic();
- _quadrature = new Quadrature3D();
_gravityField = 0;
CPPUNIT_ASSERT(0 != _quadrature);
GeometryTet3D geometry;
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicit3DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,11 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicit3DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
+ CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitGravData1DLinear.hh"
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
@@ -29,8 +30,9 @@
void
pylith::feassemble::TestElasticityImplicitGrav1DLinear::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitGravData1DLinear();
- _quadrature = new Quadrature1D();
_gravityField = new spatialdata::spatialdb::GravityField();
CPPUNIT_ASSERT(0 != _quadrature);
CPPUNIT_ASSERT(0 != _gravityField);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,10 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicitGrav1DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitGravData1DQuadratic.hh"
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
@@ -29,8 +30,9 @@
void
pylith::feassemble::TestElasticityImplicitGrav1DQuadratic::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitGravData1DQuadratic();
- _quadrature = new Quadrature1D();
_gravityField = new spatialdata::spatialdb::GravityField();
CPPUNIT_ASSERT(0 != _quadrature);
CPPUNIT_ASSERT(0 != _gravityField);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav1DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,10 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicitGrav1DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitGravData2DLinear.hh"
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature2D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D
#include "pylith/materials/ElasticPlaneStrain.hh" // USES ElasticPlaneStrain
#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
@@ -29,8 +30,9 @@
void
pylith::feassemble::TestElasticityImplicitGrav2DLinear::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitGravData2DLinear();
- _quadrature = new Quadrature2D();
_gravityField = new spatialdata::spatialdb::GravityField();
CPPUNIT_ASSERT(0 != _quadrature);
CPPUNIT_ASSERT(0 != _gravityField);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,10 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicitGrav2DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,8 @@
#include "data/ElasticityImplicitGravData2DQuadratic.hh"
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature2D
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D
#include "pylith/materials/ElasticPlaneStrain.hh" // USES ElasticPlaneStrain
#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
@@ -29,8 +30,9 @@
void
pylith::feassemble::TestElasticityImplicitGrav2DQuadratic::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitGravData2DQuadratic();
- _quadrature = new Quadrature2D();
_gravityField = new spatialdata::spatialdb::GravityField();
CPPUNIT_ASSERT(0 != _quadrature);
CPPUNIT_ASSERT(0 != _gravityField);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav2DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,10 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicitGrav2DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,6 +16,8 @@
#include "data/ElasticityImplicitGravData3DLinear.hh"
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/Quadrature3D.hh" // USES Quadrature3D
#include "pylith/feassemble/GeometryTet3D.hh" // USES GeometryTet3D
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
@@ -29,10 +31,9 @@
void
pylith::feassemble::TestElasticityImplicitGrav3DLinear::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitGravData3DLinear();
- _quadrature = new Quadrature3D();
- // _gravityField = 0;
- // spatialdata::spatialdb::GravityField* _gravityField;
_gravityField = new spatialdata::spatialdb::GravityField();
CPPUNIT_ASSERT(0 != _quadrature);
CPPUNIT_ASSERT(0 != _gravityField);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DLinear.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,10 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicitGrav3DLinear );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,6 +16,8 @@
#include "data/ElasticityImplicitGravData3DQuadratic.hh"
+#include "pylith/topology/Mesh.hh" // USES Quadrature<Mesh>
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/Quadrature3D.hh" // USES Quadrature3D
#include "pylith/feassemble/GeometryTet3D.hh" // USES GeometryTet3D
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
@@ -29,10 +31,9 @@
void
pylith::feassemble::TestElasticityImplicitGrav3DQuadratic::setUp(void)
{ // setUp
+ TestElasticityImplicit::setUp();
+
_data = new ElasticityImplicitGravData3DQuadratic();
- _quadrature = new Quadrature3D();
- // _gravityField = 0;
- // spatialdata::spatialdb::GravityField* _gravityField;
_gravityField = new spatialdata::spatialdb::GravityField();
CPPUNIT_ASSERT(0 != _quadrature);
CPPUNIT_ASSERT(0 != _gravityField);
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestElasticityImplicitGrav3DQuadratic.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,9 +38,10 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticityImplicitGrav3DQuadratic );
- CPPUNIT_TEST( testUpdateState );
+ CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST( testIntegrateResidual );
CPPUNIT_TEST( testIntegrateJacobian );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST_SUITE_END();
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,14 +16,12 @@
#include "pylith/feassemble/ElasticityExplicit.hh" // USES ElasticityExplicit
#include "pylith/feassemble/ElasticityImplicit.hh" // USES ElasticityImplicit
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/utils/constdefs.h" // USES MAXDOUBLE
#include "spatialdata/spatialdb/GravityField.hh" // USES GravityField
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-#include <petscmat.h>
-
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestIntegrator );
@@ -45,8 +43,9 @@
pylith::feassemble::TestIntegrator::testStableTimeStep(void)
{ // testStableTimeStep
ElasticityExplicit integrator;
+ topology::Mesh mesh;
- CPPUNIT_ASSERT_EQUAL(pylith::PYLITH_MAXDOUBLE, integrator.stableTimeStep());
+ CPPUNIT_ASSERT_EQUAL(pylith::PYLITH_MAXDOUBLE, integrator.stableTimeStep(mesh));
} // testStableTimeStep
// ----------------------------------------------------------------------
@@ -57,7 +56,7 @@
// Since quadrature is cloned, test setting quadrature by testing
// value of minJacobian
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
const double minJacobian = 4.0;
quadrature.minJacobian(minJacobian);
@@ -68,32 +67,33 @@
} // testQuadrature
// ----------------------------------------------------------------------
+// Test normalizer().
+void
+pylith::feassemble::TestIntegrator::testNormalizer(void)
+{ // testNormalizer
+ const double lengthScale = 2.0;
+
+ spatialdata::units::Nondimensional normalizer;
+ normalizer.lengthScale(lengthScale);
+
+ ElasticityExplicit integrator;
+ integrator.normalizer(normalizer);
+
+ CPPUNIT_ASSERT_EQUAL(lengthScale, integrator._normalizer->lengthScale());
+} // testNormalizer
+
+// ----------------------------------------------------------------------
// Test gravityField().
void
pylith::feassemble::TestIntegrator::testGravityField(void)
{ // testGravityField
- // Test gravity field by testing value of gravity vector.
- const int spaceDim = 3;
- const double gravityE[] = { 0.0, 0.0, -9.80665 };
-
ElasticityImplicit integrator;
spatialdata::spatialdb::GravityField gravityField;
- integrator.gravityField(&gravityField);
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(spaceDim);
+ CPPUNIT_ASSERT(0 == integrator._gravityField);
- integrator._gravityField->open();
- double gravity[spaceDim];
- const double coords[] = { 1.0, 2.0, 3.0 };
- const int err = integrator._gravityField->query(gravity, spaceDim,
- coords, spaceDim, &cs);
- CPPUNIT_ASSERT_EQUAL(0, err);
- integrator._gravityField->close();
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < spaceDim; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(gravityE[i], gravity[i], tolerance);
+ integrator.gravityField(&gravityField);
+ CPPUNIT_ASSERT(0 != integrator._gravityField);
} // testGravityField
// ----------------------------------------------------------------------
@@ -101,7 +101,7 @@
void
pylith::feassemble::TestIntegrator::testInitCellVector(void)
{ // testInitCellVector
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -109,10 +109,10 @@
integrator._initCellVector();
- CPPUNIT_ASSERT(0 != integrator._cellVector);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellVector.size());
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellVector[i]);
} // testInitCellVector
@@ -121,7 +121,7 @@
void
pylith::feassemble::TestIntegrator::testResetCellVector(void)
{ // testResetCellVector
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -129,13 +129,13 @@
integrator._initCellVector();
- CPPUNIT_ASSERT(0 != integrator._cellVector);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellVector.size());
+ for (size_t i=0; i < size; ++i)
integrator._cellVector[i] = 1.4+2*i;
integrator._resetCellVector();
- for (int i=0; i < size; ++i)
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellVector[i]);
} // testResetCellVector
@@ -144,7 +144,7 @@
void
pylith::feassemble::TestIntegrator::testInitCellMatrix(void)
{ // testInitCellMatrix
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -152,11 +152,11 @@
integrator._initCellMatrix();
- CPPUNIT_ASSERT(0 != integrator._cellMatrix);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis() *
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellMatrix.size());
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellMatrix[i]);
} // testInitCellMatrix
@@ -165,7 +165,7 @@
void
pylith::feassemble::TestIntegrator::testResetCellMatrix(void)
{ // testResetCellMatrix
- Quadrature1D quadrature;
+ Quadrature<topology::Mesh> quadrature;
_initQuadrature(&quadrature);
ElasticityExplicit integrator;
@@ -173,21 +173,22 @@
integrator._initCellMatrix();
- CPPUNIT_ASSERT(0 != integrator._cellMatrix);
- const int size =
+ const size_t size =
quadrature.spaceDim() * quadrature.numBasis() *
quadrature.spaceDim() * quadrature.numBasis();
- for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(size, integrator._cellMatrix.size());
+ for (size_t i=0; i < size; ++i)
integrator._cellMatrix[i] = 1.23 + 1.2*i;
integrator._resetCellMatrix();
- for (int i=0; i < size; ++i)
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(0.0, integrator._cellMatrix[i]);
} // testResetCellMatrix
// ----------------------------------------------------------------------
// Set quadrature information.
void
-pylith::feassemble::TestIntegrator::_initQuadrature(Quadrature1D* quadrature)
+pylith::feassemble::TestIntegrator::_initQuadrature(
+ Quadrature<topology::Mesh>* quadrature)
{ // _initQuadrature
CPPUNIT_ASSERT(0 != quadrature);
@@ -201,8 +202,11 @@
const double quadWts[] = { 2.0 };
const double minJacobian = 1.0;
- quadrature->initialize(basis, basisDeriv, quadPtsRef, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim);
+ quadrature->initialize(basis, numQuadPts, numBasis,
+ basisDeriv, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
} // _initQuadrature
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestIntegrator.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,21 +23,16 @@
#include <cppunit/extensions/HelperMacros.h>
+#include "pylith/topology/topologyfwd.hh" // USES Mesh
+#include "pylith/feassemble/feassemblefwd.hh" // USES Quadrature
+
/// Namespace for pylith package
namespace pylith {
namespace feassemble {
class TestIntegrator;
-
- class Quadrature1D; // USES Quadrature1D
} // feassemble
} // pylith
-namespace spatialdata {
- namespace spatialdb {
- class GravityField; // USES GravityField
- } // spatialdb
-} // spatialdata
-
/// C++ unit testing for Integrator
class pylith::feassemble::TestIntegrator : public CppUnit::TestFixture
{ // class TestIntegrator
@@ -49,6 +44,7 @@
CPPUNIT_TEST( testStableTimeStep );
CPPUNIT_TEST( testQuadrature );
+ CPPUNIT_TEST( testNormalizer );
CPPUNIT_TEST( testGravityField );
CPPUNIT_TEST( testInitCellVector );
CPPUNIT_TEST( testResetCellVector );
@@ -66,32 +62,35 @@
/// Test stableTimeStep().
void testStableTimeStep(void);
- /// Test quadrature()
+ /// Test quadrature().
void testQuadrature(void);
- /// Test gravityField()
+ /// Test normalizer().
+ void testNormalizer(void);
+
+ /// Test gravityField().
void testGravityField(void);
- /// Test _initCellVector()
+ /// Test _initCellVector().
void testInitCellVector(void);
- /// Test _resetCellVector()
+ /// Test _resetCellVector().
void testResetCellVector(void);
- /// Test _initCellMatrix()
+ /// Test _initCellMatrix().
void testInitCellMatrix(void);
- /// Test _resetCellMatrix()
+ /// Test _resetCellMatrix().
void testResetCellMatrix(void);
- // PRIVATE METHODS ////////////////////////////////////////////////////
+ // PRIVATE METHODS /////////////////////////////////////////////////////
private :
- /** Initialize 1-D quadrature object.
+ /** Initialize quadrature.
*
- * @param quadrature Quadrature object
+ * @param quadrature Quadrature to initiqlize.
*/
- void _initQuadrature(Quadrature1D* quadrature);
+ void _initQuadrature(Quadrature<topology::Mesh>* quadrature);
}; // class TestIntegrator
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,10 +14,13 @@
#include "TestQuadrature.hh" // Implementation of class methods
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
+
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
+#include "pylith/feassemble/GeometryTri2D.hh" // USES GeometryTri2D
-#include "data/QuadratureData.hh" // USES QuadratureData
+#include "data/QuadratureData2DLinear.hh" // USES QuadratureData2DLinear
#include <string.h> // USES memcpy()
@@ -25,9 +28,9 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestQuadrature );
// ----------------------------------------------------------------------
-// Test clone
+// Test copy constuctor.
void
-pylith::feassemble::TestQuadrature::testClone(void)
+pylith::feassemble::TestQuadrature::testCopyConstructor(void)
{ // testClone
// Semi-random values manually set to check cloning
const double minJacobianE = 1.0;
@@ -47,134 +50,64 @@
GeometryLine1D geometry;
// Set values
- Quadrature1D qOrig;
- qOrig._minJacobian = minJacobianE;
- qOrig._checkConditioning = checkConditioning;
- qOrig._cellDim = cellDimE;
- qOrig._numBasis = numBasisE;
- qOrig._numQuadPts = numQuadPtsE;
- qOrig._spaceDim = spaceDimE;
+ Quadrature<topology::Mesh> qOrig;
+ qOrig.refGeometry(&geometry);
+ qOrig.minJacobian(minJacobianE);
+ qOrig.checkConditioning(checkConditioning);
+ qOrig.initialize(basisE, numQuadPtsE, numBasisE,
+ basisDerivE, numQuadPtsE, numBasisE, cellDimE,
+ quadPtsRefE, numQuadPtsE, cellDimE,
+ quadWtsE, numQuadPtsE,
+ spaceDimE);
- size_t size = 2;
- qOrig._basis.resize(size);
- memcpy(&qOrig._basis[0], basisE, size*sizeof(double));
+ // Copy
+ Quadrature<topology::Mesh> qCopy(qOrig);
- size = 2;
- qOrig._basisDerivRef.resize(size);
- memcpy(&qOrig._basisDerivRef[0], basisDerivE, size*sizeof(double));
+ // Check copy
+ CPPUNIT_ASSERT(0 == qCopy._engine);
+ CPPUNIT_ASSERT_EQUAL(minJacobianE, qCopy._minJacobian);
+ CPPUNIT_ASSERT_EQUAL(checkConditioning, qCopy._checkConditioning);
+ CPPUNIT_ASSERT_EQUAL(cellDimE, qCopy.cellDim());
+ CPPUNIT_ASSERT_EQUAL(numBasisE, qCopy.numBasis());
+ CPPUNIT_ASSERT_EQUAL(numQuadPtsE, qCopy.numQuadPts());
+ CPPUNIT_ASSERT_EQUAL(spaceDimE, qCopy.spaceDim());
- size = 1;
- qOrig._quadPtsRef.resize(size);
- memcpy(&qOrig._quadPtsRef[0], quadPtsRefE, size*sizeof(double));
-
- size = 1;
- qOrig._quadWts.resize(size);
- memcpy(&qOrig._quadWts[0], quadWtsE, size*sizeof(double));
-
- size = 1;
- qOrig._quadPts.resize(size);
- memcpy(&qOrig._quadPts[0], quadPtsE, size*sizeof(double));
-
- size = 1;
- qOrig._jacobian.resize(size);
- memcpy(&qOrig._jacobian[0], jacobianE, size*sizeof(double));
-
- size = 1;
- qOrig._jacobianInv.resize(size);
- memcpy(&qOrig._jacobianInv[0], jacobianInvE, size*sizeof(double));
-
- size = 1;
- qOrig._jacobianDet.resize(size);
- memcpy(&qOrig._jacobianDet[0], jacobianDetE, size*sizeof(double));
-
- qOrig._geometry = geometry.clone();
-
- // Clone
- const Quadrature* qCopy = qOrig.clone();
-
- // Check clone
- CPPUNIT_ASSERT(0 != qCopy);
-
- CPPUNIT_ASSERT_EQUAL(minJacobianE, qCopy->_minJacobian);
- CPPUNIT_ASSERT_EQUAL(checkConditioning, qCopy->_checkConditioning);
- CPPUNIT_ASSERT_EQUAL(cellDimE, qCopy->cellDim());
- CPPUNIT_ASSERT_EQUAL(numBasisE, qCopy->numBasis());
- CPPUNIT_ASSERT_EQUAL(numQuadPtsE, qCopy->numQuadPts());
- CPPUNIT_ASSERT_EQUAL(spaceDimE, qCopy->spaceDim());
-
- const double_array& basis = qCopy->basis();
- size = numBasisE * numQuadPtsE;
+ const double_array& basis = qCopy.basis();
+ size_t size = numBasisE * numQuadPtsE;
CPPUNIT_ASSERT_EQUAL(size, basis.size());
for (int i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(basisE[i], basis[i]);
- const double_array& basisDerivRef = qCopy->_basisDerivRef;
+ const double_array& basisDerivRef = qCopy._basisDerivRef;
size = numBasisE * numQuadPtsE * spaceDimE;
CPPUNIT_ASSERT_EQUAL(size, basisDerivRef.size());
for (int i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(basisDerivE[i], basisDerivRef[i]);
- const double_array& quadPtsRef = qCopy->_quadPtsRef;
+ const double_array& quadPtsRef = qCopy._quadPtsRef;
size = numQuadPtsE * cellDimE;
CPPUNIT_ASSERT_EQUAL(size, quadPtsRef.size());
for (int i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(quadPtsRefE[i], quadPtsRef[i]);
- const double_array& quadWts = qCopy->quadWts();
+ const double_array& quadWts = qCopy.quadWts();
size = numQuadPtsE;
CPPUNIT_ASSERT_EQUAL(size, quadWts.size());
for (int i=0; i < size; ++i)
CPPUNIT_ASSERT_EQUAL(quadWtsE[i], quadWts[i]);
- const double_array& quadPts = qCopy->quadPts();
- size = 1;
- CPPUNIT_ASSERT_EQUAL(size, quadPts.size());
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(quadPtsE[i], quadPts[i]);
+ CPPUNIT_ASSERT_EQUAL(geometry.cellDim(), qCopy.refGeometry().cellDim());
+ CPPUNIT_ASSERT_EQUAL(geometry.spaceDim(), qCopy.refGeometry().spaceDim());
+ CPPUNIT_ASSERT_EQUAL(geometry.numCorners(), qCopy.refGeometry().numCorners());
+} // testCopyConstructor
- const double_array& jacobian = qCopy->_jacobian;
- size = 1;
- CPPUNIT_ASSERT_EQUAL(size, jacobian.size());
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(jacobianE[i], jacobian[i]);
-
- const double_array& jacobianInv = qCopy->jacobianInv();
- size = 1;
- CPPUNIT_ASSERT_EQUAL(size, jacobianInv.size());
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(jacobianInvE[i], jacobianInv[i]);
-
- const double_array& jacobianDet = qCopy->jacobianDet();
- size = 1;
- CPPUNIT_ASSERT_EQUAL(size, jacobianDet.size());
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(jacobianDetE[i], jacobianDet[i]);
-
- CPPUNIT_ASSERT(0 != qCopy->_geometry);
- CPPUNIT_ASSERT_EQUAL(geometry.cellDim(), qCopy->_geometry->cellDim());
- CPPUNIT_ASSERT_EQUAL(geometry.spaceDim(), qCopy->_geometry->spaceDim());
- CPPUNIT_ASSERT_EQUAL(geometry.numCorners(), qCopy->_geometry->numCorners());
-
- delete qCopy; qCopy = 0;
-} // testCopy
-
// ----------------------------------------------------------------------
-// Test minJacobian()
-void
-pylith::feassemble::TestQuadrature::testMinJacobian(void)
-{ // testMinJacobian
- Quadrature1D q;
- const double min = 1.0;
- q.minJacobian(min);
- CPPUNIT_ASSERT_EQUAL(min, q._minJacobian);
-} // testMinJacobian
-
-// ----------------------------------------------------------------------
// Test checkConditioning()
void
pylith::feassemble::TestQuadrature::testCheckConditioning(void)
{ // testCheckConditioning
- Quadrature1D q;
+ Quadrature<topology::Mesh> q;
+
CPPUNIT_ASSERT_EQUAL(false, q.checkConditioning());
q.checkConditioning(true);
CPPUNIT_ASSERT_EQUAL(true, q.checkConditioning());
@@ -183,159 +116,162 @@
} // testCheckConditioning
// ----------------------------------------------------------------------
-// Test refGeometry()
+// Test quadPts(), basisDeriv(), jacobian(), and jacobianDet().
void
-pylith::feassemble::TestQuadrature::testRefGeometry(void)
-{ // testRefGeometry
- GeometryLine1D geometry;
- Quadrature1D quadrature;
- quadrature.refGeometry(&geometry);
- const CellGeometry& test = quadrature.refGeometry();
+pylith::feassemble::TestQuadrature::testEngineAccessors(void)
+{ // testEngineAccessors
+ const int cellDim = 2;
+ const int numBasis = 5;
+ const int numQuadPts = 1;
+ const int spaceDim = 3;
+ const double basis[] = {
+ 1.1, 1.2, 1.3, 1.4, 1.5
+ };
+ const double basisDerivRef[] = {
+ 2.1, 2.2, 2.3,
+ 2.4, 2.5, 2.6,
+ 2.7, 2.8, 2.9,
+ 2.10, 2.11, 2.12,
+ 2.13, 2.14, 2.15,
+ };
+ const double quadPtsRef[] = { 3.1, 3.2, 3.3 };
+ const double quadWts[] = { 4.0 };
- CPPUNIT_ASSERT_EQUAL(geometry.cellDim(), test.cellDim());
- CPPUNIT_ASSERT_EQUAL(geometry.spaceDim(), test.spaceDim());
- CPPUNIT_ASSERT_EQUAL(geometry.numCorners(), test.numCorners());
-} // testRefGeometry
+ QuadratureRefCell refCell;
+ refCell.initialize(basis, numQuadPts, numBasis,
+ basisDerivRef, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
-// ----------------------------------------------------------------------
-// Test initialize()
-void
-pylith::feassemble::TestQuadrature::testInitialize(void)
-{ // initialize
-
- const int cellDim = 1;
- const int numBasis = 2;
- const int numQuadPts = 1;
- const int spaceDim = 1;
- const double basis[] = { 0.5, 0.5 };
- const double basisDerivRef[] = { -0.5, 0.5 };
- const double quadPtsRef[] = { 0.0 };
- const double quadWts[] = { 2.0 };
- const double minJacobian = 1.0;
+ Quadrature1D engine(refCell);
+ engine.initialize();
- Quadrature1D q;
- q.initialize(basis, basisDerivRef, quadPtsRef, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim);
-
- CPPUNIT_ASSERT_EQUAL(cellDim, q._cellDim);
- CPPUNIT_ASSERT_EQUAL(numBasis, q._numBasis);
- CPPUNIT_ASSERT_EQUAL(numQuadPts, q._numQuadPts);
- CPPUNIT_ASSERT_EQUAL(spaceDim, q._spaceDim);
+ Quadrature<topology::Mesh> q;
+ q._engine = engine.clone();
- size_t size = numBasis * numQuadPts;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(basis[i], q._basis[i]);
+ size_t size = 0;
- size = numBasis * numQuadPts * spaceDim;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(basisDerivRef[i], q._basisDerivRef[i]);
+ size = numQuadPts * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, q.quadPts().size());
- size = numQuadPts * cellDim;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(quadPtsRef[i], q._quadPtsRef[i]);
+ size = numQuadPts * cellDim * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, q.jacobian().size());
size = numQuadPts;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_EQUAL(quadWts[i], q._quadWts[i]);
+ CPPUNIT_ASSERT_EQUAL(size, q.jacobianDet().size());
- // Make sure Jacobian stuff has been allocated
- size = numQuadPts*cellDim*spaceDim;
- CPPUNIT_ASSERT_EQUAL(size, q._jacobian.size());
-
- size = numQuadPts*spaceDim*cellDim;
- CPPUNIT_ASSERT_EQUAL(size, q._jacobianInv.size());
-
- size = numQuadPts;
- CPPUNIT_ASSERT_EQUAL(size, q._jacobianDet.size());
-
- size = numQuadPts*spaceDim;
- CPPUNIT_ASSERT_EQUAL(size, q._quadPts.size());
-} // initialize
+ size = numQuadPts * numBasis * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, q.basisDeriv().size());
+} // testEngineAccessors
// ----------------------------------------------------------------------
-// Test initialize() & computeGeometry()
+// Test computeGeometry() and retrieveGeometry()
void
-pylith::feassemble::TestQuadrature::_testComputeGeometry(Quadrature* pQuad,
- const QuadratureData& data) const
+pylith::feassemble::TestQuadrature::testComputeGeometry(void)
{ // testComputeGeometry
+ typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+ QuadratureData2DLinear data;
const int cellDim = data.cellDim;
const int numBasis = data.numBasis;
const int numQuadPts = data.numQuadPts;
const int spaceDim = data.spaceDim;
- const double* basis = data.basis;
- const double* basisDerivRef = data.basisDerivRef;
- const double* basisDeriv = data.basisDeriv;
- const double* quadPtsRef = data.quadPtsRef;
- const double* quadWts = data.quadWts;
- const int numVertices = data.numVertices;
const int numCells = data.numCells;
const double* vertCoords = data.vertices;
- const int* cells = data.cells;
- const double* quadPts = data.quadPts;
- const double* jacobian = data.jacobian;
- const double* jacobianInv = data.jacobianInv;
- const double* jacobianDet = data.jacobianDet;
+ const double* quadPtsE = data.quadPts;
+ const double* jacobianE = data.jacobian;
+ const double* jacobianDetE = data.jacobianDet;
+ const double* basisDerivE = data.basisDeriv;
const double minJacobian = 1.0e-06;
- pQuad->minJacobian(minJacobian);
- pQuad->initialize(basis, basisDerivRef, quadPtsRef, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim);
-
// Create mesh with test cell
- ALE::Obj<Mesh> mesh = new Mesh(PETSC_COMM_WORLD, cellDim);
- CPPUNIT_ASSERT(!mesh.isNull());
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
+ topology::Mesh mesh(data.cellDim);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ ALE::Obj<SieveMesh::sieve_type> sieve =
+ new SieveMesh::sieve_type(mesh.comm());
CPPUNIT_ASSERT(!sieve.isNull());
+ // Cells and vertices
const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, numCells,
- (int*) cells, numVertices, interpolate, numBasis);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
+ const_cast<int*>(data.cells),
+ data.numVertices,
+ interpolate, numBasis);
+ std::map<ALE::Mesh::point_type,ALE::Mesh::point_type> renumbering;
ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, vertCoords);
-
- // Check values from computeGeometry()
- const ALE::Obj<Mesh::label_sequence>& cellsMesh = mesh->heightStratum(0);
- CPPUNIT_ASSERT(!cellsMesh.isNull());
- const Mesh::label_sequence::iterator e_iter = cellsMesh->begin();
- const ALE::Obj<Mesh::real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- CPPUNIT_ASSERT(!coordinates.isNull());
- pQuad->computeGeometry(mesh, coordinates, *e_iter);
+ sieveMesh->setSieve(sieve);
+ sieveMesh->stratify();
+ ALE::SieveBuilder<SieveMesh>::buildCoordinates(sieveMesh, spaceDim,
+ data.vertices);
- CPPUNIT_ASSERT(1 == numCells);
+ // Setup quadrature and compute geometry
+ GeometryTri2D geometry;
+ Quadrature<topology::Mesh> quadrature;
+ quadrature.refGeometry(&geometry);
+ quadrature.minJacobian(minJacobian);
+ quadrature.initialize(data.basis, numQuadPts, numBasis,
+ data.basisDerivRef, numQuadPts, numBasis, cellDim,
+ data.quadPtsRef, numQuadPts, cellDim,
+ data.quadWts, numQuadPts,
+ spaceDim);
+ const ALE::Obj<SieveMesh::label_sequence>& cells = sieveMesh->heightStratum(0);
+ CPPUNIT_ASSERT(!cells.isNull());
+ quadrature.computeGeometry(mesh, cells);
+
+ size_t size = 0;
+
+ // Check values from computeGeometry()
const double tolerance = 1.0e-06;
- int size = numQuadPts * spaceDim;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(quadPts[i], pQuad->_quadPts[i], tolerance);
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter) {
+ quadrature.retrieveGeometry(*c_iter);
- size = numQuadPts * cellDim * spaceDim;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobian[i], pQuad->_jacobian[i],
- tolerance);
+ const double_array& quadPts = quadrature.quadPts();
+ size = numQuadPts * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, quadPts.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(quadPtsE[i], quadPts[i], tolerance);
- size = numQuadPts * spaceDim * cellDim;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianInv[i], pQuad->_jacobianInv[i],
- tolerance);
+ const double_array& jacobian = quadrature.jacobian();
+ size = numQuadPts * cellDim * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, jacobian.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianE[i], jacobian[i], tolerance);
- size = numQuadPts;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianDet[i], pQuad->_jacobianDet[i],
- tolerance);
+ const double_array& jacobianDet = quadrature.jacobianDet();
+ size = numQuadPts;
+ CPPUNIT_ASSERT_EQUAL(size, jacobianDet.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianDetE[i], jacobianDet[i], tolerance);
+
+ const double_array& basisDeriv = quadrature.basisDeriv();
+ size = numQuadPts * numBasis * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, basisDeriv.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(basisDerivE[i], basisDeriv[i], tolerance);
+ } // for
- size = numQuadPts * numBasis * spaceDim;
- for (int i=0; i < size; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(basisDeriv[i], pQuad->_basisDeriv[i],
- tolerance);
+ // Check clear()
+ quadrature.clear();
+
+ CPPUNIT_ASSERT(0 == quadrature._quadPtsField);
+ CPPUNIT_ASSERT(0 == quadrature._jacobianField);
+ CPPUNIT_ASSERT(0 == quadrature._jacobianDetField);
+ CPPUNIT_ASSERT(0 == quadrature._basisDerivField);
+ CPPUNIT_ASSERT(0 == quadrature._engine);
+ // Make sure caling clear without data doesn't generate errors
+ quadrature.clear();
} // testComputeGeometry
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,9 +26,7 @@
/// Namespace for pylith package
namespace pylith {
namespace feassemble {
- class Quadrature;
class TestQuadrature;
- class QuadratureData;
} // feassemble
} // pylith
@@ -39,43 +37,28 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature );
- CPPUNIT_TEST( testClone );
- CPPUNIT_TEST( testMinJacobian );
+ CPPUNIT_TEST( testCopyConstructor );
CPPUNIT_TEST( testCheckConditioning );
- CPPUNIT_TEST( testRefGeometry );
- CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testEngineAccessors );
+ CPPUNIT_TEST( testComputeGeometry );
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
- /// Test clone()
- void testClone(void);
+ /// Test copy constructor.
+ void testCopyConstructor(void);
- /// Test minJacobian()
- void testMinJacobian(void);
-
- void testCheckConditioning(void);
/// Test checkConditioning()
+ void testCheckConditioning(void);
- /// Test refGeometry()
- void testRefGeometry(void);
+ /// Test quadPts(), basisDeriv(), jacobian(), and jacobianDet().
+ void testEngineAccessors(void);
- /// Test initialize()
- void testInitialize(void);
+ /// Test computeGeometry(), retrieveGeometry(), and clear().
+ void testComputeGeometry(void);
- // PROTECTED METHODS //////////////////////////////////////////////////
-protected :
-
- /** Test initialize() & computeGeometry()
- *
- * @param pQuad Pointer to quadrature
- * @param data Data for testing quadrature
- */
- void _testComputeGeometry(Quadrature* pQuad,
- const QuadratureData& data) const;
-
}; // class TestQuadrature
#endif // pylith_feassemble_testquadrature_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,6 +15,7 @@
#include "TestQuadrature0D.hh" // Implementation of class methods
#include "pylith/feassemble/Quadrature0D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestQuadrature0D );
@@ -24,7 +25,8 @@
void
pylith::feassemble::TestQuadrature0D::testConstructor(void)
{ // testConstructor
- Quadrature0D quadrature;
+ QuadratureRefCell refCell;
+ Quadrature0D quadrature(refCell);
} // testConstructor
// ----------------------------------------------------------------------
@@ -37,7 +39,7 @@
const int numQuadPts = 1;
const int spaceDim = 1;
const double basis[] = { 1.0 };
- const double basisDeriv[] = { 1.0 };
+ const double basisDerivRef[] = { 1.0 };
const double quadPtsRef[] = { 0.0 };
const double quadWts[] = { 1.0 };
@@ -52,48 +54,27 @@
const double minJacobian = 1.0e-06;
- Quadrature0D quadrature;
+ QuadratureRefCell refCell;
+ refCell.minJacobian(minJacobian);
+ refCell.initialize(basis, numQuadPts, numBasis,
+ basisDerivRef, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
- quadrature.minJacobian(minJacobian);
- quadrature.initialize(basis, basisDeriv, quadPtsRef, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim);
+ Quadrature0D engine(refCell);
- // Create mesh with test cell
- ALE::Obj<Mesh> mesh = new Mesh(PETSC_COMM_WORLD, cellDim);
- CPPUNIT_ASSERT(!mesh.isNull());
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
- CPPUNIT_ASSERT(!sieve.isNull());
+ engine.initialize();
+ engine.computeGeometry(vertCoords, spaceDim, 0);
- const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, numCells,
- (int*) cells, numVertices, interpolate, numBasis);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, vertCoords);
-
- // Check values from computeGeometry()
- const ALE::Obj<Mesh::label_sequence>& cellsMesh = mesh->heightStratum(0);
- CPPUNIT_ASSERT(!cellsMesh.isNull());
- const Mesh::label_sequence::iterator e_iter = cellsMesh->begin();
- const ALE::Obj<Mesh::real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- CPPUNIT_ASSERT(!coordinates.isNull());
- quadrature.Quadrature::computeGeometry(mesh, coordinates, *e_iter);
-
- CPPUNIT_ASSERT(1 == numCells);
-
const double tolerance = 1.0e-06;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(quadPts[0], quadrature._quadPts[0],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(quadPts[0], engine._quadPts[0],
tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobian[0], quadrature._jacobian[0],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobian[0], engine._jacobian[0],
tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianInv[0], quadrature._jacobianInv[0],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianInv[0], engine._jacobianInv[0],
tolerance);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianDet[0], quadrature._jacobianDet[0],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianDet[0], engine._jacobianDet[0],
tolerance);
} // testPoint
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature0D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_feassemble_testquadrature0d_hh)
#define pylith_feassemble_testquadrature0d_hh
-#include "TestQuadrature.hh"
+#include "TestQuadratureEngine.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,13 +31,15 @@
} // pylith
/// C++ unit testing for Quadrature0D
-class pylith::feassemble::TestQuadrature0D : public TestQuadrature
+class pylith::feassemble::TestQuadrature0D : public TestQuadratureEngine
{ // class TestQuadrature0D
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature0D );
+
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testPoint );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,6 +15,7 @@
#include "TestQuadrature1D.hh" // Implementation of class methods
#include "pylith/feassemble/Quadrature1D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
#include "pylith/feassemble/GeometryLine1D.hh"
#include "data/QuadratureData1DLinear.hh"
@@ -28,7 +29,8 @@
void
pylith::feassemble::TestQuadrature1D::testConstructor(void)
{ // testConstructor
- Quadrature1D quadrature;
+ QuadratureRefCell refCell;
+ Quadrature1D quadrature(refCell);
} // testConstructor
// ----------------------------------------------------------------------
@@ -36,12 +38,14 @@
void
pylith::feassemble::TestQuadrature1D::testLinear(void)
{ // testLinear
- Quadrature1D q;
GeometryLine1D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature1D q(refCell);
QuadratureData1DLinear data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinear
// ----------------------------------------------------------------------
@@ -49,12 +53,14 @@
void
pylith::feassemble::TestQuadrature1D::testQuadratic(void)
{ // testQuadratic
- Quadrature1D q;
GeometryLine1D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature1D q(refCell);
QuadratureData1DQuadratic data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testQuadratic
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_feassemble_testquadrature1d_hh)
#define pylith_feassemble_testquadrature1d_hh
-#include "TestQuadrature.hh"
+#include "TestQuadratureEngine.hh" // ISA TestQuadratureEngine
/// Namespace for pylith package
namespace pylith {
@@ -31,14 +31,16 @@
} // pylith
/// C++ unit testing for Quadrature1D
-class pylith::feassemble::TestQuadrature1D : public TestQuadrature
+class pylith::feassemble::TestQuadrature1D : public TestQuadratureEngine
{ // class TestQuadrature1D
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature1D );
+
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testLinear );
CPPUNIT_TEST( testQuadratic );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -57,4 +59,5 @@
#endif // pylith_feassemble_testquadrature1d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,6 +15,7 @@
#include "TestQuadrature1Din2D.hh" // Implementation of class methods
#include "pylith/feassemble/Quadrature1Din2D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
#include "pylith/feassemble/GeometryLine2D.hh"
#include "data/QuadratureData1Din2DLinear.hh"
@@ -28,7 +29,8 @@
void
pylith::feassemble::TestQuadrature1Din2D::testConstructor(void)
{ // testConstructor
- Quadrature1Din2D quadrature;
+ QuadratureRefCell refCell;
+ Quadrature1Din2D quadrature(refCell);
} // testConstructor
// ----------------------------------------------------------------------
@@ -36,12 +38,14 @@
void
pylith::feassemble::TestQuadrature1Din2D::testLinear(void)
{ // testLinear
- Quadrature1Din2D q;
GeometryLine2D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature1Din2D q(refCell);
QuadratureData1Din2DLinear data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinear
// ----------------------------------------------------------------------
@@ -49,12 +53,14 @@
void
pylith::feassemble::TestQuadrature1Din2D::testQuadratic(void)
{ // testQuadratic
- Quadrature1Din2D q;
GeometryLine2D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature1Din2D q(refCell);
QuadratureData1Din2DQuadratic data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testQuadratic
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_feassemble_testquadrature1din2d_hh)
#define pylith_feassemble_testquadrature1din2d_hh
-#include "TestQuadrature.hh"
+#include "TestQuadratureEngine.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,14 +31,16 @@
} // pylith
/// C++ unit testing for Quadrature1Din2D
-class pylith::feassemble::TestQuadrature1Din2D : public TestQuadrature
+class pylith::feassemble::TestQuadrature1Din2D : public TestQuadratureEngine
{ // class TestQuadrature1D
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature1Din2D );
+
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testLinear );
CPPUNIT_TEST( testQuadratic );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -57,4 +59,5 @@
#endif // pylith_feassemble_testquadrature1din2d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,7 +15,8 @@
#include "TestQuadrature1Din3D.hh" // Implementation of class methods
#include "pylith/feassemble/Quadrature1Din3D.hh"
-#include "pylith/feassemble/GeomertyLine3D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
+#include "pylith/feassemble/GeometryLine3D.hh"
#include "data/QuadratureData1Din3DLinear.hh"
#include "data/QuadratureData1Din3DQuadratic.hh"
@@ -28,7 +29,8 @@
void
pylith::feassemble::TestQuadrature1Din3D::testConstructor(void)
{ // testConstructor
- Quadrature1Din3D quadrature;
+ QuadratureRefCell refCell;
+ Quadrature1Din3D quadrature(refCell);
} // testConstructor
// ----------------------------------------------------------------------
@@ -36,12 +38,14 @@
void
pylith::feassemble::TestQuadrature1Din3D::testLinear(void)
{ // testLinear
- Quadrature1Din3D q;
GeometryLine3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature1Din3D q(refCell);
QuadratureData1Din3DLinear data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinear
// ----------------------------------------------------------------------
@@ -49,12 +53,14 @@
void
pylith::feassemble::TestQuadrature1Din3D::testQuadratic(void)
{ // testQuadratic
- Quadrature1Din3D q;
GeometryLine3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature1Din3D q(refCell);
QuadratureData1Din3DQuadratic data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testQuadratic
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature1Din3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_feassemble_testquadrature1din3d_hh)
#define pylith_feassemble_testquadrature1din3d_hh
-#include "TestQuadrature.hh"
+#include "TestQuadratureEngine.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,14 +31,16 @@
} // pylith
/// C++ unit testing for Quadrature1Din3D
-class pylith::feassemble::TestQuadrature1Din3D : public TestQuadrature
+class pylith::feassemble::TestQuadrature1Din3D : public TestQuadratureEngine
{ // class TestQuadrature1D
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature1Din3D );
+
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testLinear );
CPPUNIT_TEST( testQuadratic );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -57,4 +59,5 @@
#endif // pylith_feassemble_testquadrature1din3d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,6 +15,7 @@
#include "TestQuadrature2D.hh" // Implementation of class methods
#include "pylith/feassemble/Quadrature2D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
#include "pylith/feassemble/GeometryTri2D.hh"
#include "data/QuadratureData2DLinear.hh"
@@ -28,7 +29,8 @@
void
pylith::feassemble::TestQuadrature2D::testConstructor(void)
{ // testConstructor
- Quadrature2D quadrature;
+ QuadratureRefCell refCell;
+ Quadrature2D quadrature(refCell);
} // testConstructor
// ----------------------------------------------------------------------
@@ -36,12 +38,14 @@
void
pylith::feassemble::TestQuadrature2D::testLinear(void)
{ // testLinear
- Quadrature2D q;
GeometryTri2D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature2D q(refCell);
QuadratureData2DLinear data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinear
// ----------------------------------------------------------------------
@@ -49,12 +53,15 @@
void
pylith::feassemble::TestQuadrature2D::testQuadratic(void)
{ // testQuadratic
- Quadrature2D q;
GeometryTri2D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature2D q(refCell);
QuadratureData2DQuadratic data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testQuadratic
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_feassemble_testquadrature2d_hh)
#define pylith_feassemble_testquadrature2d_hh
-#include "TestQuadrature.hh"
+#include "TestQuadratureEngine.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,14 +31,16 @@
} // pylith
/// C++ unit testing for Quadrature2D
-class pylith::feassemble::TestQuadrature2D : public TestQuadrature
+class pylith::feassemble::TestQuadrature2D : public TestQuadratureEngine
{ // class TestQuadrature2D
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature2D );
+
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testLinear );
CPPUNIT_TEST( testQuadratic );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -53,8 +55,9 @@
/// Test initialize() & computeGeometry() w/quadratic basis fns
void testQuadratic(void);
-}; // class TestQuadrature
+}; // class TestQuadrature2D
#endif // pylith_feassemble_testquadrature2d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,6 +15,7 @@
#include "TestQuadrature2Din3D.hh" // Implementation of class methods
#include "pylith/feassemble/Quadrature2Din3D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
#include "pylith/feassemble/GeometryTri3D.hh"
#include "data/QuadratureData2Din3DLinearXYZ.hh"
@@ -31,7 +32,8 @@
void
pylith::feassemble::TestQuadrature2Din3D::testConstructor(void)
{ // testConstructor
- Quadrature2Din3D quadrature;
+ QuadratureRefCell refCell;
+ Quadrature2Din3D quadrature(refCell);
} // testConstructor
// ----------------------------------------------------------------------
@@ -39,12 +41,14 @@
void
pylith::feassemble::TestQuadrature2Din3D::testLinearXYZ(void)
{ // testLinearXYZ
- Quadrature2Din3D q;
GeometryTri3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature2Din3D q(refCell);
QuadratureData2Din3DLinearXYZ data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinearXYZ
// ----------------------------------------------------------------------
@@ -52,12 +56,14 @@
void
pylith::feassemble::TestQuadrature2Din3D::testLinearXY(void)
{ // testLinearXY
- Quadrature2Din3D q;
- QuadratureData2Din3DLinearXY data;
GeometryTri3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
- _testComputeGeometry(&q, data);
+ Quadrature2Din3D q(refCell);
+ QuadratureData2Din3DLinearXY data;
+
+ _testComputeGeometry(&q, &refCell, data);
} // testLinearXY
// ----------------------------------------------------------------------
@@ -65,12 +71,14 @@
void
pylith::feassemble::TestQuadrature2Din3D::testLinearYZ(void)
{ // testLinearYZ
- Quadrature2Din3D q;
GeometryTri3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature2Din3D q(refCell);
QuadratureData2Din3DLinearYZ data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinearYZ
// ----------------------------------------------------------------------
@@ -78,12 +86,14 @@
void
pylith::feassemble::TestQuadrature2Din3D::testLinearXZ(void)
{ // testLinearXZ
- Quadrature2Din3D q;
GeometryTri3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature2Din3D q(refCell);
QuadratureData2Din3DLinearXZ data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinearXZ
// ----------------------------------------------------------------------
@@ -91,12 +101,15 @@
void
pylith::feassemble::TestQuadrature2Din3D::testQuadratic(void)
{ // testQuadratic
- Quadrature2Din3D q;
GeometryTri3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature2Din3D q(refCell);
QuadratureData2Din3DQuadratic data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testQuadratic
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature2Din3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_feassemble_testquadrature2din3d_hh)
#define pylith_feassemble_testquadrature2din3d_hh
-#include "TestQuadrature.hh"
+#include "TestQuadratureEngine.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,17 +31,19 @@
} // pylith
/// C++ unit testing for Quadrature2Din3D
-class pylith::feassemble::TestQuadrature2Din3D : public TestQuadrature
+class pylith::feassemble::TestQuadrature2Din3D : public TestQuadratureEngine
{ // class TestQuadrature2D
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature2Din3D );
+
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testLinearXYZ );
CPPUNIT_TEST( testLinearXY );
CPPUNIT_TEST( testLinearYZ );
CPPUNIT_TEST( testLinearXZ );
CPPUNIT_TEST( testQuadratic );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -69,4 +71,5 @@
#endif // pylith_feassemble_testquadrature2din3d_hh
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,6 +15,7 @@
#include "TestQuadrature3D.hh" // Implementation of class methods
#include "pylith/feassemble/Quadrature3D.hh"
+#include "pylith/feassemble/QuadratureRefCell.hh"
#include "pylith/feassemble/GeometryTet3D.hh"
#include "data/QuadratureData3DLinear.hh"
@@ -28,7 +29,8 @@
void
pylith::feassemble::TestQuadrature3D::testConstructor(void)
{ // testConstructor
- Quadrature3D quadrature;
+ QuadratureRefCell refCell;
+ Quadrature3D quadrature(refCell);
} // testConstructor
// ----------------------------------------------------------------------
@@ -36,12 +38,14 @@
void
pylith::feassemble::TestQuadrature3D::testLinear(void)
{ // testLinear
- Quadrature3D q;
GeometryTet3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature3D q(refCell);
QuadratureData3DLinear data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testLinear
// ----------------------------------------------------------------------
@@ -49,12 +53,15 @@
void
pylith::feassemble::TestQuadrature3D::testQuadratic(void)
{ // testQuadratic
- Quadrature3D q;
GeometryTet3D geometry;
- q.refGeometry(&geometry);
+ QuadratureRefCell refCell;
+ refCell.refGeometry(&geometry);
+
+ Quadrature3D q(refCell);
QuadratureData3DQuadratic data;
- _testComputeGeometry(&q, data);
+ _testComputeGeometry(&q, &refCell, data);
} // testQuadratic
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadrature3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_feassemble_testquadrature3d_hh)
#define pylith_feassemble_testquadrature3d_hh
-#include "TestQuadrature.hh"
+#include "TestQuadratureEngine.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,14 +31,16 @@
} // pylith
/// C++ unit testing for Quadrature3D
-class pylith::feassemble::TestQuadrature3D : public TestQuadrature
+class pylith::feassemble::TestQuadrature3D : public TestQuadratureEngine
{ // class TestQuadrature3D
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestQuadrature3D );
+
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testLinear );
CPPUNIT_TEST( testQuadratic );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -57,4 +59,5 @@
#endif // pylith_feassemble_testquadrature3d_hh
+
// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestQuadratureEngine.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,213 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestQuadratureEngine.hh" // Implementation of class methods
+
+#include "pylith/feassemble/QuadratureRefCell.hh" // USES QuadratureRefCell
+#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+
+#include "data/QuadratureData.hh" // USES QuadratureData
+
+#include <string.h> // USES memcpy()
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestQuadratureEngine );
+
+// ----------------------------------------------------------------------
+// Test copy constructor.
+void
+pylith::feassemble::TestQuadratureEngine::testCopyConstructor(void)
+{ // testClone
+ // Semi-random values manually set to check cloning
+ const double quadPtsE[] = { 12.8 };
+ const double jacobianE[] = { 2.56 };
+ const double jacobianInvE[] = { 5.12 };
+ const double jacobianDetE[] = { 10.24 };
+ const double basisDerivE[] = { 0.8, 1.6 };
+
+ QuadratureRefCell refCell;
+
+ Quadrature1D engineOrig(refCell);
+ size_t size = 0;
+
+ // Set values
+ size = 1;
+ engineOrig._quadPts.resize(size);
+ memcpy(&engineOrig._quadPts[0], quadPtsE, size*sizeof(double));
+
+ size = 1;
+ engineOrig._jacobian.resize(size);
+ memcpy(&engineOrig._jacobian[0], jacobianE, size*sizeof(double));
+
+ size = 1;
+ engineOrig._jacobianInv.resize(size);
+ memcpy(&engineOrig._jacobianInv[0], jacobianInvE, size*sizeof(double));
+
+ size = 1;
+ engineOrig._jacobianDet.resize(size);
+ memcpy(&engineOrig._jacobianDet[0], jacobianDetE, size*sizeof(double));
+
+ // Copy
+ const QuadratureEngine* engine = engineOrig.clone();
+ CPPUNIT_ASSERT(0 != engine);
+
+ const double_array& quadPts = engine->quadPts();
+ size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, quadPts.size());
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(quadPtsE[i], quadPts[i]);
+
+ const double_array& jacobian = engine->_jacobian;
+ size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, jacobian.size());
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(jacobianE[i], jacobian[i]);
+
+ const double_array& jacobianInv = engine->_jacobianInv;
+ size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, jacobianInv.size());
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(jacobianInvE[i], jacobianInv[i]);
+
+ const double_array& jacobianDet = engine->jacobianDet();
+ size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, jacobianDet.size());
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(jacobianDetE[i], jacobianDet[i]);
+
+ delete engine; engine = 0;
+} // testCopyConstructor
+
+// ----------------------------------------------------------------------
+// Test initialize().
+void
+pylith::feassemble::TestQuadratureEngine::testInitialize(void)
+{ // testInitialize
+ const int cellDim = 2;
+ const int numBasis = 5;
+ const int numQuadPts = 1;
+ const int spaceDim = 3;
+ const double basis[] = {
+ 1.1, 1.2, 1.3, 1.4, 1.5
+ };
+ const double basisDerivRef[] = {
+ 2.1, 2.2, 2.3,
+ 2.4, 2.5, 2.6,
+ 2.7, 2.8, 2.9,
+ 2.10, 2.11, 2.12,
+ 2.13, 2.14, 2.15,
+ };
+ const double quadPtsRef[] = { 3.1, 3.2, 3.3 };
+ const double quadWts[] = { 4.0 };
+
+ QuadratureRefCell refCell;
+ refCell.initialize(basis, numQuadPts, numBasis,
+ basisDerivRef, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
+
+ Quadrature1D engine(refCell);
+ engine.initialize();
+
+ size_t size = 0;
+
+ size = numQuadPts * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, engine.quadPts().size());
+
+ size = numQuadPts * cellDim * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, engine.jacobian().size());
+
+ size = numQuadPts * cellDim * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, engine._jacobianInv.size());
+
+ size = numQuadPts;
+ CPPUNIT_ASSERT_EQUAL(size, engine.jacobianDet().size());
+
+ size = numQuadPts * numBasis * spaceDim;
+ CPPUNIT_ASSERT_EQUAL(size, engine.basisDeriv().size());
+} // testInitialize
+
+// ----------------------------------------------------------------------
+// Test computeGeometry().
+void
+pylith::feassemble::TestQuadratureEngine::_testComputeGeometry(
+ QuadratureEngine* engine,
+ QuadratureRefCell* refCell,
+ const QuadratureData& data) const
+{ // testComputeGeometry
+ const int cellDim = data.cellDim;
+ const int numBasis = data.numBasis;
+ const int numQuadPts = data.numQuadPts;
+ const int spaceDim = data.spaceDim;
+ const double* basis = data.basis;
+ const double* basisDerivRef = data.basisDerivRef;
+ const double* quadPtsRef = data.quadPtsRef;
+ const double* quadWts = data.quadWts;
+
+ const int numVertices = data.numVertices;
+ const int numCells = data.numCells;
+ const double* vertCoords = data.vertices;
+ const int* cells = data.cells;
+ const double* quadPtsE = data.quadPts;
+ const double* jacobianE = data.jacobian;
+ const double* jacobianInvE = data.jacobianInv;
+ const double* jacobianDetE = data.jacobianDet;
+ const double* basisDerivE = data.basisDeriv;
+
+ CPPUNIT_ASSERT(1 == numCells);
+ CPPUNIT_ASSERT(0 != engine);
+ CPPUNIT_ASSERT(0 != refCell);
+
+ const double minJacobian = 1.0e-06;
+ refCell->minJacobian(minJacobian);
+ refCell->initialize(basis, numQuadPts, numBasis,
+ basisDerivRef, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
+
+ // Check values from computeGeometry()
+ engine->initialize();
+ engine->computeGeometry(vertCoords, spaceDim, 0);
+
+
+ const double tolerance = 1.0e-06;
+ int size = numQuadPts * spaceDim;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(quadPtsE[i], engine->_quadPts[i], tolerance);
+
+ size = numQuadPts * cellDim * spaceDim;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianE[i], engine->_jacobian[i],
+ tolerance);
+
+ size = numQuadPts * spaceDim * cellDim;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianInvE[i], engine->_jacobianInv[i],
+ tolerance);
+
+ size = numQuadPts;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(jacobianDetE[i], engine->_jacobianDet[i],
+ tolerance);
+
+ size = numQuadPts * numBasis * spaceDim;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(basisDerivE[i], engine->_basisDeriv[i],
+ tolerance);
+} // testComputeGeometry
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestQuadratureEngine.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureEngine.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/feassemble/TestQuadratureEngine.hh
+ *
+ * @brief C++ TestQuadratureEngine object
+ *
+ * C++ unit testing for Quadrature.
+ */
+
+#if !defined(pylith_feassemble_testquadrature_hh)
+#define pylith_feassemble_testquadrature_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/feassemble/feassemblefwd.hh" // forward declarations
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace feassemble {
+ class TestQuadratureEngine;
+ class QuadratureData;
+ } // feassemble
+} // pylith
+
+/// C++ unit testing for Quadrature
+class pylith::feassemble::TestQuadratureEngine : public CppUnit::TestFixture
+{ // class TestQuadratureEngine
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestQuadratureEngine );
+
+ CPPUNIT_TEST( testCopyConstructor );
+ CPPUNIT_TEST( testInitialize );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test copy constructor.
+ void testCopyConstructor(void);
+
+ /// Test initialize().
+ void testInitialize(void);
+
+ // PROTECTED METHODS //////////////////////////////////////////////////
+protected :
+
+ /** Test computeGeometry() and retrieveGeometry().
+ *
+ * @param engine Quadrature engine.
+ * @param refCell Quadrature reference cell information.
+ * @param data Data for testing quadrature
+ */
+ void _testComputeGeometry(QuadratureEngine* engine,
+ QuadratureRefCell* refCell,
+ const QuadratureData& data) const;
+
+}; // class TestQuadratureEngine
+
+#endif // pylith_feassemble_testquadratureengine_hh
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestQuadratureRefCell.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,109 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestQuadratureRefCell.hh" // Implementation of class methods
+
+#include "pylith/feassemble/QuadratureRefCell.hh" // USES QuadratureRefCell
+#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
+
+#include "data/QuadratureData.hh" // USES QuadratureData
+
+#include <string.h> // USES memcpy()
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::feassemble::TestQuadratureRefCell );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::feassemble::TestQuadratureRefCell::testConstructor(void)
+{ // testConstructor
+ QuadratureRefCell q;
+} // testMinJacobian
+
+// ----------------------------------------------------------------------
+// Test minJacobian()
+void
+pylith::feassemble::TestQuadratureRefCell::testMinJacobian(void)
+{ // testMinJacobian
+ QuadratureRefCell q;
+
+ const double min = 1.0;
+ q.minJacobian(min);
+ CPPUNIT_ASSERT_EQUAL(min, q._minJacobian);
+} // testMinJacobian
+
+// ----------------------------------------------------------------------
+// Test refGeometry()
+void
+pylith::feassemble::TestQuadratureRefCell::testRefGeometry(void)
+{ // testRefGeometry
+ GeometryLine1D geometry;
+ QuadratureRefCell quadrature;
+
+ quadrature.refGeometry(&geometry);
+ const CellGeometry& test = quadrature.refGeometry();
+
+ CPPUNIT_ASSERT_EQUAL(geometry.cellDim(), test.cellDim());
+ CPPUNIT_ASSERT_EQUAL(geometry.spaceDim(), test.spaceDim());
+ CPPUNIT_ASSERT_EQUAL(geometry.numCorners(), test.numCorners());
+} // testRefGeometry
+
+// ----------------------------------------------------------------------
+// Test initialize()
+void
+pylith::feassemble::TestQuadratureRefCell::testInitialize(void)
+{ // initialize
+
+ const int cellDim = 1;
+ const int numBasis = 2;
+ const int numQuadPts = 1;
+ const int spaceDim = 1;
+ const double basis[] = { 0.5, 0.5 };
+ const double basisDerivRef[] = { -0.5, 0.5 };
+ const double quadPtsRef[] = { 0.0 };
+ const double quadWts[] = { 2.0 };
+ const double minJacobian = 1.0;
+
+ QuadratureRefCell q;
+ q.initialize(basis, numQuadPts, numBasis,
+ basisDerivRef, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
+
+ CPPUNIT_ASSERT_EQUAL(cellDim, q._cellDim);
+ CPPUNIT_ASSERT_EQUAL(numBasis, q._numBasis);
+ CPPUNIT_ASSERT_EQUAL(numQuadPts, q._numQuadPts);
+ CPPUNIT_ASSERT_EQUAL(spaceDim, q._spaceDim);
+
+ size_t size = numBasis * numQuadPts;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(basis[i], q._basis[i]);
+
+ size = numBasis * numQuadPts * spaceDim;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(basisDerivRef[i], q._basisDerivRef[i]);
+
+ size = numQuadPts * cellDim;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(quadPtsRef[i], q._quadPtsRef[i]);
+
+ size = numQuadPts;
+ for (int i=0; i < size; ++i)
+ CPPUNIT_ASSERT_EQUAL(quadWts[i], q._quadWts[i]);
+} // initialize
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/feassemble/TestQuadratureRefCell.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/feassemble/TestQuadratureRefCell.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,67 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/feassemble/TestQuadratureRefCell.hh
+ *
+ * @brief C++ TestQuadratureRefCell object
+ *
+ * C++ unit testing for QuadratureRefCell.
+ */
+
+#if !defined(pylith_feassemble_testquadraturerefcell_hh)
+#define pylith_feassemble_testquadraturerefcell_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace feassemble {
+ class TestQuadratureRefCell;
+ class QuadratureRefCellData;
+ } // feassemble
+} // pylith
+
+/// C++ unit testing for QuadratureRefCell
+class pylith::feassemble::TestQuadratureRefCell : public CppUnit::TestFixture
+{ // class TestQuadratureRefCell
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestQuadratureRefCell );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testMinJacobian );
+ CPPUNIT_TEST( testRefGeometry );
+ CPPUNIT_TEST( testInitialize );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test minJacobian()
+ void testMinJacobian(void);
+
+ /// Test refGeometry()
+ void testRefGeometry(void);
+
+ /// Test initialize()
+ void testInitialize(void);
+
+}; // class TestQuadratureRefCell
+
+#endif // pylith_feassemble_testquadraturerefcell_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,18 +21,21 @@
# Primary source files
testmaterials_SOURCES = \
+ TestMetadata.cc \
TestMaterial.cc \
TestElasticMaterial.cc \
- TestElasticIsotropic3D.cc \
+ TestElasticStrain1D.cc \
+ TestElasticStress1D.cc \
TestElasticPlaneStrain.cc \
TestElasticPlaneStress.cc \
- TestElasticStrain1D.cc \
- TestElasticStress1D.cc \
- TestGenMaxwellIsotropic3D.cc \
+ TestElasticIsotropic3D.cc \
TestMaxwellIsotropic3D.cc \
test_materials.cc
+# TestGenMaxwellIsotropic3D.cc
+
+
noinst_HEADERS = \
TestMaterial.hh \
TestElasticMaterial.hh \
@@ -48,16 +51,17 @@
testmaterials_SOURCES += \
data/MaterialData.cc \
data/ElasticMaterialData.cc \
- data/ElasticIsotropic3DData.cc \
+ data/ElasticStrain1DData.cc \
+ data/ElasticStress1DData.cc \
data/ElasticPlaneStrainData.cc \
data/ElasticPlaneStressData.cc \
- data/ElasticStrain1DData.cc \
- data/ElasticStress1DData.cc \
- data/GenMaxwellIsotropic3DElasticData.cc \
- data/GenMaxwellIsotropic3DTimeDepData.cc \
+ data/ElasticIsotropic3DData.cc \
data/MaxwellIsotropic3DElasticData.cc \
data/MaxwellIsotropic3DTimeDepData.cc
+# data/GenMaxwellIsotropic3DElasticData.cc \
+# data/GenMaxwellIsotropic3DTimeDepData.cc
+
noinst_HEADERS += \
data/MaterialData.hh \
data/ElasticMaterialData.hh \
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -30,55 +30,8 @@
_matElastic = new ElasticIsotropic3D();
_data = new ElasticIsotropic3DData();
_dataElastic = new ElasticIsotropic3DData();
+ setupNormalizer();
} // setUp
-// ----------------------------------------------------------------------
-// Test usesUpdateState()
-void
-pylith::materials::TestElasticIsotropic3D::testUsesUpdateProperties(void)
-{ // testUsesUpdateProperties
- ElasticIsotropic3D material;
- CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateProperties());
-} // testUsesUpdateProperties
-// ----------------------------------------------------------------------
-// Test updateProperties()
-void
-pylith::materials::TestElasticIsotropic3D::testUpdateProperties(void)
-{ // testUpdateProperties
- ElasticIsotropic3D material;
- ElasticIsotropic3DData data;
-
- const int numParams = data.numParameters;
-
- double_array parameters(numParams);
- const int paramsSize = 1;
- for (int i=0; i < numParams; ++i) {
- for (int j=0; j < paramsSize; ++j)
- parameters[i*paramsSize+j] = i+j;
- } // for
-
- const int tensorSize = 9;
- const int initialStateSize = 9;
- double_array totalStrain(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrain[i] = i;
- initialState[i] = 0.1*i;
- } // for
-
- material._updateProperties(¶meters[0], numParams, &totalStrain[0],
- tensorSize, &initialState[0], initialStateSize);
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParams; ++i)
- for (int j=0; j < paramsSize; ++j)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i+j), parameters[i*paramsSize+j],
- tolerance);
-
- for (int i=0; i < tensorSize; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i), totalStrain[i], tolerance);
-} // testUpdateProperties
-
-
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticIsotropic3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,9 +26,7 @@
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class ElasticIsotropic3D;
class TestElasticIsotropic3D;
- class ElasticIsotropic3DData;
} // materials
} // pylith
@@ -39,17 +37,20 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticIsotropic3D );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testTensorSize );
CPPUNIT_TEST( testDBToProperties );
- CPPUNIT_TEST( testDBValues );
- CPPUNIT_TEST( testProperties );
+ CPPUNIT_TEST( testNonDimProperties );
+ CPPUNIT_TEST( testDimProperties );
+ CPPUNIT_TEST( testDBToStateVars );
+ CPPUNIT_TEST( testNonDimStateVars );
+ CPPUNIT_TEST( testDimStateVars );
CPPUNIT_TEST( test_calcDensity );
CPPUNIT_TEST( test_calcStress );
CPPUNIT_TEST( test_calcElasticConsts );
+ CPPUNIT_TEST( test_updateStateVars );
CPPUNIT_TEST( test_stableTimeStepImplicit );
- CPPUNIT_TEST( testUsesUpdateProperties );
- CPPUNIT_TEST( testUpdateProperties );
-
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -58,12 +59,6 @@
/// Setup testing data.
void setUp(void);
- /// Test usesUpdateProperties().
- void testUsesUpdateProperties(void);
-
- /// Test updateProperties()
- void testUpdateProperties(void);
-
}; // class TestElasticIsotropic3D
#endif // pylith_materials_testelasticisotropic3d_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,76 +15,248 @@
#include "TestElasticMaterial.hh" // Implementation of class methods
#include "data/ElasticMaterialData.hh" // USES ElasticMaterialData
-#include "data/ElasticIsotropic3DData.hh" // USES ElasticIsotropic3DData
+#include "data/ElasticStrain1DData.hh" // USES ElasticStrain1DData
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
+#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
+#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
+
#include "pylith/utils/array.hh" // USES double_array
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
+#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
+#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
+
+#include <cstring> // USES memcpy()
+
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestElasticMaterial );
// ----------------------------------------------------------------------
-// Test calcDensity()
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+
+// ----------------------------------------------------------------------
+// Test dbInitialStress()
void
-pylith::materials::TestElasticMaterial::testCalcDensity(void)
-{ // testCalcDensity
- ALE::Obj<Mesh> mesh;
- { // create mesh
- const int cellDim = 1;
- const int numCorners = 2;
- const int spaceDim = 1;
- const int numVertices = 2;
- const int numCells = 1;
- const double vertCoords[] = { -1.0, 1.0};
- const int cells[] = { 0, 1};
- CPPUNIT_ASSERT(0 != vertCoords);
- CPPUNIT_ASSERT(0 != cells);
+pylith::materials::TestElasticMaterial::testDBInitialStress(void)
+{ // testDBInitialStress
+ const std::string& label = "my_database";
+ spatialdata::spatialdb::SimpleDB db;
+ db.label(label.c_str());
+
+ ElasticIsotropic3D material;
+ material.dbInitialStress(&db);
+
+ CPPUNIT_ASSERT(0 != material._dbInitialStress);
+ CPPUNIT_ASSERT_EQUAL(label, std::string(material._dbInitialStress->label()));
+} // testDBInitialStress
- mesh = new Mesh(PETSC_COMM_WORLD, cellDim);
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
+// ----------------------------------------------------------------------
+// Test dbInitialStrain()
+void
+pylith::materials::TestElasticMaterial::testDBInitialStrain(void)
+{ // testDBInitialStrain
+ const std::string& label = "my_database";
+ spatialdata::spatialdb::SimpleDB db;
+ db.label(label.c_str());
+
+ ElasticIsotropic3D material;
+ material.dbInitialStrain(&db);
+
+ CPPUNIT_ASSERT(0 != material._dbInitialStrain);
+ CPPUNIT_ASSERT_EQUAL(label, std::string(material._dbInitialStrain->label()));
+} // testDBInitialStrain
- const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+// ----------------------------------------------------------------------
+// Test initialize()
+void
+pylith::materials::TestElasticMaterial::testInitialize(void)
+{ // testInitialize
+ topology::Mesh mesh;
+ ElasticStrain1D material;
+ ElasticStrain1DData data;
+ _initialize(&mesh, &material, &data);
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, numCells,
- const_cast<int*>(cells), numVertices, interpolate, numCorners);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, vertCoords);
- } // create mesh
+ // Get cells associated with material
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ SieveMesh::point_type cell = *cells->begin();
+ const double tolerance = 1.0e-06;
+ const int tensorSize = material._tensorSize;
+ const int numQuadPts = data.numLocs;
+
+ // Test initialStress field
+ CPPUNIT_ASSERT(0 != material._initialStress);
+ const ALE::Obj<RealSection>& stressSection =
+ material.initialStressField().section();
+ CPPUNIT_ASSERT(!stressSection.isNull());
+ int fiberDim = numQuadPts * tensorSize;
+ CPPUNIT_ASSERT_EQUAL(fiberDim, stressSection->getFiberDimension(cell));
+ const double* initialStress = stressSection->restrictPoint(cell);
+ CPPUNIT_ASSERT(0 != initialStress);
+ const double* initialStressE = data.initialStress;
+ CPPUNIT_ASSERT(0 != initialStressE);
+ for (int i=0; i < fiberDim; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, initialStress[i]/initialStressE[i],
+ tolerance);
+
+ // Test initialStrain field
+ CPPUNIT_ASSERT(0 != material._initialStrain);
+ const ALE::Obj<RealSection>& strainSection =
+ material.initialStrainField().section();
+ CPPUNIT_ASSERT(!strainSection.isNull());
+ fiberDim = numQuadPts * tensorSize;
+ CPPUNIT_ASSERT_EQUAL(fiberDim, strainSection->getFiberDimension(cell));
+ const double* initialStrain = strainSection->restrictPoint(cell);
+ CPPUNIT_ASSERT(0 != initialStrain);
+ const double* initialStrainE = data.initialStrain;
+ CPPUNIT_ASSERT(0 != initialStrainE);
+ for (int i=0; i < fiberDim; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, initialStrain[i]/initialStrainE[i],
+ tolerance);
+
+ // Test cell arrays
+ size_t size = data.numLocs*data.numPropsQuadPt;
+ CPPUNIT_ASSERT_EQUAL(size, material._propertiesCell.size());
+
+ size = data.numLocs*data.numVarsQuadPt;
+ CPPUNIT_ASSERT_EQUAL(size, material._stateVarsCell.size());
+
+ size = data.numLocs*tensorSize;
+ CPPUNIT_ASSERT_EQUAL(size, material._initialStressCell.size());
+
+ size = data.numLocs*tensorSize;
+ CPPUNIT_ASSERT_EQUAL(size, material._initialStrainCell.size());
+
+ size = data.numLocs;
+ CPPUNIT_ASSERT_EQUAL(size, material._densityCell.size());
+
+ size = data.numLocs*tensorSize;
+ CPPUNIT_ASSERT_EQUAL(size, material._stressCell.size());
+
+ int numElasticConsts = 0;
+ switch (data.dimension)
+ { // switch
+ case 1 :
+ numElasticConsts = 1;
+ break;
+ case 2 :
+ numElasticConsts = 6;
+ break;
+ case 3 :
+ numElasticConsts = 21;
+ break;
+ default :
+ assert(0);
+ } // switch
+ size = data.numLocs*numElasticConsts;
+ CPPUNIT_ASSERT_EQUAL(size, material._elasticConstsCell.size());
+} // testInitialize
+
+// ----------------------------------------------------------------------
+// Test retrievePropsAndVars().
+void
+pylith::materials::TestElasticMaterial::testRetrievePropsAndVars(void)
+{ // testRetrievePropsAndVars
+ topology::Mesh mesh;
+ ElasticStrain1D material;
+ ElasticStrain1DData data;
+ _initialize(&mesh, &material, &data);
+
// Get cells associated with material
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ SieveMesh::point_type cell = *cells->begin();
- ElasticIsotropic3D material;
- ElasticIsotropic3DData data;
- const int numQuadPts = 2;
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
-
- Mesh::label_sequence::iterator c_iter = cells->begin();
+ material.retrievePropsAndVars(cell);
- const int fiberDim = numQuadPts * numParamsQuadPt;
- material._properties = new real_section_type(mesh->comm(), mesh->debug());
- material._properties->setChart(mesh->getSieve()->getChart());
- material._properties->setFiberDimension(cells, fiberDim);
- mesh->allocate(material._properties);
+ const double tolerance = 1.0e-06;
+ const int tensorSize = material._tensorSize;
+ const int numQuadPts = data.numLocs;
+ const int numVarsQuadPt = data.numVarsQuadPt;
- material._properties->updatePoint(*c_iter, data.parameterData);
+ // Test cell arrays
+ const double* propertiesE = data.properties;
+ CPPUNIT_ASSERT(0 != propertiesE);
+ const double_array& properties = material._propertiesCell;
+ size_t size = data.numLocs*data.numPropsQuadPt;
+ CPPUNIT_ASSERT_EQUAL(size, properties.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, properties[i]/propertiesE[i],
+ tolerance);
- material.getPropertiesCell(*c_iter, numQuadPts);
+ const double* stateVarsE = data.stateVars;
+ CPPUNIT_ASSERT( (0 < numVarsQuadPt && 0 != stateVarsE) ||
+ (0 == numVarsQuadPt && 0 == stateVarsE) );
+ const double_array& stateVars = material._stateVarsCell;
+ size = data.numLocs*numVarsQuadPt;
+ CPPUNIT_ASSERT_EQUAL(size, stateVars.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, stateVars[i]/stateVarsE[i],
+ tolerance);
+
+ const double* initialStressE = data.initialStress;
+ CPPUNIT_ASSERT(0 != initialStressE);
+ const double_array& initialStress = material._initialStressCell;
+ size = data.numLocs*tensorSize;
+ CPPUNIT_ASSERT_EQUAL(size, initialStress.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, initialStress[i]/initialStressE[i],
+ tolerance);
+
+ const double* initialStrainE = data.initialStrain;
+ CPPUNIT_ASSERT(0 != initialStrainE);
+ const double_array& initialStrain = material._initialStrainCell;
+ size = data.numLocs*tensorSize;
+ CPPUNIT_ASSERT_EQUAL(size, initialStrain.size());
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, initialStrain[i]/initialStrainE[i],
+ tolerance);
+} // testRetrievePropsAndVars
+
+// ----------------------------------------------------------------------
+// Test calcDensity()
+void
+pylith::materials::TestElasticMaterial::testCalcDensity(void)
+{ // testCalcDensity
+ topology::Mesh mesh;
+ ElasticStrain1D material;
+ ElasticStrain1DData data;
+ _initialize(&mesh, &material, &data);
+
+ // Get cells associated with material
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ SieveMesh::point_type cell = *cells->begin();
+
+ material.retrievePropsAndVars(cell);
const double_array& density = material.calcDensity();
- const double tolerance = 1.0e-06;
+ const int tensorSize = material._tensorSize;
+ const int numQuadPts = data.numLocs;
+
const double* densityE = data.density;
CPPUNIT_ASSERT(0 != densityE);
- const double size = numQuadPts;
- for (int i=0; i < size; ++i)
+ const size_t size = numQuadPts;
+ CPPUNIT_ASSERT_EQUAL(size, density.size());
+ const double tolerance = 1.0e-06;
+ for (size_t i=0; i < size; ++i)
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, density[i]/densityE[i], tolerance);
} // testCalcDensity
@@ -92,80 +264,36 @@
// Test calcStress()
void
pylith::materials::TestElasticMaterial::testCalcStress(void)
-{ // testCalcProperties
- ALE::Obj<Mesh> mesh;
- { // create mesh
- const int cellDim = 1;
- const int numCorners = 2;
- const int spaceDim = 1;
- const int numVertices = 2;
- const int numCells = 1;
- const double vertCoords[] = { -1.0, 1.0};
- const int cells[] = { 0, 1};
- CPPUNIT_ASSERT(0 != vertCoords);
- CPPUNIT_ASSERT(0 != cells);
+{ // testCalcStress
+ topology::Mesh mesh;
+ ElasticStrain1D material;
+ ElasticStrain1DData data;
+ _initialize(&mesh, &material, &data);
- mesh = new Mesh(PETSC_COMM_WORLD, cellDim);
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
-
- const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, numCells,
- const_cast<int*>(cells), numVertices, interpolate, numCorners);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, vertCoords);
- } // create mesh
-
// Get cells associated with material
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ SieveMesh::point_type cell = *cells->begin();
- ElasticIsotropic3D material;
- ElasticIsotropic3DData data;
- const int numQuadPts = 2;
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
+ const int tensorSize = material._tensorSize;
+ const int numQuadPts = data.numLocs;
- Mesh::label_sequence::iterator c_iter = cells->begin();
+ // Setup total strain
+ double_array strain(data.strain, numQuadPts*tensorSize);
- const int fiberDim = numQuadPts * numParamsQuadPt;
- material._properties = new real_section_type(mesh->comm(), mesh->debug());
- material._properties->setChart(mesh->getSieve()->getChart());
- material._properties->setFiberDimension(cells, fiberDim);
- mesh->allocate(material._properties);
-
- material._properties->updatePoint(*c_iter, data.parameterData);
- const int strainSize = material._tensorSize;
- double_array strain(data.strain, numQuadPts*strainSize);
-
- const int initialStateSize = material._tensorSize;
- material._initialStateSize = initialStateSize;
- const int initialStateFiberDim = numQuadPts * initialStateSize;
- material._initialState = new real_section_type(mesh->comm(), mesh->debug());
- material._initialState->setChart(mesh->getSieve()->getChart());
- material._initialState->setFiberDimension(cells, initialStateFiberDim);
- mesh->allocate(material._initialState);
- material._initialState->updatePoint(*c_iter, data.initialState);
-
- material.getPropertiesCell(*c_iter, numQuadPts);
+ material.retrievePropsAndVars(cell);
const double_array& stress = material.calcStress(strain);
- const double tolerance = 1.0e-06;
const double* stressE = data.stress;
CPPUNIT_ASSERT(0 != stressE);
-
- const int size = numQuadPts * strainSize;;
- CPPUNIT_ASSERT_EQUAL(size, int(stress.size()));
- for (int i=0; i < size; ++i)
- if (fabs(stressE[i]) > tolerance)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, stress[i]/stressE[i], tolerance);
- else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(stressE[i], stress[i], tolerance);
+ const size_t size = numQuadPts * tensorSize;
+ CPPUNIT_ASSERT_EQUAL(size, stress.size());
+ const double tolerance = 1.0e-06;
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, stress[i]/stressE[i], tolerance);
} // testCalcStress
// ----------------------------------------------------------------------
@@ -173,153 +301,89 @@
void
pylith::materials::TestElasticMaterial::testCalcDerivElastic(void)
{ // testCalcDerivElastic
- ALE::Obj<Mesh> mesh;
- { // create mesh
- const int cellDim = 1;
- const int numCorners = 2;
- const int spaceDim = 1;
- const int numVertices = 2;
- const int numCells = 1;
- const double vertCoords[] = { -1.0, 1.0};
- const int cells[] = { 0, 1};
- CPPUNIT_ASSERT(0 != vertCoords);
- CPPUNIT_ASSERT(0 != cells);
+ topology::Mesh mesh;
+ ElasticStrain1D material;
+ ElasticStrain1DData data;
+ _initialize(&mesh, &material, &data);
- mesh = new Mesh(PETSC_COMM_WORLD, cellDim);
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
-
- const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, numCells,
- const_cast<int*>(cells), numVertices, interpolate, numCorners);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, vertCoords);
- } // create mesh
-
// Get cells associated with material
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ SieveMesh::point_type cell = *cells->begin();
- ElasticIsotropic3D material;
- ElasticIsotropic3DData data;
- const int numQuadPts = 2;
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
+ const int tensorSize = material._tensorSize;
+ const int numQuadPts = data.numLocs;
- Mesh::label_sequence::iterator c_iter = cells->begin();
+ // Setup total strain
+ double_array strain(data.strain, numQuadPts*tensorSize);
- const int fiberDim = numQuadPts * numParamsQuadPt;
- material._properties = new real_section_type(mesh->comm(), mesh->debug());
- material._properties->setChart(mesh->getSieve()->getChart());
- material._properties->setFiberDimension(cells, fiberDim);
- mesh->allocate(material._properties);
+ material.retrievePropsAndVars(cell);
+ const double_array& elasticConsts = material.calcDerivElastic(strain);
- material._properties->updatePoint(*c_iter, data.parameterData);
- const int strainSize = material._tensorSize;
- double_array strain(data.strain, numQuadPts*strainSize);
+ int numElasticConsts = 0;
+ switch (data.dimension)
+ { // switch
+ case 1 :
+ numElasticConsts = 1;
+ break;
+ case 2 :
+ numElasticConsts = 6;
+ break;
+ case 3 :
+ numElasticConsts = 21;
+ break;
+ default :
+ assert(0);
+ } // switch
- const int initialStateSize = material._tensorSize;
- material._initialStateSize = initialStateSize;
- const int initialStateFiberDim = numQuadPts * initialStateSize;
- material._initialState = new real_section_type(mesh->comm(), mesh->debug());
- material._initialState->setChart(mesh->getSieve()->getChart());
- material._initialState->setFiberDimension(cells, initialStateFiberDim);
- mesh->allocate(material._initialState);
-
- material.getPropertiesCell(*c_iter, numQuadPts);
- const double_array& elasticConsts = material.calcDerivElastic(strain);
-
- const double tolerance = 1.0e-06;
const double* elasticConstsE = data.elasticConsts;
CPPUNIT_ASSERT(0 != elasticConstsE);
-
- const int size = elasticConsts.size();
- for (int i=0; i < size; ++i)
- if (fabs(elasticConstsE[i]) > tolerance)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
- elasticConsts[i]/elasticConstsE[i],
- tolerance);
- else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(elasticConstsE[i],
- elasticConsts[i],
- tolerance);
+ const size_t size = numQuadPts * numElasticConsts;
+ CPPUNIT_ASSERT_EQUAL(size, elasticConsts.size());
+ const double tolerance = 1.0e-06;
+ for (size_t i=0; i < size; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, elasticConsts[i]/elasticConstsE[i],
+ tolerance);
} // testCalcDerivElastic
// ----------------------------------------------------------------------
-// Test calcDensity()
+// Test updateStateVars()
void
+pylith::materials::TestElasticMaterial::testUpdateStateVars(void)
+{ // testUpdateStateVars
+ std::cout << "\n\nWARNING!! WARNING!! WARNING!!\n"
+ "Need to implement using material with state variables.\n\n";
+} // testUpdateStateVars
+
+// ----------------------------------------------------------------------
+// Test calcStableTimeStepImplicit()
+void
pylith::materials::TestElasticMaterial::testStableTimeStepImplicit(void)
{ // testStableTimeStepImplicit
- ALE::Obj<Mesh> mesh;
- { // create mesh
- const int cellDim = 1;
- const int numCorners = 2;
- const int spaceDim = 1;
- const int numVertices = 2;
- const int numCells = 1;
- const double vertCoords[] = { -1.0, 1.0};
- const int cells[] = { 0, 1};
- CPPUNIT_ASSERT(0 != vertCoords);
- CPPUNIT_ASSERT(0 != cells);
+ topology::Mesh mesh;
+ ElasticStrain1D material;
+ ElasticStrain1DData data;
+ _initialize(&mesh, &material, &data);
- mesh = new Mesh(PETSC_COMM_WORLD, cellDim);
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
-
- const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s =
- new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, numCells,
- const_cast<int*>(cells), numVertices, interpolate, numCorners);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, vertCoords);
- } // create mesh
-
// Get cells associated with material
- const ALE::Obj<real_section_type>& coordinates =
- mesh->getRealSection("coordinates");
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+ SieveMesh::point_type cell = *cells->begin();
- ElasticIsotropic3D material;
- ElasticIsotropic3DData data;
- const int numQuadPts = 2;
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
+ material.retrievePropsAndVars(cell);
+ const double dt = material.stableTimeStepImplicit(mesh);
- const int initialStateSize = material._tensorSize;
- material._initialStateSize = initialStateSize;
- const int initialStateFiberDim = numQuadPts * initialStateSize;
- material._initialState = new real_section_type(mesh->comm(), mesh->debug());
- material._initialState->setChart(mesh->getSieve()->getChart());
- material._initialState->setFiberDimension(cells, initialStateFiberDim);
- mesh->allocate(material._initialState);
-
- Mesh::label_sequence::iterator c_iter = cells->begin();
-
- const int fiberDim = numQuadPts * numParamsQuadPt;
- material._properties = new real_section_type(mesh->comm(), mesh->debug());
- material._properties->setChart(mesh->getSieve()->getChart());
- material._properties->setFiberDimension(cells, fiberDim);
- mesh->allocate(material._properties);
-
- material._properties->updatePoint(*c_iter, data.parameterData);
-
- material.getPropertiesCell(*c_iter, numQuadPts);
- const double dt = material.stableTimeStepImplicit();
-
const double tolerance = 1.0e-06;
const double dtE = data.dtStableImplicit;
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, dt/dtE, tolerance);
} // testStableTimeStepImplicit
-
+
// ----------------------------------------------------------------------
// Setup testing data.
void
@@ -349,46 +413,86 @@
CPPUNIT_ASSERT(0 != _dataElastic);
const ElasticMaterialData* data = _dataElastic;
- double_array density(1);
- _matElastic->_calcDensity(&density[0], data->parameterData, data->numParamsQuadPt);
+ const int numLocs = data->numLocs;
+ const int numPropsQuadPt = data->numPropsQuadPt;
+ const int numVarsQuadPt = data->numVarsQuadPt;
+
+ double density = 0;
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
- const double* densityE = data->density;
- CPPUNIT_ASSERT(0 != densityE);
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &data->properties[iLoc*numPropsQuadPt],
+ numPropsQuadPt*sizeof(double));
+ memcpy(&stateVars[0], &data->stateVars[iLoc*numVarsQuadPt],
+ numVarsQuadPt*sizeof(double));
- const double tolerance = 1.0e-06;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, density[0]/densityE[0], tolerance);
+ _matElastic->_calcDensity(&density,
+ &properties[0], properties.size(),
+ &stateVars[0], stateVars.size());
+
+ const double densityE = data->density[iLoc];
+
+ const double tolerance = 1.0e-06;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, density/densityE, tolerance);
+ } // for
} // _testCalcDensity
// ----------------------------------------------------------------------
// Test _calcStress()
void
pylith::materials::TestElasticMaterial::test_calcStress(void)
-{ // _testCalcElasticConsts
+{ // _testCalcStress
CPPUNIT_ASSERT(0 != _matElastic);
CPPUNIT_ASSERT(0 != _dataElastic);
const ElasticMaterialData* data = _dataElastic;
const bool computeStateVars = true;
- const int stressSize = _matElastic->_tensorSize;
- double_array stress(stressSize);
- _matElastic->_calcStress(&stress[0], stress.size(),
- data->parameterData, data->numParamsQuadPt,
- data->strain, stressSize,
- data->initialState, data->numInitialStateValues,
- computeStateVars);
+ const int numLocs = data->numLocs;
+ const int numPropsQuadPt = data->numPropsQuadPt;
+ const int numVarsQuadPt = data->numVarsQuadPt;
+ const int tensorSize = _matElastic->_tensorSize;
- const double* stressE = data->stress;
- CPPUNIT_ASSERT(0 != stressE);
+ double_array stress(tensorSize);
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
+ double_array strain(tensorSize);
+ double_array initialStress(tensorSize);
+ double_array initialStrain(tensorSize);
- const double tolerance = 1.0e-06;
- for (int i=0; i < stressSize; ++i)
- if (fabs(stressE[i]) > tolerance)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, stress[i]/stressE[i],
- tolerance);
- else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(stressE[i], stress[i],
- tolerance);
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &data->properties[iLoc*numPropsQuadPt],
+ properties.size()*sizeof(double));
+ memcpy(&stateVars[0], &data->stateVars[iLoc*numVarsQuadPt],
+ stateVars.size()*sizeof(double));
+ memcpy(&strain[0], &data->strain[iLoc*tensorSize],
+ strain.size()*sizeof(double));
+ memcpy(&initialStress[0], &data->initialStress[iLoc*tensorSize],
+ initialStress.size()*sizeof(double));
+ memcpy(&initialStrain[0], &data->initialStrain[iLoc*tensorSize],
+ initialStrain.size()*sizeof(double));
+
+ _matElastic->_calcStress(&stress[0], stress.size(),
+ &properties[0], properties.size(),
+ &stateVars[0], stateVars.size(),
+ &strain[0], strain.size(),
+ &initialStress[0], initialStress.size(),
+ &initialStrain[0], initialStrain.size(),
+ computeStateVars);
+
+ const double* stressE = &data->stress[iLoc*tensorSize];
+ CPPUNIT_ASSERT(0 != stressE);
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < tensorSize; ++i)
+ if (fabs(stressE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, stress[i]/stressE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stressE[i], stress[i],
+ tolerance);
+ } // for
} // _testCalcStress
// ----------------------------------------------------------------------
@@ -401,43 +505,122 @@
const ElasticMaterialData* data = _dataElastic;
int numConsts = 0;
- int strainSize = 0;
+ int tensorSize = 0;
switch(data->dimension)
{ // switch
case 1 :
numConsts = 1;
- strainSize = 1;
+ tensorSize = 1;
break;
case 2 :
numConsts = 6;
- strainSize = 3;
+ tensorSize = 3;
break;
case 3 :
numConsts = 21;
- strainSize = 6;
+ tensorSize = 6;
break;
} // switch
+ const int numLocs = data->numLocs;
+ const int numPropsQuadPt = data->numPropsQuadPt;
+ const int numVarsQuadPt = data->numVarsQuadPt;
+
double_array elasticConsts(numConsts);
- _matElastic->_calcElasticConsts(&elasticConsts[0], numConsts,
- data->parameterData, data->numParamsQuadPt,
- data->strain, strainSize,
- data->initialState,
- data->numInitialStateValues);
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
+ double_array strain(tensorSize);
+ double_array initialStress(tensorSize);
+ double_array initialStrain(tensorSize);
- const double* elasticConstsE = data->elasticConsts;
- CPPUNIT_ASSERT(0 != elasticConstsE);
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &data->properties[iLoc*numPropsQuadPt],
+ numPropsQuadPt*sizeof(double));
+ memcpy(&stateVars[0], &data->stateVars[iLoc*numVarsQuadPt],
+ numVarsQuadPt*sizeof(double));
+ memcpy(&strain[0], &data->strain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStress[0], &data->initialStress[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStrain[0], &data->initialStrain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
- const double tolerance = 1.0e-06;
- for (int i=0; i < numConsts; ++i)
- if (fabs(elasticConstsE[i]) > tolerance)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, elasticConsts[i]/elasticConstsE[i],
- tolerance);
- else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(elasticConstsE[i], elasticConsts[i],
- tolerance);
+ _matElastic->_calcElasticConsts(&elasticConsts[0], elasticConsts.size(),
+ &properties[0], properties.size(),
+ &stateVars[0], stateVars.size(),
+ &strain[0], strain.size(),
+ &initialStress[0], initialStress.size(),
+ &initialStrain[0], initialStrain.size());
+
+ const double* elasticConstsE = &data->elasticConsts[iLoc*numConsts];
+ CPPUNIT_ASSERT(0 != elasticConstsE);
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numConsts; ++i)
+ if (fabs(elasticConstsE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, elasticConsts[i]/elasticConstsE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(elasticConstsE[i], elasticConsts[i],
+ tolerance);
+ } // for
} // _testCalcElasticConsts
+// ----------------------------------------------------------------------
+// Test _updateStateVars()
+void
+pylith::materials::TestElasticMaterial::test_updateStateVars(void)
+{ // test_updateStateVars
+ CPPUNIT_ASSERT(0 != _matElastic);
+ CPPUNIT_ASSERT(0 != _dataElastic);
+ const ElasticMaterialData* data = _dataElastic;
+ const bool computeStateVars = true;
+
+ const int numLocs = data->numLocs;
+ const int numPropsQuadPt = data->numPropsQuadPt;
+ const int numVarsQuadPt = data->numVarsQuadPt;
+ const int tensorSize = _matElastic->_tensorSize;
+
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
+ double_array strain(tensorSize);
+ double_array initialStress(tensorSize);
+ double_array initialStrain(tensorSize);
+
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &data->properties[iLoc*numPropsQuadPt],
+ numPropsQuadPt*sizeof(double));
+ memcpy(&stateVars[0], &data->stateVars[iLoc*numVarsQuadPt],
+ numVarsQuadPt*sizeof(double));
+ memcpy(&strain[0], &data->strain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStress[0], &data->initialStress[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStrain[0], &data->initialStrain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+
+ _matElastic->_updateStateVars(&stateVars[0], stateVars.size(),
+ &properties[0], properties.size(),
+ &strain[0], strain.size(),
+ &initialStress[0], initialStress.size(),
+ &initialStrain[0], initialStrain.size());
+
+ const double* stateVarsE =
+ (numVarsQuadPt > 0) ? &data->stateVarsUpdated[iLoc*numVarsQuadPt] : 0;
+ CPPUNIT_ASSERT( (0 < numVarsQuadPt && 0 != stateVarsE) ||
+ (0 == numVarsQuadPt && 0 == stateVarsE) );
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numVarsQuadPt; ++i)
+ if (fabs(stateVarsE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, stateVars[i]/stateVarsE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsE[i], stateVars[i],
+ tolerance);
+ } // for
+} // test_updateStateVars
+
// ----------------------------------------------------------------------
// Test _stableTimeStepImplicit()
void
@@ -448,8 +631,8 @@
const ElasticMaterialData* data = _dataElastic;
const double dt =
- _matElastic->_stableTimeStepImplicit(data->parameterData,
- data->numParamsQuadPt);
+ _matElastic->_stableTimeStepImplicit(data->properties, data->numPropsQuadPt,
+ data->stateVars, data->numVarsQuadPt);
const double dtE = data->dtStableImplicit;
@@ -457,5 +640,107 @@
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, dt/dtE, tolerance);
} // _testStableTimeStepImplicit
+// ----------------------------------------------------------------------
+// Setup nondimensionalization.
+void
+pylith::materials::TestElasticMaterial::setupNormalizer(void)
+{ // setupNormalizer
+ spatialdata::units::Nondimensional normalizer;
+ normalizer.lengthScale(_data->lengthScale);
+ normalizer.pressureScale(_data->pressureScale);
+ normalizer.timeScale(_data->timeScale);
+ normalizer.densityScale(_data->densityScale);
+ _material->normalizer(normalizer);
+ _matElastic->normalizer(normalizer);
+} // setupNormalizer
+// ----------------------------------------------------------------------
+// Setup mesh and material.
+void
+pylith::materials::TestElasticMaterial::_initialize(
+ topology::Mesh* mesh,
+ ElasticStrain1D* material,
+ const ElasticStrain1DData* data)
+{ // _initialize
+ CPPUNIT_ASSERT(0 != mesh);
+ CPPUNIT_ASSERT(0 != material);
+ CPPUNIT_ASSERT(0 != data);
+
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename("data/line3.mesh");
+ iohandler.read(mesh);
+
+ // Set up coordinates
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(mesh->dimension());
+ cs.initialize();
+ mesh->coordsys(&cs);
+
+ // Setup quadrature
+ feassemble::Quadrature<topology::Mesh> quadrature;
+ feassemble::GeometryLine1D geometry;
+ quadrature.refGeometry(&geometry);
+ const int cellDim = 1;
+ const int numCorners = 3;
+ const int numQuadPts = 2;
+ const int spaceDim = 1;
+ const double basis[] = { 0.455, -0.122, 0.667, -0.122, 0.455, 0.667 };
+ const double basisDeriv[] = {
+ -1.07735027e+00,
+ -7.73502692e-02,
+ 1.15470054e+00,
+ 7.73502692e-02,
+ 1.07735027e+00,
+ -1.15470054e+00,
+ };
+ const double quadPtsRef[] = { -0.577350269, 0.577350269 };
+ const double quadWts[] = { 1.0, 1.0 };
+ quadrature.initialize(basis, numQuadPts, numCorners,
+ basisDeriv, numQuadPts, numCorners, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
+
+
+ // Get cells associated with material
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+
+ // Compute geometry for cells
+ quadrature.computeGeometry(*mesh, cells);
+
+ spatialdata::spatialdb::SimpleDB db;
+ spatialdata::spatialdb::SimpleIOAscii dbIO;
+ dbIO.filename("data/matinitialize.spatialdb");
+ db.ioHandler(&dbIO);
+ db.queryType(spatialdata::spatialdb::SimpleDB::NEAREST);
+
+ spatialdata::spatialdb::SimpleDB dbStress;
+ spatialdata::spatialdb::SimpleIOAscii dbIOStress;
+ dbIOStress.filename("data/matstress.spatialdb");
+ dbStress.ioHandler(&dbIOStress);
+ dbStress.queryType(spatialdata::spatialdb::SimpleDB::NEAREST);
+
+ spatialdata::spatialdb::SimpleDB dbStrain;
+ spatialdata::spatialdb::SimpleIOAscii dbIOStrain;
+ dbIOStrain.filename("data/matstrain.spatialdb");
+ dbStrain.ioHandler(&dbIOStrain);
+ dbStrain.queryType(spatialdata::spatialdb::SimpleDB::NEAREST);
+
+ spatialdata::units::Nondimensional normalizer;
+
+ material->dbProperties(&db);
+ material->id(materialId);
+ material->label("my_material");
+ material->normalizer(normalizer);
+ material->dbInitialStress(&dbStress);
+ material->dbInitialStrain(&dbStrain);
+
+ material->initialize(*mesh, &quadrature);
+} // _initialize
+
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticMaterial.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,13 +22,15 @@
#define pylith_materials_testelasticmaterial_hh
#include "TestMaterial.hh"
+#include "pylith/materials/materialsfwd.hh" // forward declarations
+#include "pylith/topology/topologyfwd.hh" // forward declarations
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class ElasticMaterial;
class TestElasticMaterial;
class ElasticMaterialData;
+ class ElasticStrain1DData;
} // materials
} // pylith
@@ -39,9 +41,14 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticMaterial );
+ CPPUNIT_TEST( testDBInitialStress );
+ CPPUNIT_TEST( testDBInitialStrain );
+ CPPUNIT_TEST( testInitialize );
+ CPPUNIT_TEST( testRetrievePropsAndVars );
CPPUNIT_TEST( testCalcDensity );
CPPUNIT_TEST( testCalcStress );
CPPUNIT_TEST( testCalcDerivElastic );
+ CPPUNIT_TEST( testUpdateStateVars );
CPPUNIT_TEST( testStableTimeStepImplicit );
CPPUNIT_TEST_SUITE_END();
@@ -49,6 +56,18 @@
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
+ /// Test dbInitialStress().
+ void testDBInitialStress(void);
+
+ /// Test dbInitialStrain().
+ void testDBInitialStrain(void);
+
+ /// Test initialize().
+ void testInitialize(void);
+
+ /// Test retrievePropsAndVars().
+ void testRetrievePropsAndVars(void);
+
/// Test calcDensity()
void testCalcDensity(void);
@@ -58,6 +77,9 @@
/// Test calcDerivElastic()
void testCalcDerivElastic(void);
+ /// Test updateStateVars().
+ void testUpdateStateVars(void);
+
/// Test stableTimeStepImplicit().
void testStableTimeStepImplicit(void);
@@ -83,16 +105,37 @@
/// Test _calcElasticConsts().
void test_calcElasticConsts(void);
+ /// Test _updateStateVars().
+ void test_updateStateVars(void);
+
/// Test _stableTimeStepImplicit().
void test_stableTimeStepImplicit(void);
+ // PROTECTED METHODS //////////////////////////////////////////////////
+protected :
+ /// Setup nondimensionalization.
+ void setupNormalizer(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
ElasticMaterial* _matElastic; ///< Test subject.
ElasticMaterialData* _dataElastic; ///< Data for tests.
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ /** Setup mesh and material.
+ *
+ * @param mesh Finite-element mesh.
+ * @param material Elastic material.
+ * @param data Data with properties for elastic material.
+ */
+ void _initialize(topology::Mesh* mesh,
+ ElasticStrain1D* material,
+ const ElasticStrain1DData* data);
+
}; // class TestElasticMaterial
#endif // pylith_materials_testelasticmaterial_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -30,55 +30,8 @@
_matElastic = new ElasticPlaneStrain();
_data = new ElasticPlaneStrainData();
_dataElastic = new ElasticPlaneStrainData();
+ setupNormalizer();
} // setUp
-// ----------------------------------------------------------------------
-// Test usesUpdateProperties()
-void
-pylith::materials::TestElasticPlaneStrain::testUsesUpdateProperties(void)
-{ // testUsesUpdateProperties
- ElasticPlaneStrain material;
- CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateProperties());
-} // testUsesUpdateProperties
-// ----------------------------------------------------------------------
-// Test updateProperties()
-void
-pylith::materials::TestElasticPlaneStrain::testUpdateProperties(void)
-{ // testUpdateProperties
- ElasticPlaneStrain material;
- ElasticPlaneStrainData data;
-
- const int numParams = data.numParameters;
-
- double_array parameters(numParams);
- const int paramsSize = 1;
- for (int i=0; i < numParams; ++i) {
- for (int j=0; j < paramsSize; ++j)
- parameters[i*paramsSize+j] = i+j;
- } // for
-
- const int tensorSize = 9;
- const int initialStateSize = 9;
- double_array totalStrain(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrain[i] = i;
- initialState[i] = 0.1*i;
- } // for
-
- material._updateProperties(¶meters[0], numParams, &totalStrain[0],
- tensorSize, &initialState[0], initialStateSize);
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParams; ++i)
- for (int j=0; j < paramsSize; ++j)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i+j), parameters[i*paramsSize+j],
- tolerance);
-
- for (int i=0; i < tensorSize; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i), totalStrain[i], tolerance);
-} // testUpdateProperties
-
-
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStrain.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,9 +26,7 @@
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class ElasticPlaneStrain;
class TestElasticPlaneStrain;
- class ElasticPlaneStrainData;
} // materials
} // pylith
@@ -39,17 +37,20 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticPlaneStrain );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testTensorSize );
CPPUNIT_TEST( testDBToProperties );
- CPPUNIT_TEST( testDBValues );
- CPPUNIT_TEST( testProperties );
+ CPPUNIT_TEST( testNonDimProperties );
+ CPPUNIT_TEST( testDimProperties );
+ CPPUNIT_TEST( testDBToStateVars );
+ CPPUNIT_TEST( testNonDimStateVars );
+ CPPUNIT_TEST( testDimStateVars );
CPPUNIT_TEST( test_calcDensity );
CPPUNIT_TEST( test_calcStress );
CPPUNIT_TEST( test_calcElasticConsts );
+ CPPUNIT_TEST( test_updateStateVars );
CPPUNIT_TEST( test_stableTimeStepImplicit );
- CPPUNIT_TEST( testUsesUpdateProperties );
- CPPUNIT_TEST( testUpdateProperties );
-
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -58,12 +59,6 @@
/// Setup testing data.
void setUp(void);
- /// Test usesUpdateProperties().
- void testUsesUpdateProperties(void);
-
- /// Test updateProperties()
- void testUpdateProperties(void);
-
}; // class TestElasticPlaneStrain
#endif // pylith_materials_testelasticplanestrain_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -30,55 +30,8 @@
_matElastic = new ElasticPlaneStress();
_data = new ElasticPlaneStressData();
_dataElastic = new ElasticPlaneStressData();
+ setupNormalizer();
} // setUp
-// ----------------------------------------------------------------------
-// Test usesUpdateProperties()
-void
-pylith::materials::TestElasticPlaneStress::testUsesUpdateProperties(void)
-{ // testUsesUpdateProperties
- ElasticPlaneStress material;
- CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateProperties());
-} // testUsesUpdateProperties
-// ----------------------------------------------------------------------
-// Test updateProperties()
-void
-pylith::materials::TestElasticPlaneStress::testUpdateProperties(void)
-{ // testUpdateProperties
- ElasticPlaneStress material;
- ElasticPlaneStressData data;
-
- const int numParams = data.numParameters;
-
- double_array parameters(numParams);
- const int paramsSize = 1;
- for (int i=0; i < numParams; ++i) {
- for (int j=0; j < paramsSize; ++j)
- parameters[i*paramsSize+j] = i+j;
- } // for
-
- const int tensorSize = 9;
- const int initialStateSize = 9;
- double_array totalStrain(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrain[i] = i;
- initialState[i] = 0.1*i;
- } // for
-
- material._updateProperties(¶meters[0], numParams, &totalStrain[0],
- tensorSize, &initialState[0], initialStateSize);
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParams; ++i)
- for (int j=0; j < paramsSize; ++j)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i+j), parameters[i*paramsSize+j],
- tolerance);
-
- for (int i=0; i < tensorSize; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i), totalStrain[i], tolerance);
-} // testUpdateProperties
-
-
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticPlaneStress.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,9 +26,7 @@
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class ElasticPlaneStress;
class TestElasticPlaneStress;
- class ElasticPlaneStressData;
} // materials
} // pylith
@@ -39,17 +37,20 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticPlaneStress );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testTensorSize );
CPPUNIT_TEST( testDBToProperties );
- CPPUNIT_TEST( testDBValues );
- CPPUNIT_TEST( testProperties );
+ CPPUNIT_TEST( testNonDimProperties );
+ CPPUNIT_TEST( testDimProperties );
+ CPPUNIT_TEST( testDBToStateVars );
+ CPPUNIT_TEST( testNonDimStateVars );
+ CPPUNIT_TEST( testDimStateVars );
CPPUNIT_TEST( test_calcDensity );
CPPUNIT_TEST( test_calcStress );
CPPUNIT_TEST( test_calcElasticConsts );
+ CPPUNIT_TEST( test_updateStateVars );
CPPUNIT_TEST( test_stableTimeStepImplicit );
- CPPUNIT_TEST( testUsesUpdateProperties );
- CPPUNIT_TEST( testUpdateProperties );
-
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -58,12 +59,6 @@
/// Setup testing data.
void setUp(void);
- /// Test usesUpdateProperties().
- void testUsesUpdateProperties(void);
-
- /// Test updateProperties()
- void testUpdateProperties(void);
-
}; // class TestElasticPlaneStress
#endif // pylith_materials_testelasticplanestress_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -30,55 +30,8 @@
_matElastic = new ElasticStrain1D();
_data = new ElasticStrain1DData();
_dataElastic = new ElasticStrain1DData();
+ setupNormalizer();
} // setUp
-// ----------------------------------------------------------------------
-// Test usesUpdateProperties()
-void
-pylith::materials::TestElasticStrain1D::testUsesUpdateProperties(void)
-{ // testUsesUpdateProperties
- ElasticStrain1D material;
- CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateProperties());
-} // testUsesUpdateProperties
-// ----------------------------------------------------------------------
-// Test updateProperties()
-void
-pylith::materials::TestElasticStrain1D::testUpdateProperties(void)
-{ // testUpdateProperties
- ElasticStrain1D material;
- ElasticStrain1DData data;
-
- const int numParams = data.numParameters;
-
- double_array parameters(numParams);
- const int paramsSize = 1;
- for (int i=0; i < numParams; ++i) {
- for (int j=0; j < paramsSize; ++j)
- parameters[i*paramsSize+j] = i+j;
- } // for
-
- const int tensorSize = 9;
- const int initialStateSize = 9;
- double_array initialState(initialStateSize);
- double_array totalStrain(tensorSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrain[i] = i;
- initialState[i] = 0.1*i;
- } // for
-
- material._updateProperties(¶meters[0], numParams, &totalStrain[0],
- tensorSize, &initialState[0], initialStateSize);
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParams; ++i)
- for (int j=0; j < paramsSize; ++j)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i+j), parameters[i*paramsSize+j],
- tolerance);
-
- for (int i=0; i < tensorSize; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i), totalStrain[i], tolerance);
-} // testUpdateProperties
-
-
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStrain1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,9 +26,7 @@
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class ElasticStrain1D;
class TestElasticStrain1D;
- class ElasticStrain1DData;
} // materials
} // pylith
@@ -39,17 +37,20 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticStrain1D );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testTensorSize );
CPPUNIT_TEST( testDBToProperties );
- CPPUNIT_TEST( testDBValues );
- CPPUNIT_TEST( testProperties );
+ CPPUNIT_TEST( testNonDimProperties );
+ CPPUNIT_TEST( testDimProperties );
+ CPPUNIT_TEST( testDBToStateVars );
+ CPPUNIT_TEST( testNonDimStateVars );
+ CPPUNIT_TEST( testDimStateVars );
CPPUNIT_TEST( test_calcDensity );
CPPUNIT_TEST( test_calcStress );
CPPUNIT_TEST( test_calcElasticConsts );
+ CPPUNIT_TEST( test_updateStateVars );
CPPUNIT_TEST( test_stableTimeStepImplicit );
- CPPUNIT_TEST( testUsesUpdateProperties );
- CPPUNIT_TEST( testUpdateProperties );
-
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -58,12 +59,6 @@
/// Setup testing data.
void setUp(void);
- /// Test usesUpdateProperties().
- void testUsesUpdateProperties(void);
-
- /// Test updateProperties()
- void testUpdateProperties(void);
-
}; // class TestElasticStrain1D
#endif // pylith_materials_testelasticstrain1d_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -30,55 +30,8 @@
_matElastic = new ElasticStress1D();
_data = new ElasticStress1DData();
_dataElastic = new ElasticStress1DData();
+ setupNormalizer();
} // setUp
-// ----------------------------------------------------------------------
-// Test usesUpdateProperties()
-void
-pylith::materials::TestElasticStress1D::testUsesUpdateProperties(void)
-{ // testUsesUpdateProperties
- ElasticStress1D material;
- CPPUNIT_ASSERT_EQUAL(false, material.usesUpdateProperties());
-} // testUsesUpdateProperties
-// ----------------------------------------------------------------------
-// Test updateProperties()
-void
-pylith::materials::TestElasticStress1D::testUpdateProperties(void)
-{ // testUpdateProperties
- ElasticStress1D material;
- ElasticStress1DData data;
-
- const int numParams = data.numParameters;
-
- double_array parameters(numParams);
- const int paramsSize = 1;
- for (int i=0; i < numParams; ++i) {
- for (int j=0; j < paramsSize; ++j)
- parameters[i*paramsSize+j] = i+j;
- } // for
-
- const int tensorSize = 9;
- const int initialStateSize = 9;
- double_array totalStrain(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrain[i] = i;
- initialState[i] = 0.1*i;
- } // for
-
- material._updateProperties(¶meters[0], numParams, &totalStrain[0],
- tensorSize, &initialState[0], initialStateSize);
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParams; ++i)
- for (int j=0; j < paramsSize; ++j)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i+j), parameters[i*paramsSize+j],
- tolerance);
-
- for (int i=0; i < tensorSize; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(double(i), totalStrain[i], tolerance);
-} // testUpdateProperties
-
-
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestElasticStress1D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,9 +26,7 @@
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class ElasticStress1D;
class TestElasticStress1D;
- class ElasticStress1DData;
} // materials
} // pylith
@@ -39,17 +37,20 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestElasticStress1D );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testTensorSize );
CPPUNIT_TEST( testDBToProperties );
- CPPUNIT_TEST( testDBValues );
- CPPUNIT_TEST( testProperties );
+ CPPUNIT_TEST( testNonDimProperties );
+ CPPUNIT_TEST( testDimProperties );
+ CPPUNIT_TEST( testDBToStateVars );
+ CPPUNIT_TEST( testNonDimStateVars );
+ CPPUNIT_TEST( testDimStateVars );
CPPUNIT_TEST( test_calcDensity );
CPPUNIT_TEST( test_calcStress );
CPPUNIT_TEST( test_calcElasticConsts );
+ CPPUNIT_TEST( test_updateStateVars );
CPPUNIT_TEST( test_stableTimeStepImplicit );
- CPPUNIT_TEST( testUsesUpdateProperties );
- CPPUNIT_TEST( testUpdateProperties );
-
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -58,12 +59,6 @@
/// Setup testing data.
void setUp(void);
- /// Test usesUpdateProperties().
- void testUsesUpdateProperties(void);
-
- /// Test updateProperties()
- void testUpdateProperties(void);
-
}; // class TestElasticStress1D
#endif // pylith_materials_testelasticstress1d_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,58 +16,33 @@
#include "data/MaterialData.hh" // USES MaterialData
+#include "pylith/utils/array.hh" // USES double_array
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include "pylith/materials/ElasticIsotropic3D.hh" // USES ElasticIsotropic3D
-#include "pylith/utils/array.hh" // USES double_array
-#include "pylith/feassemble/Quadrature1D.hh" // USES Quadrature1D
+#include "pylith/materials/ElasticStrain1D.hh" // USES ElasticStrain1D
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "pylith/feassemble/GeometryLine1D.hh" // USES GeometryLine1D
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
#include "spatialdata/spatialdb/SimpleDB.hh" // USES SimpleDB
#include "spatialdata/spatialdb/SimpleIOAscii.hh" // USES SimpleIOAscii
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
#include "spatialdata/units/Nondimensional.hh" // USES Nondimensional
-#include "pylith/utils/sievetypes.hh" // USES Mesh
+#include <cstring> // USES strcmp()
+#include <cassert> // USES assert()
+#include <cmath> // USES sqrt()
-#include <string.h> // USES strcmp()
-#include <math.h> // USES assert()
-
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestMaterial );
// ----------------------------------------------------------------------
-// Test db()
-void
-pylith::materials::TestMaterial::testDB(void)
-{ // testDB
- const char* label = "my_database";
- spatialdata::spatialdb::SimpleDB db;
- db.label(label);
-
- ElasticIsotropic3D material;
- material.db(&db);
-
- CPPUNIT_ASSERT(0 != material._db);
- CPPUNIT_ASSERT(0 == strcmp(label, material._db->label()));
-} // testDB
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
// ----------------------------------------------------------------------
-// Test initialStateDB()
-void
-pylith::materials::TestMaterial::testInitialStateDB(void)
-{ // testInitialStateDB
- const char* label = "my_database";
- spatialdata::spatialdb::SimpleDB initialStateDB;
- initialStateDB.label(label);
-
- ElasticIsotropic3D material;
- material.initialStateDB(&initialStateDB);
-
- CPPUNIT_ASSERT(0 != material._initialStateDB);
- CPPUNIT_ASSERT(0 == strcmp(label, material._initialStateDB->label()));
-} // testInitialStateDB
-// ----------------------------------------------------------------------
-
// Test id()
void
pylith::materials::TestMaterial::testID(void)
@@ -84,11 +59,11 @@
void
pylith::materials::TestMaterial::testLabel(void)
{ // testLabel
- const char* label = "the_database";
+ const std::string& label = "the database";
ElasticIsotropic3D material;
- material.label(label);
+ material.label(label.c_str());
- CPPUNIT_ASSERT(0 == strcmp(label, material.label().c_str()));
+ CPPUNIT_ASSERT_EQUAL(label, std::string(material.label()));
} // testLabel
// ----------------------------------------------------------------------
@@ -104,6 +79,54 @@
} // testTimeStep
// ----------------------------------------------------------------------
+// Test dbProperties()
+void
+pylith::materials::TestMaterial::testDBProperties(void)
+{ // testDBProperties
+ const std::string& label = "my_database";
+ spatialdata::spatialdb::SimpleDB db;
+ db.label(label.c_str());
+
+ ElasticIsotropic3D material;
+ material.dbProperties(&db);
+
+ CPPUNIT_ASSERT(0 != material._dbProperties);
+ CPPUNIT_ASSERT_EQUAL(label, std::string(material._dbProperties->label()));
+} // testDBProperties
+
+// ----------------------------------------------------------------------
+// Test dbStateVars()
+void
+pylith::materials::TestMaterial::testDBStateVars(void)
+{ // testDBStateVars
+ const std::string& label = "my_database";
+ spatialdata::spatialdb::SimpleDB db;
+ db.label(label.c_str());
+
+ ElasticIsotropic3D material;
+ material.dbInitialState(&db);
+
+ CPPUNIT_ASSERT(0 != material._dbInitialState);
+ CPPUNIT_ASSERT_EQUAL(label, std::string(material._dbInitialState->label()));
+} // testDBStateVars
+
+// ----------------------------------------------------------------------
+// Test normalizer()
+void
+pylith::materials::TestMaterial::testNormalizer(void)
+{ // testNormalizer
+ spatialdata::units::Nondimensional normalizer;
+ const double lengthScale = 2.0;
+ normalizer.lengthScale(lengthScale);
+
+ ElasticIsotropic3D material;
+ material.normalizer(normalizer);
+
+ CPPUNIT_ASSERT(0 != material._normalizer);
+ CPPUNIT_ASSERT_EQUAL(lengthScale, material._normalizer->lengthScale());
+} // testNormalizer
+
+// ----------------------------------------------------------------------
// Test needNewJacobian()
void
pylith::materials::TestMaterial::testNeedNewJacobian(void)
@@ -124,123 +147,114 @@
void
pylith::materials::TestMaterial::testInitialize(void)
{ // testInitialize
- ALE::Obj<Mesh> mesh;
- const int materialID = 24;
- { // create mesh
- const int cellDim = 1;
- const int numCorners = 3;
- const int spaceDim = 1;
- const int numVertices = 3;
- const int numCells = 1;
- const double vertCoords[] = { -1.0, 0.0, 1.0};
- const int cells[] = { 0, 1, 2 };
- CPPUNIT_ASSERT(0 != vertCoords);
- CPPUNIT_ASSERT(0 != cells);
+ // Setup mesh
+ topology::Mesh mesh;
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename("data/line3.mesh");
+ iohandler.read(&mesh);
- mesh = new Mesh(PETSC_COMM_WORLD, cellDim);
- ALE::Obj<sieve_type> sieve = new sieve_type(mesh->comm());
-
- const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, numCells,
- const_cast<int*>(cells), numVertices,
- interpolate, numCorners);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- mesh->setSieve(sieve);
- mesh->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(mesh, spaceDim, vertCoords);
-
- } // create mesh
-
- { // set material ids
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
- const ALE::Obj<Mesh::label_type>& labelMaterials = mesh->createLabel("material-id");
- int i = 0;
- for(Mesh::label_sequence::iterator e_iter = cells->begin();
- e_iter != cells->end();
- ++e_iter)
- mesh->setValue(labelMaterials, *e_iter, materialID);
- } // set material ids
-
+ // Set up coordinates
spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(1);
+ cs.setSpaceDim(mesh.dimension());
cs.initialize();
+ mesh.coordsys(&cs);
- feassemble::Quadrature1D quadrature;
+ // Setup quadrature
+ feassemble::Quadrature<topology::Mesh> quadrature;
feassemble::GeometryLine1D geometry;
quadrature.refGeometry(&geometry);
const int cellDim = 1;
const int numCorners = 3;
const int numQuadPts = 2;
const int spaceDim = 1;
- const double basis[] = { 0.455, 0.667, -0.122, -0.122, 0.667, 0.455 };
- const double basisDeriv[] = { -1.077, 1.155, -0.077, 0.077, -1.155, 1.077 };
+ const double basis[] = { 0.455, -0.122, 0.667, -0.122, 0.455, 0.667 };
+ const double basisDeriv[] = {
+ -1.07735027e+00,
+ -7.73502692e-02,
+ 1.15470054e+00,
+ 7.73502692e-02,
+ 1.07735027e+00,
+ -1.15470054e+00,
+ };
const double quadPtsRef[] = { -0.577350269, 0.577350269 };
const double quadWts[] = { 1.0, 1.0 };
- quadrature.initialize(basis, basisDeriv, quadPtsRef, quadWts,
- cellDim, numCorners, numQuadPts, spaceDim);
+ quadrature.initialize(basis, numQuadPts, numCorners,
+ basisDeriv, numQuadPts, numCorners, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
+
+ // Get cells associated with material
+ const int materialId = 24;
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->getLabelStratum("material-id", materialId);
+
+ // Compute geometry for cells
+ quadrature.computeGeometry(mesh, cells);
+
spatialdata::spatialdb::SimpleDB db;
- spatialdata::spatialdb::SimpleIOAscii iohandler;
- iohandler.filename("data/matinitialize.spatialdb");
- db.ioHandler(&iohandler);
+ spatialdata::spatialdb::SimpleIOAscii dbIO;
+ dbIO.filename("data/matinitialize.spatialdb");
+ db.ioHandler(&dbIO);
db.queryType(spatialdata::spatialdb::SimpleDB::NEAREST);
spatialdata::units::Nondimensional normalizer;
- ElasticIsotropic3D material;
- material.db(&db);
- material.id(materialID);
+ ElasticStrain1D material;
+ material.dbProperties(&db);
+ material.id(materialId);
material.label("my_material");
material.normalizer(normalizer);
- material.initialize(mesh, &cs, &quadrature);
+ material.initialize(mesh, &quadrature);
- const double densityA = 2000.0;
- const double vsA = 100.0;
- const double vpA = 180.0;
+ const double densityA = 2500.0;
+ const double vsA = 3000.0;
+ const double vpA = vsA*sqrt(3.0);
const double muA = vsA*vsA*densityA;
const double lambdaA = vpA*vpA*densityA - 2.0*muA;
- const double densityB = 3000.0;
- const double vsB = 200.0;
- const double vpB = 400.0;
+ const double densityB = 2000.0;
+ const double vsB = 1200.0;
+ const double vpB = vsB*sqrt(3.0);
const double muB = vsB*vsB*densityB;
const double lambdaB = vpB*vpB*densityB - 2.0*muB;
const double densityE[] = { densityA, densityB };
const double muE[] = { muA, muB };
const double lambdaE[] = { lambdaA, lambdaB };
- // Get cells associated with material
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
-
- Mesh::label_sequence::iterator c_iter = cells->begin();
+ SieveMesh::point_type cell = *cells->begin();
const double tolerance = 1.0e-06;
- const real_section_type::value_type* paramsCell =
- material._properties->restrictPoint(*c_iter);
- CPPUNIT_ASSERT(0 != paramsCell);
+ CPPUNIT_ASSERT(0 != material._properties);
+ const Obj<RealSection>& propertiesSection = material._properties->section();
+ CPPUNIT_ASSERT(!propertiesSection.isNull());
+ const double* propertiesCell = propertiesSection->restrictPoint(cell);
+ CPPUNIT_ASSERT(0 != propertiesCell);
- const int pidDensity = 0;
- const int pidMu = 1;
- const int pidLambda = 2;
+ const int p_density = 0;
+ const int p_mu = 1;
+ const int p_lambda = 2;
// density
for (int i=0; i < numQuadPts; ++i) {
- const int index = i*material._totalPropsQuadPt + pidDensity;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, paramsCell[index]/densityE[i], tolerance);
+ const int index = i*material._numPropsQuadPt + p_density;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, propertiesCell[index]/densityE[i],
+ tolerance);
} // for
// mu
for (int i=0; i < numQuadPts; ++i) {
- const int index = i*material._totalPropsQuadPt + pidMu;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, paramsCell[index]/muE[i], tolerance);
+ const int index = i*material._numPropsQuadPt + p_mu;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, propertiesCell[index]/muE[i], tolerance);
} // for
// lambda
for (int i=0; i < numQuadPts; ++i) {
- const int index = i*material._totalPropsQuadPt + pidLambda;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, paramsCell[index]/lambdaE[i], tolerance);
+ const int index = i*material._numPropsQuadPt + p_lambda;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, propertiesCell[index]/lambdaE[i],
+ tolerance);
} // for
} // testInitialize
@@ -263,71 +277,254 @@
} // tearDown
// ----------------------------------------------------------------------
-// Test DBToProperties
+// Test dimension()
void
+pylith::materials::TestMaterial::testDimension(void)
+{ // testDimension
+ CPPUNIT_ASSERT_EQUAL(_data->dimension, _material->dimension());
+} // testDimension
+
+// ----------------------------------------------------------------------
+// Test dimension()
+void
+pylith::materials::TestMaterial::testTensorSize(void)
+{ // testTensorSize
+ int tensorSize = 0;
+ const int dimension = _data->dimension;
+ switch(dimension)
+ { // switch
+ case 1 :
+ tensorSize = 1;
+ break;
+ case 2 :
+ tensorSize = 3;
+ break;
+ case 3 :
+ tensorSize = 6;
+ break;
+ default :
+ assert(0);
+ } // switch
+ CPPUNIT_ASSERT(tensorSize > 0);
+
+ CPPUNIT_ASSERT_EQUAL(tensorSize, _material->tensorSize());
+} // testTensorSize
+
+// ----------------------------------------------------------------------
+// Test _dbToProperties().
+void
pylith::materials::TestMaterial::testDBToProperties(void)
{ // testDBToProperties
CPPUNIT_ASSERT(0 != _material);
CPPUNIT_ASSERT(0 != _data);
const int numLocs = _data->numLocs;
- const int numDBValues = _data->numDBValues;
- double_array dbData(numDBValues);
+ const int numDBProperties = _data->numDBProperties;
+ double_array dbValues(numDBProperties);
+ const int propertiesSize = _data->numPropsQuadPt;
+ double_array properties(propertiesSize);
+
for (int iLoc=0; iLoc < numLocs; ++iLoc) {
- for (int i=0; i < numDBValues; ++i)
- dbData[i] = _data->dbData[iLoc*numDBValues+i];
+ for (int i=0; i < numDBProperties; ++i)
+ dbValues[i] = _data->dbProperties[iLoc*numDBProperties+i];
- const int numProperties = _data->numParameters;
- int numParamEntries = 0;
- for (int iParam=0; iParam < numProperties; ++iParam)
- numParamEntries += _data->numParamValues[iParam];
+ _material->_dbToProperties(&properties[0], dbValues);
+
+ const double* const propertiesE = &_data->properties[iLoc*propertiesSize];
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < propertiesSize; ++i) {
+ if (fabs(propertiesE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
+ properties[i]/propertiesE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(propertiesE[i], properties[i],
+ tolerance);
+ } // for
+ } // for
+} // testDBToProperties
- double_array parameterData(numParamEntries);
+// ----------------------------------------------------------------------
+// Test _nondimProperties().
+void
+pylith::materials::TestMaterial::testNonDimProperties(void)
+{ // testNonDimProperties
+ CPPUNIT_ASSERT(0 != _material);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const int numLocs = _data->numLocs;
+ const int propertiesSize = _data->numPropsQuadPt;
+ double_array propertiesNondim(propertiesSize);
+ double_array properties(propertiesSize);
- double* const parameterDataE = &_data->parameterData[iLoc*numParamEntries];
- _material->_dbToProperties(¶meterData[0], dbData);
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &_data->properties[iLoc*propertiesSize],
+ propertiesSize*sizeof(double));
+ _material->_nondimProperties(&properties[0], properties.size());
+
+ const double* const propertiesNondimE =
+ &_data->propertiesNondim[iLoc*propertiesSize];
+ CPPUNIT_ASSERT(0 != propertiesNondimE);
+
const double tolerance = 1.0e-06;
- for (int i=0; i < numParamEntries; ++i) {
- if (fabs(parameterDataE[i]) > tolerance)
+ for (int i=0; i < propertiesSize; ++i) {
+ if (fabs(propertiesNondimE[i]) > tolerance)
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
- parameterData[i]/parameterDataE[i],
+ properties[i]/propertiesNondimE[i],
tolerance);
else
- CPPUNIT_ASSERT_DOUBLES_EQUAL(parameterDataE[i], parameterData[i],
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(propertiesNondimE[i], properties[i],
tolerance);
} // for
} // for
-} // testDBToProperties
+} // testNonDimProperties
// ----------------------------------------------------------------------
-// Test _dbValues and _numDBValues.
+// Test _dimProperties().
void
-pylith::materials::TestMaterial::testDBValues(void)
-{ // testDBValues
+pylith::materials::TestMaterial::testDimProperties(void)
+{ // testDimProperties
CPPUNIT_ASSERT(0 != _material);
CPPUNIT_ASSERT(0 != _data);
+
+ const int numLocs = _data->numLocs;
+ const int propertiesSize = _data->numPropsQuadPt;
+ double_array properties(propertiesSize);
- const int numDBValues = _data->numDBValues;
- CPPUNIT_ASSERT_EQUAL(numDBValues, _material->_numDBValues);
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
- char** const dbValuesE = _data->dbValues;
- for (int i=0; i < numDBValues; ++i)
- CPPUNIT_ASSERT(0 == strcmp(dbValuesE[i], _material->_dbValues[i]));
-} // testDBValues
+ memcpy(&properties[0], &_data->propertiesNondim[iLoc*propertiesSize],
+ propertiesSize*sizeof(double));
+ _material->_dimProperties(&properties[0], properties.size());
+
+ const double* const propertiesE =
+ &_data->properties[iLoc*propertiesSize];
+ CPPUNIT_ASSERT(0 != propertiesE);
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < propertiesSize; ++i) {
+ if (fabs(propertiesE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
+ properties[i]/propertiesE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(propertiesE[i], properties[i],
+ tolerance);
+ } // for
+ } // for
+} // testDimProperties
+
// ----------------------------------------------------------------------
-// Test _numProperties.
+// Test _dbToStateVars().
void
-pylith::materials::TestMaterial::testProperties(void)
-{ // testProperties
+pylith::materials::TestMaterial::testDBToStateVars(void)
+{ // testDBToStateVars
CPPUNIT_ASSERT(0 != _material);
CPPUNIT_ASSERT(0 != _data);
+
+ const int numLocs = _data->numLocs;
+ const int numDBStateVars = _data->numDBStateVars;
+ double_array dbValues(numDBStateVars);
- const int numProperties = _data->numParameters;
- CPPUNIT_ASSERT_EQUAL(numProperties, _material->_numProperties);
-} // testProperties
+ const int stateVarsSize = _data->numVarsQuadPt;
+ double_array stateVars(stateVarsSize);
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ for (int i=0; i < numDBStateVars; ++i)
+ dbValues[i] = _data->dbStateVars[iLoc*numDBStateVars+i];
+ _material->_dbToStateVars(&stateVars[0], dbValues);
+
+ const double* const stateVarsE =
+ (stateVarsSize > 0) ? &_data->stateVars[iLoc*stateVarsSize] : 0;
+ CPPUNIT_ASSERT( (0 < stateVarsSize && 0 != stateVarsE) ||
+ (0 == stateVarsSize && 0 == stateVarsE) );
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < stateVarsSize; ++i) {
+ if (fabs(stateVarsE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
+ stateVars[i]/stateVarsE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsE[i], stateVars[i],
+ tolerance);
+ } // for
+ } // for
+} // testDBToStateVars
+
+// ----------------------------------------------------------------------
+// Test _nondimStateVars().
+void
+pylith::materials::TestMaterial::testNonDimStateVars(void)
+{ // testNonDimStateVars
+ CPPUNIT_ASSERT(0 != _material);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const int numLocs = _data->numLocs;
+ const int stateVarsSize = _data->numVarsQuadPt;
+ double_array stateVars(stateVarsSize);
+
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+
+ memcpy(&stateVars[0], &_data->stateVars[iLoc*stateVarsSize],
+ stateVarsSize*sizeof(double));
+ _material->_nondimStateVars(&stateVars[0], stateVars.size());
+
+ const double* const stateVarsNondimE =
+ (stateVarsSize > 0) ? &_data->stateVarsNondim[iLoc*stateVarsSize] : 0;
+ CPPUNIT_ASSERT( (0 < stateVarsSize && 0 != stateVarsNondimE) ||
+ (0 == stateVarsSize && 0 == stateVarsNondimE) );
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < stateVarsSize; ++i) {
+ if (fabs(stateVarsNondimE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
+ stateVars[i]/stateVarsNondimE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsNondimE[i], stateVars[i],
+ tolerance);
+ } // for
+ } // for
+} // testNonDimStateVars
+
+// ----------------------------------------------------------------------
+// Test _dimStateVars().
+void
+pylith::materials::TestMaterial::testDimStateVars(void)
+{ // testDimStateVars
+ CPPUNIT_ASSERT(0 != _material);
+ CPPUNIT_ASSERT(0 != _data);
+
+ const int numLocs = _data->numLocs;
+ const int stateVarsSize = _data->numVarsQuadPt;
+ double_array stateVars(stateVarsSize);
+
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+
+ memcpy(&stateVars[0], &_data->stateVarsNondim[iLoc*stateVarsSize],
+ stateVarsSize*sizeof(double));
+ _material->_dimStateVars(&stateVars[0], stateVars.size());
+
+ const double* const stateVarsE =
+ (stateVarsSize > 0) ? &_data->stateVars[iLoc*stateVarsSize] : 0;
+ CPPUNIT_ASSERT( (0 < stateVarsSize && 0 != stateVarsE) ||
+ (0 == stateVarsSize && 0 == stateVarsE) );
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < stateVarsSize; ++i) {
+ if (fabs(stateVarsE[i]) > tolerance)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0,
+ stateVars[i]/stateVarsE[i],
+ tolerance);
+ else
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsE[i], stateVars[i],
+ tolerance);
+ } // for
+ } // for
+} // testDimStateVars
+
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaterial.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,10 +23,11 @@
#include <cppunit/extensions/HelperMacros.h>
+#include "pylith/materials/materialsfwd.hh" // forward declarations
+
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class Material;
class TestMaterial;
class MaterialData;
} // materials
@@ -39,11 +40,12 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestMaterial );
- CPPUNIT_TEST( testDB );
- CPPUNIT_TEST( testInitialStateDB );
CPPUNIT_TEST( testID );
CPPUNIT_TEST( testLabel );
CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testDBProperties );
+ CPPUNIT_TEST( testDBStateVars );
+ CPPUNIT_TEST( testNormalizer );
CPPUNIT_TEST( testNeedNewJacobian );
CPPUNIT_TEST( testInitialize );
@@ -52,13 +54,7 @@
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
- /// Test db()
- void testDB(void);
-
- /// Test initialStateDB()
- void testInitialStateDB(void);
-
- /// Test id()
+ /// Test id().
void testID(void);
/// Test label()
@@ -67,6 +63,15 @@
/// Test timeStep()
void testTimeStep(void);
+ /// Test dbProperties()
+ void testDBProperties(void);
+
+ /// Test dbStateVars().
+ void testDBStateVars(void);
+
+ /// Test normalizer().
+ void testNormalizer(void);
+
/// Test needNewJacobian()
void testNeedNewJacobian(void);
@@ -86,15 +91,30 @@
virtual
void tearDown(void);
- /// Test dbToProperties().
+ /// Test dimension().
+ void testDimension();
+
+ /// Test tensorSize().
+ void testTensorSize();
+
+ /// Test _dbToProperties().
void testDBToProperties(void);
- /// Test dbValues().
- void testDBValues(void);
+ /// Test _nondimProperties().
+ void testNonDimProperties(void);
- /// Test _numProperties.
- void testProperties(void);
+ /// Test _dimProperties().
+ void testDimProperties(void);
+ /// Test _dbToStateVars().
+ void testDBToStateVars(void);
+
+ /// Test _nondimStateVars().
+ void testNonDimStateVars(void);
+
+ /// Test _dimStateVars().
+ void testDimStateVars(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,6 +19,8 @@
#include "pylith/materials/MaxwellIsotropic3D.hh" // USES MaxwellIsotropic3D
+#include <cstring> // USES memcpy()
+
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestMaxwellIsotropic3D );
@@ -31,6 +33,7 @@
_matElastic = new MaxwellIsotropic3D();
_data = new MaxwellIsotropic3DElasticData();
_dataElastic = new MaxwellIsotropic3DElasticData();
+ setupNormalizer();
} // setUp
// ----------------------------------------------------------------------
@@ -65,107 +68,121 @@
material._calcStressFn);
CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcElasticConstsElastic,
material._calcElasticConstsFn);
- CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updatePropertiesElastic,
- material._updatePropertiesFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updateStateVarsElastic,
+ material._updateStateVarsFn);
material.useElasticBehavior(false);
CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcStressViscoelastic,
material._calcStressFn);
CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_calcElasticConstsViscoelastic,
material._calcElasticConstsFn);
- CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updatePropertiesViscoelastic,
- material._updatePropertiesFn);
+ CPPUNIT_ASSERT_EQUAL(&pylith::materials::MaxwellIsotropic3D::_updateStateVarsViscoelastic,
+ material._updateStateVarsFn);
} // testUseElasticBehavior
// ----------------------------------------------------------------------
-// Test usesUpdateProperties()
+// Test usesHasStateVars()
void
-pylith::materials::TestMaxwellIsotropic3D::testUsesUpdateProperties(void)
-{ // testUsesUpdateProperties
+pylith::materials::TestMaxwellIsotropic3D::testHasStateVars(void)
+{ // testHasStateVars
MaxwellIsotropic3D material;
- CPPUNIT_ASSERT_EQUAL(true, material.usesUpdateProperties());
-} // testUsesUpdateProperties
+ CPPUNIT_ASSERT_EQUAL(true, material.hasStateVars());
+} // testHasStateVars
// ----------------------------------------------------------------------
-// Test calcStressElastic()
+// Test _calcStressElastic()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcStressElastic(void)
-{ // testCalcStressElastic
+pylith::materials::TestMaxwellIsotropic3D::test_calcStressElastic(void)
+{ // test_calcStressElastic
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(true);
test_calcStress();
-} // testCalcStressElastic
+} // test_calcStressElastic
// ----------------------------------------------------------------------
// Test calcElasticConstsElastic()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcElasticConstsElastic(void)
-{ // testElasticConstsElastic
+pylith::materials::TestMaxwellIsotropic3D::test_calcElasticConstsElastic(void)
+{ // test_calcElasticConstsElastic
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(true);
test_calcElasticConsts();
-} // testElasticConstsElastic
+} // test_calcElasticConstsElastic
// ----------------------------------------------------------------------
-// Test updatePropertiesElastic()
+// Test _updateStateVarsElastic()
void
-pylith::materials::TestMaxwellIsotropic3D::testUpdatePropertiesElastic(void)
-{ // testUpdatePropertiesElastic
+pylith::materials::TestMaxwellIsotropic3D::test_updateStateVarsElastic(void)
+{ // test_updateStateVarsElastic
+ // :TODO: Use TestElasticMaterial::test_updateStateVars
+ // instead. This requires moving the calculation of the expected
+ // state vars below to the Python code (where it belongs) and
+ // setting the stateVarsUpdate attribute in the Python object.
+
MaxwellIsotropic3D material;
- MaxwellIsotropic3DElasticData data;
+ material.useElasticBehavior(true);
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
+ const bool computeStateVars = true;
+
+ const int numLocs = _dataElastic->numLocs;
+ const int numPropsQuadPt = _dataElastic->numPropsQuadPt;
+ const int numVarsQuadPt = _dataElastic->numVarsQuadPt;
+ const int tensorSize = material.tensorSize();
+
+ double_array stress(tensorSize);
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
+ double_array strain(tensorSize);
+ double_array initialStress(tensorSize);
+ double_array initialStrain(tensorSize);
+
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &_dataElastic->properties[iLoc*numPropsQuadPt],
+ numPropsQuadPt*sizeof(double));
+ memcpy(&stateVars[0], &_dataElastic->stateVars[iLoc*numVarsQuadPt],
+ numVarsQuadPt*sizeof(double));
+ memcpy(&strain[0], &_dataElastic->strain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStress[0], &_dataElastic->initialStress[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStrain[0], &_dataElastic->initialStrain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
- const int tensorSize = 6;
- const int initialStateSize = 6;
- double_array totalStrain(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrain[i] = i;
- initialState[i] = 0.1*i;
- } // for
+ const double meanStrain = (strain[0] + strain[1] + strain[2]) / 3.0;
+
+ // Compute expected state variables
+ double_array stateVarsE(numVarsQuadPt);
+ const int s_totalStrain = 0;
+ const int s_viscousStrain = s_totalStrain + tensorSize;
- const double meanStrain =
- (totalStrain[0] + totalStrain[1] + totalStrain[2]) / 3.0;
+ // State variable 'total_strain' should match 'strain'
+ for (int i=0; i < tensorSize; ++i)
+ stateVarsE[s_totalStrain+i] = strain[i];
+
+ // State variable 'viscous_strain'
+ const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+ for (int i=0; i < tensorSize; ++i)
+ stateVarsE[s_viscousStrain+i] = strain[i] - diag[i]*meanStrain;
+
+ material._updateStateVars(&stateVars[0], stateVars.size(),
+ &properties[0], properties.size(),
+ &strain[0], strain.size(),
+ &initialStress[0], initialStress.size(),
+ &initialStrain[0], initialStrain.size());
- double_array parameters(numParamsQuadPt);
- double_array parametersE(numParamsQuadPt);
- for (int i=0, index=0; i < numParams; ++i)
- for (int j=0; j < data.numParamValues[i]; ++j, ++index) {
- parametersE[index] = i+j;
- parameters[index] = i+j;
- } // for
-
- // Set up vector parameters, which are the only ones updated.
- const int pidStrainT = 4;
- const int pidVisStrain = pidStrainT + 6;
- for (int i=0; i < 3; ++i) {
- parametersE[pidStrainT+i] = totalStrain[i];
- parametersE[pidVisStrain+i] = totalStrain[i] - meanStrain;
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numVarsQuadPt; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsE[i], stateVars[i], tolerance);
} // for
-
- for (int i=3; i < 6; ++i) {
- parametersE[pidStrainT+i] = totalStrain[i];
- parametersE[pidVisStrain+i] = totalStrain[i];
- } // for
-
- material._updateProperties(¶meters[0], numParamsQuadPt,
- &totalStrain[0], tensorSize,
- &initialState[0], initialStateSize);
+} // test_updateStateVarsElastic
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParamsQuadPt; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(parametersE[i], parameters[i], tolerance);
-} // testUpdatePropertiesElastic
-
// ----------------------------------------------------------------------
-// Test calcStressTimeDep()
+// Test _calcStressTimeDep()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcStressTimeDep(void)
-{ // testCalcStressTimeDep
+pylith::materials::TestMaxwellIsotropic3D::test_calcStressTimeDep(void)
+{ // test_calcStressTimeDep
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(false);
@@ -174,13 +191,13 @@
double dt = 2.0e+5;
_matElastic->timeStep(dt);
test_calcStress();
-} // testCalcStressTimeDep
+} // test_calcStressTimeDep
// ----------------------------------------------------------------------
-// Test calcElasticConstsTimeDep()
+// Test _calcElasticConstsTimeDep()
void
-pylith::materials::TestMaxwellIsotropic3D::testCalcElasticConstsTimeDep(void)
-{ // testElasticConstsTimeDep
+pylith::materials::TestMaxwellIsotropic3D::test_calcElasticConstsTimeDep(void)
+{ // test_calcElasticConstsTimeDep
CPPUNIT_ASSERT(0 != _matElastic);
_matElastic->useElasticBehavior(false);
@@ -189,85 +206,96 @@
double dt = 2.0e+5;
_matElastic->timeStep(dt);
test_calcElasticConsts();
-} // testElasticConstsTimeDep
+} // test_calcElasticConstsTimeDep
// ----------------------------------------------------------------------
-// Test updatePropertiesTimeDep()
+// Test _updateStateVarsTimeDep()
void
-pylith::materials::TestMaxwellIsotropic3D::testUpdatePropertiesTimeDep(void)
-{ // testUpdatePropertiesTimeDep
+pylith::materials::TestMaxwellIsotropic3D::test_updateStateVarsTimeDep(void)
+{ // test_updateStateVarsTimeDep
+ // :TODO: Use TestElasticMaterial::test_updateStateVars
+ // instead. This requires moving the calculation of the expected
+ // state vars below to the Python code (where it belongs) and
+ // setting the stateVarsUpdate attribute in the Python object.
+
MaxwellIsotropic3D material;
- MaxwellIsotropic3DTimeDepData data;
-
- const int numParams = data.numParameters;
- const int numParamsQuadPt = data.numParamsQuadPt;
-
material.useElasticBehavior(false);
const double dt = 2.0e+5;
material.timeStep(dt);
- const double viscosity = 1.0e+18;
- const double mu = 3.0e+10;
- const double maxwelltime = viscosity / mu;
-
- const int tensorSize = 6;
- const int initialStateSize = 6;
- double_array totalStrainTpdt(tensorSize);
- double_array totalStrainT(tensorSize);
- double_array visStrainT(tensorSize);
- double_array initialState(initialStateSize);
- for (int i=0; i < tensorSize; ++i) {
- totalStrainTpdt[i] = i;
- totalStrainT[i] = totalStrainTpdt[i] / 2.0;
- visStrainT[i] = totalStrainTpdt[i] / 4.0;
- initialState[i] = 0.1*i;
- } // for
- const double meanStrainTpdt =
- (totalStrainTpdt[0] + totalStrainTpdt[1] + totalStrainTpdt[2]) / 3.0;
- const double meanStrainT =
- (totalStrainT[0] + totalStrainT[1] + totalStrainT[2]) / 3.0;
+ const bool computeStateVars = true;
+
+ const int numLocs = _dataElastic->numLocs;
+ const int numPropsQuadPt = _dataElastic->numPropsQuadPt;
+ const int numVarsQuadPt = _dataElastic->numVarsQuadPt;
+ const int tensorSize = material.tensorSize();
+
+ double_array stress(tensorSize);
+ double_array properties(numPropsQuadPt);
+ double_array stateVars(numVarsQuadPt);
+ double_array strain(tensorSize);
+ double_array initialStress(tensorSize);
+ double_array initialStrain(tensorSize);
+
+ for (int iLoc=0; iLoc < numLocs; ++iLoc) {
+ memcpy(&properties[0], &_dataElastic->properties[iLoc*numPropsQuadPt],
+ numPropsQuadPt*sizeof(double));
+ memcpy(&stateVars[0], &_dataElastic->stateVars[iLoc*numVarsQuadPt],
+ numVarsQuadPt*sizeof(double));
+ memcpy(&strain[0], &_dataElastic->strain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStress[0], &_dataElastic->initialStress[iLoc*tensorSize],
+ tensorSize*sizeof(double));
+ memcpy(&initialStrain[0], &_dataElastic->initialStrain[iLoc*tensorSize],
+ tensorSize*sizeof(double));
- const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+ const double meanStrain = (strain[0] + strain[1] + strain[2]) / 3.0;
+
+ // Compute expected state variables
+ double_array stateVarsE(numVarsQuadPt);
+ const int s_totalStrain = 0;
+ const int s_viscousStrain = s_totalStrain + tensorSize;
- double_array parameters(numParamsQuadPt);
- double_array parametersE(numParamsQuadPt);
- for (int i=0, index=0; i < numParams; ++i)
- for (int j=0; j < data.numParamValues[i]; ++j, ++index) {
- parametersE[index] = i+j;
- parameters[index] = i+j;
- } // for
+ // State variable 'total_strain' should match 'strain'
+ for (int i=0; i < tensorSize; ++i)
+ stateVarsE[s_totalStrain+i] = strain[i];
+
+ // State variable 'viscous_strain'
+ const double meanStrainTpdt =
+ (strain[0] + strain[1] + strain[2]) / 3.0;
+ const double meanStrainT =
+ (stateVars[s_totalStrain+0] +
+ stateVars[s_totalStrain+1] +
+ stateVars[s_totalStrain+2]) / 3.0;
- const int pidMaxwellTime = 3;
- const int pidStrainT = pidMaxwellTime + 1;
- const int pidVisStrain = pidStrainT + 6;
+ const int p_maxwellTime = 3;
+ const double maxwellTime = properties[p_maxwellTime];
+ const double dq = maxwellTime*(1.0-exp(-dt/maxwellTime))/dt;
+ const double expFac = exp(-dt/maxwellTime);
+ double devStrainTpdt = 0.0;
+ double devStrainT = 0.0;
- parameters[pidMaxwellTime] = maxwelltime;
- parametersE[pidMaxwellTime] = maxwelltime;
+ const double diag[] = { 1.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
+ for (int i=0; i < tensorSize; ++i) {
+ devStrainTpdt = strain[i] - diag[i]*meanStrainTpdt;
+ devStrainT = stateVars[s_totalStrain+i] - diag[i]*meanStrainT;
+ stateVarsE[s_viscousStrain+i] =
+ expFac * stateVars[s_viscousStrain+i] +
+ dq * (devStrainTpdt - devStrainT);
+ } //for
- const double dq = maxwelltime*(1.0-exp(-dt/maxwelltime))/dt;
- const double expFac = exp(-dt/maxwelltime);
- double devStrainTpdt = 0.0;
- double devStrainT = 0.0;
+ material._updateStateVars(&stateVars[0], stateVars.size(),
+ &properties[0], properties.size(),
+ &strain[0], strain.size(),
+ &initialStress[0], initialStress.size(),
+ &initialStrain[0], initialStrain.size());
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < numVarsQuadPt; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(stateVarsE[i], stateVars[i], tolerance);
+ } // for
+} // test_updateStateVarsTimeDep
- for (int i=0; i < tensorSize; ++i) {
- devStrainTpdt = totalStrainTpdt[i] - diag[i]*meanStrainTpdt;
- devStrainT = totalStrainT[i] - diag[i]*meanStrainT;
- parameters[pidStrainT+i] = totalStrainT[i];
- parameters[pidVisStrain+i] = visStrainT[i];
- parametersE[pidStrainT+i] = totalStrainTpdt[i];
- parametersE[pidVisStrain+i] =
- expFac * visStrainT[i] + dq * (devStrainTpdt - devStrainT);
- } //for
-
- material._updateProperties(¶meters[0], numParamsQuadPt,
- &totalStrainTpdt[0], tensorSize,
- &initialState[0], initialStateSize);
-
- const double tolerance = 1.0e-06;
- for (int i=0; i < numParamsQuadPt; ++i)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(parametersE[i], parameters[i], tolerance);
-} // testUpdatePropertiesTimeDep
-
// ----------------------------------------------------------------------
// Test _stableTimeStepImplicit()
void
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMaxwellIsotropic3D.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,7 +26,6 @@
/// Namespace for pylith package
namespace pylith {
namespace materials {
- class MaxwellIsotropic3D;
class TestMaxwellIsotropic3D;
class MaxwellIsotropic3DElasticData;
class MaxwellIsotropic3DTimeDepData;
@@ -40,22 +39,29 @@
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
CPPUNIT_TEST_SUITE( TestMaxwellIsotropic3D );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testTensorSize );
CPPUNIT_TEST( testDBToProperties );
- CPPUNIT_TEST( testDBValues );
- CPPUNIT_TEST( testProperties );
+ CPPUNIT_TEST( testNonDimProperties );
+ CPPUNIT_TEST( testDimProperties );
+ CPPUNIT_TEST( testDBToStateVars );
+ CPPUNIT_TEST( testNonDimStateVars );
+ CPPUNIT_TEST( testDimStateVars );
CPPUNIT_TEST( test_calcDensity );
+ CPPUNIT_TEST( test_stableTimeStepImplicit );
+ // Need to test Maxwell viscoelastic specific behavior.
CPPUNIT_TEST( testTimeStep );
CPPUNIT_TEST( testUseElasticBehavior );
- CPPUNIT_TEST( testCalcStressElastic );
- CPPUNIT_TEST( testCalcStressTimeDep );
- CPPUNIT_TEST( testCalcElasticConstsElastic );
- CPPUNIT_TEST( testCalcElasticConstsTimeDep );
- CPPUNIT_TEST( testUsesUpdateProperties );
- CPPUNIT_TEST( testUpdatePropertiesElastic );
- CPPUNIT_TEST( testUpdatePropertiesTimeDep );
- CPPUNIT_TEST( test_stableTimeStepImplicit );
+ CPPUNIT_TEST( testHasStateVars );
+ CPPUNIT_TEST( test_calcStressElastic );
+ CPPUNIT_TEST( test_calcStressTimeDep );
+ CPPUNIT_TEST( test_calcElasticConstsElastic );
+ CPPUNIT_TEST( test_calcElasticConstsTimeDep );
+ CPPUNIT_TEST( test_updateStateVarsElastic );
+ CPPUNIT_TEST( test_updateStateVarsTimeDep );
+
CPPUNIT_TEST_SUITE_END();
// PUBLIC METHODS /////////////////////////////////////////////////////
@@ -70,26 +76,26 @@
/// Test useElasticBehavior()
void testUseElasticBehavior(void);
- /// Test usesUpdateProperties()
- void testUsesUpdateProperties(void);
+ /// Test hasStateVars()
+ void testHasStateVars(void);
- /// Test calcStressElastic()
- void testCalcStressElastic(void);
+ /// Test _calcStressElastic()
+ void test_calcStressElastic(void);
- /// Test calcStressTimeDep()
- void testCalcStressTimeDep(void);
+ /// Test _calcElasticConstsElastic()
+ void test_calcElasticConstsElastic(void);
- /// Test calcElasticConstsElastic()
- void testCalcElasticConstsElastic(void);
+ /// Test _updateStateVarsElastic()
+ void test_updateStateVarsElastic(void);
- /// Test calcElasticConstsTimeDep()
- void testCalcElasticConstsTimeDep(void);
+ /// Test _calcStressTimeDep()
+ void test_calcStressTimeDep(void);
- /// Test updatePropertiesElastic()
- void testUpdatePropertiesElastic(void);
+ /// Test _calcElasticConstsTimeDep()
+ void test_calcElasticConstsTimeDep(void);
- /// Test updatePropertiesTimeDep()
- void testUpdatePropertiesTimeDep(void);
+ /// Test _updateStatevarsTimeDep()
+ void test_updateStateVarsTimeDep(void);
/// Test _stableTimeStepImplicit()
void test_stableTimeStepImplicit(void);
Copied: short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMetadata.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,219 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestMetadata.hh" // Implementation of class methods
+
+#include "pylith/materials/Metadata.hh" // USES Metadata
+#include "pylith/utils/array.hh" // USES double_array
+
+#include <cstring> // USES strcmp()
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::materials::TestMetadata );
+
+// ----------------------------------------------------------------------
+namespace pylith {
+ namespace materials {
+ namespace _TestMetadata {
+ const Metadata::ParamDescription properties[] = {
+ { "one", 1, pylith::topology::FieldBase::SCALAR },
+ { "two", 2, pylith::topology::FieldBase::VECTOR },
+ { "three", 3, pylith::topology::FieldBase::TENSOR },
+ };
+ const int numProperties = 3;
+ const char* dbProperties[] = {
+ "prop_one", "prop_two", "prop_three", "prop_four",
+ };
+ const int numDBProperties = 4;
+ const Metadata::ParamDescription stateVars[] = {
+ { "var1", 1, pylith::topology::FieldBase::TENSOR },
+ { "var2", 3, pylith::topology::FieldBase::VECTOR },
+ };
+ const int numStateVars = 2;
+ const char* dbStateVars[] = {
+ "var_one", "var_two", "var_three",
+ };
+ const int numDBStateVars = 3;
+ } // _TestMetadata
+ } // materials
+} // pylith
+
+// ----------------------------------------------------------------------
+// Setup test data.
+void
+pylith::materials::TestMetadata::setUp(void)
+{ // setUp
+ _metadata = new Metadata(_TestMetadata::properties,
+ _TestMetadata::numProperties,
+ _TestMetadata::dbProperties,
+ _TestMetadata::numDBProperties,
+ _TestMetadata::stateVars,
+ _TestMetadata::numStateVars,
+ _TestMetadata::dbStateVars,
+ _TestMetadata::numDBStateVars);
+ CPPUNIT_ASSERT(0 != _metadata);
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down test data.
+void
+pylith::materials::TestMetadata::tearDown(void)
+{ // tearDown
+ delete _metadata; _metadata = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::materials::TestMetadata::testConstructor(void)
+{ // testConstructor
+ CPPUNIT_ASSERT(0 != _metadata);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test copy constructor.
+void
+pylith::materials::TestMetadata::testCopyConstructor(void)
+{ // testCopyConstructor
+ Metadata m(*_metadata);
+
+ delete _metadata; _metadata = &m;
+ testProperties();
+ testStateVars();
+ testFiberDim();
+ testFieldType();
+ testDBProperties();
+ testDBStateVars();
+
+ _metadata = 0;
+} // testCopyConstructor
+
+// ----------------------------------------------------------------------
+// Test properties().
+void
+pylith::materials::TestMetadata::testProperties(void)
+{ // testProperties
+ CPPUNIT_ASSERT(0 != _metadata);
+
+ const string_vector& properties = _metadata->properties();
+ const size_t numProperties = _TestMetadata::numProperties;
+ CPPUNIT_ASSERT_EQUAL(numProperties, properties.size());
+ for (size_t i=0; i < numProperties; ++i)
+ CPPUNIT_ASSERT_EQUAL(std::string(_TestMetadata::properties[i].name),
+ properties[i]);
+} // testProperties
+
+// ----------------------------------------------------------------------
+// Test stateVars().
+void
+pylith::materials::TestMetadata::testStateVars(void)
+{ // testStateVars
+ CPPUNIT_ASSERT(0 != _metadata);
+
+ const string_vector& stateVars = _metadata->stateVars();
+ const size_t numStateVars = _TestMetadata::numStateVars;
+ CPPUNIT_ASSERT_EQUAL(numStateVars, stateVars.size());
+ for (size_t i=0; i < numStateVars; ++i)
+ CPPUNIT_ASSERT_EQUAL(std::string(_TestMetadata::stateVars[i].name),
+ stateVars[i]);
+} // testStateVars
+
+// ----------------------------------------------------------------------
+// Test fiberDim().
+void
+pylith::materials::TestMetadata::testFiberDim(void)
+{ // testFiberDim
+ CPPUNIT_ASSERT(0 != _metadata);
+
+ { // check property
+ const int index = 1;
+ const char* property = _TestMetadata::properties[index].name;
+ const int fiberDimE = _TestMetadata::properties[index].fiberDim;
+ const int fiberDim = _metadata->fiberDim(property, Metadata::PROPERTY);
+ CPPUNIT_ASSERT_EQUAL(fiberDimE, fiberDim);
+ } // check property
+
+ { // check state variable
+ const int index = 1;
+ const char* stateVar = _TestMetadata::stateVars[index].name;
+ const int fiberDimE = _TestMetadata::stateVars[index].fiberDim;
+ const int fiberDim = _metadata->fiberDim(stateVar, Metadata::STATEVAR);
+ CPPUNIT_ASSERT_EQUAL(fiberDimE, fiberDim);
+ } // check state variable
+} // testFiberDim
+
+// ----------------------------------------------------------------------
+// Test fieldType().
+void
+pylith::materials::TestMetadata::testFieldType(void)
+{ // testFieldType
+ CPPUNIT_ASSERT(0 != _metadata);
+
+ { // check property
+ const int index = 2;
+ const char* property = _TestMetadata::properties[index].name;
+ const topology::FieldBase::VectorFieldEnum fieldTypeE =
+ _TestMetadata::properties[index].fieldType;
+ const topology::FieldBase::VectorFieldEnum fieldType =
+ _metadata->fieldType(property, Metadata::PROPERTY);
+ CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldType);
+ } // check property
+
+ { // check state variable
+ const int index = 0;
+ const char* stateVar = _TestMetadata::stateVars[index].name;
+ const topology::FieldBase::VectorFieldEnum fieldTypeE =
+ _TestMetadata::stateVars[index].fieldType;
+ const topology::FieldBase::VectorFieldEnum fieldType =
+ _metadata->fieldType(stateVar, Metadata::STATEVAR);
+ CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldType);
+ } // check state variable
+} // testFieldType
+
+// ----------------------------------------------------------------------
+// Test dbProperties().
+void
+pylith::materials::TestMetadata::testDBProperties(void)
+{ // testDBProperties
+ CPPUNIT_ASSERT(0 != _metadata);
+
+ const int numDBProperties = _TestMetadata::numDBProperties;
+ CPPUNIT_ASSERT_EQUAL(numDBProperties, _metadata->numDBProperties());
+
+ const char* const* dbPropertiesE = _TestMetadata::dbProperties;
+ const char* const* dbProperties = _metadata->dbProperties();
+
+ for (int i=0; i < numDBProperties; ++i)
+ CPPUNIT_ASSERT(0 == strcmp(dbPropertiesE[i], dbProperties[i]));
+} // testDBProperties
+
+// ----------------------------------------------------------------------
+// Test dbStateVars().
+void
+pylith::materials::TestMetadata::testDBStateVars(void)
+{ // testDBStateVars
+ CPPUNIT_ASSERT(0 != _metadata);
+
+ const int numDBStateVars = _TestMetadata::numDBStateVars;
+ CPPUNIT_ASSERT_EQUAL(numDBStateVars, _metadata->numDBStateVars());
+
+ const char* const* dbStateVarsE = _TestMetadata::dbStateVars;
+ const char* const* dbStateVars = _metadata->dbStateVars();
+
+ for (int i=0; i < numDBStateVars; ++i)
+ CPPUNIT_ASSERT(0 == strcmp(dbStateVarsE[i], dbStateVars[i]));
+} // testDBStateVars
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/TestMetadata.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/TestMetadata.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/materials/TestMetadata.hh
+ *
+ * @brief C++ TestMetadata object
+ *
+ * C++ unit testing for Material.
+ */
+
+#if !defined(pylith_materials_testmetadata_hh)
+#define pylith_materials_testmetadata_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/materials/materialsfwd.hh" // forward declarations
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace materials {
+ class TestMetadata;
+ } // materials
+} // pylith
+
+/// C++ unit testing for Material
+class pylith::materials::TestMetadata : public CppUnit::TestFixture
+{ // class TestMetadata
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestMetadata );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testCopyConstructor );
+ CPPUNIT_TEST( testProperties );
+ CPPUNIT_TEST( testStateVars );
+ CPPUNIT_TEST( testFiberDim );
+ CPPUNIT_TEST( testFieldType );
+ CPPUNIT_TEST( testDBProperties );
+ CPPUNIT_TEST( testDBStateVars );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup test data.
+ void setUp(void);
+
+ /// Tear down test data.
+ void tearDown(void);
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test copy constructor.
+ void testCopyConstructor(void);
+
+ /// Test properties().
+ void testProperties(void);
+
+ /// Test stateVars().
+ void testStateVars(void);
+
+ /// Test fiberDim().
+ void testFiberDim(void);
+
+ /// Test fieldType().
+ void testFieldType(void);
+
+ /// Test dbProperties() and numDBProperties().
+ void testDBProperties(void);
+
+ /// Test dbStateVars() and numDBStateVars().
+ void testDBStateVars(void);
+
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ Metadata* _metadata; ///< Object for testing
+
+}; // class TestMetadata
+
+#endif // pylith_materials_testmetadata_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 3
+numElasticConsts = 21
+tensorSize = 6
+
# ElasticIsotropic3D class
class ElasticIsotropic3D(ElasticMaterialApp):
"""
@@ -35,67 +39,85 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 3
+ numLocs = 2
- self.numDBValues = 3
- self.numInitialStateValues = 6
- self.dbValues = ["density", "vs", "vp"]
- self.initialStateDBValues = ["stress_xx", "stress_yy", "stress_zz",
- "stress_xy", "stress_yz", "stress_xz" ]
- self.numParameters = 3
- self.numParamValues = [1, 1, 1]
- self.parameterNames = ["density", "mu", "lambda"]
+ self.dimension = dimension
+ self.numLocs = numLocs
+
+ self.dbPropertyValues = ["density", "vs", "vp"]
+ self.propertyValues = ["density", "mu", "lambda"]
+ self.numPropertyValues = numpy.array([1, 1, 1], dtype=numpy.int32)
densityA = 2500.0
vsA = 3000.0
vpA = vsA*3**0.5
- strainA = [1.1e-4, 2.2e-4, 3.3e-4, 4.4e-4, 5.5e-4, 6.6e-4]
- initialStateA = [1.2e4, 2.3e4, 3.4e4, 4.5e4, 5.6e4, 6.7e4]
+ strainA = [1.1e-4, 1.2e-4, 1.3e-4, 1.4e-4, 1.5e-4, 1.6e-4]
+ initialStressA = [2.1e4, 2.2e4, 2.3e4, 2.4e4, 2.5e4, 2.6e4]
+ initialStrainA = [3.1e-4, 3.2e-4, 3.3e-4, 3.4e-4, 3.5e-6, 3.6e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
- strainB = [1.2e-4, 2.3e-4, 3.4e-4, 4.5e-4, 5.6e-4, 6.7e-4]
- initialStateB = [2.1e4, 3.2e4, 4.3e4, 5.4e4, 6.5e4, 7.6e4]
-
- self.dbData = numpy.array([ [densityA, vsA, vpA],
- [densityB, vsB, vpB] ],
- dtype=numpy.float64)
- muA = vsA*vsA*densityA
- lambdaA = vpA*vpA*densityA - 2.0*muA
+ strainB = [4.1e-4, 4.2e-4, 4.3e-4, 4.4e-4, 4.5e-4, 4.6e-4]
+ initialStressB = [5.1e4, 5.2e4, 5.3e4, 5.4e4, 5.5e4, 5.6e4]
+ initialStrainB = [6.1e-4, 6.2e-4, 6.3e-4, 6.4e-4, 6.5e-6, 6.6e-4]
muB = vsB*vsB*densityB
lambdaB = vpB*vpB*densityB - 2.0*muB
- self.parameterData = numpy.array([ [densityA, muA, lambdaA],
- [densityB, muB, lambdaB] ],
+
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
+
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA],
+ [densityB, vsB, vpB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA],
+ [densityB, muB, lambdaB] ],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0],
+ [densityB/density0, muB/mu0, lambdaB/mu0] ],
+ dtype=numpy.float64)
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
dtype=numpy.float64)
- self.numLocs = 2
- numElasticConsts = 21
- self.density = numpy.array([densityA, densityB],
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
- self.strain = numpy.array([strainA, strainB],
+ self.strain = numpy.array([strainA,
+ strainB],
dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 6), dtype=numpy.float64)
- self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
- dtype=numpy.float64)
+ stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
+ elasticConsts = numpy.zeros( (numLocs, numElasticConsts),
+ dtype=numpy.float64)
- (self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, densityA, muA, lambdaA,
- initialStateA)
- (self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, densityB, muB, lambdaB,
- initialStateB)
+ (elasticConsts[0,:], stress[0,:]) = \
+ self._calcStress(strainA, densityA, muA, lambdaA,
+ initialStressA, initialStrainA)
+ (elasticConsts[1,:], stress[1,:]) = \
+ self._calcStress(strainB, densityB, muB, lambdaB,
+ initialStressB, initialStrainB)
+
+ self.stress = stress
+ self.elasticConsts = elasticConsts
return
- def _calcStress(self, strainV, densityV, muV, lambdaV, initialStateV):
+ def _calcStress(self, strainV, densityV, muV, lambdaV,
+ initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
"""
@@ -127,8 +149,9 @@
C2323, C2313,
C1313], dtype=numpy.float64)
- strain = numpy.reshape(strainV, (6,1))
- initialState = numpy.reshape(initialStateV, (6,1))
+ strain = numpy.reshape(strainV, (tensorSize,1))
+ initialStress = numpy.reshape(initialStressV, (tensorSize,1))
+ initialStrain = numpy.reshape(initialStrainV, (tensorSize,1))
elastic = numpy.array([ [C1111, C1122, C1133, C1112, C1123, C1113],
[C1122, C2222, C2233, C2212, C2223, C2213],
[C1133, C2233, C3333, C3312, C3323, C3313],
@@ -136,7 +159,7 @@
[C1123, C2223, C3323, C1223, C2323, C2313],
[C1113, C2213, C3313, C1213, C2313, C1313] ],
dtype=numpy.float64)
- stress = numpy.dot(elastic, strain) + initialState
+ stress = numpy.dot(elastic,strain-initialStrain) + initialStress
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,40 +17,47 @@
const int pylith::materials::ElasticIsotropic3DData::_dimension = 3;
-const int pylith::materials::ElasticIsotropic3DData::_numDBValues = 3;
+const int pylith::materials::ElasticIsotropic3DData::_numLocs = 2;
-const int pylith::materials::ElasticIsotropic3DData::_numInitialStateValues = 6;
+const int pylith::materials::ElasticIsotropic3DData::_numProperties = 3;
-const int pylith::materials::ElasticIsotropic3DData::_numParameters = 3;
+const int pylith::materials::ElasticIsotropic3DData::_numStateVars = 0;
-const int pylith::materials::ElasticIsotropic3DData::_numParamsQuadPt = 3;
+const int pylith::materials::ElasticIsotropic3DData::_numDBProperties = 3;
-const int pylith::materials::ElasticIsotropic3DData::_numLocs = 2;
+const int pylith::materials::ElasticIsotropic3DData::_numDBStateVars = 0;
+const int pylith::materials::ElasticIsotropic3DData::_numPropsQuadPt = 3;
+
+const int pylith::materials::ElasticIsotropic3DData::_numVarsQuadPt = 0;
+
+const double pylith::materials::ElasticIsotropic3DData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::ElasticIsotropic3DData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::ElasticIsotropic3DData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::ElasticIsotropic3DData::_densityScale = 1.00000000e+03;
+
const double pylith::materials::ElasticIsotropic3DData::_dtStableImplicit = 1.00000000e+30;
-const int pylith::materials::ElasticIsotropic3DData::_numParamValues[] = {
+const int pylith::materials::ElasticIsotropic3DData::_numPropertyValues[] = {
1,
1,
1,
};
-const char* pylith::materials::ElasticIsotropic3DData::_dbValues[] = {
+const int* pylith::materials::ElasticIsotropic3DData::_numStateVarValues = 0;
+
+const char* pylith::materials::ElasticIsotropic3DData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
};
-const char* pylith::materials::ElasticIsotropic3DData::_initialStateDBValues[] = {
-"stress_xx",
-"stress_yy",
-"stress_zz",
-"stress_xy",
-"stress_yz",
-"stress_xz",
-};
+const char** pylith::materials::ElasticIsotropic3DData::_dbStateVarValues = 0;
-const double pylith::materials::ElasticIsotropic3DData::_dbData[] = {
+const double pylith::materials::ElasticIsotropic3DData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -59,22 +66,9 @@
2.07846097e+03,
};
-const double pylith::materials::ElasticIsotropic3DData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
-};
+const double* pylith::materials::ElasticIsotropic3DData::_dbStateVars = 0;
-const double pylith::materials::ElasticIsotropic3DData::_parameterData[] = {
+const double pylith::materials::ElasticIsotropic3DData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
@@ -83,21 +77,19 @@
2.88000000e+09,
};
-const double pylith::materials::ElasticIsotropic3DData::_initialState[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double* pylith::materials::ElasticIsotropic3DData::_stateVars = 0;
+
+const double pylith::materials::ElasticIsotropic3DData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
};
+const double* pylith::materials::ElasticIsotropic3DData::_stateVarsNondim = 0;
+
const double pylith::materials::ElasticIsotropic3DData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -105,32 +97,32 @@
const double pylith::materials::ElasticIsotropic3DData::_strain[] = {
1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
+ 1.20000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
4.40000000e-04,
- 5.50000000e-04,
- 6.60000000e-04,
- 1.20000000e-04,
- 2.30000000e-04,
- 3.40000000e-04,
4.50000000e-04,
- 5.60000000e-04,
- 6.70000000e-04,
+ 4.60000000e-04,
};
const double pylith::materials::ElasticIsotropic3DData::_stress[] = {
- 1.98120000e+07,
- 2.47730000e+07,
- 2.97340000e+07,
- 1.98450000e+07,
- 2.48060000e+07,
- 2.97670000e+07,
- 2.69940000e+06,
- 3.34400000e+06,
- 3.98860000e+06,
- 2.64600000e+06,
- 3.29060000e+06,
- 3.93520000e+06,
+ -2.24790000e+07,
+ -2.24780000e+07,
+ -2.24770000e+07,
+ -8.97600000e+06,
+ 6.61750000e+06,
+ -8.97400000e+06,
+ -2.82900000e+06,
+ -2.82800000e+06,
+ -2.82700000e+06,
+ -1.09800000e+06,
+ 2.60956000e+06,
+ -1.09600000e+06,
};
const double pylith::materials::ElasticIsotropic3DData::_elasticConsts[] = {
@@ -178,26 +170,70 @@
5.76000000e+09,
};
+const double pylith::materials::ElasticIsotropic3DData::_initialStress[] = {
+ 2.10000000e+04,
+ 2.20000000e+04,
+ 2.30000000e+04,
+ 2.40000000e+04,
+ 2.50000000e+04,
+ 2.60000000e+04,
+ 5.10000000e+04,
+ 5.20000000e+04,
+ 5.30000000e+04,
+ 5.40000000e+04,
+ 5.50000000e+04,
+ 5.60000000e+04,
+};
+
+const double pylith::materials::ElasticIsotropic3DData::_initialStrain[] = {
+ 3.10000000e-04,
+ 3.20000000e-04,
+ 3.30000000e-04,
+ 3.40000000e-04,
+ 3.50000000e-06,
+ 3.60000000e-04,
+ 6.10000000e-04,
+ 6.20000000e-04,
+ 6.30000000e-04,
+ 6.40000000e-04,
+ 6.50000000e-06,
+ 6.60000000e-04,
+};
+
+const double* pylith::materials::ElasticIsotropic3DData::_stateVarsUpdated = 0;
+
pylith::materials::ElasticIsotropic3DData::ElasticIsotropic3DData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::ElasticIsotropic3DData::~ElasticIsotropic3DData(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticIsotropic3DData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int* _numStateVarValues;
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char** _dbStateVarValues;
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double* _dbStateVars;
- static const double _initialState[];
+ static const double _properties[];
+ static const double* _stateVars;
+
+ static const double _propertiesNondim[];
+
+ static const double* _stateVarsNondim;
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_elasticisotropic3ddata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialApp.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialApp.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialApp.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -58,26 +58,38 @@
Script.__init__(self, name)
# Material information
- self.dimension = None
- self.numDBValues = None
- self.numInitialStateValues = None
- self.numParameters = None
- self.numParamsQuadPt = None
- self.numParamValues = None
- self.dbValues = None
- self.initialStateDBValues = None
- self.dbData = None
- self.initialStateDBData = None
- self.parameterData = None
- self.initialState = None
+ self.dimension = 0
+ self.numLocs = 0
+ self.numProperties = 0
+ self.numStateVars = 0
+ self.numDBProperties = 0
+ self.numDBStateVars = 0
+ self.numPropsQuadPt = 0
+ self.numVarsQuadPt = 0
+ self.numPropertyValues = None
+ self.numStateVarValues = None
+ self.dbPropertyValues = None
+ self.dbStateVarValues = None
+ self.dbProperties = None
+ self.dbStateVars = None
+ self.properties = None
+ self.stateVars = None
+ self.propertiesNondim = None
+ self.stateVarsNondim = None
+ self.lengthScale = 0
+ self.timeScale = 0
+ self.pressureScale = 0
+ self.densityScale = 0
# Elastic material information
- self.numLocs = None
+ self.dtStableImplicit = 1.0e+30
self.density = None
self.strain = None
self.stress = None
self.elasticConsts = None
- self.dtStableImplicit = 1.0e+30
+ self.initialStress = None
+ self.initialStrain = None
+ self.stateVarsUpdated = None
return
@@ -102,45 +114,86 @@
def _initData(self):
- self.numParamsQuadPt = numpy.sum(self.numParamValues)
+ self.numDBProperties = len(self.dbPropertyValues)
+ if not self.dbStateVarValues is None:
+ self.numDBStateVars = len(self.dbStateVarValues)
+ self.numPropsQuadPt = numpy.sum(self.numPropertyValues)
+ if not self.numStateVarValues is None:
+ self.numVarsQuadPt = numpy.sum(self.numStateVarValues)
+ self.numProperties = self.numPropertyValues.shape[0]
+ if not self.numStateVarValues is None:
+ self.numStateVars = self.numStateVarValues.shape[0]
self.data.addScalar(vtype="int", name="_dimension",
value=self.dimension,
format="%d")
- self.data.addScalar(vtype="int", name="_numDBValues",
- value=self.numDBValues,
+ self.data.addScalar(vtype="int", name="_numLocs",
+ value=self.numLocs,
format="%d")
- self.data.addScalar(vtype="int", name="_numInitialStateValues",
- value=self.numInitialStateValues,
+ self.data.addScalar(vtype="int", name="_numProperties",
+ value=self.numProperties,
format="%d")
- self.data.addScalar(vtype="int", name="_numParameters",
- value=self.numParameters,
+ self.data.addScalar(vtype="int", name="_numStateVars",
+ value=self.numStateVars,
format="%d")
- self.data.addScalar(vtype="int", name="_numParamsQuadPt",
- value=self.numParamsQuadPt,
+ self.data.addScalar(vtype="int", name="_numDBProperties",
+ value=self.numDBProperties,
format="%d")
- self.data.addArray(vtype="int", name="_numParamValues",
- values=self.numParamValues,
+ self.data.addScalar(vtype="int", name="_numDBStateVars",
+ value=self.numDBStateVars,
+ format="%d")
+ self.data.addScalar(vtype="int", name="_numPropsQuadPt",
+ value=self.numPropsQuadPt,
+ format="%d")
+ self.data.addScalar(vtype="int", name="_numVarsQuadPt",
+ value=self.numVarsQuadPt,
+ format="%d")
+ self.data.addArray(vtype="int", name="_numPropertyValues",
+ values=self.numPropertyValues,
format="%d", ncols=1)
- self.data.addArray(vtype="char*", name="_dbValues", values=self.dbValues,
+ self.data.addArray(vtype="int", name="_numStateVarValues",
+ values=self.numStateVarValues,
+ format="%d", ncols=1)
+ self.data.addArray(vtype="char*", name="_dbPropertyValues",
+ values=self.dbPropertyValues,
format="\"%s\"", ncols=1)
- self.data.addArray(vtype="char*", name="_initialStateDBValues",
- values=self.initialStateDBValues,
+ self.data.addArray(vtype="char*", name="_dbStateVarValues",
+ values=self.dbStateVarValues,
format="\"%s\"", ncols=1)
- self.data.addArray(vtype="double", name="_dbData", values=self.dbData,
+ self.data.addArray(vtype="double", name="_dbProperties",
+ values=self.dbProperties,
format="%16.8e", ncols=1)
- self.data.addArray(vtype="double", name="_initialStateDBData",
- values=self.initialStateDBData,
+ self.data.addArray(vtype="double", name="_dbStateVars",
+ values=self.dbStateVars,
format="%16.8e", ncols=1)
- self.data.addArray(vtype="double", name="_parameterData",
- values=self.parameterData,
+ self.data.addArray(vtype="double", name="_properties",
+ values=self.properties,
format="%16.8e", ncols=1)
- self.data.addArray(vtype="double", name="_initialState",
- values=self.initialState,
+ self.data.addArray(vtype="double", name="_stateVars",
+ values=self.stateVars,
format="%16.8e", ncols=1)
+ self.data.addArray(vtype="double", name="_propertiesNondim",
+ values=self.propertiesNondim,
+ format="%16.8e", ncols=1)
+ self.data.addArray(vtype="double", name="_stateVarsNondim",
+ values=self.stateVarsNondim,
+ format="%16.8e", ncols=1)
+ self.data.addScalar(vtype="double", name="_lengthScale",
+ value=self.lengthScale,
+ format="%16.8e")
+ self.data.addScalar(vtype="double", name="_timeScale",
+ value=self.timeScale,
+ format="%16.8e")
+ self.data.addScalar(vtype="double", name="_pressureScale",
+ value=self.pressureScale,
+ format="%16.8e")
+ self.data.addScalar(vtype="double", name="_densityScale",
+ value=self.densityScale,
+ format="%16.8e")
- self.data.addScalar(vtype="int", name="_numLocs", value=self.numLocs,
- format="%d")
+ self.data.addScalar(vtype="double", name="_dtStableImplicit",
+ value=self.dtStableImplicit,
+ format="%16.8e")
self.data.addArray(vtype="double", name="_density",
values=self.density,
format="%16.8e", ncols=1)
@@ -153,9 +206,15 @@
self.data.addArray(vtype="double", name="_elasticConsts",
values=self.elasticConsts,
format="%16.8e", ncols=1)
- self.data.addScalar(vtype="double", name="_dtStableImplicit",
- value=self.dtStableImplicit,
- format="%16.8e")
+ self.data.addArray(vtype="double", name="_initialStress",
+ values=self.initialStress,
+ format="%16.8e", ncols=1)
+ self.data.addArray(vtype="double", name="_initialStrain",
+ values=self.initialStrain,
+ format="%16.8e", ncols=1)
+ self.data.addArray(vtype="double", name="_stateVarsUpdated",
+ values=self.stateVarsUpdated,
+ format="%16.8e", ncols=1)
return
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,7 +17,10 @@
density(0),
strain(0),
stress(0),
- elasticConsts(0)
+ elasticConsts(0),
+ initialStress(0),
+ initialStrain(0),
+ stateVarsUpdated(0)
{ // constructor
} // constructor
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticMaterialData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -36,12 +36,17 @@
// PUBLIC MEMBERS ///////////////////////////////////////////////////////
public:
- double dtStableImplicit; ///< Stable time step for implicit time stepping
- double* density; ///< Density at locations
- double* strain; ///< Strain at locations
- double* stress; ///< Stress at locations
- double* elasticConsts; ///< Elastic constants at locations
+ double dtStableImplicit; ///< Stable time step for implicit time stepping.
+ double* density; ///< Density at location.
+ double* strain; ///< Strain at location.
+ double* stress; ///< Stress at location.
+ double* elasticConsts; ///< Elastic constants at location.
+ double* initialStress; ///< Initial stress at location.
+ double* initialStrain; ///< Initial strain at location.
+
+ double* stateVarsUpdated; ///< Updated state variables at location.
+
};
#endif // pylith_materials_elasticmaterialdata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrain.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrain.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 2
+numElasticConsts = 6
+tensorSize = 3
+
# ElasticPlaneStrain class
class ElasticPlaneStrain(ElasticMaterialApp):
"""
@@ -35,66 +39,84 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 2
+ numLocs = 2
- self.numDBValues = 3
- self.numInitialStateValues = 3
- self.dbValues = ["density", "vs", "vp"]
- self.initialStateDBValues = ["stress_xx", "stress_yy", "stress_xy"]
- self.numParameters = 3
- self.numParamValues = [1, 1, 1]
- self.parameterNames = ["density", "mu", "lambda"]
+ self.dimension = dimension
+ self.numLocs = numLocs
+
+ self.dbPropertyValues = ["density", "vs", "vp"]
+ self.propertyValues = ["density", "mu", "lambda"]
+ self.numPropertyValues = numpy.array([1, 1, 1], dtype=numpy.int32)
densityA = 2500.0
vsA = 3000.0
vpA = vsA*3**0.5
- strainA = [1.1e-4, 2.2e-4, 3.3e-4]
- initialStateA = [1.2e4, 2.1e4, 3.2e4]
+ strainA = [1.1e-4, 1.2e-4, 1.3e-4]
+ initialStressA = [2.1e4, 2.2e4, 2.3e4]
+ initialStrainA = [3.1e-4, 3.2e-4, 3.3e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
- strainB = [1.2e-4, 2.3e-4, 3.4e-4]
- initialStateB = [2.1e4, 3.2e4, 4.3e4]
-
- self.dbData = numpy.array([ [densityA, vsA, vpA],
- [densityB, vsB, vpB] ],
- dtype=numpy.float64)
- muA = vsA*vsA*densityA
- lambdaA = vpA*vpA*densityA - 2.0*muA
+ strainB = [4.1e-4, 4.2e-4, 4.3e-4]
+ initialStressB = [5.1e4, 5.2e4, 5.3e4]
+ initialStrainB = [6.1e-4, 6.2e-4, 6.3e-4]
muB = vsB*vsB*densityB
lambdaB = vpB*vpB*densityB - 2.0*muB
- self.parameterData = numpy.array([ [densityA, muA, lambdaA],
- [densityB, muB, lambdaB] ],
+
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
+
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA],
+ [densityB, vsB, vpB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA], [densityB, muB, lambdaB] ],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0],
+ [densityB/density0, muB/mu0, lambdaB/mu0] ],
+ dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
+ dtype=numpy.float64)
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
- self.numLocs = 2
- numElasticConsts = 6
- self.density = numpy.array([densityA, densityB],
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
- self.strain = numpy.array([strainA, strainB],
+ self.strain = numpy.array([strainA,
+ strainB],
dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 3), dtype=numpy.float64)
- self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
- dtype=numpy.float64)
+
+ stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
+ elasticConsts = numpy.zeros( (numLocs, numElasticConsts),
+ dtype=numpy.float64)
- (self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, densityA, muA, lambdaA,
- initialStateA)
- (self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, densityB, muB, lambdaB,
- initialStateB)
+ (elasticConsts[0,:], stress[0,:]) = \
+ self._calcStress(strainA, densityA, muA, lambdaA,
+ initialStressA, initialStrainA)
+ (elasticConsts[1,:], stress[1,:]) = \
+ self._calcStress(strainB, densityB, muB, lambdaB,
+ initialStressB, initialStrainB)
+
+ self.stress = stress
+ self.elasticConsts = elasticConsts
return
- def _calcStress(self, strainV, densityV, muV, lambdaV, initialStateV):
+ def _calcStress(self, strainV, densityV, muV, lambdaV,
+ initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
"""
@@ -108,13 +130,14 @@
C2222, C2212,
C1212], dtype=numpy.float64)
- strain = numpy.reshape(strainV, (3,1))
+ strain = numpy.reshape(strainV, (tensorSize,1))
elastic = numpy.array([ [C1111, C1122, C1112],
[C1122, C2222, C2212],
[C1112, C2212, C1212] ],
dtype=numpy.float64)
- initialState = numpy.reshape(initialStateV, (3,1))
- stress = numpy.dot(elastic, strain) + initialState
+ initialStress = numpy.reshape(initialStressV, (tensorSize,1))
+ initialStrain = numpy.reshape(initialStrainV, (tensorSize,1))
+ stress = numpy.dot(elastic,strain-initialStrain) + initialStress
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,37 +17,47 @@
const int pylith::materials::ElasticPlaneStrainData::_dimension = 2;
-const int pylith::materials::ElasticPlaneStrainData::_numDBValues = 3;
+const int pylith::materials::ElasticPlaneStrainData::_numLocs = 2;
-const int pylith::materials::ElasticPlaneStrainData::_numInitialStateValues = 3;
+const int pylith::materials::ElasticPlaneStrainData::_numProperties = 3;
-const int pylith::materials::ElasticPlaneStrainData::_numParameters = 3;
+const int pylith::materials::ElasticPlaneStrainData::_numStateVars = 0;
-const int pylith::materials::ElasticPlaneStrainData::_numParamsQuadPt = 3;
+const int pylith::materials::ElasticPlaneStrainData::_numDBProperties = 3;
-const int pylith::materials::ElasticPlaneStrainData::_numLocs = 2;
+const int pylith::materials::ElasticPlaneStrainData::_numDBStateVars = 0;
+const int pylith::materials::ElasticPlaneStrainData::_numPropsQuadPt = 3;
+
+const int pylith::materials::ElasticPlaneStrainData::_numVarsQuadPt = 0;
+
+const double pylith::materials::ElasticPlaneStrainData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::ElasticPlaneStrainData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::ElasticPlaneStrainData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::ElasticPlaneStrainData::_densityScale = 1.00000000e+03;
+
const double pylith::materials::ElasticPlaneStrainData::_dtStableImplicit = 1.00000000e+30;
-const int pylith::materials::ElasticPlaneStrainData::_numParamValues[] = {
+const int pylith::materials::ElasticPlaneStrainData::_numPropertyValues[] = {
1,
1,
1,
};
-const char* pylith::materials::ElasticPlaneStrainData::_dbValues[] = {
+const int* pylith::materials::ElasticPlaneStrainData::_numStateVarValues = 0;
+
+const char* pylith::materials::ElasticPlaneStrainData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
};
-const char* pylith::materials::ElasticPlaneStrainData::_initialStateDBValues[] = {
-"stress_xx",
-"stress_yy",
-"stress_xy",
-};
+const char** pylith::materials::ElasticPlaneStrainData::_dbStateVarValues = 0;
-const double pylith::materials::ElasticPlaneStrainData::_dbData[] = {
+const double pylith::materials::ElasticPlaneStrainData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -56,16 +66,9 @@
2.07846097e+03,
};
-const double pylith::materials::ElasticPlaneStrainData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
-};
+const double* pylith::materials::ElasticPlaneStrainData::_dbStateVars = 0;
-const double pylith::materials::ElasticPlaneStrainData::_parameterData[] = {
+const double pylith::materials::ElasticPlaneStrainData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
@@ -74,15 +77,19 @@
2.88000000e+09,
};
-const double pylith::materials::ElasticPlaneStrainData::_initialState[] = {
- 1.20000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
+const double* pylith::materials::ElasticPlaneStrainData::_stateVars = 0;
+
+const double pylith::materials::ElasticPlaneStrainData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
};
+const double* pylith::materials::ElasticPlaneStrainData::_stateVarsNondim = 0;
+
const double pylith::materials::ElasticPlaneStrainData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -90,20 +97,20 @@
const double pylith::materials::ElasticPlaneStrainData::_strain[] = {
1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
1.20000000e-04,
- 2.30000000e-04,
- 3.40000000e-04,
+ 1.30000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
};
const double pylith::materials::ElasticPlaneStrainData::_stress[] = {
- 1.23870000e+07,
- 1.73460000e+07,
- 1.48820000e+07,
- 1.72020000e+06,
- 2.36480000e+06,
- 2.00140000e+06,
+ -1.79790000e+07,
+ -1.79780000e+07,
+ -8.97700000e+06,
+ -2.25300000e+06,
+ -2.25200000e+06,
+ -1.09900000e+06,
};
const double pylith::materials::ElasticPlaneStrainData::_elasticConsts[] = {
@@ -121,26 +128,58 @@
5.76000000e+09,
};
+const double pylith::materials::ElasticPlaneStrainData::_initialStress[] = {
+ 2.10000000e+04,
+ 2.20000000e+04,
+ 2.30000000e+04,
+ 5.10000000e+04,
+ 5.20000000e+04,
+ 5.30000000e+04,
+};
+
+const double pylith::materials::ElasticPlaneStrainData::_initialStrain[] = {
+ 3.10000000e-04,
+ 3.20000000e-04,
+ 3.30000000e-04,
+ 6.10000000e-04,
+ 6.20000000e-04,
+ 6.30000000e-04,
+};
+
+const double* pylith::materials::ElasticPlaneStrainData::_stateVarsUpdated = 0;
+
pylith::materials::ElasticPlaneStrainData::ElasticPlaneStrainData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::ElasticPlaneStrainData::~ElasticPlaneStrainData(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStrainData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int* _numStateVarValues;
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char** _dbStateVarValues;
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double* _dbStateVars;
- static const double _initialState[];
+ static const double _properties[];
+ static const double* _stateVars;
+
+ static const double _propertiesNondim[];
+
+ static const double* _stateVarsNondim;
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_elasticplanestraindata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStress.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStress.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStress.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 2
+numElasticConsts = 6
+tensorSize = 3
+
# ElasticPlaneStrain class
class ElasticPlaneStrain(ElasticMaterialApp):
"""
@@ -35,65 +39,84 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 2
+ numLocs = 2
- self.numDBValues = 3
- self.numInitialStateValues = 3
- self.dbValues = ["density", "vs", "vp"]
- self.initialStateDBValues = ["stress_xx", "stress_yy", "stress_xy"]
- self.numParameters = 3
- self.numParamValues = [1, 1, 1]
- self.parameterNames = ["density", "mu", "lambda"]
+ self.dimension = dimension
+ self.numLocs = numLocs
+
+ self.dbPropertyValues = ["density", "vs", "vp"]
+ self.propertyValues = ["density", "mu", "lambda"]
+ self.numPropertyValues = numpy.array([1, 1, 1], dtype=numpy.int32)
densityA = 2500.0
vsA = 3000.0
vpA = vsA*3**0.5
- strainA = [1.1e-4, 2.2e-4, 3.3e-4]
- initialStateA = [1.2e4, 2.3e4, 3.2e4]
+ strainA = [1.1e-4, 1.2e-4, 1.3e-4]
+ initialStressA = [2.1e4, 2.2e4, 2.3e4]
+ initialStrainA = [3.1e-4, 3.2e-4, 3.3e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
- strainB = [1.2e-4, 2.3e-4, 3.4e-4]
- initialStateB = [2.1e4, 3.2e4, 4.3e4]
-
- self.dbData = numpy.array([ [densityA, vsA, vpA],
- [densityB, vsB, vpB] ],
- dtype=numpy.float64)
- muA = vsA*vsA*densityA
- lambdaA = vpA*vpA*densityA - 2.0*muA
+ strainB = [4.1e-4, 4.2e-4, 4.3e-4]
+ initialStressB = [5.1e4, 5.2e4, 5.3e4]
+ initialStrainB = [6.1e-4, 6.2e-4, 6.3e-4]
muB = vsB*vsB*densityB
lambdaB = vpB*vpB*densityB - 2.0*muB
- self.parameterData = numpy.array([ [densityA, muA, lambdaA],
- [densityB, muB, lambdaB] ],
+
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
+
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA],
+ [densityB, vsB, vpB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA], [densityB, muB, lambdaB] ],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0],
+ [densityB/density0, muB/mu0, lambdaB/mu0] ],
+ dtype=numpy.float64)
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
dtype=numpy.float64)
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
- self.numLocs = 2
- numElasticConsts = 6
- self.density = numpy.array([densityA, densityB],
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
- self.strain = numpy.array([strainA, strainB],
+ self.strain = numpy.array([strainA,
+ strainB],
dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 3), dtype=numpy.float64)
- self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
- dtype=numpy.float64)
+
+ stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
+ elasticConsts = numpy.zeros( (numLocs, numElasticConsts),
+ dtype=numpy.float64)
- (self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, densityA, muA, lambdaA,
- initialStateA)
- (self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, densityB, muB, lambdaB,
- initialStateB)
+ (elasticConsts[0,:], stress[0,:]) = \
+ self._calcStress(strainA, densityA, muA, lambdaA,
+ initialStressA, initialStrainA)
+ (elasticConsts[1,:], stress[1,:]) = \
+ self._calcStress(strainB, densityB, muB, lambdaB,
+ initialStressB, initialStrainB)
+
+ self.stress = stress
+ self.elasticConsts = elasticConsts
return
- def _calcStress(self, strainV, densityV, muV, lambdaV, initialStateV):
+ def _calcStress(self, strainV, densityV, muV, lambdaV,
+ initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
"""
@@ -107,13 +130,14 @@
C2222, C2212,
C1212], dtype=numpy.float64)
- strain = numpy.reshape(strainV, (3,1))
- initialState = numpy.reshape(initialStateV, (3,1))
+ strain = numpy.reshape(strainV, (tensorSize,1))
+ initialStress = numpy.reshape(initialStressV, (tensorSize,1))
+ initialStrain = numpy.reshape(initialStrainV, (tensorSize,1))
elastic = numpy.array([ [C1111, C1122, C1112],
[C1122, C2222, C2212],
[C1112, C2212, C1212] ],
dtype=numpy.float64)
- stress = numpy.dot(elastic, strain) + initialState
+ stress = numpy.dot(elastic,strain-initialStrain) + initialStress
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,37 +17,47 @@
const int pylith::materials::ElasticPlaneStressData::_dimension = 2;
-const int pylith::materials::ElasticPlaneStressData::_numDBValues = 3;
+const int pylith::materials::ElasticPlaneStressData::_numLocs = 2;
-const int pylith::materials::ElasticPlaneStressData::_numInitialStateValues = 3;
+const int pylith::materials::ElasticPlaneStressData::_numProperties = 3;
-const int pylith::materials::ElasticPlaneStressData::_numParameters = 3;
+const int pylith::materials::ElasticPlaneStressData::_numStateVars = 0;
-const int pylith::materials::ElasticPlaneStressData::_numParamsQuadPt = 3;
+const int pylith::materials::ElasticPlaneStressData::_numDBProperties = 3;
-const int pylith::materials::ElasticPlaneStressData::_numLocs = 2;
+const int pylith::materials::ElasticPlaneStressData::_numDBStateVars = 0;
+const int pylith::materials::ElasticPlaneStressData::_numPropsQuadPt = 3;
+
+const int pylith::materials::ElasticPlaneStressData::_numVarsQuadPt = 0;
+
+const double pylith::materials::ElasticPlaneStressData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::ElasticPlaneStressData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::ElasticPlaneStressData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::ElasticPlaneStressData::_densityScale = 1.00000000e+03;
+
const double pylith::materials::ElasticPlaneStressData::_dtStableImplicit = 1.00000000e+30;
-const int pylith::materials::ElasticPlaneStressData::_numParamValues[] = {
+const int pylith::materials::ElasticPlaneStressData::_numPropertyValues[] = {
1,
1,
1,
};
-const char* pylith::materials::ElasticPlaneStressData::_dbValues[] = {
+const int* pylith::materials::ElasticPlaneStressData::_numStateVarValues = 0;
+
+const char* pylith::materials::ElasticPlaneStressData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
};
-const char* pylith::materials::ElasticPlaneStressData::_initialStateDBValues[] = {
-"stress_xx",
-"stress_yy",
-"stress_xy",
-};
+const char** pylith::materials::ElasticPlaneStressData::_dbStateVarValues = 0;
-const double pylith::materials::ElasticPlaneStressData::_dbData[] = {
+const double pylith::materials::ElasticPlaneStressData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -56,16 +66,9 @@
2.07846097e+03,
};
-const double pylith::materials::ElasticPlaneStressData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.20000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
-};
+const double* pylith::materials::ElasticPlaneStressData::_dbStateVars = 0;
-const double pylith::materials::ElasticPlaneStressData::_parameterData[] = {
+const double pylith::materials::ElasticPlaneStressData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
@@ -74,15 +77,19 @@
2.88000000e+09,
};
-const double pylith::materials::ElasticPlaneStressData::_initialState[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.20000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
+const double* pylith::materials::ElasticPlaneStressData::_stateVars = 0;
+
+const double pylith::materials::ElasticPlaneStressData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
};
+const double* pylith::materials::ElasticPlaneStressData::_stateVarsNondim = 0;
+
const double pylith::materials::ElasticPlaneStressData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -90,20 +97,20 @@
const double pylith::materials::ElasticPlaneStressData::_strain[] = {
1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
1.20000000e-04,
- 2.30000000e-04,
- 3.40000000e-04,
+ 1.30000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
};
const double pylith::materials::ElasticPlaneStressData::_stress[] = {
- 9.91200000e+06,
- 1.48730000e+07,
- 1.48820000e+07,
- 1.38420000e+06,
- 2.02880000e+06,
- 2.00140000e+06,
+ -1.49790000e+07,
+ -1.49780000e+07,
+ -8.97700000e+06,
+ -1.86900000e+06,
+ -1.86800000e+06,
+ -1.09900000e+06,
};
const double pylith::materials::ElasticPlaneStressData::_elasticConsts[] = {
@@ -121,26 +128,58 @@
5.76000000e+09,
};
+const double pylith::materials::ElasticPlaneStressData::_initialStress[] = {
+ 2.10000000e+04,
+ 2.20000000e+04,
+ 2.30000000e+04,
+ 5.10000000e+04,
+ 5.20000000e+04,
+ 5.30000000e+04,
+};
+
+const double pylith::materials::ElasticPlaneStressData::_initialStrain[] = {
+ 3.10000000e-04,
+ 3.20000000e-04,
+ 3.30000000e-04,
+ 6.10000000e-04,
+ 6.20000000e-04,
+ 6.30000000e-04,
+};
+
+const double* pylith::materials::ElasticPlaneStressData::_stateVarsUpdated = 0;
+
pylith::materials::ElasticPlaneStressData::ElasticPlaneStressData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::ElasticPlaneStressData::~ElasticPlaneStressData(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticPlaneStressData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int* _numStateVarValues;
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char** _dbStateVarValues;
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double* _dbStateVars;
- static const double _initialState[];
+ static const double _properties[];
+ static const double* _stateVars;
+
+ static const double _propertiesNondim[];
+
+ static const double* _stateVarsNondim;
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_elasticplanestressdata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 1
+numElasticConsts = 1
+tensorSize = 1
+
# ElasticStrain1D class
class ElasticStrain1D(ElasticMaterialApp):
"""
@@ -35,78 +39,96 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 1
+ numLocs = 2
- self.numDBValues = 3
- self.numInitialStateValues = 1
- self.dbValues = ["density", "vs", "vp"]
- self.initialStateDBValues = ["stress_xx"]
- self.numParameters = 3
- self.numParamValues = [1, 1, 1]
- self.parameterNames = ["density", "mu", "lambda"]
+ self.dimension = dimension
+ self.numLocs = numLocs
+
+ self.dbPropertyValues = ["density", "vs", "vp"]
+ self.propertyValues = ["density", "mu", "lambda"]
+ self.numPropertyValues = numpy.array([1, 1, 1], dtype=numpy.int32)
densityA = 2500.0
vsA = 3000.0
vpA = vsA*3**0.5
strainA = [1.1e-4]
- initialStateA = [1.2e4]
+ initialStressA = [2.1e4]
+ initialStrainA = [3.1e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
- strainB = [1.2e-4]
- initialStateB = [2.1e4]
-
- self.dbData = numpy.array([ [densityA, vsA, vpA],
- [densityB, vsB, vpB] ],
- dtype=numpy.float64)
- muA = vsA*vsA*densityA
- lambdaA = vpA*vpA*densityA - 2.0*muA
- lambda2muA = lambdaA + 2.0*muA
+ strainB = [4.1e-4]
+ initialStressB = [5.1e4]
+ initialStrainB = [6.1e-4]
muB = vsB*vsB*densityB
lambdaB = vpB*vpB*densityB - 2.0*muB
- lambda2muB = lambdaB + 2.0*muB
- self.parameterData = numpy.array([ [densityA, muA, lambdaA],
- [densityB, muB, lambdaB] ],
+
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
+
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA],
+ [densityB, vsB, vpB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA], [densityB, muB, lambdaB] ],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0],
+ [densityB/density0, muB/mu0, lambdaB/mu0] ],
+ dtype=numpy.float64)
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
dtype=numpy.float64)
-
- self.numLocs = 2
- numElasticConsts = 1
- self.density = numpy.array([densityA, densityB],
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
+
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
- self.strain = numpy.array([strainA, strainB],
+ self.strain = numpy.array([strainA,
+ strainB],
dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 1), dtype=numpy.float64)
- self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
- dtype=numpy.float64)
+
+ stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
+ elasticConsts = numpy.zeros( (numLocs, numElasticConsts),
+ dtype=numpy.float64)
- (self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, densityA, lambda2muA,
- initialStateA)
- (self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, densityB, lambda2muB,
- initialStateB)
+ (elasticConsts[0,:], stress[0,:]) = \
+ self._calcStress(strainA, densityA, muA, lambdaA,
+ initialStressA, initialStrainA)
+ (elasticConsts[1,:], stress[1,:]) = \
+ self._calcStress(strainB, densityB, muB, lambdaB,
+ initialStressB, initialStrainB)
+
+ self.stress = stress
+ self.elasticConsts = elasticConsts
return
- def _calcStress(self, strainV, densityV, lambda2muV, initialStateV):
+ def _calcStress(self, strainV, densityV, muV, lambdaV,
+ initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
"""
- C1111 = lambda2muV
+ C1111 = lambdaV + 2.0*muV
elasticConsts = numpy.array([C1111], dtype=numpy.float64)
strain = numpy.reshape(strainV, (1,1))
- initialState = numpy.reshape(initialStateV, (1,1))
+ initialStress = numpy.reshape(initialStressV, (1,1))
+ initialStrain = numpy.reshape(initialStrainV, (1,1))
elastic = numpy.array([ [C1111] ],
dtype=numpy.float64)
- stress = numpy.dot(elastic, strain) + initialState
+ stress = numpy.dot(elastic,strain-initialStrain) + initialStress
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,35 +17,47 @@
const int pylith::materials::ElasticStrain1DData::_dimension = 1;
-const int pylith::materials::ElasticStrain1DData::_numDBValues = 3;
+const int pylith::materials::ElasticStrain1DData::_numLocs = 2;
-const int pylith::materials::ElasticStrain1DData::_numInitialStateValues = 1;
+const int pylith::materials::ElasticStrain1DData::_numProperties = 3;
-const int pylith::materials::ElasticStrain1DData::_numParameters = 3;
+const int pylith::materials::ElasticStrain1DData::_numStateVars = 0;
-const int pylith::materials::ElasticStrain1DData::_numParamsQuadPt = 3;
+const int pylith::materials::ElasticStrain1DData::_numDBProperties = 3;
-const int pylith::materials::ElasticStrain1DData::_numLocs = 2;
+const int pylith::materials::ElasticStrain1DData::_numDBStateVars = 0;
+const int pylith::materials::ElasticStrain1DData::_numPropsQuadPt = 3;
+
+const int pylith::materials::ElasticStrain1DData::_numVarsQuadPt = 0;
+
+const double pylith::materials::ElasticStrain1DData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::ElasticStrain1DData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::ElasticStrain1DData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::ElasticStrain1DData::_densityScale = 1.00000000e+03;
+
const double pylith::materials::ElasticStrain1DData::_dtStableImplicit = 1.00000000e+30;
-const int pylith::materials::ElasticStrain1DData::_numParamValues[] = {
+const int pylith::materials::ElasticStrain1DData::_numPropertyValues[] = {
1,
1,
1,
};
-const char* pylith::materials::ElasticStrain1DData::_dbValues[] = {
+const int* pylith::materials::ElasticStrain1DData::_numStateVarValues = 0;
+
+const char* pylith::materials::ElasticStrain1DData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
};
-const char* pylith::materials::ElasticStrain1DData::_initialStateDBValues[] = {
-"stress_xx",
-};
+const char** pylith::materials::ElasticStrain1DData::_dbStateVarValues = 0;
-const double pylith::materials::ElasticStrain1DData::_dbData[] = {
+const double pylith::materials::ElasticStrain1DData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -54,12 +66,9 @@
2.07846097e+03,
};
-const double pylith::materials::ElasticStrain1DData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.10000000e+04,
-};
+const double* pylith::materials::ElasticStrain1DData::_dbStateVars = 0;
-const double pylith::materials::ElasticStrain1DData::_parameterData[] = {
+const double pylith::materials::ElasticStrain1DData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
@@ -68,11 +77,19 @@
2.88000000e+09,
};
-const double pylith::materials::ElasticStrain1DData::_initialState[] = {
- 1.20000000e+04,
- 2.10000000e+04,
+const double* pylith::materials::ElasticStrain1DData::_stateVars = 0;
+
+const double pylith::materials::ElasticStrain1DData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
};
+const double* pylith::materials::ElasticStrain1DData::_stateVarsNondim = 0;
+
const double pylith::materials::ElasticStrain1DData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -80,12 +97,12 @@
const double pylith::materials::ElasticStrain1DData::_strain[] = {
1.10000000e-04,
- 1.20000000e-04,
+ 4.10000000e-04,
};
const double pylith::materials::ElasticStrain1DData::_stress[] = {
- 7.43700000e+06,
- 1.05780000e+06,
+ -1.34790000e+07,
+ -1.67700000e+06,
};
const double pylith::materials::ElasticStrain1DData::_elasticConsts[] = {
@@ -93,26 +110,50 @@
8.64000000e+09,
};
+const double pylith::materials::ElasticStrain1DData::_initialStress[] = {
+ 2.10000000e+04,
+ 5.10000000e+04,
+};
+
+const double pylith::materials::ElasticStrain1DData::_initialStrain[] = {
+ 3.10000000e-04,
+ 6.10000000e-04,
+};
+
+const double* pylith::materials::ElasticStrain1DData::_stateVarsUpdated = 0;
+
pylith::materials::ElasticStrain1DData::ElasticStrain1DData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::ElasticStrain1DData::~ElasticStrain1DData(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStrain1DData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int* _numStateVarValues;
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char** _dbStateVarValues;
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double* _dbStateVars;
- static const double _initialState[];
+ static const double _properties[];
+ static const double* _stateVars;
+
+ static const double _propertiesNondim[];
+
+ static const double* _stateVarsNondim;
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_elasticstrain1ddata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 1
+numElasticConsts = 1
+tensorSize = 1
+
# ElasticStress1D class
class ElasticStress1D(ElasticMaterialApp):
"""
@@ -35,65 +39,84 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 1
+ numLocs = 2
- self.numDBValues = 3
- self.numInitialStateValues = 1
- self.dbValues = ["density", "vs", "vp"]
- self.initialStateDBValues = ["stress_xx"]
- self.numParameters = 3
- self.numParamValues = [1, 1, 1]
- self.parameterNames = ["density", "mu", "lambda"]
+ self.dimension = dimension
+ self.numLocs = numLocs
+
+ self.dbPropertyValues = ["density", "vs", "vp"]
+ self.propertyValues = ["density", "mu", "lambda"]
+ self.numPropertyValues = numpy.array([1, 1, 1], dtype=numpy.int32)
densityA = 2500.0
vsA = 3000.0
vpA = vsA*3**0.5
strainA = [1.1e-4]
- initialStateA = [1.2e4]
+ initialStressA = [2.1e4]
+ initialStrainA = [3.1e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
- strainB = [1.2e-4]
- initialStateB = [2.1e4]
-
- self.dbData = numpy.array([ [densityA, vsA, vpA],
- [densityB, vsB, vpB] ],
- dtype=numpy.float64)
- muA = vsA*vsA*densityA
- lambdaA = vpA*vpA*densityA - 2.0*muA
+ strainB = [4.1e-4]
+ initialStressB = [5.1e4]
+ initialStrainB = [6.1e-4]
muB = vsB*vsB*densityB
lambdaB = vpB*vpB*densityB - 2.0*muB
- self.parameterData = numpy.array([ [densityA, muA, lambdaA],
- [densityB, muB, lambdaB] ],
+
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
+
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA],
+ [densityB, vsB, vpB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA], [densityB, muB, lambdaB] ],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0],
+ [densityB/density0, muB/mu0, lambdaB/mu0] ],
+ dtype=numpy.float64)
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
dtype=numpy.float64)
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
- self.numLocs = 2
- numElasticConsts = 1
- self.density = numpy.array([densityA, densityB],
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
- self.strain = numpy.array([strainA, strainB],
+ self.strain = numpy.array([strainA,
+ strainB],
dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 1), dtype=numpy.float64)
- self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
- dtype=numpy.float64)
+
+ stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
+ elasticConsts = numpy.zeros( (numLocs, numElasticConsts),
+ dtype=numpy.float64)
- (self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, densityA, muA, lambdaA,
- initialStateA)
- (self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, densityB, muB, lambdaB,
- initialStateB)
+ (elasticConsts[0,:], stress[0,:]) = \
+ self._calcStress(strainA, densityA, muA, lambdaA,
+ initialStressA, initialStrainA)
+ (elasticConsts[1,:], stress[1,:]) = \
+ self._calcStress(strainB, densityB, muB, lambdaB,
+ initialStressB, initialStrainB)
+
+ self.stress = stress
+ self.elasticConsts = elasticConsts
return
- def _calcStress(self, strainV, densityV, muV, lambdaV, initialStateV):
+ def _calcStress(self, strainV, densityV, muV, lambdaV,
+ initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
"""
@@ -101,10 +124,11 @@
elasticConsts = numpy.array([C1111], dtype=numpy.float64)
strain = numpy.reshape(strainV, (1,1))
- initialState = numpy.reshape(initialStateV, (1,1))
+ initialStress = numpy.reshape(initialStressV, (1,1))
+ initialStrain = numpy.reshape(initialStrainV, (1,1))
elastic = numpy.array([ [C1111] ],
dtype=numpy.float64)
- stress = numpy.dot(elastic, strain) + initialState
+ stress = numpy.dot(elastic,strain-initialStrain) + initialStress
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,35 +17,47 @@
const int pylith::materials::ElasticStress1DData::_dimension = 1;
-const int pylith::materials::ElasticStress1DData::_numDBValues = 3;
+const int pylith::materials::ElasticStress1DData::_numLocs = 2;
-const int pylith::materials::ElasticStress1DData::_numInitialStateValues = 1;
+const int pylith::materials::ElasticStress1DData::_numProperties = 3;
-const int pylith::materials::ElasticStress1DData::_numParameters = 3;
+const int pylith::materials::ElasticStress1DData::_numStateVars = 0;
-const int pylith::materials::ElasticStress1DData::_numParamsQuadPt = 3;
+const int pylith::materials::ElasticStress1DData::_numDBProperties = 3;
-const int pylith::materials::ElasticStress1DData::_numLocs = 2;
+const int pylith::materials::ElasticStress1DData::_numDBStateVars = 0;
+const int pylith::materials::ElasticStress1DData::_numPropsQuadPt = 3;
+
+const int pylith::materials::ElasticStress1DData::_numVarsQuadPt = 0;
+
+const double pylith::materials::ElasticStress1DData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::ElasticStress1DData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::ElasticStress1DData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::ElasticStress1DData::_densityScale = 1.00000000e+03;
+
const double pylith::materials::ElasticStress1DData::_dtStableImplicit = 1.00000000e+30;
-const int pylith::materials::ElasticStress1DData::_numParamValues[] = {
+const int pylith::materials::ElasticStress1DData::_numPropertyValues[] = {
1,
1,
1,
};
-const char* pylith::materials::ElasticStress1DData::_dbValues[] = {
+const int* pylith::materials::ElasticStress1DData::_numStateVarValues = 0;
+
+const char* pylith::materials::ElasticStress1DData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
};
-const char* pylith::materials::ElasticStress1DData::_initialStateDBValues[] = {
-"stress_xx",
-};
+const char** pylith::materials::ElasticStress1DData::_dbStateVarValues = 0;
-const double pylith::materials::ElasticStress1DData::_dbData[] = {
+const double pylith::materials::ElasticStress1DData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -54,12 +66,9 @@
2.07846097e+03,
};
-const double pylith::materials::ElasticStress1DData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.10000000e+04,
-};
+const double* pylith::materials::ElasticStress1DData::_dbStateVars = 0;
-const double pylith::materials::ElasticStress1DData::_parameterData[] = {
+const double pylith::materials::ElasticStress1DData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
@@ -68,11 +77,19 @@
2.88000000e+09,
};
-const double pylith::materials::ElasticStress1DData::_initialState[] = {
- 1.20000000e+04,
- 2.10000000e+04,
+const double* pylith::materials::ElasticStress1DData::_stateVars = 0;
+
+const double pylith::materials::ElasticStress1DData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
};
+const double* pylith::materials::ElasticStress1DData::_stateVarsNondim = 0;
+
const double pylith::materials::ElasticStress1DData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -80,12 +97,12 @@
const double pylith::materials::ElasticStress1DData::_strain[] = {
1.10000000e-04,
- 1.20000000e-04,
+ 4.10000000e-04,
};
const double pylith::materials::ElasticStress1DData::_stress[] = {
- 6.19950000e+06,
- 8.85000000e+05,
+ -1.12290000e+07,
+ -1.38900000e+06,
};
const double pylith::materials::ElasticStress1DData::_elasticConsts[] = {
@@ -93,26 +110,50 @@
7.20000000e+09,
};
+const double pylith::materials::ElasticStress1DData::_initialStress[] = {
+ 2.10000000e+04,
+ 5.10000000e+04,
+};
+
+const double pylith::materials::ElasticStress1DData::_initialStrain[] = {
+ 3.10000000e-04,
+ 6.10000000e-04,
+};
+
+const double* pylith::materials::ElasticStress1DData::_stateVarsUpdated = 0;
+
pylith::materials::ElasticStress1DData::ElasticStress1DData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::ElasticStress1DData::~ElasticStress1DData(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/ElasticStress1DData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int* _numStateVarValues;
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char** _dbStateVarValues;
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double* _dbStateVars;
- static const double _initialState[];
+ static const double _properties[];
+ static const double* _stateVars;
+
+ static const double _propertiesNondim[];
+
+ static const double* _stateVarsNondim;
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_elasticstress1ddata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,7 +11,10 @@
#
dist_noinst_DATA = \
- matinitialize.spatialdb
+ matinitialize.spatialdb \
+ matstress.spatialdb \
+ matstrain.spatialdb \
+ line3.mesh
noinst_TMP =
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,11 +17,24 @@
pylith::materials::MaterialData::MaterialData(void) :
dimension(0),
numLocs(0),
- numDBValues(0),
- numParameters(0),
- numParamsQuadPt(0),
- numParamValues(0),
- dbValues(0)
+ numProperties(0),
+ numStateVars(0),
+ numDBProperties(0),
+ numDBStateVars(0),
+ numPropsQuadPt(0),
+ numVarsQuadPt(0),
+ numPropertyValues(0),
+ numStateVarValues(0),
+ dbPropertyValues(0),
+ dbStateVarValues(0),
+ dbProperties(0),
+ dbStateVars(0),
+ properties(0),
+ stateVars(0),
+ lengthScale(0),
+ timeScale(0),
+ pressureScale(0),
+ densityScale(0)
{ // constructor
} // constructor
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaterialData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -37,19 +37,32 @@
int dimension; ///< Number of dimensions
int numLocs; ///< Number of locations
- int numDBValues; ///< Number of database values
- int numParameters; ///< Number of parameters
- int numInitialStateValues; ///< Number of initial state values.
- int numParamsQuadPt; ///< Number of parameters per quadrature point.
- int* numParamValues; ///< Number of values for each parameter
+ int numProperties; ///< Number of parameters for physical properties.
+ int numStateVars; ///< Number of state variables.
+ int numDBProperties; ///< Number of db values for properties.
+ int numDBStateVars; ///< Number of db values for state variables.
- char** dbValues; ///< Aray of names of database values;
- char** initialStateDBValues; ///< Names of initial state database values;
+ int numPropsQuadPt; ///< Number of properties at each quadrature point
+ int numVarsQuadPt; ///< Number of state variables at each quadrature point
- double* dbData; ///< Array of database values at locations
- double* initialStateDBData; ///< Initial state database values at locations
- double* parameterData; ///< Array of parameter values at locations
- double* initialState; ///< Initial state values at locations
+ int* numPropertyValues; ///< Number of values for each property
+ int* numStateVarValues; ///< Number of values for each state variable
+
+ char** dbPropertyValues; ///< Names of db values for properties.
+ char** dbStateVarValues; ///< Names of db values for state variables.
+
+ double* dbProperties; ///< Database values for properties at locations.
+ double* dbStateVars; ///< Database values for state variables at locations.
+ double* properties; ///< Properties at locations.
+ double* stateVars; ///< State variables at locations.
+ double* propertiesNondim; ///< Nondimensional properties at locations.
+ double* stateVarsNondim; ///< Nondimensional state variables at locations.
+
+ double lengthScale; ///< Length scale for nondimensionalization.
+ double timeScale; ///< Time scale for nondimensionalization.
+ double pressureScale; ///< Pressure scale for nondimensionalization.
+ double densityScale; ///< Density scale for nondimensionalization.
+
};
#endif // pylith_materials_materialdata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElastic.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 3
+numElasticConsts = 21
+tensorSize = 6
+
# MaxwellIsotropic3DElastic class
class MaxwellIsotropic3DElastic(ElasticMaterialApp):
"""
@@ -35,81 +39,109 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 3
+ numLocs = 2
- self.numDBValues = 4
- self.numInitialStateValues = 6
- self.dbValues = ["density", "vs", "vp", "viscosity"]
- self.initialStateDBValues = ["stress_xx", "stress_yy", "stress_zz",
- "stress_xy", "stress_yz", "stress_xy"]
- self.numParameters = 6
- self.numParamValues = [1, 1, 1, 1, 6, 6]
- self.parameterNames = ["density", "mu", "lambda", "maxwellTime", "strainT", "visStrain"]
+ self.dimension = dimension
+ self.numLocs = numLocs
- self.dt = 2.0e5
+ self.dbPropertyValues = ["density", "vs", "vp", "viscosity"]
+ self.numPropertyValues = numpy.array([1, 1, 1, 1], dtype=numpy.int32)
+ self.dbStateVarValues = ["total-strain-xx",
+ "total-strain-yy",
+ "total-strain-zz",
+ "total-strain-xy",
+ "total-strain-yz",
+ "total-strain-xz",
+ "viscous-strain-xx",
+ "viscous-strain-yy",
+ "viscous-strain-zz",
+ "viscous-strain-xy",
+ "viscous-strain-yz",
+ "viscous-strain-xz",
+ ]
+ self.numStateVarValues = numpy.array([6, 6], dtype=numpy.int32)
+
densityA = 2500.0
vsA = 3000.0
vpA = vsA*3**0.5
viscosityA = 1.0e18
- strainA = [1.1e-4, 2.2e-4, 3.3e-4, 4.4e-4, 5.5e-4, 6.6e-4]
- initialStateA = [1.2e4, 2.3e4, 3.4e4, 4.5e4, 5.6e4, 6.7e4]
+ strainA = [1.1e-4, 1.2e-4, 1.3e-4, 1.4e-4, 1.5e-4, 1.6e-4]
+ initialStressA = [2.1e4, 2.2e4, 2.3e4, 2.4e4, 2.5e4, 2.6e4]
+ initialStrainA = [3.1e-4, 3.2e-4, 3.3e-4, 3.4e-4, 3.5e-4, 3.6e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
+ maxwellTimeA = viscosityA / muA
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
viscosityB = 1.0e18
- strainB = [1.2e-4, 2.3e-4, 3.4e-4, 4.5e-4, 5.6e-4, 6.7e-4]
- initialStateB = [2.1e4, 3.2e4, 4.3e4, 5.4e4, 6.5e4, 7.6e4]
-
- self.dbData = numpy.array([ [densityA, vsA, vpA, viscosityA],
- [densityB, vsB, vpB, viscosityB] ],
- dtype=numpy.float64)
- muA = vsA*vsA*densityA
- lambdaA = vpA*vpA*densityA - 2.0*muA
- maxwellTimeA = viscosityA/muA
- strainTA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
- visStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
-
+ strainB = [4.1e-4, 4.2e-4, 4.3e-4, 4.4e-4, 4.5e-4, 4.6e-4]
+ initialStressB = [5.1e4, 5.2e4, 5.3e4, 5.4e4, 5.5e4, 5.6e4]
+ initialStrainB = [6.1e-4, 6.2e-4, 6.3e-4, 6.4e-4, 6.5e-4, 6.6e-4]
muB = vsB*vsB*densityB
lambdaB = vpB*vpB*densityB - 2.0*muB
- maxwellTimeB = viscosityB/muB
- strainTB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
- visStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ maxwellTimeB = viscosityB / muB
- vecParamsA = numpy.hstack((strainTA, visStrainA))
- vecParamsB = numpy.hstack((strainTB, visStrainB))
- vecParams = numpy.vstack((vecParamsA, vecParamsB))
- scalarParams = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
- [densityB, muB, lambdaB, maxwellTimeB] ],
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
+
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA, viscosityA],
+ [densityB, vsB, vpB, viscosityB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
+ [densityB, muB, lambdaB, maxwellTimeB] ],
dtype=numpy.float64)
- self.parameterData = numpy.hstack((scalarParams, vecParams))
- self.numLocs = 2
- numElasticConsts = 21
- self.density = numpy.array([densityA, densityB],
+ # TEMPORARY, need to determine how to use initial state variables
+ self.dbStateVars = numpy.zeros( (numLocs, tensorSize+tensorSize),
+ dtype=numpy.float64)
+ self.stateVars = numpy.zeros( (numLocs, tensorSize+tensorSize),
+ dtype=numpy.float64)
+
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ time0 = self.timeScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0, maxwellTimeA/time0],
+ [densityB/density0, muB/mu0, lambdaB/mu0, maxwellTimeB/time0] ],
+ dtype=numpy.float64)
+
+ self.stateVarsNondim = self.stateVars # no scaling
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
+ dtype=numpy.float64)
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
+
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
- self.strain = numpy.array([strainA, strainB],
+ self.strain = numpy.array([strainA,
+ strainB],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 6), dtype=numpy.float64)
- self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
- dtype=numpy.float64)
+
+ self.stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
+ self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts), \
+ dtype=numpy.float64)
(self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, muA, lambdaA,
- initialStateA)
+ self._calcStress(strainA, muA, lambdaA, \
+ initialStressA, initialStrainA)
(self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, muB, lambdaB,
- initialStateB)
+ self._calcStress(strainB, muB, lambdaB, \
+ initialStressB, initialStrainB)
+ self.dtStableImplicit = 0.1*min(maxwellTimeA, maxwellTimeB)
return
- def _calcStress(self, strainV, muV, lambdaV, initialStateV):
+ def _calcStress(self, strainV, muV, lambdaV, initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
"""
@@ -142,7 +174,8 @@
C1313], dtype=numpy.float64)
strain = numpy.reshape(strainV, (6,1))
- initialState = numpy.reshape(initialStateV, (6,1))
+ initialStress = numpy.reshape(initialStressV, (tensorSize,1))
+ initialStrain = numpy.reshape(initialStrainV, (tensorSize,1))
elastic = numpy.array([ [C1111, C1122, C1133, C1112, C1123, C1113],
[C1122, C2222, C2233, C2212, C2223, C2213],
[C1133, C2233, C3333, C3312, C3323, C3313],
@@ -150,7 +183,7 @@
[C1123, C2223, C3323, C1223, C2323, C2313],
[C1113, C2213, C3313, C1213, C2313, C1313] ],
dtype=numpy.float64)
- stress = numpy.dot(elastic, strain) + initialState
+ stress = numpy.dot(elastic, strain-initialStrain) + initialStress
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,44 +17,65 @@
const int pylith::materials::MaxwellIsotropic3DElasticData::_dimension = 3;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numDBValues = 4;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numLocs = 2;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numInitialStateValues = 6;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numParameters = 6;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numStateVars = 2;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numParamsQuadPt = 16;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numDBProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numLocs = 2;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numDBStateVars = 12;
-const double pylith::materials::MaxwellIsotropic3DElasticData::_dtStableImplicit = 1.00000000e+30;
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numPropsQuadPt = 4;
-const int pylith::materials::MaxwellIsotropic3DElasticData::_numParamValues[] = {
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numVarsQuadPt = 12;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_densityScale = 1.00000000e+03;
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_dtStableImplicit = 4.44444444e+06;
+
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numPropertyValues[] = {
1,
1,
1,
1,
+};
+
+const int pylith::materials::MaxwellIsotropic3DElasticData::_numStateVarValues[] = {
6,
6,
};
-const char* pylith::materials::MaxwellIsotropic3DElasticData::_dbValues[] = {
+const char* pylith::materials::MaxwellIsotropic3DElasticData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
"viscosity",
};
-const char* pylith::materials::MaxwellIsotropic3DElasticData::_initialStateDBValues[] = {
-"stress_xx",
-"stress_yy",
-"stress_zz",
-"stress_xy",
-"stress_yz",
-"stress_xy",
+const char* pylith::materials::MaxwellIsotropic3DElasticData::_dbStateVarValues[] = {
+"total-strain-xx",
+"total-strain-yy",
+"total-strain-zz",
+"total-strain-xy",
+"total-strain-yz",
+"total-strain-xz",
+"viscous-strain-xx",
+"viscous-strain-yy",
+"viscous-strain-zz",
+"viscous-strain-xy",
+"viscous-strain-yz",
+"viscous-strain-xz",
};
-const double pylith::materials::MaxwellIsotropic3DElasticData::_dbData[] = {
+const double pylith::materials::MaxwellIsotropic3DElasticData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -65,26 +86,45 @@
1.00000000e+18,
};
-const double pylith::materials::MaxwellIsotropic3DElasticData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DElasticData::_dbStateVars[] = {
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
};
-const double pylith::materials::MaxwellIsotropic3DElasticData::_parameterData[] = {
+const double pylith::materials::MaxwellIsotropic3DElasticData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
4.44444444e+07,
+ 2.00000000e+03,
+ 2.88000000e+09,
+ 2.88000000e+09,
+ 3.47222222e+08,
+};
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_stateVars[] = {
0.00000000e+00,
0.00000000e+00,
0.00000000e+00,
@@ -97,10 +137,6 @@
0.00000000e+00,
0.00000000e+00,
0.00000000e+00,
- 2.00000000e+03,
- 2.88000000e+09,
- 2.88000000e+09,
- 3.47222222e+08,
0.00000000e+00,
0.00000000e+00,
0.00000000e+00,
@@ -115,21 +151,44 @@
0.00000000e+00,
};
-const double pylith::materials::MaxwellIsotropic3DElasticData::_initialState[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DElasticData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 4.44444444e+07,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
+ 3.47222222e+08,
};
+const double pylith::materials::MaxwellIsotropic3DElasticData::_stateVarsNondim[] = {
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+};
+
const double pylith::materials::MaxwellIsotropic3DElasticData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -137,32 +196,32 @@
const double pylith::materials::MaxwellIsotropic3DElasticData::_strain[] = {
1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
+ 1.20000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
4.40000000e-04,
- 5.50000000e-04,
- 6.60000000e-04,
- 1.20000000e-04,
- 2.30000000e-04,
- 3.40000000e-04,
4.50000000e-04,
- 5.60000000e-04,
- 6.70000000e-04,
+ 4.60000000e-04,
};
const double pylith::materials::MaxwellIsotropic3DElasticData::_stress[] = {
- 1.98120000e+07,
- 2.47730000e+07,
- 2.97340000e+07,
- 1.98450000e+07,
- 2.48060000e+07,
- 2.97670000e+07,
- 2.69940000e+06,
- 3.34400000e+06,
- 3.98860000e+06,
- 2.64600000e+06,
- 3.29060000e+06,
- 3.93520000e+06,
+ -2.24790000e+07,
+ -2.24780000e+07,
+ -2.24770000e+07,
+ -8.97600000e+06,
+ -8.97500000e+06,
+ -8.97400000e+06,
+ -2.82900000e+06,
+ -2.82800000e+06,
+ -2.82700000e+06,
+ -1.09800000e+06,
+ -1.09700000e+06,
+ -1.09600000e+06,
};
const double pylith::materials::MaxwellIsotropic3DElasticData::_elasticConsts[] = {
@@ -210,26 +269,70 @@
5.76000000e+09,
};
+const double pylith::materials::MaxwellIsotropic3DElasticData::_initialStress[] = {
+ 2.10000000e+04,
+ 2.20000000e+04,
+ 2.30000000e+04,
+ 2.40000000e+04,
+ 2.50000000e+04,
+ 2.60000000e+04,
+ 5.10000000e+04,
+ 5.20000000e+04,
+ 5.30000000e+04,
+ 5.40000000e+04,
+ 5.50000000e+04,
+ 5.60000000e+04,
+};
+
+const double pylith::materials::MaxwellIsotropic3DElasticData::_initialStrain[] = {
+ 3.10000000e-04,
+ 3.20000000e-04,
+ 3.30000000e-04,
+ 3.40000000e-04,
+ 3.50000000e-04,
+ 3.60000000e-04,
+ 6.10000000e-04,
+ 6.20000000e-04,
+ 6.30000000e-04,
+ 6.40000000e-04,
+ 6.50000000e-04,
+ 6.60000000e-04,
+};
+
+const double* pylith::materials::MaxwellIsotropic3DElasticData::_stateVarsUpdated = 0;
+
pylith::materials::MaxwellIsotropic3DElasticData::MaxwellIsotropic3DElasticData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::MaxwellIsotropic3DElasticData::~MaxwellIsotropic3DElasticData(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DElasticData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int _numStateVarValues[];
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char* _dbStateVarValues[];
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double _dbStateVars[];
- static const double _initialState[];
+ static const double _properties[];
+ static const double _stateVars[];
+
+ static const double _propertiesNondim[];
+
+ static const double _stateVarsNondim[];
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_maxwellisotropic3delasticdata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDep.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -20,6 +20,10 @@
import numpy
# ----------------------------------------------------------------------
+dimension = 3
+numElasticConsts = 21
+tensorSize = 6
+
# MaxwellIsotropic3DTimeDep class
class MaxwellIsotropic3DTimeDep(ElasticMaterialApp):
"""
@@ -35,97 +39,136 @@
"""
ElasticMaterialApp.__init__(self, name)
- self.dimension = 3
+ numLocs = 2
- self.numDBValues = 4
- self.numInitialStateValues = 6
- self.dbValues = ["density", "vs", "vp" , "viscosity"]
- self.initialStateDBValues = ["stress_xx", "stress_yy", "stress_zz",
- "stress_xy", "stress_yz", "stress_xy"]
- self.numParameters = 6
- self.numParamValues = [1, 1, 1, 1, 6, 6]
- self.parameterNames = ["density", "mu", "lambda", "maxwellTime", "strainT", "visStrain"]
+ self.dimension = dimension
+ self.numLocs = numLocs
+ self.dbPropertyValues = ["density", "vs", "vp", "viscosity"]
+ self.propertyValues = ["density", "mu", "lambda", "maxwellTime"]
+ self.numPropertyValues = numpy.array([1, 1, 1, 1], dtype=numpy.int32)
+
+ self.dbStateVarValues = ["total-strain-xx",
+ "total-strain-yy",
+ "total-strain-zz",
+ "total-strain-xy",
+ "total-strain-yz",
+ "total-strain-xz",
+ "viscous-strain-xx",
+ "viscous-strain-yy",
+ "viscous-strain-zz",
+ "viscous-strain-xy",
+ "viscous-strain-yz",
+ "viscous-strain-xz",
+ ]
+ self.stateVarValues = ["total-strain", "viscous-strain"]
+ self.numStateVarValues = numpy.array([6, 6], dtype=numpy.int32)
+
self.dt = 2.0e5
densityA = 2500.0
vsA = 3000.0
vpA = vsA*3**0.5
viscosityA = 1.0e18
- strainA = [1.1e-4, 2.2e-4, 3.3e-4, 4.4e-4, 5.5e-4, 6.6e-4]
+ strainA = [1.1e-4, 1.2e-4, 1.3e-4, 1.4e-4, 1.5e-4, 1.6e-4]
+ initialStressA = [2.1e4, 2.2e4, 2.3e4, 2.4e4, 2.5e4, 2.6e4]
+ #initialStrainA = [3.6e-4, 3.5e-4, 3.4e-4, 3.3e-4, 3.2e-4, 3.1e-4]
+ muA = vsA*vsA*densityA
+ lambdaA = vpA*vpA*densityA - 2.0*muA
+ maxwellTimeA = viscosityA / muA
meanStrainA = (strainA[1] + strainA[2] + strainA[3])/3.0
- initialStateA = [1.2e4, 2.3e4, 3.4e4, 4.5e4, 5.6e4, 6.7e4]
-
+
densityB = 2000.0
vsB = 1200.0
vpB = vsB*3**0.5
viscosityB = 1.0e19
strainB = [1.2e-4, 2.3e-4, 3.4e-4, 4.5e-4, 5.6e-4, 6.7e-4]
+ strainB = [4.1e-4, 4.2e-4, 4.3e-4, 4.4e-4, 4.5e-4, 4.6e-4]
+ initialStressB = [5.1e4, 5.2e4, 5.3e4, 5.4e4, 5.5e4, 5.6e4]
+ #initialStrainB = [6.1e-4, 6.2e-4, 6.3e-4, 6.6e-4, 6.5e-4, 6.4e-4]
+ muB = vsB*vsB*densityB
+ lambdaB = vpB*vpB*densityB - 2.0*muB
+ maxwellTimeB = viscosityB / muB
meanStrainB = (strainB[1] + strainB[2] + strainB[3])/3.0
- initialStateB = [2.1e4, 3.2e4, 4.3e4, 5.4e4, 6.5e4, 7.6e4]
- diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
+ # TEMPORARY, need to determine how to use initial strain
+ initialStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ initialStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+
+ diag = numpy.array([1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
+ dtype=numpy.float64)
- self.dbData = numpy.array([ [densityA, vsA, vpA, viscosityA],
- [densityB, vsB, vpB, viscosityB] ],
- dtype=numpy.float64)
- muA = vsA*vsA*densityA
- lambdaA = vpA*vpA*densityA - 2.0*muA
- maxwellTimeA = viscosityA/muA
- visStrainA = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ self.lengthScale = 1.0e+3
+ self.pressureScale = muA
+ self.timeScale = 1.0
+ self.densityScale = 1.0e+3
- muB = vsB*vsB*densityB
- lambdaB = vpB*vpB*densityB - 2.0*muB
- maxwellTimeB = viscosityB/muB
- visStrainB = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+ self.dbProperties = numpy.array([ [densityA, vsA, vpA, viscosityA],
+ [densityB, vsB, vpB, viscosityB] ],
+ dtype=numpy.float64)
+ self.properties = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
+ [densityB, muB, lambdaB, maxwellTimeB] ],
+ dtype=numpy.float64)
- # Simplest approach for now is to assume this is the first step after the elastic solution.
- # In that case, both the total strain from the last step (strainT) and the total viscous
- # strain (visStrain) are defined by the assigned elastic strain.
- strainTA = strainA[:]
- strainTB = strainB[:]
- for i in range(6):
- visStrainA[i] = strainA[i] - diag[i] * meanStrainA
- visStrainB[i] = strainB[i] - diag[i] * meanStrainB
+ # TEMPORARY, need to determine how to use initial state variables
+ self.dbStateVars = numpy.zeros( (numLocs, tensorSize),
+ dtype=numpy.float64)
- vecParamsA = numpy.hstack((strainTA, visStrainA))
- vecParamsB = numpy.hstack((strainTB, visStrainB))
- vecParams = numpy.vstack((vecParamsA, vecParamsB))
- scalarParams = numpy.array([ [densityA, muA, lambdaA, maxwellTimeA],
- [densityB, muB, lambdaB, maxwellTimeB] ],
- dtype=numpy.float64)
- self.parameterData = numpy.hstack((scalarParams, vecParams))
+ mu0 = self.pressureScale
+ density0 = self.densityScale
+ time0 = self.timeScale
+ self.propertiesNondim = \
+ numpy.array([ [densityA/density0, muA/mu0, lambdaA/mu0, maxwellTimeA/time0],
+ [densityB/density0, muB/mu0, lambdaB/mu0, maxwellTimeB/time0] ],
+ dtype=numpy.float64)
+
+ self.initialStress = numpy.array([initialStressA,
+ initialStressB],
+ dtype=numpy.float64)
+ self.initialStrain = numpy.array([initialStrainA,
+ initialStrainB],
+ dtype=numpy.float64)
- self.numLocs = 2
- numElasticConsts = 21
- self.density = numpy.array([densityA, densityB],
+ self.density = numpy.array([densityA,
+ densityB],
dtype=numpy.float64)
+ # Simplest approach for now is to assume this is the first step
+ # after the elastic solution. In that case, both the total strain
+ # from the last step (total_strain) and the total viscous strain
+ # (viscous_strain) are defined by the assigned elastic strain.
+ totalStrainA = strainA
+ totalStrainB = strainB
+ viscousStrainA = numpy.array(strainA) - diag*meanStrainA
+ viscousStrainB = numpy.array(strainB) - diag*meanStrainB
+ self.stateVars = numpy.array([ [totalStrainA, viscousStrainA],
+ [totalStrainB, viscousStrainB] ],
+ dtype=numpy.float64)
+ self.stateVarsNondim = self.stateVars # no scaling
+
self.strain = numpy.array([strainA, strainB],
dtype=numpy.float64)
- self.initialStateDBData = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.initialState = numpy.array([initialStateA, initialStateB],
- dtype=numpy.float64)
- self.stress = numpy.zeros( (self.numLocs, 6), dtype=numpy.float64)
+ self.stress = numpy.zeros( (numLocs, tensorSize), dtype=numpy.float64)
self.elasticConsts = numpy.zeros( (self.numLocs, numElasticConsts),
dtype=numpy.float64)
(self.elasticConsts[0,:], self.stress[0,:]) = \
- self._calcStress(strainA, muA, lambdaA,
- maxwellTimeA, strainTA,
- visStrainA, initialStateA)
+ self._calcStress(strainA,
+ muA, lambdaA, maxwellTimeA,
+ totalStrainA, viscousStrainA,
+ initialStressA, initialStrainA)
(self.elasticConsts[1,:], self.stress[1,:]) = \
- self._calcStress(strainB, muB, lambdaB,
- maxwellTimeB, strainTB,
- visStrainB, initialStateB)
+ self._calcStress(strainB,
+ muB, lambdaB, maxwellTimeB,
+ totalStrainB, viscousStrainB,
+ initialStressB, initialStrainB)
self.dtStableImplicit = 0.1*min(maxwellTimeA, maxwellTimeB)
return
- def _calcStress(self, strainV, muV, lambdaV, maxwellTimeV, strainTV,
- visStrainV, initialStateV):
+ def _calcStress(self, strainV, muV, lambdaV, maxwellTimeV, totalStrainV,
+ viscousStrainV, initialStressV, initialStrainV):
"""
Compute stress and derivative of elasticity matrix.
This assumes behavior is always viscoelastic.
@@ -133,12 +176,17 @@
import math
bulkModulus = lambdaV + 2.0 * muV/3.0
+ diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
- diag = [1.0, 1.0, 1.0, 0.0, 0.0, 0.0]
- traceStrainT = strainTV[0] + strainTV[1] + strainTV[2]
+ totalStrainR = numpy.array(totalStrainV) - numpy.array(initialStrainV)
+ print strainV
+ print initialStrainV
+ print totalStrainR
+
+ traceStrainT = totalStrainR[0] + totalStrainR[1] + totalStrainR[2]
traceStrainTpdt = strainV[0] + strainV[1] + strainV[2]
- meanStrainT = traceStrainT/3.0
- meanStrainTpdt = traceStrainTpdt/3.0
+ meanStrainT = traceStrainT / 3.0
+ meanStrainTpdt = traceStrainTpdt / 3.0
meanStressTpdt = bulkModulus * traceStrainTpdt
timeFrac = 1.0e-5
numTerms = 5
@@ -189,20 +237,22 @@
stressV = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
expFac = math.exp(-self.dt/maxwellTimeV)
+ print "expFac:",expFac
+ print "viscousStrain",viscousStrainV
elasFac = 2.0*muV
devStrainTpdt = 0.0
devStrainT = 0.0
devStressTpdt = 0.0
- visStrain = 0.0
- for iComp in range(6):
+ viscousStrain = 0.0
+ for iComp in range(tensorSize):
devStrainTpdt = strainV[iComp] - diag[iComp]*meanStrainTpdt
- devStrainT = strainTV[iComp] - diag[iComp]*meanStrainT
- visStrain = expFac*visStrainV[iComp] + dq*(devStrainTpdt - devStrainT)
- devStressTpdt = elasFac*visStrain
+ devStrainT = totalStrainR[iComp] - diag[iComp]*meanStrainT
+ viscousStrain = expFac*viscousStrainV[iComp] + dq*(devStrainTpdt - devStrainT)
+ devStressTpdt = elasFac*viscousStrain
stressV[iComp] = diag[iComp]*meanStressTpdt + devStressTpdt + \
- initialStateV[iComp]
+ initialStressV[iComp]
- stress = numpy.reshape(stressV, (6,1))
+ stress = numpy.reshape(stressV, (tensorSize,1))
return (elasticConsts, numpy.ravel(stress))
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,44 +17,65 @@
const int pylith::materials::MaxwellIsotropic3DTimeDepData::_dimension = 3;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numDBValues = 4;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numLocs = 2;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numInitialStateValues = 6;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numParameters = 6;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numStateVars = 2;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numParamsQuadPt = 16;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numDBProperties = 4;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numLocs = 2;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numDBStateVars = 12;
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numPropsQuadPt = 4;
+
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numVarsQuadPt = 12;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_lengthScale = 1.00000000e+03;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_timeScale = 1.00000000e+00;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_pressureScale = 2.25000000e+10;
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_densityScale = 1.00000000e+03;
+
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dtStableImplicit = 4.44444444e+06;
-const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numParamValues[] = {
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numPropertyValues[] = {
1,
1,
1,
1,
+};
+
+const int pylith::materials::MaxwellIsotropic3DTimeDepData::_numStateVarValues[] = {
6,
6,
};
-const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_dbValues[] = {
+const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_dbPropertyValues[] = {
"density",
"vs",
"vp",
"viscosity",
};
-const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStateDBValues[] = {
-"stress_xx",
-"stress_yy",
-"stress_zz",
-"stress_xy",
-"stress_yz",
-"stress_xy",
+const char* pylith::materials::MaxwellIsotropic3DTimeDepData::_dbStateVarValues[] = {
+"total-strain-xx",
+"total-strain-yy",
+"total-strain-zz",
+"total-strain-xy",
+"total-strain-yz",
+"total-strain-xz",
+"viscous-strain-xx",
+"viscous-strain-yy",
+"viscous-strain-zz",
+"viscous-strain-xy",
+"viscous-strain-yz",
+"viscous-strain-xz",
};
-const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dbData[] = {
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dbProperties[] = {
2.50000000e+03,
3.00000000e+03,
5.19615242e+03,
@@ -65,71 +86,97 @@
1.00000000e+19,
};
-const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStateDBData[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_dbStateVars[] = {
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
};
-const double pylith::materials::MaxwellIsotropic3DTimeDepData::_parameterData[] = {
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_properties[] = {
2.50000000e+03,
2.25000000e+10,
2.25000000e+10,
4.44444444e+07,
- 1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
- 4.40000000e-04,
- 5.50000000e-04,
- 6.60000000e-04,
- -2.20000000e-04,
- -1.10000000e-04,
- 0.00000000e+00,
- 4.40000000e-04,
- 5.50000000e-04,
- 6.60000000e-04,
2.00000000e+03,
2.88000000e+09,
2.88000000e+09,
3.47222222e+09,
+};
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_stateVars[] = {
+ 1.10000000e-04,
1.20000000e-04,
- 2.30000000e-04,
- 3.40000000e-04,
- 4.50000000e-04,
- 5.60000000e-04,
- 6.70000000e-04,
- -2.20000000e-04,
- -1.10000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ -2.00000000e-05,
+ -1.00000000e-05,
0.00000000e+00,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
+ 4.40000000e-04,
4.50000000e-04,
- 5.60000000e-04,
- 6.70000000e-04,
+ 4.60000000e-04,
+ -2.00000000e-05,
+ -1.00000000e-05,
+ -5.42101086e-20,
+ 4.40000000e-04,
+ 4.50000000e-04,
+ 4.60000000e-04,
};
-const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialState[] = {
- 1.20000000e+04,
- 2.30000000e+04,
- 3.40000000e+04,
- 4.50000000e+04,
- 5.60000000e+04,
- 6.70000000e+04,
- 2.10000000e+04,
- 3.20000000e+04,
- 4.30000000e+04,
- 5.40000000e+04,
- 6.50000000e+04,
- 7.60000000e+04,
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_propertiesNondim[] = {
+ 2.50000000e+00,
+ 1.00000000e+00,
+ 1.00000000e+00,
+ 4.44444444e+07,
+ 2.00000000e+00,
+ 1.28000000e-01,
+ 1.28000000e-01,
+ 3.47222222e+09,
};
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_stateVarsNondim[] = {
+ 1.10000000e-04,
+ 1.20000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ -2.00000000e-05,
+ -1.00000000e-05,
+ 0.00000000e+00,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
+ 4.40000000e-04,
+ 4.50000000e-04,
+ 4.60000000e-04,
+ -2.00000000e-05,
+ -1.00000000e-05,
+ -5.42101086e-20,
+ 4.40000000e-04,
+ 4.50000000e-04,
+ 4.60000000e-04,
+};
+
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_density[] = {
2.50000000e+03,
2.00000000e+03,
@@ -137,32 +184,32 @@
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_strain[] = {
1.10000000e-04,
- 2.20000000e-04,
- 3.30000000e-04,
+ 1.20000000e-04,
+ 1.30000000e-04,
+ 1.40000000e-04,
+ 1.50000000e-04,
+ 1.60000000e-04,
+ 4.10000000e-04,
+ 4.20000000e-04,
+ 4.30000000e-04,
4.40000000e-04,
- 5.50000000e-04,
- 6.60000000e-04,
- 1.20000000e-04,
- 2.30000000e-04,
- 3.40000000e-04,
4.50000000e-04,
- 5.60000000e-04,
- 6.70000000e-04,
+ 4.60000000e-04,
};
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_stress[] = {
- 1.49064499e+07,
- 1.98452250e+07,
- 2.47840000e+07,
- 1.97561002e+07,
- 2.46948752e+07,
- 2.96336503e+07,
- 2.06587299e+06,
- 2.71043649e+06,
- 3.35500000e+06,
- 2.64585071e+06,
- 3.29041421e+06,
- 3.93497772e+06,
+ 1.26250409e+07,
+ 1.30740205e+07,
+ 1.35230000e+07,
+ 6.29571369e+06,
+ 6.74469324e+06,
+ 7.19367279e+06,
+ 5.98380664e+06,
+ 6.04240332e+06,
+ 6.10100000e+06,
+ 2.58825402e+06,
+ 2.64685071e+06,
+ 2.70544739e+06,
};
const double pylith::materials::MaxwellIsotropic3DTimeDepData::_elasticConsts[] = {
@@ -210,26 +257,70 @@
5.75983412e+09,
};
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStress[] = {
+ 2.10000000e+04,
+ 2.20000000e+04,
+ 2.30000000e+04,
+ 2.40000000e+04,
+ 2.50000000e+04,
+ 2.60000000e+04,
+ 5.10000000e+04,
+ 5.20000000e+04,
+ 5.30000000e+04,
+ 5.40000000e+04,
+ 5.50000000e+04,
+ 5.60000000e+04,
+};
+
+const double pylith::materials::MaxwellIsotropic3DTimeDepData::_initialStrain[] = {
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+ 0.00000000e+00,
+};
+
+const double* pylith::materials::MaxwellIsotropic3DTimeDepData::_stateVarsUpdated = 0;
+
pylith::materials::MaxwellIsotropic3DTimeDepData::MaxwellIsotropic3DTimeDepData(void)
{ // constructor
dimension = _dimension;
- numDBValues = _numDBValues;
- numInitialStateValues = _numInitialStateValues;
- numParameters = _numParameters;
- numParamsQuadPt = _numParamsQuadPt;
numLocs = _numLocs;
+ numProperties = _numProperties;
+ numStateVars = _numStateVars;
+ numDBProperties = _numDBProperties;
+ numDBStateVars = _numDBStateVars;
+ numPropsQuadPt = _numPropsQuadPt;
+ numVarsQuadPt = _numVarsQuadPt;
+ lengthScale = _lengthScale;
+ timeScale = _timeScale;
+ pressureScale = _pressureScale;
+ densityScale = _densityScale;
dtStableImplicit = _dtStableImplicit;
- numParamValues = const_cast<int*>(_numParamValues);
- dbValues = const_cast<char**>(_dbValues);
- initialStateDBValues = const_cast<char**>(_initialStateDBValues);
- dbData = const_cast<double*>(_dbData);
- initialStateDBData = const_cast<double*>(_initialStateDBData);
- parameterData = const_cast<double*>(_parameterData);
- initialState = const_cast<double*>(_initialState);
+ numPropertyValues = const_cast<int*>(_numPropertyValues);
+ numStateVarValues = const_cast<int*>(_numStateVarValues);
+ dbPropertyValues = const_cast<char**>(_dbPropertyValues);
+ dbStateVarValues = const_cast<char**>(_dbStateVarValues);
+ dbProperties = const_cast<double*>(_dbProperties);
+ dbStateVars = const_cast<double*>(_dbStateVars);
+ properties = const_cast<double*>(_properties);
+ stateVars = const_cast<double*>(_stateVars);
+ propertiesNondim = const_cast<double*>(_propertiesNondim);
+ stateVarsNondim = const_cast<double*>(_stateVarsNondim);
density = const_cast<double*>(_density);
strain = const_cast<double*>(_strain);
stress = const_cast<double*>(_stress);
elasticConsts = const_cast<double*>(_elasticConsts);
+ initialStress = const_cast<double*>(_initialStress);
+ initialStrain = const_cast<double*>(_initialStrain);
+ stateVarsUpdated = const_cast<double*>(_stateVarsUpdated);
} // constructor
pylith::materials::MaxwellIsotropic3DTimeDepData::~MaxwellIsotropic3DTimeDepData(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/MaxwellIsotropic3DTimeDepData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,32 +39,50 @@
static const int _dimension;
- static const int _numDBValues;
+ static const int _numLocs;
- static const int _numInitialStateValues;
+ static const int _numProperties;
- static const int _numParameters;
+ static const int _numStateVars;
- static const int _numParamsQuadPt;
+ static const int _numDBProperties;
- static const int _numLocs;
+ static const int _numDBStateVars;
+ static const int _numPropsQuadPt;
+
+ static const int _numVarsQuadPt;
+
+ static const double _lengthScale;
+
+ static const double _timeScale;
+
+ static const double _pressureScale;
+
+ static const double _densityScale;
+
static const double _dtStableImplicit;
- static const int _numParamValues[];
+ static const int _numPropertyValues[];
- static const char* _dbValues[];
+ static const int _numStateVarValues[];
- static const char* _initialStateDBValues[];
+ static const char* _dbPropertyValues[];
- static const double _dbData[];
+ static const char* _dbStateVarValues[];
- static const double _initialStateDBData[];
+ static const double _dbProperties[];
- static const double _parameterData[];
+ static const double _dbStateVars[];
- static const double _initialState[];
+ static const double _properties[];
+ static const double _stateVars[];
+
+ static const double _propertiesNondim[];
+
+ static const double _stateVarsNondim[];
+
static const double _density[];
static const double _strain[];
@@ -73,6 +91,12 @@
static const double _elasticConsts[];
+ static const double _initialStress[];
+
+ static const double _initialStrain[];
+
+ static const double* _stateVarsUpdated;
+
};
#endif // pylith_materials_maxwellisotropic3dtimedepdata_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/generate.sh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -25,16 +25,16 @@
--data.object=ElasticIsotropic3DData \
--data.parent=ElasticMaterialData
- python GenMaxwellIsotropic3DElastic.py \
- --data.namespace=pylith,materials \
- --data.object=GenMaxwellIsotropic3DElasticData \
- --data.parent=ElasticMaterialData
-
python MaxwellIsotropic3DElastic.py \
--data.namespace=pylith,materials \
--data.object=MaxwellIsotropic3DElasticData \
--data.parent=ElasticMaterialData
+# python GenMaxwellIsotropic3DElastic.py \
+# --data.namespace=pylith,materials \
+# --data.object=GenMaxwellIsotropic3DElasticData \
+# --data.parent=ElasticMaterialData
+
# 2-D ----------------------------------------------------------------
python ElasticPlaneStrain.py \
@@ -64,10 +64,10 @@
# //////////////////////////////////////////////////////////////////////
if [ $1 == "viscoelastic" ] || [ $1 == "all" ]; then
- python GenMaxwellIsotropic3DTimeDep.py \
- --data.namespace=pylith,materials \
- --data.object=GenMaxwellIsotropic3DTimeDepData \
- --data.parent=ElasticMaterialData
+ #python GenMaxwellIsotropic3DTimeDep.py \
+ # --data.namespace=pylith,materials \
+ # --data.object=GenMaxwellIsotropic3DTimeDepData \
+ # --data.parent=ElasticMaterialData
python MaxwellIsotropic3DTimeDep.py \
--data.namespace=pylith,materials \
Copied: short/3D/PyLith/trunk/unittests/libtests/materials/data/line3.mesh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/line3.mesh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/line3.mesh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/line3.mesh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,28 @@
+// Original mesh
+//
+// 0 ----- 1 ----- 2
+//
+//
+mesh = {
+ dimension = 1
+ use-index-zero = true
+ vertices = {
+ dimension = 1
+ count = 3
+ coordinates = {
+ 0 -1.0
+ 1 0.0
+ 2 1.0
+ }
+ }
+ cells = {
+ count = 1
+ num-corners = 3
+ simplices = {
+ 0 0 2 1
+ }
+ material-ids = {
+ 0 24
+ }
+ }
+}
Modified: short/3D/PyLith/trunk/unittests/libtests/materials/data/matinitialize.spatialdb
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/matinitialize.spatialdb 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/matinitialize.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,5 +11,5 @@
space-dim = 1
}
}
--0.5 2000.0 100.0 180.0
-+0.5 3000.0 200.0 400.0
+-0.5 2500.0 3000.0 5196.15242
++0.5 2000.0 1200.0 2078.46097
Copied: short/3D/PyLith/trunk/unittests/libtests/materials/data/matstrain.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/matstrain.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/matstrain.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/matstrain.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = strain
+ value-units = Pa
+ num-locs = 2
+ data-dim = 1
+ space-dim = 1
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 1
+ }
+}
+-0.5 3.10e-04
++0.5 6.10e-04
Copied: short/3D/PyLith/trunk/unittests/libtests/materials/data/matstress.spatialdb (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/materials/data/matstress.spatialdb)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/materials/data/matstress.spatialdb (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/materials/data/matstress.spatialdb 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,15 @@
+#SPATIAL.ascii 1
+SimpleDB {
+ num-values = 1
+ value-names = stress
+ value-units = Pa
+ num-locs = 2
+ data-dim = 1
+ space-dim = 1
+ cs-data = cartesian {
+ to-meters = 1.0
+ space-dim = 1
+ }
+}
+-0.5 2.10e+04
++0.5 5.10e+04
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,11 @@
# Primary source files
testmeshio_SOURCES = \
+ TestMeshIO.cc \
+ TestMeshIOAscii.cc \
+ TestMeshIOLagrit.cc \
TestCellFilterAvg.cc \
+ TestVertexFilterVecNorm.cc \
TestDataWriterVTK.cc \
TestDataWriterVTKMesh.cc \
TestDataWriterVTKMeshLine2.cc \
@@ -29,27 +33,29 @@
TestDataWriterVTKMeshQuad4.cc \
TestDataWriterVTKMeshTet4.cc \
TestDataWriterVTKMeshHex8.cc \
+ TestDataWriterVTKMatMeshLine2.cc \
+ TestDataWriterVTKMatMeshTri3.cc \
+ TestDataWriterVTKMatMeshQuad4.cc \
+ TestDataWriterVTKMatMeshTet4.cc \
+ TestDataWriterVTKMatMeshHex8.cc \
+ TestDataWriterVTKBCMesh.cc \
+ TestDataWriterVTKBCMeshTri3.cc \
+ TestDataWriterVTKBCMeshQuad4.cc \
+ TestDataWriterVTKBCMeshTet4.cc \
+ TestDataWriterVTKBCMeshHex8.cc \
+ TestDataWriterVTKSubMesh.cc \
TestDataWriterVTKSubMeshLine2.cc \
TestDataWriterVTKSubMeshTri3.cc \
TestDataWriterVTKSubMeshQuad4.cc \
TestDataWriterVTKSubMeshTet4.cc \
TestDataWriterVTKSubMeshHex8.cc \
+ TestOutputManager.cc \
+ TestOutputSolnSubset.cc \
TestDataWriterVTKFaultMesh.cc \
TestDataWriterVTKFaultMeshTri3.cc \
TestDataWriterVTKFaultMeshQuad4.cc \
TestDataWriterVTKFaultMeshTet4.cc \
TestDataWriterVTKFaultMeshHex8.cc \
- TestDataWriterVTKBCMesh.cc \
- TestDataWriterVTKBCMeshTri3.cc \
- TestDataWriterVTKBCMeshQuad4.cc \
- TestDataWriterVTKBCMeshTet4.cc \
- TestDataWriterVTKBCMeshHex8.cc \
- TestMeshIO.cc \
- TestMeshIOAscii.cc \
- TestMeshIOLagrit.cc \
- TestOutputManager.cc \
- TestOutputSolnSubset.cc \
- TestVertexFilterVecNorm.cc \
test_meshio.cc
@@ -62,6 +68,11 @@
TestDataWriterVTKMeshQuad4.hh \
TestDataWriterVTKMeshTet4.hh \
TestDataWriterVTKMeshHex8.hh \
+ TestDataWriterVTKMatMeshLine2.hh \
+ TestDataWriterVTKMatMeshTri3.hh \
+ TestDataWriterVTKMatMeshQuad4.hh \
+ TestDataWriterVTKMatMeshTet4.hh \
+ TestDataWriterVTKMatMeshHex8.hh \
TestDataWriterVTKSubMeshLine2.hh \
TestDataWriterVTKSubMeshTri3.hh \
TestDataWriterVTKSubMeshQuad4.hh \
@@ -93,6 +104,11 @@
data/DataWriterVTKDataMeshQuad4.cc \
data/DataWriterVTKDataMeshTet4.cc \
data/DataWriterVTKDataMeshHex8.cc \
+ data/DataWriterVTKDataMatMeshLine2.cc \
+ data/DataWriterVTKDataMatMeshTri3.cc \
+ data/DataWriterVTKDataMatMeshQuad4.cc \
+ data/DataWriterVTKDataMatMeshTet4.cc \
+ data/DataWriterVTKDataMatMeshHex8.cc \
data/DataWriterVTKDataSubMeshLine2.cc \
data/DataWriterVTKDataSubMeshTri3.cc \
data/DataWriterVTKDataSubMeshQuad4.cc \
@@ -120,6 +136,7 @@
data/MeshDataCubitHex.cc \
data/MeshDataLagritTet.cc
+
noinst_HEADERS += \
data/DataWriterVTKData.hh \
data/DataWriterVTKDataMeshLine2.hh \
@@ -127,6 +144,11 @@
data/DataWriterVTKDataMeshQuad4.hh \
data/DataWriterVTKDataMeshTet4.hh \
data/DataWriterVTKDataMeshHex8.hh \
+ data/DataWriterVTKDataMatMeshLine2.hh \
+ data/DataWriterVTKDataMatMeshTri3.hh \
+ data/DataWriterVTKDataMatMeshQuad4.hh \
+ data/DataWriterVTKDataMatMeshTet4.hh \
+ data/DataWriterVTKDataMatMeshHex8.hh \
data/DataWriterVTKDataSubMeshLine2.hh \
data/DataWriterVTKDataSubMeshTri3.hh \
data/DataWriterVTKDataSubMeshQuad4.hh \
@@ -154,6 +176,7 @@
data/MeshDataCubitHex.hh \
data/MeshDataLagritTet.hh
+
AM_CPPFLAGS = \
$(PETSC_SIEVE_FLAGS) $(PETSC_INCLUDE) \
-I$(PYTHON_INCDIR) $(PYTHON_EGG_CPPFLAGS)
@@ -196,21 +219,36 @@
hex8_t10.vtk \
hex8_vertex_t10.vtk \
hex8_cell_t10.vtk \
- line2_sub_t10.vtk \
- line2_sub_vertex_t10.vtk \
- line2_sub_cell_t10.vtk \
- tri3_sub_t10.vtk \
- tri3_sub_vertex_t10.vtk \
- tri3_sub_cell_t10.vtk \
- quad4_sub_t10.vtk \
- quad4_sub_vertex_t10.vtk \
- quad4_sub_cell_t10.vtk \
- tet4_sub_t10.vtk \
- tet4_sub_vertex_t10.vtk \
- tet4_sub_cell_t10.vtk \
- hex8_sub_t10.vtk \
- hex8_sub_vertex_t10.vtk \
- hex8_sub_cell_t10.vtk \
+ line2_mat_t10.vtk \
+ line2_mat_vertex_t10.vtk \
+ line2_mat_cell_t10.vtk \
+ tri3_mat_t10.vtk \
+ tri3_mat_vertex_t10.vtk \
+ tri3_mat_cell_t10.vtk \
+ quad4_mat_t10.vtk \
+ quad4_mat_vertex_t10.vtk \
+ quad4_mat_cell_t10.vtk \
+ tet4_mat_t10.vtk \
+ tet4_mat_vertex_t10.vtk \
+ tet4_mat_cell_t10.vtk \
+ hex8_mat_t10.vtk \
+ hex8_mat_vertex_t10.vtk \
+ hex8_mat_cell_t10.vtk \
+ line2_surf_t10.vtk \
+ line2_surf_vertex_t10.vtk \
+ line2_surf_cell_t10.vtk \
+ tri3_surf_t10.vtk \
+ tri3_surf_vertex_t10.vtk \
+ tri3_surf_cell_t10.vtk \
+ quad4_surf_t10.vtk \
+ quad4_surf_vertex_t10.vtk \
+ quad4_surf_cell_t10.vtk \
+ tet4_surf_t10.vtk \
+ tet4_surf_vertex_t10.vtk \
+ tet4_surf_cell_t10.vtk \
+ hex8_surf_t10.vtk \
+ hex8_surf_vertex_t10.vtk \
+ hex8_surf_cell_t10.vtk \
tri3_fault_t10.vtk \
tri3_fault_vertex_t10.vtk \
tri3_fault_cell_t10.vtk \
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,20 +14,24 @@
#include "TestCellFilterAvg.hh" // Implementation of class methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/meshio/CellFilterAvg.hh"
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestCellFilterAvg );
// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestCellFilterAvg::testConstructor(void)
{ // testConstructor
- CellFilterAvg filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
} // testConstructor
// ----------------------------------------------------------------------
@@ -35,11 +39,15 @@
void
pylith::meshio::TestCellFilterAvg::testFilter(void)
{ // testFilter
+ typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+ typedef pylith::topology::Mesh::RealSection RealSection;
+
const char* filename = "data/quad4.mesh";
const int fiberDim = 2;
const int ncells = 2;
- const char* fieldName = "field data";
- const VectorFieldEnum fieldType = OTHER_FIELD;
+ const std::string label = "field data";
+ const topology::FieldBase::VectorFieldEnum fieldType =
+ topology::FieldBase::MULTI_SCALAR;
const double fieldValues[] = {
1.1, 1.2,
2.1, 2.2,
@@ -66,9 +74,8 @@
const double quadWts[] = { 1.5, 0.5 };
const double minJacobian = 1.0;
-
-
- const VectorFieldEnum fieldTypeE = OTHER_FIELD;
+ const topology::FieldBase::VectorFieldEnum fieldTypeE =
+ topology::FieldBase::SCALAR;
const int fiberDimE = 1;
const double fieldValuesE[] = {
(1.5*1.1 + 0.5*1.2)/2.0,
@@ -76,49 +83,58 @@
};
MeshIOAscii iohandler;
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
iohandler.filename(filename);
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
// Set cell field
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ MeshField field(mesh);
+ field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(fieldType);
+ field.label(label.c_str());
- ALE::Obj<real_section_type> field =
- new real_section_type(mesh->comm(), mesh->debug());
- field->setChart(real_section_type::chart_type(0, cells->size()));
- field->setFiberDimension(cells, fiberDim);
- mesh->allocate(field);
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
+ CPPUNIT_ASSERT(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
CPPUNIT_ASSERT_EQUAL(ncells, int(cells->size()));
-
int ipt = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter, ++ipt) {
const double* values = &fieldValues[ipt*fiberDim];
- field->updatePoint(*c_iter, values);
+ section->updatePoint(*c_iter, values);
} // for
- feassemble::Quadrature2D quadrature;
- quadrature.initialize(basis, basisDerivRef, quadPtsRef, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim);
+ feassemble::Quadrature<topology::Mesh> quadrature;
+ quadrature.initialize(basis, numQuadPts, numBasis,
+ basisDerivRef, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
- CellFilterAvg filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
filter.quadrature(&quadrature);
- VectorFieldEnum fieldTypeF = SCALAR_FIELD;
- const ALE::Obj<real_section_type>& fieldF =
- filter.filter(&fieldTypeF, field, mesh);
+ const topology::Field<topology::Mesh>& fieldF = filter.filter(field);
+ const ALE::Obj<RealSection>& sectionF = fieldF.section();
+ CPPUNIT_ASSERT(!sectionF.isNull());
- CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldTypeF);
+ CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldF.vectorFieldType());
+ CPPUNIT_ASSERT_EQUAL(label, std::string(fieldF.label()));
+
ipt = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter, ++ipt) {
- CPPUNIT_ASSERT_EQUAL(fiberDimE, fieldF->getFiberDimension(*c_iter));
- const double* values = fieldF->restrictPoint(*c_iter);
+ CPPUNIT_ASSERT_EQUAL(fiberDimE, sectionF->getFiberDimension(*c_iter));
+ const double* values = sectionF->restrictPoint(*c_iter);
CPPUNIT_ASSERT(0 != values);
const double tolerance = 1.0e-06;
for (int i=0; i < fiberDimE; ++i)
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestCellFilterAvg.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,16 +21,17 @@
#if !defined(pylith_meshio_testcellfilteravg_hh)
#define pylith_meshio_testcellfilteravg_hh
+// Include directives ---------------------------------------------------
#include <cppunit/extensions/HelperMacros.h>
-/// Namespace for pylith package
+// Forward declarations -------------------------------------------------
namespace pylith {
namespace meshio {
class TestCellFilterAvg;
} // meshio
} // pylith
-/// C++ unit testing for CellFilterAvg
+// TestCellFilterAvg ----------------------------------------------------
class pylith::meshio::TestCellFilterAvg : public CppUnit::TestFixture
{ // class TestCellFilterAvg
@@ -55,4 +56,5 @@
#endif // pylith_meshio_testcellfilteravg_hh
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,22 +16,14 @@
#include "data/DataWriterVTKData.hh" // USES DataWriterVTKData
-#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
-
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-
#include <string.h> // USES strcmp()
// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTK );
-
-// ----------------------------------------------------------------------
// Setup testing data.
void
pylith::meshio::TestDataWriterVTK::setUp(void)
{ // setUp
_data = 0;
- _flipFault = false;
} // setUp
// ----------------------------------------------------------------------
@@ -39,315 +31,10 @@
void
pylith::meshio::TestDataWriterVTK::tearDown(void)
{ // tearDown
- _mesh = 0;
delete _data; _data = 0;
} // tearDown
// ----------------------------------------------------------------------
-// Test constructor
-void
-pylith::meshio::TestDataWriterVTK::testConstructor(void)
-{ // testConstructor
- DataWriterVTK writer;
-
- CPPUNIT_ASSERT(0 == writer._viewer);
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-} // testConstructor
-
-// ----------------------------------------------------------------------
-// Test filename()
-void
-pylith::meshio::TestDataWriterVTK::testFilename(void)
-{ // testDebug
- DataWriterVTK writer;
-
- const char* filename = "data.vtk";
- writer.filename(filename);
- CPPUNIT_ASSERT_EQUAL(std::string(filename), writer._filename);
-} // testFilename
-
-// ----------------------------------------------------------------------
-// Test timeFormat()
-void
-pylith::meshio::TestDataWriterVTK::testTimeFormat(void)
-{ // testTimeFormat
- DataWriterVTK writer;
-
- const char* format = "%4.1f";
- writer.timeFormat(format);
- CPPUNIT_ASSERT_EQUAL(std::string(format), writer._timeFormat);
-} // testInterpolate
-
-// ----------------------------------------------------------------------
-// Test timeConstant()
-void
-pylith::meshio::TestDataWriterVTK::testTimeConstant(void)
-{ // testTimeConstant
- DataWriterVTK writer;
-
- const double value = 4.5;
- writer.timeConstant(value);
- CPPUNIT_ASSERT_EQUAL(value, writer._timeConstant);
-} // testInterpolate
-
-// ----------------------------------------------------------------------
-// Test openTimeStep() and closeTimeStep()
-void
-pylith::meshio::TestDataWriterVTK::testTimeStep(void)
-{ // testTimeStep
- CPPUNIT_ASSERT(!_mesh.isNull());
- CPPUNIT_ASSERT(0 != _data);
-
- DataWriterVTK writer;
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(_mesh->getDimension());
-
- writer.filename(_data->timestepFilename);
- writer.timeFormat(_data->timeFormat);
-
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- const double t = _data->time;
- const int numTimeSteps = 1;
- if (0 == _data->cellsLabel) {
- writer.open(_mesh, &cs, numTimeSteps);
- writer.openTimeStep(t, _mesh, &cs);
- } else {
- const char* label = _data->cellsLabel;
- const int id = _data->labelId;
- writer.open(_mesh, &cs, numTimeSteps, label, id);
- writer.openTimeStep(t, _mesh, &cs, label, id);
- } // else
-
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- writer.closeTimeStep();
- writer.close();
-
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- checkFile(_data->timestepFilename, t, _data->timeFormat);
-} // testTimeStep
-
-// ----------------------------------------------------------------------
-// Test writeVertexField.
-void
-pylith::meshio::TestDataWriterVTK::testWriteVertexField(void)
-{ // testWriteVertexField
- CPPUNIT_ASSERT(!_mesh.isNull());
- CPPUNIT_ASSERT(0 != _data);
-
- DataWriterVTK writer;
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(_mesh->getDimension());
-
- std::vector< ALE::Obj<real_section_type> > vertexFields;
- _createVertexFields(&vertexFields);
-
- writer.filename(_data->vertexFilename);
- writer.timeFormat(_data->timeFormat);
-
- const int nfields = _data->numVertexFields;
-
- const double t = _data->time;
- const int numTimeSteps = 1;
- if (0 == _data->cellsLabel) {
- writer.open(_mesh, &cs, numTimeSteps);
- writer.openTimeStep(t, _mesh, &cs);
- } else {
- const char* label = _data->cellsLabel;
- const int id = _data->labelId;
- writer.open(_mesh, &cs, numTimeSteps, label, id);
- writer.openTimeStep(t, _mesh, &cs, label, id);
- } // else
- for (int i=0; i < nfields; ++i) {
- writer.writeVertexField(t, _data->vertexFieldsInfo[i].name,
- vertexFields[i],
- _data->vertexFieldsInfo[i].field_type,
- _mesh);
- CPPUNIT_ASSERT(writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
- } // for
- writer.closeTimeStep();
- writer.close();
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- checkFile(_data->vertexFilename, t, _data->timeFormat);
-} // testWriteVertexField
-
-// ----------------------------------------------------------------------
-// Test writeCellField.
-void
-pylith::meshio::TestDataWriterVTK::testWriteCellField(void)
-{ // testWriteCellField
- CPPUNIT_ASSERT(!_mesh.isNull());
- CPPUNIT_ASSERT(0 != _data);
-
- DataWriterVTK writer;
-
- spatialdata::geocoords::CSCart cs;
- cs.setSpaceDim(_mesh->getDimension());
-
- std::vector< ALE::Obj<real_section_type> > cellFields;
- _createCellFields(&cellFields);
-
- writer.filename(_data->cellFilename);
- writer.timeFormat(_data->timeFormat);
-
- const int nfields = _data->numCellFields;
-
- const double t = _data->time;
- const int numTimeSteps = 1;
- if (0 == _data->cellsLabel) {
- writer.open(_mesh, &cs, numTimeSteps);
- writer.openTimeStep(t, _mesh, &cs);
- for (int i=0; i < nfields; ++i) {
- writer.writeCellField(t, _data->cellFieldsInfo[i].name,
- cellFields[i],
- _data->cellFieldsInfo[i].field_type,
- _mesh);
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(writer._wroteCellHeader);
- } // for
- } else {
- const char* label = _data->cellsLabel;
- const int id = _data->labelId;
- writer.open(_mesh, &cs, numTimeSteps, label, id);
- writer.openTimeStep(t, _mesh, &cs, label, id);
- for (int i=0; i < nfields; ++i) {
- writer.writeCellField(t, _data->cellFieldsInfo[i].name,
- cellFields[i],
- _data->cellFieldsInfo[i].field_type,
- _mesh, label, id);
- CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
- CPPUNIT_ASSERT(writer._wroteCellHeader);
- } // for
- } // else
- writer.closeTimeStep();
- writer.close();
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
- CPPUNIT_ASSERT(false == writer._wroteCellHeader);
-
- checkFile(_data->cellFilename, t, _data->timeFormat);
-} // testWriteCellField
-
-// ----------------------------------------------------------------------
-// Test _vtkFilename.
-void pylith::meshio::TestDataWriterVTK::testVtkFilename(void)
-{ // testVtkFilename
- DataWriterVTK writer;
-
- // Append info to filename if number of time steps is 0.
- writer._numTimeSteps = 0;
- writer._filename = "output.vtk";
- CPPUNIT_ASSERT_EQUAL(std::string("output_info.vtk"), writer._vtkFilename(0.0));
-
- // Use default normalization of 1.0, remove period from time stamp.
- writer._numTimeSteps = 100;
- writer._filename = "output.vtk";
- writer.timeFormat("%05.2f");
- CPPUNIT_ASSERT_EQUAL(std::string("output_t0230.vtk"),
- writer._vtkFilename(2.3));
-
- // Use normalization of 20.0, remove period from time stamp.
- writer._numTimeSteps = 100;
- writer._filename = "output.vtk";
- writer.timeFormat("%05.2f");
- writer.timeConstant(20.0);
- CPPUNIT_ASSERT_EQUAL(std::string("output_t0250.vtk"),
- writer._vtkFilename(50.0));
-} // testVtkFilename
-
-// ----------------------------------------------------------------------
-// Create vertex fields.
-void
-pylith::meshio::TestDataWriterVTK::_createVertexFields(
- std::vector< ALE::Obj<real_section_type> >* fields) const
-{ // _createVertexFields
- CPPUNIT_ASSERT(0 != fields);
- CPPUNIT_ASSERT(!_mesh.isNull());
- CPPUNIT_ASSERT(0 != _data);
-
- try {
- const int nfields = _data->numVertexFields;
-
- const ALE::Obj<Mesh::label_sequence>& vertices =
- _mesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
-
- // Set vertex fields
- fields->resize(nfields);
- for (int i=0; i < nfields; ++i) {
- (*fields)[i] = new real_section_type(_mesh->comm(), _mesh->debug());
- (*fields)[i]->setChart(_mesh->getSieve()->getChart());
- const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
- (*fields)[i]->setFiberDimension(vertices, fiberDim);
- _mesh->allocate((*fields)[i]);
-
- int ipt = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != verticesEnd;
- ++v_iter, ++ipt) {
- const double* values = &_data->vertexFields[i][ipt*fiberDim];
- (*fields)[i]->updatePoint(*v_iter, values);
- } // for
- CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
- } // for
- } catch (const ALE::Exception& err) {
- throw std::runtime_error(err.msg());
- } // catch
-} // _createVertexFields
-
-// ----------------------------------------------------------------------
-// Create cell fields.
-void
-pylith::meshio::TestDataWriterVTK::_createCellFields(
- std::vector< ALE::Obj<real_section_type> >* fields) const
-{ // _createCellFields
- CPPUNIT_ASSERT(0 != fields);
- CPPUNIT_ASSERT(!_mesh.isNull());
- CPPUNIT_ASSERT(0 != _data);
-
- try {
- const int nfields = _data->numCellFields;
-
- const ALE::Obj<Mesh::label_sequence>& cells =
- (0 == _data->cellsLabel) ?
- _mesh->depthStratum(1) :
- _mesh->getLabelStratum(_data->cellsLabel, _data->labelId);
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
-
- // Set cell fields
- fields->resize(nfields);
- for (int i=0; i < nfields; ++i) {
- (*fields)[i] = new real_section_type(_mesh->comm(), _mesh->debug());
- (*fields)[i]->setChart(_mesh->getSieve()->getChart());
- const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
- (*fields)[i]->setFiberDimension(cells, fiberDim);
- _mesh->allocate((*fields)[i]);
-
- int icell = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
- c_iter != cellsEnd;
- ++c_iter, ++icell) {
- const double* values = &_data->cellFields[i][icell*fiberDim];
- (*fields)[i]->updatePoint(*c_iter, values);
- } // for
- CPPUNIT_ASSERT_EQUAL(_data->numCells, icell);
- } // for
- } catch (const ALE::Exception& err) {
- throw std::runtime_error(err.msg());
- } // catch
-} // _createCellFields
-
-// ----------------------------------------------------------------------
// Check VTK file against archived file.
void
pylith::meshio::TestDataWriterVTK::checkFile(const char* filenameRoot,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTK.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,10 +21,6 @@
#if !defined(pylith_meshio_testdatawritervtk_hh)
#define pylith_meshio_testdatawritervtk_hh
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-#include <vector> // USES std::vector
-
#include <cppunit/extensions/HelperMacros.h>
/// Namespace for pylith package
@@ -40,17 +36,6 @@
class pylith::meshio::TestDataWriterVTK : public CppUnit::TestFixture
{ // class TestDataWriterVTK
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestDataWriterVTK );
-
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testFilename );
- CPPUNIT_TEST( testTimeFormat );
- CPPUNIT_TEST( testTimeConstant );
- CPPUNIT_TEST( testVtkFilename );
-
- CPPUNIT_TEST_SUITE_END();
-
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
@@ -60,30 +45,6 @@
/// Tear down testing data.
void tearDown(void);
- /// Test constructor
- void testConstructor(void);
-
- /// Test filename()
- void testFilename(void);
-
- /// Test timeFormat()
- void testTimeFormat(void);
-
- /// Test timeConstant()
- void testTimeConstant(void);
-
- /// Test openTimeStep() and closeTimeStep()
- void testTimeStep(void);
-
- /// Test writeVertexField.
- void testWriteVertexField(void);
-
- /// Test writeCellField.
- void testWriteCellField(void);
-
- /// Test vtkFilename.
- void testVtkFilename(void);
-
// PUBLIC METHODS /////////////////////////////////////////////////////
public :
@@ -102,26 +63,7 @@
protected :
DataWriterVTKData* _data; ///< Data for testing
- ALE::Obj<Mesh> _mesh; ///< Mesh for data
- bool _flipFault; ///< If true, flip fault orientation.
- // PRIVATE MEMBERS ////////////////////////////////////////////////////
-private :
-
- /** Create vertex fields.
- *
- * @param fields Vertex fields.
- */
- void
- _createVertexFields(std::vector< ALE::Obj<real_section_type> >* fields) const;
-
- /** Create cell fields.
- *
- * @param fields Cell fields.
- */
- void
- _createCellFields(std::vector< ALE::Obj<real_section_type> >* fields) const;
-
}; // class TestDataWriterVTK
#endif // pylith_meshio_testdatawritervtk_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,42 +16,311 @@
#include "data/DataWriterVTKData.hh" // USES DataWriterVTKData
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
-#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
-#include <Selection.hh> // USES submesh algorithms
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMesh );
-#include <map> // USES std::map
+// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::SubMesh> SubMeshField;
// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKBCMesh::setUp(void)
+{ // setUp
+ TestDataWriterVTK::setUp();
+ _mesh = 0;
+ _submesh = 0;
+ _flipFault = false;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::meshio::TestDataWriterVTKBCMesh::tearDown(void)
+{ // tearDown
+ TestDataWriterVTK::tearDown();
+ delete _mesh; _mesh = 0;
+ delete _submesh; _submesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestDataWriterVTKBCMesh::testConstructor(void)
+{ // testConstructor
+ DataWriterVTK<topology::SubMesh, SubMeshField> writer;
+
+ CPPUNIT_ASSERT(0 == writer._viewer);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test openTimeStep() and closeTimeStep()
+void
+pylith::meshio::TestDataWriterVTKBCMesh::testTimeStep(void)
+{ // testTimeStep
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, SubMeshField> writer;
+
+ writer.filename(_data->timestepFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_submesh, numTimeSteps);
+ writer.openTimeStep(t, *_submesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_submesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_submesh, label, id);
+ } // else
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ writer.closeTimeStep();
+ writer.close();
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->timestepFilename, t, _data->timeFormat);
+} // testTimeStep
+
+// ----------------------------------------------------------------------
+// Test writeVertexField.
+void
+pylith::meshio::TestDataWriterVTKBCMesh::testWriteVertexField(void)
+{ // testWriteVertexField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, SubMeshField> writer;
+
+ topology::Fields<SubMeshField> vertexFields(*_submesh);
+ _createVertexFields(&vertexFields);
+
+ writer.filename(_data->vertexFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numVertexFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_submesh, numTimeSteps);
+ writer.openTimeStep(t, *_submesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_submesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_submesh, label, id);
+ } // else
+ for (int i=0; i < nfields; ++i) {
+ const SubMeshField& field = vertexFields.get(_data->vertexFieldsInfo[i].name);
+ writer.writeVertexField(t, field);
+ CPPUNIT_ASSERT(writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ } // for
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->vertexFilename, t, _data->timeFormat);
+} // testWriteVertexField
+
+// ----------------------------------------------------------------------
+// Test writeCellField.
+void
+pylith::meshio::TestDataWriterVTKBCMesh::testWriteCellField(void)
+{ // testWriteCellField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, SubMeshField> writer;
+
+ topology::Fields<SubMeshField> cellFields(*_submesh);
+ _createCellFields(&cellFields);
+
+ writer.filename(_data->cellFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numCellFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_submesh, numTimeSteps);
+ writer.openTimeStep(t, *_submesh);
+ for (int i=0; i < nfields; ++i) {
+ const SubMeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_submesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_submesh, label, id);
+ for (int i=0; i < nfields; ++i) {
+ const SubMeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field, label, id);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } // else
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->cellFilename, t, _data->timeFormat);
+} // testWriteCellField
+
+// ----------------------------------------------------------------------
// Initialize mesh.
void
pylith::meshio::TestDataWriterVTKBCMesh::_initialize(void)
{ // _initialize
CPPUNIT_ASSERT(0 != _data);
+ delete _mesh; _mesh = new topology::Mesh;
MeshIOAscii iohandler;
iohandler.filename(_data->meshFilename);
- iohandler.read(&_meshDomain);
- CPPUNIT_ASSERT(!_meshDomain.isNull());
+ iohandler.read(_mesh);
if (0 != _data->faultLabel) {
faults::FaultCohesiveKin fault;
fault.label(_data->faultLabel);
fault.id(_data->faultId);
- fault.adjustTopology(_meshDomain, _flipFault);
+ fault.adjustTopology(_mesh, _flipFault);
} // if
- const char* label = _data->bcLabel;
- _mesh =
- ALE::Selection<Mesh>::submeshV<SubMesh>(_meshDomain,
- _meshDomain->getIntSection(label));
- CPPUNIT_ASSERT(!_mesh.isNull());
- _mesh->setRealSection("coordinates",
- _meshDomain->getRealSection("coordinates"));
+ delete _submesh; _submesh = new topology::SubMesh(*_mesh, _data->bcLabel);
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveSubMesh =
+ _submesh->sieveMesh();
+ assert(!sieveSubMesh.isNull());
+ sieveSubMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
//_mesh->view("BC mesh");
} // _initialize
+// ----------------------------------------------------------------------
+// Create vertex fields.
+void
+pylith::meshio::TestDataWriterVTKBCMesh::_createVertexFields(
+ topology::Fields<SubMeshField>* fields) const
+{ // _createVertexFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+ try {
+ const int nfields = _data->numVertexFields;
+
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveSubMesh =
+ _submesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveSubMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh::label_sequence>& vertices =
+ sieveSubMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const topology::SubMesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Set vertex fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->vertexFieldsInfo[i].name;
+ const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ SubMeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int ipt = 0;
+ for (topology::SubMesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++ipt) {
+ const double* values = &_data->vertexFields[i][ipt*fiberDim];
+ section->updatePoint(*v_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createVertexFields
+
+// ----------------------------------------------------------------------
+// Create cell fields.
+void
+pylith::meshio::TestDataWriterVTKBCMesh::_createCellFields(
+ topology::Fields<SubMeshField>* fields) const
+{ // _createCellFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ try {
+ const int nfields = _data->numCellFields;
+
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveSubMesh =
+ _submesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveSubMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh::label_sequence>& cells =
+ sieveSubMesh->heightStratum(1);
+ assert(!cells.isNull());
+ const topology::SubMesh::SieveMesh::label_sequence::iterator cellsBegin =
+ cells->begin();
+ const topology::SubMesh::SieveMesh::label_sequence::iterator cellsEnd =
+ cells->end();
+
+ // Set cell fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->cellFieldsInfo[i].name;
+ const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ SubMeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim, 1);
+ field.allocate();
+ field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int icell = 0;
+ for (topology::SubMesh::SieveMesh::label_sequence::iterator c_iter=cellsBegin;
+ c_iter != cellsEnd;
+ ++c_iter, ++icell) {
+ const double* values = &_data->cellFields[i][icell*fiberDim];
+ section->updatePoint(*c_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numCells, icell);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createCellFields
+
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,6 +23,8 @@
#include "TestDataWriterVTK.hh"
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh, Field
+
/// Namespace for pylith package
namespace pylith {
namespace meshio {
@@ -34,6 +36,34 @@
class pylith::meshio::TestDataWriterVTKBCMesh : public TestDataWriterVTK
{ // class TestDataWriterVTKBCMesh
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKBCMesh );
+
+ CPPUNIT_TEST( testConstructor );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test constructor
+ void testConstructor(void);
+
+ /// Test openTimeStep() and closeTimeStep()
+ void testTimeStep(void);
+
+ /// Test writeVertexField.
+ void testWriteVertexField(void);
+
+ /// Test writeCellField.
+ void testWriteCellField(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
@@ -43,8 +73,27 @@
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
- ALE::Obj<Mesh> _meshDomain; ///< Mesh for domain.
+ topology::Mesh* _mesh; ///< Mesh for domain
+ topology::SubMesh* _submesh; ///< Mesh for subdomain.
+ bool _flipFault; ///< If true, flip fault orientation.
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ /** Create vertex fields.
+ *
+ * @param fields Vertex fields.
+ */
+ void
+ _createVertexFields(topology::Fields<topology::Field<topology::SubMesh> >* fields) const;
+
+ /** Create cell fields.
+ *
+ * @param fields Cell fields.
+ */
+ void
+ _createCellFields(topology::Fields<topology::Field<topology::SubMesh> >* fields) const;
+
}; // class TestDataWriterVTKBCMesh
#endif // pylith_meshio_testdatawritervtkbcmesh_hh
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,7 +17,7 @@
#include "data/DataWriterVTKDataBCMeshHex8.hh" // USES DataWriterVTKDataBCMeshHex8
// ----------------------------------------------------------------------
-//CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshHex8 );
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshHex8 );
// ----------------------------------------------------------------------
// Setup testing data.
@@ -26,6 +26,7 @@
{ // setUp
TestDataWriterVTKBCMesh::setUp();
_data = new DataWriterVTKDataBCMeshHex8;
+ _flipFault = true;
_initialize();
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,7 +17,7 @@
#include "data/DataWriterVTKDataBCMeshQuad4.hh" // USES DataWriterVTKDataMeshQuad4
// ----------------------------------------------------------------------
-//CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshQuad4 );
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshQuad4 );
// ----------------------------------------------------------------------
// Setup testing data.
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,7 +17,7 @@
#include "data/DataWriterVTKDataBCMeshTet4.hh" // USES DataWriterVTKDataBCMeshTet4
// ----------------------------------------------------------------------
-//CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshTet4 );
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshTet4 );
// ----------------------------------------------------------------------
// Setup testing data.
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKBCMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,7 +17,7 @@
#include "data/DataWriterVTKDataBCMeshTri3.hh" // USES DataWriterVTKDataBCMeshTri3
// ----------------------------------------------------------------------
-//CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshTri3 );
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKBCMeshTri3 );
// ----------------------------------------------------------------------
// Setup testing data.
@@ -26,6 +26,7 @@
{ // setUp
TestDataWriterVTKBCMesh::setUp();
_data = new DataWriterVTKDataBCMeshTri3;
+ _flipFault = true;
_initialize();
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,34 +16,308 @@
#include "data/DataWriterVTKData.hh" // USES DataWriterVTKData
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
#include "pylith/faults/CohesiveTopology.hh" // USES CohesiveTopology
#include <map> // USES std::map
// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKFaultMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::SubMesh> MeshField;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::setUp(void)
+{ // setUp
+ TestDataWriterVTK::setUp();
+ _mesh = new topology::Mesh();
+ _faultMesh = new topology::SubMesh();
+ _flipFault = false;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::tearDown(void)
+{ // tearDown
+ TestDataWriterVTK::tearDown();
+ delete _mesh; _mesh = 0;
+ delete _faultMesh; _faultMesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::testConstructor(void)
+{ // testConstructor
+ DataWriterVTK<topology::SubMesh, MeshField> writer;
+
+ CPPUNIT_ASSERT(0 == writer._viewer);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test openTimeStep() and closeTimeStep()
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::testTimeStep(void)
+{ // testTimeStep
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, MeshField> writer;
+
+ writer.filename(_data->timestepFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_faultMesh, numTimeSteps);
+ writer.openTimeStep(t, *_faultMesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_faultMesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_faultMesh, label, id);
+ } // else
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ writer.closeTimeStep();
+ writer.close();
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->timestepFilename, t, _data->timeFormat);
+} // testTimeStep
+
+// ----------------------------------------------------------------------
+// Test writeVertexField.
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::testWriteVertexField(void)
+{ // testWriteVertexField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, MeshField> writer;
+
+ topology::Fields<MeshField> vertexFields(*_faultMesh);
+ _createVertexFields(&vertexFields);
+
+ writer.filename(_data->vertexFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numVertexFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_faultMesh, numTimeSteps);
+ writer.openTimeStep(t, *_faultMesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_faultMesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_faultMesh, label, id);
+ } // else
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = vertexFields.get(_data->vertexFieldsInfo[i].name);
+ writer.writeVertexField(t, field);
+ CPPUNIT_ASSERT(writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ } // for
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->vertexFilename, t, _data->timeFormat);
+} // testWriteVertexField
+
+// ----------------------------------------------------------------------
+// Test writeCellField.
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::testWriteCellField(void)
+{ // testWriteCellField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, MeshField> writer;
+
+ topology::Fields<MeshField> cellFields(*_faultMesh);
+ _createCellFields(&cellFields);
+
+ writer.filename(_data->cellFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numCellFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_faultMesh, numTimeSteps);
+ writer.openTimeStep(t, *_faultMesh);
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_faultMesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_faultMesh, label, id);
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field, label, id);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } // else
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->cellFilename, t, _data->timeFormat);
+} // testWriteCellField
+
+// ----------------------------------------------------------------------
// Initialize mesh.
void
pylith::meshio::TestDataWriterVTKFaultMesh::_initialize(void)
{ // _initialize
CPPUNIT_ASSERT(0 != _data);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _faultMesh);
MeshIOAscii iohandler;
iohandler.filename(_data->meshFilename);
- iohandler.read(&_meshDomain);
- CPPUNIT_ASSERT(!_meshDomain.isNull());
+ iohandler.read(_mesh);
faults::FaultCohesiveKin fault;
fault.label(_data->faultLabel);
fault.id(_data->faultId);
- fault.adjustTopology(_meshDomain, _flipFault);
+ fault.adjustTopology(_mesh, _flipFault);
const bool constraintCell = true;
std::map<Mesh::point_type, Mesh::point_type> cohesiveToFault;
- faults::CohesiveTopology::createParallel(&_mesh, &cohesiveToFault,
- _meshDomain, _data->faultId,
- constraintCell);
+ faults::CohesiveTopology::createFaultParallel(_faultMesh, &cohesiveToFault,
+ *_mesh, _data->faultId,
+ constraintCell);
} // _initialize
+// ----------------------------------------------------------------------
+// Create vertex fields.
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::_createVertexFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createVertexFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _faultMesh);
+ CPPUNIT_ASSERT(0 != _data);
+ try {
+ const int nfields = _data->numVertexFields;
+
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveFaultMesh =
+ _faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveFaultMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh::label_sequence>& vertices =
+ sieveFaultMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const topology::SubMesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Set vertex fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->vertexFieldsInfo[i].name;
+ const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int ipt = 0;
+ for (topology::SubMesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++ipt) {
+ const double* values = &_data->vertexFields[i][ipt*fiberDim];
+ section->updatePoint(*v_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createVertexFields
+
+// ----------------------------------------------------------------------
+// Create cell fields.
+void
+pylith::meshio::TestDataWriterVTKFaultMesh::_createCellFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createCellFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ try {
+ const int nfields = _data->numCellFields;
+
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveFaultMesh =
+ _faultMesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveFaultMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh::label_sequence>& cells =
+ sieveFaultMesh->heightStratum(0);
+ assert(!cells.isNull());
+ const topology::SubMesh::SieveMesh::label_sequence::iterator cellsBegin =
+ cells->begin();
+ const topology::SubMesh::SieveMesh::label_sequence::iterator cellsEnd =
+ cells->end();
+
+ // Set cell fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->cellFieldsInfo[i].name;
+ const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int icell = 0;
+ for (topology::SubMesh::SieveMesh::label_sequence::iterator c_iter=cellsBegin;
+ c_iter != cellsEnd;
+ ++c_iter, ++icell) {
+ const double* values = &_data->cellFields[i][icell*fiberDim];
+ section->updatePoint(*c_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numCells, icell);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createCellFields
+
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKFaultMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -23,6 +23,8 @@
#include "TestDataWriterVTK.hh"
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh, Field
+
/// Namespace for pylith package
namespace pylith {
namespace meshio {
@@ -34,6 +36,34 @@
class pylith::meshio::TestDataWriterVTKFaultMesh : public TestDataWriterVTK
{ // class TestDataWriterVTKFaultMesh
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKFaultMesh );
+
+ CPPUNIT_TEST( testConstructor );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test constructor
+ void testConstructor(void);
+
+ /// Test openTimeStep() and closeTimeStep()
+ void testTimeStep(void);
+
+ /// Test writeVertexField.
+ void testWriteVertexField(void);
+
+ /// Test writeCellField.
+ void testWriteCellField(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
@@ -43,8 +73,27 @@
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
- ALE::Obj<Mesh> _meshDomain; ///< Mesh for domain.
+ topology::Mesh* _mesh; ///< Mesh for domain
+ topology::SubMesh* _faultMesh; ///< Fault mesh.
+ bool _flipFault; ///< If true, flip fault orientation.
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ /** Create vertex fields.
+ *
+ * @param fields Vertex fields.
+ */
+ void
+ _createVertexFields(topology::Fields<topology::Field<topology::SubMesh> >* fields) const;
+
+ /** Create cell fields.
+ *
+ * @param fields Cell fields.
+ */
+ void
+ _createCellFields(topology::Fields<topology::Field<topology::SubMesh> >* fields) const;
+
}; // class TestDataWriterVTKFaultMesh
#endif // pylith_meshio_testdatawritervtkfaultmesh_hh
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKMatMeshHex8.hh" // Implementation of class methods
+
+#include "data/DataWriterVTKDataMatMeshHex8.hh" // USES DataWriterVTKDataMatMeshHex8
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKMatMeshHex8 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKMatMeshHex8::setUp(void)
+{ // setUp
+ TestDataWriterVTKMesh::setUp();
+ _data = new DataWriterVTKDataMatMeshHex8;
+ _flipFault = true;
+
+ _initialize();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKMatMeshHex8.hh
+ *
+ * @brief C++ TestDataWriterVTKMatMeshHex8 object
+ *
+ * C++ unit testing for DataWriterVTKMatMeshHex8.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtksubmeshhex8_hh)
+#define pylith_meshio_testdatawritervtksubmeshhex8_hh
+
+#include "TestDataWriterVTKMesh.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKMatMeshHex8;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKMatMeshHex8 : public TestDataWriterVTKMesh
+{ // class TestDataWriterVTKMatMeshHex8
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKMatMeshHex8 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+ CPPUNIT_TEST( testWriteCellField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKMatMeshHex8
+
+#endif // pylith_meshio_testdatawritervtksubmeshhex8_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKMatMeshLine2.hh" // Implementation of class methods
+
+#include "data/DataWriterVTKDataMatMeshLine2.hh" // USES DataWriterVTKDataMeshLine2
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKMatMeshLine2 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKMatMeshLine2::setUp(void)
+{ // setUp
+ TestDataWriterVTKMesh::setUp();
+ _data = new DataWriterVTKDataMatMeshLine2;
+ _initialize();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKMatMeshLine2.hh
+ *
+ * @brief C++ TestDataWriterVTKMatMeshLine2 object
+ *
+ * C++ unit testing for DataWriterVTKMatMeshLine2.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtksubmeshline2_hh)
+#define pylith_meshio_testdatawritervtksubmeshline2_hh
+
+#include "TestDataWriterVTKMesh.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKMatMeshLine2;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKMatMeshLine2 : public TestDataWriterVTKMesh
+{ // class TestDataWriterVTKMatMeshLine2
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKMatMeshLine2 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+ CPPUNIT_TEST( testWriteCellField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKMatMeshLine2
+
+#endif // pylith_meshio_testdatawritervtksubmeshline2_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKMatMeshQuad4.hh" // Implementation of class methods
+
+#include "data/DataWriterVTKDataMatMeshQuad4.hh" // USES DataWriterVTKDataMeshQuad4
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKMatMeshQuad4 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKMatMeshQuad4::setUp(void)
+{ // setUp
+ TestDataWriterVTKMesh::setUp();
+ _data = new DataWriterVTKDataMatMeshQuad4;
+ _initialize();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKMatMeshQuad4.hh
+ *
+ * @brief C++ TestDataWriterVTKMatMeshQuad4 object
+ *
+ * C++ unit testing for DataWriterVTKMatMeshQuad4.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtksubmeshquad4_hh)
+#define pylith_meshio_testdatawritervtksubmeshquad4_hh
+
+#include "TestDataWriterVTKMesh.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKMatMeshQuad4;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKMatMeshQuad4 : public TestDataWriterVTKMesh
+{ // class TestDataWriterVTKMatMeshQuad4
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKMatMeshQuad4 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+ CPPUNIT_TEST( testWriteCellField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKMatMeshQuad4
+
+#endif // pylith_meshio_testdatawritervtksubmeshquad4_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKMatMeshTet4.hh" // Implementation of class methods
+
+#include "data/DataWriterVTKDataMatMeshTet4.hh" // USES DataWriterVTKDataMeshTet4
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKMatMeshTet4 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKMatMeshTet4::setUp(void)
+{ // setUp
+ TestDataWriterVTKMesh::setUp();
+ _data = new DataWriterVTKDataMatMeshTet4;
+ _initialize();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKMatMeshTet4.hh
+ *
+ * @brief C++ TestDataWriterVTKMatMeshTet4 object
+ *
+ * C++ unit testing for DataWriterVTKMatMeshTet4.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtksubmeshtet4_hh)
+#define pylith_meshio_testdatawritervtksubmeshtet4_hh
+
+#include "TestDataWriterVTKMesh.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKMatMeshTet4;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKMatMeshTet4 : public TestDataWriterVTKMesh
+{ // class TestDataWriterVTKMatMeshTet4
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKMatMeshTet4 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+ CPPUNIT_TEST( testWriteCellField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKMatMeshTet4
+
+#endif // pylith_meshio_testdatawritervtksubmeshtet4_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKMatMeshTri3.hh" // Implementation of class methods
+
+#include "data/DataWriterVTKDataMatMeshTri3.hh" // USES DataWriterVTKDataMeshTri3
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKMatMeshTri3 );
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKMatMeshTri3::setUp(void)
+{ // setUp
+ TestDataWriterVTKMesh::setUp();
+ _data = new DataWriterVTKDataMatMeshTri3;
+ _flipFault = true;
+
+ _initialize();
+} // setUp
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,57 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKMatMeshTri3.hh
+ *
+ * @brief C++ TestDataWriterVTKMatMeshTri3 object
+ *
+ * C++ unit testing for DataWriterVTKMatMeshTri3.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtksubmeshtri3_hh)
+#define pylith_meshio_testdatawritervtksubmeshtri3_hh
+
+#include "TestDataWriterVTKMesh.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKMatMeshTri3;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKMatMeshTri3 : public TestDataWriterVTKMesh
+{ // class TestDataWriterVTKMatMeshTri3
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKMatMeshTri3 );
+
+ CPPUNIT_TEST( testTimeStep );
+ CPPUNIT_TEST( testWriteVertexField );
+ CPPUNIT_TEST( testWriteCellField );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+}; // class TestDataWriterVTKMatMeshTri3
+
+#endif // pylith_meshio_testdatawritervtksubmeshtri3_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,20 +16,256 @@
#include "data/DataWriterVTKData.hh" // USES DataWriterVTKData
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKMesh::setUp(void)
+{ // setUp
+ TestDataWriterVTK::setUp();
+ _mesh = 0;
+ _flipFault = false;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::meshio::TestDataWriterVTKMesh::tearDown(void)
+{ // tearDown
+ TestDataWriterVTK::tearDown();
+ delete _mesh; _mesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestDataWriterVTKMesh::testConstructor(void)
+{ // testConstructor
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ CPPUNIT_ASSERT(0 == writer._viewer);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test filename()
+void
+pylith::meshio::TestDataWriterVTKMesh::testFilename(void)
+{ // testDebug
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ const char* filename = "data.vtk";
+ writer.filename(filename);
+ CPPUNIT_ASSERT_EQUAL(std::string(filename), writer._filename);
+} // testFilename
+
+// ----------------------------------------------------------------------
+// Test timeFormat()
+void
+pylith::meshio::TestDataWriterVTKMesh::testTimeFormat(void)
+{ // testTimeFormat
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ const char* format = "%4.1f";
+ writer.timeFormat(format);
+ CPPUNIT_ASSERT_EQUAL(std::string(format), writer._timeFormat);
+} // testInterpolate
+
+// ----------------------------------------------------------------------
+// Test timeConstant()
+void
+pylith::meshio::TestDataWriterVTKMesh::testTimeConstant(void)
+{ // testTimeConstant
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ const double value = 4.5;
+ writer.timeConstant(value);
+ CPPUNIT_ASSERT_EQUAL(value, writer._timeConstant);
+} // testInterpolate
+
+// ----------------------------------------------------------------------
+// Test openTimeStep() and closeTimeStep()
+void
+pylith::meshio::TestDataWriterVTKMesh::testTimeStep(void)
+{ // testTimeStep
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ writer.filename(_data->timestepFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_mesh, numTimeSteps);
+ writer.openTimeStep(t, *_mesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_mesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_mesh, label, id);
+ } // else
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ writer.closeTimeStep();
+ writer.close();
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->timestepFilename, t, _data->timeFormat);
+} // testTimeStep
+
+// ----------------------------------------------------------------------
+// Test writeVertexField.
+void
+pylith::meshio::TestDataWriterVTKMesh::testWriteVertexField(void)
+{ // testWriteVertexField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ topology::Fields<MeshField> vertexFields(*_mesh);
+ _createVertexFields(&vertexFields);
+
+ writer.filename(_data->vertexFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numVertexFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_mesh, numTimeSteps);
+ writer.openTimeStep(t, *_mesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_mesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_mesh, label, id);
+ } // else
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = vertexFields.get(_data->vertexFieldsInfo[i].name);
+ writer.writeVertexField(t, field);
+ CPPUNIT_ASSERT(writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ } // for
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->vertexFilename, t, _data->timeFormat);
+} // testWriteVertexField
+
+// ----------------------------------------------------------------------
+// Test writeCellField.
+void
+pylith::meshio::TestDataWriterVTKMesh::testWriteCellField(void)
+{ // testWriteCellField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ topology::Fields<MeshField> cellFields(*_mesh);
+ _createCellFields(&cellFields);
+
+ writer.filename(_data->cellFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numCellFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_mesh, numTimeSteps);
+ writer.openTimeStep(t, *_mesh);
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_mesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_mesh, label, id);
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field, label, id);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } // else
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->cellFilename, t, _data->timeFormat);
+} // testWriteCellField
+
+// ----------------------------------------------------------------------
+// Test _vtkFilename.
+void pylith::meshio::TestDataWriterVTKMesh::testVtkFilename(void)
+{ // testVtkFilename
+ DataWriterVTK<topology::Mesh, MeshField> writer;
+
+ // Append info to filename if number of time steps is 0.
+ writer._numTimeSteps = 0;
+ writer._filename = "output.vtk";
+ CPPUNIT_ASSERT_EQUAL(std::string("output_info.vtk"), writer._vtkFilename(0.0));
+
+ // Use default normalization of 1.0, remove period from time stamp.
+ writer._numTimeSteps = 100;
+ writer._filename = "output.vtk";
+ writer.timeFormat("%05.2f");
+ CPPUNIT_ASSERT_EQUAL(std::string("output_t0230.vtk"),
+ writer._vtkFilename(2.3));
+
+ // Use normalization of 20.0, remove period from time stamp.
+ writer._numTimeSteps = 100;
+ writer._filename = "output.vtk";
+ writer.timeFormat("%05.2f");
+ writer.timeConstant(20.0);
+ CPPUNIT_ASSERT_EQUAL(std::string("output_t0250.vtk"),
+ writer._vtkFilename(50.0));
+} // testVtkFilename
+
+// ----------------------------------------------------------------------
// Initialize mesh.
void
pylith::meshio::TestDataWriterVTKMesh::_initialize(void)
{ // _initialize
CPPUNIT_ASSERT(0 != _data);
+ delete _mesh; _mesh = new topology::Mesh;
MeshIOAscii iohandler;
iohandler.filename(_data->meshFilename);
- iohandler.read(&_mesh);
- CPPUNIT_ASSERT(!_mesh.isNull());
+ iohandler.read(_mesh);
if (0 != _data->faultLabel) {
faults::FaultCohesiveKin fault;
@@ -39,5 +275,100 @@
} // if
} // _initialize
+// ----------------------------------------------------------------------
+// Create vertex fields.
+void
+pylith::meshio::TestDataWriterVTKMesh::_createVertexFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createVertexFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+ try {
+ const int nfields = _data->numVertexFields;
+
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<topology::Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const topology::Mesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Set vertex fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->vertexFieldsInfo[i].name;
+ const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int ipt = 0;
+ for (topology::Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++ipt) {
+ const double* values = &_data->vertexFields[i][ipt*fiberDim];
+ section->updatePoint(*v_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createVertexFields
+
+// ----------------------------------------------------------------------
+// Create cell fields.
+void
+pylith::meshio::TestDataWriterVTKMesh::_createCellFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createCellFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ try {
+ const int nfields = _data->numCellFields;
+
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<topology::Mesh::SieveMesh::label_sequence>& cells =
+ (0 == _data->cellsLabel) ?
+ sieveMesh->depthStratum(1) :
+ sieveMesh->getLabelStratum(_data->cellsLabel, _data->labelId);
+ const topology::Mesh::SieveMesh::label_sequence::iterator cellsEnd =
+ cells->end();
+
+ // Set cell fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->cellFieldsInfo[i].name;
+ const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int icell = 0;
+ for (topology::Mesh::SieveMesh::label_sequence::iterator c_iter=cells->begin();
+ c_iter != cellsEnd;
+ ++c_iter, ++icell) {
+ const double* values = &_data->cellFields[i][icell*fiberDim];
+ section->updatePoint(*c_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numCells, icell);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createCellFields
+
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,8 +21,10 @@
#if !defined(pylith_meshio_testdatawritervtkmesh_hh)
#define pylith_meshio_testdatawritervtkmesh_hh
-#include "TestDataWriterVTK.hh"
+#include "TestDataWriterVTK.hh" // ISA TestDataWriterVTK
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, Field
+
/// Namespace for pylith package
namespace pylith {
namespace meshio {
@@ -34,12 +36,79 @@
class pylith::meshio::TestDataWriterVTKMesh : public TestDataWriterVTK
{ // class TestDataWriterVTKMesh
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testFilename );
+ CPPUNIT_TEST( testTimeFormat );
+ CPPUNIT_TEST( testTimeConstant );
+ CPPUNIT_TEST( testVtkFilename );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test constructor
+ void testConstructor(void);
+
+ /// Test filename()
+ void testFilename(void);
+
+ /// Test timeFormat()
+ void testTimeFormat(void);
+
+ /// Test timeConstant()
+ void testTimeConstant(void);
+
+ /// Test openTimeStep() and closeTimeStep()
+ void testTimeStep(void);
+
+ /// Test writeVertexField.
+ void testWriteVertexField(void);
+
+ /// Test writeCellField.
+ void testWriteCellField(void);
+
+ /// Test vtkFilename.
+ void testVtkFilename(void);
+
// PROTECTED MEMBERS //////////////////////////////////////////////////
protected :
/// Initialize mesh.
void _initialize(void);
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ topology::Mesh* _mesh; ///< Mesh for data
+ bool _flipFault; ///< If true, flip fault orientation.
+
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ /** Create vertex fields.
+ *
+ * @param fields Vertex fields.
+ */
+ void
+ _createVertexFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
+
+ /** Create cell fields.
+ *
+ * @param fields Cell fields.
+ */
+ void
+ _createCellFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
+
}; // class TestDataWriterVTKMesh
#endif // pylith_meshio_testdatawritervtkmesh_hh
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKSubMesh.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,328 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestDataWriterVTKSubMesh.hh" // Implementation of class methods
+
+#include "data/DataWriterVTKData.hh" // USES DataWriterVTKData
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
+#include "pylith/faults/FaultCohesiveKin.hh" // USES FaultCohesiveKin
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestDataWriterVTKSubMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+typedef pylith::topology::Field<pylith::topology::SubMesh> SubMeshField;
+
+// ----------------------------------------------------------------------
+// Setup testing data.
+void
+pylith::meshio::TestDataWriterVTKSubMesh::setUp(void)
+{ // setUp
+ TestDataWriterVTK::setUp();
+ _mesh = 0;
+ _submesh = 0;
+ _flipFault = false;
+} // setUp
+
+// ----------------------------------------------------------------------
+// Tear down testing data.
+void
+pylith::meshio::TestDataWriterVTKSubMesh::tearDown(void)
+{ // tearDown
+ TestDataWriterVTK::tearDown();
+ delete _mesh; _mesh = 0;
+ delete _submesh; _submesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor
+void
+pylith::meshio::TestDataWriterVTKSubMesh::testConstructor(void)
+{ // testConstructor
+ DataWriterVTK<topology::SubMesh, MeshField> writer;
+
+ CPPUNIT_ASSERT(0 == writer._viewer);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test openTimeStep() and closeTimeStep()
+void
+pylith::meshio::TestDataWriterVTKSubMesh::testTimeStep(void)
+{ // testTimeStep
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, MeshField> writer;
+
+ writer.filename(_data->timestepFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_submesh, numTimeSteps);
+ writer.openTimeStep(t, *_submesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_submesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_submesh, label, id);
+ } // else
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ writer.closeTimeStep();
+ writer.close();
+
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->timestepFilename, t, _data->timeFormat);
+} // testTimeStep
+
+// ----------------------------------------------------------------------
+// Test writeVertexField.
+void
+pylith::meshio::TestDataWriterVTKSubMesh::testWriteVertexField(void)
+{ // testWriteVertexField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, MeshField> writer;
+
+ topology::Fields<MeshField> vertexFields(*_mesh);
+ _createVertexFields(&vertexFields);
+
+ writer.filename(_data->vertexFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numVertexFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_submesh, numTimeSteps);
+ writer.openTimeStep(t, *_submesh);
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_submesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_submesh, label, id);
+ } // else
+ for (int i=0; i < nfields; ++i) {
+ const MeshField& field = vertexFields.get(_data->vertexFieldsInfo[i].name);
+ writer.writeVertexField(t, field);
+ CPPUNIT_ASSERT(writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ } // for
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->vertexFilename, t, _data->timeFormat);
+} // testWriteVertexField
+
+// ----------------------------------------------------------------------
+// Test writeCellField.
+void
+pylith::meshio::TestDataWriterVTKSubMesh::testWriteCellField(void)
+{ // testWriteCellField
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ DataWriterVTK<topology::SubMesh, SubMeshField> writer;
+
+ topology::Fields<SubMeshField> cellFields(*_submesh);
+ _createCellFields(&cellFields);
+
+ writer.filename(_data->cellFilename);
+ writer.timeFormat(_data->timeFormat);
+
+ const int nfields = _data->numCellFields;
+
+ const double t = _data->time;
+ const int numTimeSteps = 1;
+ if (0 == _data->cellsLabel) {
+ writer.open(*_submesh, numTimeSteps);
+ writer.openTimeStep(t, *_submesh);
+ for (int i=0; i < nfields; ++i) {
+ const SubMeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } else {
+ const char* label = _data->cellsLabel;
+ const int id = _data->labelId;
+ writer.open(*_submesh, numTimeSteps, label, id);
+ writer.openTimeStep(t, *_submesh, label, id);
+ for (int i=0; i < nfields; ++i) {
+ const SubMeshField& field = cellFields.get(_data->cellFieldsInfo[i].name);
+ writer.writeCellField(t, field, label, id);
+ CPPUNIT_ASSERT(false == writer._wroteVertexHeader);
+ CPPUNIT_ASSERT(writer._wroteCellHeader);
+ } // for
+ } // else
+ writer.closeTimeStep();
+ writer.close();
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+ CPPUNIT_ASSERT(false == writer._wroteCellHeader);
+
+ checkFile(_data->cellFilename, t, _data->timeFormat);
+} // testWriteCellField
+
+// ----------------------------------------------------------------------
+// Initialize mesh.
+void
+pylith::meshio::TestDataWriterVTKSubMesh::_initialize(void)
+{ // _initialize
+ CPPUNIT_ASSERT(0 != _data);
+
+ delete _mesh; _mesh = new topology::Mesh;
+ MeshIOAscii iohandler;
+ iohandler.filename(_data->meshFilename);
+ iohandler.read(_mesh);
+
+ if (0 != _data->faultLabel) {
+ faults::FaultCohesiveKin fault;
+ fault.label(_data->faultLabel);
+ fault.id(_data->faultId);
+ fault.adjustTopology(_mesh, _flipFault);
+ } // if
+
+ CPPUNIT_ASSERT(0 != _data->bcLabel);
+ delete _submesh; _submesh = new topology::SubMesh(*_mesh, _data->bcLabel);
+ const ALE::Obj<topology::Mesh::SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ assert(!sieveMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveSubMesh =
+ _submesh->sieveMesh();
+ assert(!sieveSubMesh.isNull());
+ sieveSubMesh->setRealSection("coordinates",
+ sieveMesh->getRealSection("coordinates"));
+ //_mesh->view("BC mesh");
+} // _initialize
+
+// ----------------------------------------------------------------------
+// Create vertex fields.
+void
+pylith::meshio::TestDataWriterVTKSubMesh::_createVertexFields(
+ topology::Fields<MeshField>* fields) const
+{ // _createVertexFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ try {
+ const int nfields = _data->numVertexFields;
+
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveMesh =
+ _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const topology::SubMesh::SieveMesh::label_sequence::iterator verticesEnd =
+ vertices->end();
+
+ // Set vertex fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->vertexFieldsInfo[i].name;
+ const int fiberDim = _data->vertexFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ MeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(_data->vertexFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int ipt = 0;
+ for (topology::SubMesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != verticesEnd;
+ ++v_iter, ++ipt) {
+ const double* values = &_data->vertexFields[i][ipt*fiberDim];
+ section->updatePoint(*v_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numVertices, ipt);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createVertexFields
+
+// ----------------------------------------------------------------------
+// Create cell fields.
+void
+pylith::meshio::TestDataWriterVTKSubMesh::_createCellFields(
+ topology::Fields<SubMeshField>* fields) const
+{ // _createCellFields
+ CPPUNIT_ASSERT(0 != fields);
+ CPPUNIT_ASSERT(0 != _mesh);
+ CPPUNIT_ASSERT(0 != _data);
+
+ try {
+ const int nfields = _data->numCellFields;
+
+ const ALE::Obj<topology::SubMesh::SieveMesh>& sieveSubMesh =
+ _submesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveSubMesh.isNull());
+ const ALE::Obj<topology::SubMesh::SieveMesh::label_sequence>& cells =
+ sieveSubMesh->heightStratum(1);
+ assert(!cells.isNull());
+ const topology::SubMesh::SieveMesh::label_sequence::iterator cellsBegin =
+ cells->begin();
+ const topology::SubMesh::SieveMesh::label_sequence::iterator cellsEnd =
+ cells->end();
+
+ // Set cell fields
+ for (int i=0; i < nfields; ++i) {
+ const char* name = _data->cellFieldsInfo[i].name;
+ const int fiberDim = _data->cellFieldsInfo[i].fiber_dim;
+ fields->add(name, name);
+ SubMeshField& field = fields->get(name);
+ field.newSection(topology::FieldBase::CELLS_FIELD, fiberDim, 1);
+ field.allocate();
+ field.vectorFieldType(_data->cellFieldsInfo[i].field_type);
+
+ const ALE::Obj<topology::SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int icell = 0;
+ for (topology::SubMesh::SieveMesh::label_sequence::iterator c_iter=cellsBegin;
+ c_iter != cellsEnd;
+ ++c_iter, ++icell) {
+ const double* values = &_data->cellFields[i][icell*fiberDim];
+ section->updatePoint(*c_iter, values);
+ } // for
+ CPPUNIT_ASSERT_EQUAL(_data->numCells, icell);
+ } // for
+ } catch (const ALE::Exception& err) {
+ throw std::runtime_error(err.msg());
+ } // catch
+} // _createCellFields
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/TestDataWriterVTKSubMesh.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/meshio/TestDataWriterVTKSubMesh.hh
+ *
+ * @brief C++ TestDataWriterVTKSubMesh object
+ *
+ * C++ unit testing for DataWriterVTKSubMesh.
+ */
+
+#if !defined(pylith_meshio_testdatawritervtksubmesh_hh)
+#define pylith_meshio_testdatawritervtksubmesh_hh
+
+#include "TestDataWriterVTK.hh"
+
+#include "pylith/topology/topologyfwd.hh" // USES Mesh, SubMesh, Field
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace meshio {
+ class TestDataWriterVTKSubMesh;
+ } // meshio
+} // pylith
+
+/// C++ unit testing for DataWriterVTK
+class pylith::meshio::TestDataWriterVTKSubMesh : public TestDataWriterVTK
+{ // class TestDataWriterVTKSubMesh
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestDataWriterVTKSubMesh );
+
+ CPPUNIT_TEST( testConstructor );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup testing data.
+ void setUp(void);
+
+ /// Tear down testing data.
+ void tearDown(void);
+
+ /// Test constructor
+ void testConstructor(void);
+
+ /// Test openTimeStep() and closeTimeStep()
+ void testTimeStep(void);
+
+ /// Test writeVertexField.
+ void testWriteVertexField(void);
+
+ /// Test writeCellField.
+ void testWriteCellField(void);
+
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ /// Initialize mesh.
+ void _initialize(void);
+
+ // PROTECTED MEMBERS //////////////////////////////////////////////////
+protected :
+
+ topology::Mesh* _mesh; ///< Mesh for domain
+ topology::SubMesh* _submesh; ///< Mesh for subdomain.
+ bool _flipFault; ///< If true, flip fault orientation.
+
+ // PRIVATE MEMBERS ////////////////////////////////////////////////////
+private :
+
+ /** Create vertex fields.
+ *
+ * @param fields Vertex fields.
+ */
+ void
+ _createVertexFields(topology::Fields<topology::Field<topology::Mesh> >* fields) const;
+
+ /** Create cell fields.
+ *
+ * @param fields Cell fields.
+ */
+ void
+ _createCellFields(topology::Fields<topology::Field<topology::SubMesh> >* fields) const;
+
+}; // class TestDataWriterVTKSubMesh
+
+#endif // pylith_meshio_testdatawritervtksubmesh_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,7 +24,7 @@
void
pylith::meshio::TestDataWriterVTKSubMeshHex8::setUp(void)
{ // setUp
- TestDataWriterVTKMesh::setUp();
+ TestDataWriterVTKSubMesh::setUp();
_data = new DataWriterVTKDataSubMeshHex8;
_flipFault = true;
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_meshio_testdatawritervtksubmeshhex8_hh)
#define pylith_meshio_testdatawritervtksubmeshhex8_hh
-#include "TestDataWriterVTKMesh.hh"
+#include "TestDataWriterVTKSubMesh.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,7 +31,7 @@
} // pylith
/// C++ unit testing for DataWriterVTK
-class pylith::meshio::TestDataWriterVTKSubMeshHex8 : public TestDataWriterVTKMesh
+class pylith::meshio::TestDataWriterVTKSubMeshHex8 : public TestDataWriterVTKSubMesh
{ // class TestDataWriterVTKSubMeshHex8
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,7 +24,7 @@
void
pylith::meshio::TestDataWriterVTKSubMeshLine2::setUp(void)
{ // setUp
- TestDataWriterVTKMesh::setUp();
+ TestDataWriterVTKSubMesh::setUp();
_data = new DataWriterVTKDataSubMeshLine2;
_initialize();
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_meshio_testdatawritervtksubmeshline2_hh)
#define pylith_meshio_testdatawritervtksubmeshline2_hh
-#include "TestDataWriterVTKMesh.hh"
+#include "TestDataWriterVTKSubMesh.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,7 +31,7 @@
} // pylith
/// C++ unit testing for DataWriterVTK
-class pylith::meshio::TestDataWriterVTKSubMeshLine2 : public TestDataWriterVTKMesh
+class pylith::meshio::TestDataWriterVTKSubMeshLine2 : public TestDataWriterVTKSubMesh
{ // class TestDataWriterVTKSubMeshLine2
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,7 +24,7 @@
void
pylith::meshio::TestDataWriterVTKSubMeshQuad4::setUp(void)
{ // setUp
- TestDataWriterVTKMesh::setUp();
+ TestDataWriterVTKSubMesh::setUp();
_data = new DataWriterVTKDataSubMeshQuad4;
_initialize();
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_meshio_testdatawritervtksubmeshquad4_hh)
#define pylith_meshio_testdatawritervtksubmeshquad4_hh
-#include "TestDataWriterVTKMesh.hh"
+#include "TestDataWriterVTKSubMesh.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,7 +31,7 @@
} // pylith
/// C++ unit testing for DataWriterVTK
-class pylith::meshio::TestDataWriterVTKSubMeshQuad4 : public TestDataWriterVTKMesh
+class pylith::meshio::TestDataWriterVTKSubMeshQuad4 : public TestDataWriterVTKSubMesh
{ // class TestDataWriterVTKSubMeshQuad4
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,7 +24,7 @@
void
pylith::meshio::TestDataWriterVTKSubMeshTet4::setUp(void)
{ // setUp
- TestDataWriterVTKMesh::setUp();
+ TestDataWriterVTKSubMesh::setUp();
_data = new DataWriterVTKDataSubMeshTet4;
_initialize();
} // setUp
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_meshio_testdatawritervtksubmeshtet4_hh)
#define pylith_meshio_testdatawritervtksubmeshtet4_hh
-#include "TestDataWriterVTKMesh.hh"
+#include "TestDataWriterVTKSubMesh.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,7 +31,7 @@
} // pylith
/// C++ unit testing for DataWriterVTK
-class pylith::meshio::TestDataWriterVTKSubMeshTet4 : public TestDataWriterVTKMesh
+class pylith::meshio::TestDataWriterVTKSubMeshTet4 : public TestDataWriterVTKSubMesh
{ // class TestDataWriterVTKSubMeshTet4
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,7 +24,7 @@
void
pylith::meshio::TestDataWriterVTKSubMeshTri3::setUp(void)
{ // setUp
- TestDataWriterVTKMesh::setUp();
+ TestDataWriterVTKSubMesh::setUp();
_data = new DataWriterVTKDataSubMeshTri3;
_flipFault = true;
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterVTKSubMeshTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,7 +21,7 @@
#if !defined(pylith_meshio_testdatawritervtksubmeshtri3_hh)
#define pylith_meshio_testdatawritervtksubmeshtri3_hh
-#include "TestDataWriterVTKMesh.hh"
+#include "TestDataWriterVTKSubMesh.hh"
/// Namespace for pylith package
namespace pylith {
@@ -31,7 +31,7 @@
} // pylith
/// C++ unit testing for DataWriterVTK
-class pylith::meshio::TestDataWriterVTKSubMeshTri3 : public TestDataWriterVTKMesh
+class pylith::meshio::TestDataWriterVTKSubMeshTri3 : public TestDataWriterVTKSubMesh
{ // class TestDataWriterVTKSubMeshTri3
// CPPUNIT TEST SUITE /////////////////////////////////////////////////
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,8 +14,9 @@
#include "TestMeshIO.hh" // Implementation of class methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/meshio/MeshIO.hh" // USES MeshIO
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+
#include "pylith/utils/array.hh" // USES int_array
#include "data/MeshData.hh"
@@ -24,8 +25,11 @@
#include <stdexcept> // USES std::logic_error
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
// Get simple mesh for testing I/O.
-ALE::Obj<pylith::Mesh>*
+pylith::topology::Mesh*
pylith::meshio::TestMeshIO::_createMesh(const MeshData& data)
{ // _createMesh
// buildTopology() requires zero based index
@@ -41,45 +45,49 @@
CPPUNIT_ASSERT(0 != data.groupTypes);
} // if
- ALE::Obj<Mesh>* mesh = new ALE::Obj<Mesh>;
+ topology::Mesh* mesh = new topology::Mesh(data.cellDim);
CPPUNIT_ASSERT(0 != mesh);
- *mesh = new Mesh(PETSC_COMM_WORLD, data.cellDim);
- CPPUNIT_ASSERT(!mesh->isNull());
- ALE::Obj<sieve_type> sieve = new sieve_type((*mesh)->comm());
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ ALE::Obj<SieveMesh::sieve_type> sieve =
+ new SieveMesh::sieve_type(mesh->comm());
CPPUNIT_ASSERT(!sieve.isNull());
// Cells and vertices
const bool interpolate = false;
- ALE::Obj<ALE::Mesh::sieve_type> s = new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, data.cellDim, data.numCells,
- const_cast<int*>(data.cells), data.numVertices,
+ const_cast<int*>(data.cells),
+ data.numVertices,
interpolate, data.numCorners);
- std::map<Mesh::point_type,Mesh::point_type> renumbering;
+ std::map<ALE::Mesh::point_type,ALE::Mesh::point_type> renumbering;
ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- (*mesh)->setSieve(sieve);
- (*mesh)->stratify();
- ALE::SieveBuilder<Mesh>::buildCoordinates(*mesh, data.spaceDim,
- data.vertices);
+ sieveMesh->setSieve(sieve);
+ sieveMesh->stratify();
+ ALE::SieveBuilder<SieveMesh>::buildCoordinates(sieveMesh, data.spaceDim,
+ data.vertices);
// Material ids
- const ALE::Obj<Mesh::label_sequence>& cells = (*mesh)->heightStratum(0);
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
CPPUNIT_ASSERT(!cells.isNull());
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- (*mesh)->createLabel("material-id");
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->createLabel("material-id");
CPPUNIT_ASSERT(!labelMaterials.isNull());
int i = 0;
- for(Mesh::label_sequence::iterator e_iter=cells->begin();
+ for(SieveMesh::label_sequence::iterator e_iter=cells->begin();
e_iter != cells->end();
++e_iter)
- (*mesh)->setValue(labelMaterials, *e_iter, data.materialIds[i++]);
+ sieveMesh->setValue(labelMaterials, *e_iter, data.materialIds[i++]);
// Groups
for (int iGroup=0, index=0; iGroup < data.numGroups; ++iGroup) {
- const ALE::Obj<int_section_type>& groupField =
- (*mesh)->getIntSection(data.groupNames[iGroup]);
+ const ALE::Obj<SieveMesh::int_section_type>& groupField =
+ sieveMesh->getIntSection(data.groupNames[iGroup]);
CPPUNIT_ASSERT(!groupField.isNull());
- groupField->setChart((*mesh)->getSieve()->getChart());
+ groupField->setChart(sieveMesh->getSieve()->getChart());
MeshIO::GroupPtType type;
const int numPoints = data.groupSizes[iGroup];
@@ -89,14 +97,13 @@
groupField->setFiberDimension(data.groups[index++], 1);
} else if (0 == strcasecmp("vertex", data.groupTypes[iGroup])) {
type = MeshIO::VERTEX;
- const int numCells = (*mesh)->heightStratum(0)->size();
+ const int numCells = sieveMesh->heightStratum(0)->size();
for(int i=0; i < numPoints; ++i)
groupField->setFiberDimension(data.groups[index++]+numCells, 1);
} else
throw std::logic_error("Could not parse group type.");
- (*mesh)->allocate(groupField);
+ sieveMesh->allocate(groupField);
} // for
- (*mesh)->getFactory()->clear();
return mesh;
} // _createMesh
@@ -104,16 +111,22 @@
// ----------------------------------------------------------------------
// Check values in mesh against data.
void
-pylith::meshio::TestMeshIO::_checkVals(const ALE::Obj<Mesh>& mesh,
+pylith::meshio::TestMeshIO::_checkVals(const topology::Mesh& mesh,
const MeshData& data)
{ // _checkVals
+ typedef SieveMesh::int_section_type::chart_type chart_type;
+
// Check mesh dimension
- CPPUNIT_ASSERT_EQUAL(data.cellDim, mesh->getDimension());
+ CPPUNIT_ASSERT_EQUAL(data.cellDim, mesh.dimension());
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
// Check vertices
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<Mesh::real_section_type>& coordsField =
- mesh->getRealSection("coordinates");
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ const ALE::Obj<SieveMesh::real_section_type>& coordsField =
+ sieveMesh->getRealSection("coordinates");
const int numVertices = vertices->size();
CPPUNIT_ASSERT(!vertices.isNull());
CPPUNIT_ASSERT(!coordsField.isNull());
@@ -122,41 +135,41 @@
coordsField->getFiberDimension(*vertices->begin()));
int i = 0;
const int spaceDim = data.spaceDim;
- for(Mesh::label_sequence::iterator v_iter =
+ for(SieveMesh::label_sequence::iterator v_iter =
vertices->begin();
v_iter != vertices->end();
++v_iter) {
- const Mesh::real_section_type::value_type *vertexCoords =
+ const SieveMesh::real_section_type::value_type *vertexCoords =
coordsField->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != vertexCoords);
const double tolerance = 1.0e-06;
for (int iDim=0; iDim < spaceDim; ++iDim)
if (data.vertices[i] < 1.0) {
CPPUNIT_ASSERT_DOUBLES_EQUAL(data.vertices[i++], vertexCoords[iDim],
- tolerance);
+ tolerance);
} else {
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, vertexCoords[iDim]/data.vertices[i++],
- tolerance);
+ tolerance);
}
} // for
// check cells
- const ALE::Obj<sieve_type>& sieve = mesh->getSieve();
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
+ const ALE::Obj<SieveMesh::sieve_type>& sieve = sieveMesh->getSieve();
+ const ALE::Obj<SieveMesh::label_sequence>& cells = sieveMesh->heightStratum(0);
const int numCells = cells->size();
CPPUNIT_ASSERT_EQUAL(data.numCells, numCells);
- const int numCorners = mesh->getNumCellCorners();
+ const int numCorners = sieveMesh->getNumCellCorners();
CPPUNIT_ASSERT_EQUAL(data.numCorners, numCorners);
- ALE::ISieveVisitor::PointRetriever<Mesh::sieve_type> pV(sieve->getMaxConeSize());
+ ALE::ISieveVisitor::PointRetriever<SieveMesh::sieve_type> pV(sieve->getMaxConeSize());
const int offset = numCells;
i = 0;
- for(Mesh::label_sequence::iterator e_iter = cells->begin();
+ for(SieveMesh::label_sequence::iterator e_iter = cells->begin();
e_iter != cells->end();
++e_iter) {
sieve->cone(*e_iter, pV);
- const Mesh::point_type *cone = pV.getPoints();
+ const SieveMesh::point_type *cone = pV.getPoints();
for(int p = 0; p < pV.getSize(); ++p, ++i) {
CPPUNIT_ASSERT_EQUAL(data.cells[i], cone[p]-offset);
}
@@ -164,23 +177,23 @@
} // for
// check materials
- const ALE::Obj<Mesh::label_type>& labelMaterials =
- mesh->getLabel("material-id");
+ const ALE::Obj<SieveMesh::label_type>& labelMaterials =
+ sieveMesh->getLabel("material-id");
const int idDefault = -999;
const int size = numCells;
int_array materialIds(size);
i = 0;
- for(Mesh::label_sequence::iterator e_iter = cells->begin();
+ for(SieveMesh::label_sequence::iterator e_iter = cells->begin();
e_iter != cells->end();
++e_iter)
- materialIds[i++] = mesh->getValue(labelMaterials, *e_iter, idDefault);
+ materialIds[i++] = sieveMesh->getValue(labelMaterials, *e_iter, idDefault);
for (int iCell=0; iCell < numCells; ++iCell)
CPPUNIT_ASSERT_EQUAL(data.materialIds[iCell], materialIds[iCell]);
// Check groups
const ALE::Obj<std::set<std::string> >& groupNames =
- mesh->getIntSections();
+ sieveMesh->getIntSections();
if (data.numGroups > 0) {
CPPUNIT_ASSERT(!groupNames.isNull());
CPPUNIT_ASSERT_EQUAL(data.numGroups, int(groupNames->size()));
@@ -190,22 +203,30 @@
for (std::set<std::string>::const_iterator name=groupNames->begin();
name != groupNames->end();
++name, ++iGroup) {
- const ALE::Obj<int_section_type>& groupField = mesh->getIntSection(*name);
+ const ALE::Obj<SieveMesh::int_section_type>& groupField =
+ sieveMesh->getIntSection(*name);
CPPUNIT_ASSERT(!groupField.isNull());
- const int_section_type::chart_type& chart = groupField->getChart();
- Mesh::point_type firstPoint;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
- if (groupField->getFiberDimension(*c_iter)) {firstPoint = *c_iter; break;}
- }
+ const chart_type& chart = groupField->getChart();
+ SieveMesh::point_type firstPoint;
+ for(chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chart.end();
+ ++c_iter) {
+ if (groupField->getFiberDimension(*c_iter)) {
+ firstPoint = *c_iter;
+ break;
+ } // if
+ } // for
std::string groupType =
- (mesh->height(firstPoint) == 0) ? "cell" : "vertex";
+ (sieveMesh->height(firstPoint) == 0) ? "cell" : "vertex";
const int numPoints = groupField->size();
int_array points(numPoints);
int i = 0;
const int offset = ("vertex" == groupType) ? numCells : 0;
- for(int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chart.end(); ++c_iter) {
- if (groupField->getFiberDimension(*c_iter)) points[i++] = *c_iter - offset;
- }
+ for(chart_type::const_iterator c_iter = chart.begin();
+ c_iter != chart.end();
+ ++c_iter)
+ if (groupField->getFiberDimension(*c_iter))
+ points[i++] = *c_iter - offset;
CPPUNIT_ASSERT_EQUAL(std::string(data.groupNames[iGroup]), *name);
CPPUNIT_ASSERT_EQUAL(std::string(data.groupTypes[iGroup]), groupType);
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIO.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,21 +21,23 @@
#if !defined(pylith_meshio_testmeshio_hh)
#define pylith_meshio_testmeshio_hh
+// Include directives ---------------------------------------------------
#include <cppunit/extensions/HelperMacros.h>
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/topology/topologyfwd.hh" // USES Mesh
+#include "pylith/meshio/meshiofwd.hh" // USES MeshIO
+// Forward declarations -------------------------------------------------
/// Namespace for pylith package
namespace pylith {
namespace meshio {
class TestMeshIO;
- class MeshIO;
- class MeshData;
+ class MeshData; // test data
} // meshio
} // pylith
-/// C++ unit testing for TestMeshIO
+// MeshIO ---------------------------------------------------------------
class pylith::meshio::TestMeshIO : public CppUnit::TestFixture
{ // class TestMeshIO
@@ -46,16 +48,16 @@
*
* @param data Mesh data
*
- * @returns PETSc mesh
+ * @returns PyLith mesh
*/
- ALE::Obj<pylith::Mesh>* _createMesh(const MeshData& data);
+ topology::Mesh* _createMesh(const MeshData& data);
/** Check values in mesh against data.
*
- * @param mesh PETSc mesh
+ * @param mesh PyLith mesh
* @param data Mesh data
*/
- void _checkVals(const ALE::Obj<Mesh>& mesh,
+ void _checkVals(const topology::Mesh& mesh,
const MeshData& data);
/** Test debug().
@@ -74,4 +76,5 @@
#endif // pylith_meshio_testmeshio_hh
+
// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
#include "pylith/meshio/MeshIOAscii.hh"
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "data/MeshData1D.hh"
#include "data/MeshData1Din2D.hh"
@@ -155,7 +155,7 @@
pylith::meshio::TestMeshIOAscii::_testWriteRead(const MeshData& data,
const char* filename)
{ // _testWriteRead
- ALE::Obj<Mesh>* meshOut = _createMesh(data);
+ topology::Mesh* meshOut = _createMesh(data);
// Write mesh
MeshIOAscii iohandler;
@@ -164,7 +164,7 @@
delete meshOut; meshOut = 0;
// Read mesh
- ALE::Obj<Mesh> meshIn;
+ topology::Mesh meshIn;
iohandler.read(&meshIn);
// Make sure meshIn matches data
@@ -178,7 +178,7 @@
const char* filename)
{ // _testWriteRead
// Read mesh
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
MeshIOAscii iohandler;
iohandler.filename(filename);
iohandler.read(&mesh);
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOAscii.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,9 +21,10 @@
#if !defined(pylith_meshio_testmeshioascii_hh)
#define pylith_meshio_testmeshioascii_hh
+// Include directives ---------------------------------------------------
#include "TestMeshIO.hh"
-/// Namespace for pylith package
+// Forward declarations -------------------------------------------------
namespace pylith {
namespace meshio {
class TestMeshIOAscii;
@@ -31,7 +32,7 @@
} // meshio
} // pylith
-/// C++ unit testing for Quadrature1D
+// TestMeshIOAscii ------------------------------------------------------
class pylith::meshio::TestMeshIOAscii : public TestMeshIO
{ // class TestMeshIOAscii
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
#include "pylith/meshio/MeshIOCubit.hh"
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/utils/array.hh" // USES int_array
#include "data/MeshDataCubitTri.hh"
@@ -30,6 +30,9 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestMeshIOCubit );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestMeshIOCubit::testConstructor(void)
@@ -117,7 +120,7 @@
iohandler.filename(filename);
// Read mesh
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
iohandler.read(&mesh);
// Make sure meshIn matches data
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOCubit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,9 +21,10 @@
#if !defined(pylith_meshio_testmeshiocubit_hh)
#define pylith_meshio_testmeshiocubit_hh
+// Include directives ---------------------------------------------------
#include "TestMeshIO.hh"
-/// Namespace for pylith package
+// Forward declarations -------------------------------------------------
namespace pylith {
namespace meshio {
class TestMeshIOCubit;
@@ -31,7 +32,7 @@
} // meshio
} // pylith
-/// C++ unit testing for Quadrature1D
+// TestMeshIOCubit ------------------------------------------------------
class pylith::meshio::TestMeshIOCubit : public TestMeshIO
{ // class TestMeshIOCubit
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,7 +16,7 @@
#include "pylith/meshio/MeshIOLagrit.hh"
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/utils/array.hh" // USES int_array
#include "data/MeshDataLagritTet.hh"
@@ -33,6 +33,9 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestMeshIOLagrit );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestMeshIOLagrit::testConstructor(void)
@@ -146,7 +149,7 @@
#endif
// Read mesh
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
iohandler.read(&mesh);
// Make sure meshIn matches data
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestMeshIOLagrit.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,9 +21,10 @@
#if !defined(pylith_meshio_testmeshiolagrit_hh)
#define pylith_meshio_testmeshiolagrit_hh
+// Include directives ---------------------------------------------------
#include "TestMeshIO.hh"
-/// Namespace for pylith package
+// Forward declarations -------------------------------------------------
namespace pylith {
namespace meshio {
class TestMeshIOLagrit;
@@ -31,7 +32,7 @@
} // meshio
} // pylith
-/// C++ unit testing for Quadrature1D
+// TestMeshIOLagrit -----------------------------------------------------
class pylith::meshio::TestMeshIOLagrit : public TestMeshIO
{ // class TestMeshIOLagrit
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputManager.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputManager.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputManager.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,6 +14,8 @@
#include "TestOutputManager.hh" // Implementation of class methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
#include "pylith/meshio/OutputManager.hh"
#include "TestDataWriterVTK.hh" // USES TestDataWriterVTK::checkFile()
@@ -23,7 +25,7 @@
#include "pylith/meshio/DataWriterVTK.hh" // USES DataWriterVTK
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/feassemble/Quadrature2D.hh" // USES Quadrature
+#include "pylith/feassemble/Quadrature.hh" // USES Quadrature
#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
@@ -33,11 +35,16 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestOutputManager );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestOutputManager::testConstructor(void)
{ // testConstructor
- OutputManager manager;
+ OutputManager<topology::Mesh, MeshField> manager;
} // testConstructor
// ----------------------------------------------------------------------
@@ -45,7 +52,7 @@
void
pylith::meshio::TestOutputManager::testCoordsys(void)
{ // testCoordsys
- OutputManager manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._coordsys);
@@ -59,11 +66,11 @@
void
pylith::meshio::TestOutputManager::testWriter(void)
{ // testWriter
- OutputManager manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._writer);
- DataWriterVTK writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
manager.writer(&writer);
CPPUNIT_ASSERT(0 != manager._writer);
} // testWriter
@@ -73,12 +80,12 @@
void
pylith::meshio::TestOutputManager::testVertexFilter(void)
{ // testVertexFilter
- OutputManager manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._vertexFilter);
CPPUNIT_ASSERT(0 == manager._cellFilter);
- VertexFilterVecNorm filter;
+ VertexFilterVecNorm<MeshField> filter;
manager.vertexFilter(&filter);
CPPUNIT_ASSERT(0 != manager._vertexFilter);
CPPUNIT_ASSERT(0 == manager._cellFilter);
@@ -89,12 +96,12 @@
void
pylith::meshio::TestOutputManager::testCellFilter(void)
{ // testCellFilter
- OutputManager manager;
+ OutputManager<topology::Mesh, MeshField> manager;
CPPUNIT_ASSERT(0 == manager._vertexFilter);
CPPUNIT_ASSERT(0 == manager._cellFilter);
- CellFilterAvg filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
manager.cellFilter(&filter);
CPPUNIT_ASSERT(0 != manager._cellFilter);
CPPUNIT_ASSERT(0 == manager._vertexFilter);
@@ -105,23 +112,22 @@
void
pylith::meshio::TestOutputManager::testOpenClose(void)
{ // testOpenClose
- OutputManager manager;
+ OutputManager<topology::Mesh, MeshField> manager;
+ topology::Mesh mesh;
MeshIOAscii iohandler;
- ALE::Obj<Mesh> mesh;
iohandler.filename("data/tri3.mesh");
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
spatialdata::geocoords::CSCart cs;
const int numTimeSteps = 1;
// TODO Replace DataVTKWriter with writer that has nontrivial
// open()/close().
- DataWriterVTK writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
manager.writer(&writer);
- manager.open(mesh, &cs, numTimeSteps);
+ manager.open(mesh, numTimeSteps);
manager.close();
} // testOpenClose
@@ -130,13 +136,12 @@
void
pylith::meshio::TestOutputManager::testOpenCloseTimeStep(void)
{ // testOpenCloseTimeStep
- OutputManager manager;
+ OutputManager<topology::Mesh, MeshField> manager;
+ topology::Mesh mesh;
MeshIOAscii iohandler;
- ALE::Obj<Mesh> mesh;
iohandler.filename("data/tri3.mesh");
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
spatialdata::geocoords::CSCart cs;
const int numTimeSteps = 1;
@@ -144,13 +149,13 @@
const char* filenameRoot = "output.vtk";
const char* timeFormat = "%3.1f";
- DataWriterVTK writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
writer.filename(filenameRoot);
writer.timeFormat(timeFormat);
manager.writer(&writer);
- manager.open(mesh, &cs, numTimeSteps);
- manager.openTimeStep(t, mesh, &cs);
+ manager.open(mesh, numTimeSteps);
+ manager.openTimeStep(t, mesh);
manager.closeTimeStep();
manager.close();
@@ -162,13 +167,12 @@
void
pylith::meshio::TestOutputManager::testAppendVertexField(void)
{ // testAppendVertexField
- OutputManager manager;
-
const char* meshFilename = "data/tri3.mesh";
const int fiberDim = 2;
const int nvertices = 4;
- const char* fieldName = "field data";
- const VectorFieldEnum fieldType = VECTOR_FIELD;
+ const char* label = "field data";
+ const topology::FieldBase::VectorFieldEnum fieldType =
+ topology::FieldBase::VECTOR;
const double fieldValues[] = {
1.1, 1.2,
2.1, 2.2,
@@ -176,30 +180,34 @@
4.1, 4.2
};
+ topology::Mesh mesh;
MeshIOAscii iohandler;
- ALE::Obj<Mesh> mesh;
iohandler.filename(meshFilename);
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
// Set vertex field
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
- ALE::Obj<real_section_type> field =
- new real_section_type(mesh->comm(), mesh->debug());
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, fiberDim);
- mesh->allocate(field);
+ MeshField field(mesh);
+ field.newSection(vertices, fiberDim);
+ field.allocate();
+ field.label(label);
+ field.vectorFieldType(fieldType);
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
CPPUNIT_ASSERT_EQUAL(nvertices, int(vertices->size()));
-
int ipt = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++ipt) {
const double* values = &fieldValues[ipt*fiberDim];
- field->updatePoint(*v_iter, values);
+ section->updatePoint(*v_iter, values);
} // for
spatialdata::geocoords::CSCart cs;
@@ -209,27 +217,28 @@
const char* filenameRootF = "output_vertex_filter.vtk";
const char* timeFormat = "%3.1f";
- DataWriterVTK writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
writer.filename(filenameRoot);
writer.timeFormat(timeFormat);
+
+ OutputManager<topology::Mesh, MeshField> manager;
manager.writer(&writer);
-
- manager.open(mesh, &cs, numTimeSteps);
- manager.openTimeStep(t, mesh, &cs);
- manager.appendVertexField(t, fieldName, field, fieldType, mesh);
+ manager.open(mesh, numTimeSteps);
+ manager.openTimeStep(t, mesh);
+ manager.appendVertexField(t, field);
manager.closeTimeStep();
manager.close();
TestDataWriterVTK::checkFile(filenameRoot, t, timeFormat);
- VertexFilterVecNorm filter;
+ VertexFilterVecNorm<MeshField> filter;
manager.vertexFilter(&filter);
writer.filename(filenameRootF);
manager.writer(&writer);
- manager.open(mesh, &cs, numTimeSteps);
- manager.openTimeStep(t, mesh, &cs);
- manager.appendVertexField(t, fieldName, field, fieldType, mesh);
+ manager.open(mesh, numTimeSteps);
+ manager.openTimeStep(t, mesh);
+ manager.appendVertexField(t, field);
manager.closeTimeStep();
manager.close();
@@ -241,42 +250,46 @@
void
pylith::meshio::TestOutputManager::testAppendCellField(void)
{ // testAppendCellField
- OutputManager manager;
const char* meshFilename = "data/tri3.mesh";
const int fiberDim = 2;
const int ncells = 2;
- const char* fieldName = "field data";
- const VectorFieldEnum fieldType = OTHER_FIELD;
+ const char* label = "field data";
+ const topology::FieldBase::VectorFieldEnum fieldType =
+ topology::FieldBase::MULTI_SCALAR;
const double fieldValues[] = {
1.1, 1.2,
2.1, 2.2,
};
+ topology::Mesh mesh;
MeshIOAscii iohandler;
- ALE::Obj<Mesh> mesh;
iohandler.filename(meshFilename);
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
// Set cell field
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveMesh->heightStratum(0);
+ CPPUNIT_ASSERT(!cells.isNull());
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
- ALE::Obj<real_section_type> field =
- new real_section_type(mesh->comm(), mesh->debug());
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(cells, fiberDim);
- mesh->allocate(field);
+ MeshField field(mesh);
+ field.newSection(cells, fiberDim);
+ field.allocate();
+ field.label(label);
+ field.vectorFieldType(fieldType);
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
CPPUNIT_ASSERT_EQUAL(ncells, int(cells->size()));
-
int ipt = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin();
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin();
c_iter != cellsEnd;
++c_iter, ++ipt) {
const double* values = &fieldValues[ipt*fiberDim];
- field->updatePoint(*c_iter, values);
+ section->updatePoint(*c_iter, values);
} // for
spatialdata::geocoords::CSCart cs;
@@ -286,14 +299,15 @@
const char* filenameRootF = "output_cell_filter.vtk";
const char* timeFormat = "%3.1f";
- DataWriterVTK writer;
+ DataWriterVTK<topology::Mesh, MeshField> writer;
writer.filename(filenameRoot);
writer.timeFormat(timeFormat);
+
+ OutputManager<topology::Mesh, MeshField> manager;
manager.writer(&writer);
-
- manager.open(mesh, &cs, numTimeSteps);
- manager.openTimeStep(t, mesh, &cs);
- manager.appendCellField(t, fieldName, field, fieldType, mesh);
+ manager.open(mesh, numTimeSteps);
+ manager.openTimeStep(t, mesh);
+ manager.appendCellField(t, field);
manager.closeTimeStep();
manager.close();
@@ -321,20 +335,22 @@
const double quadWts[] = { 1.5, 0.5 };
const double minJacobian = 1.0;
- feassemble::Quadrature2D quadrature;
- quadrature.initialize(basis, basisDerivRef, quadPtsRef, quadWts,
- cellDim, numBasis, numQuadPts, spaceDim);
+ feassemble::Quadrature<topology::Mesh> quadrature;
+ quadrature.initialize(basis, numQuadPts, numBasis,
+ basisDerivRef, numQuadPts, numBasis, cellDim,
+ quadPtsRef, numQuadPts, cellDim,
+ quadWts, numQuadPts,
+ spaceDim);
-
- CellFilterAvg filter;
+ CellFilterAvg<topology::Mesh, MeshField> filter;
filter.quadrature(&quadrature);
manager.cellFilter(&filter);
writer.filename(filenameRootF);
manager.writer(&writer);
- manager.open(mesh, &cs, numTimeSteps);
- manager.openTimeStep(t, mesh, &cs);
- manager.appendCellField(t, fieldName, field, fieldType, mesh);
+ manager.open(mesh, numTimeSteps);
+ manager.openTimeStep(t, mesh);
+ manager.appendCellField(t, field);
manager.closeTimeStep();
manager.close();
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestOutputSolnSubset.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,6 +16,9 @@
#include "pylith/meshio/OutputSolnSubset.hh"
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
#include <string.h> // USES strcmp()
@@ -24,6 +27,11 @@
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestOutputSolnSubset );
// ----------------------------------------------------------------------
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::SubMesh::SieveMesh SieveSubMesh;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestOutputSolnSubset::testConstructor(void)
@@ -57,40 +65,43 @@
const int ncorners = 2;
const int cellsE[] = { 2, 4, 4, 6 };
+ topology::Mesh mesh;
MeshIOAscii iohandler;
- ALE::Obj<Mesh> mesh;
iohandler.filename("data/quad4.mesh");
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
OutputSolnSubset output;
output.label(label);
- const ALE::Obj<Mesh> submesh = output.subdomainMesh(mesh);
+ const topology::SubMesh& submesh = output.subdomainMesh(mesh);
+ const ALE::Obj<SieveMesh>& sieveSubMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveSubMesh.isNull());
// Check vertices
- const ALE::Obj<Mesh::label_sequence>& vertices = submesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveSubMesh->depthStratum(0);
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
CPPUNIT_ASSERT_EQUAL(nvertices, int(vertices->size()));
int ipt = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++ipt)
CPPUNIT_ASSERT_EQUAL(verticesE[ipt], *v_iter);
// Check cells
- const ALE::Obj<Mesh::label_sequence>& cells = submesh->heightStratum(1);
- const Mesh::label_sequence::iterator cellsEnd = cells->end();
- const ALE::Obj<sieve_type>& sieve = submesh->getSieve();
+ const ALE::Obj<SieveMesh::label_sequence>& cells =
+ sieveSubMesh->heightStratum(1);
+ const SieveMesh::label_sequence::iterator cellsEnd = cells->end();
+ const ALE::Obj<SieveSubMesh::sieve_type>& sieve = sieveSubMesh->getSieve();
assert(!sieve.isNull());
typedef ALE::SieveAlg<Mesh> SieveAlg;
CPPUNIT_ASSERT_EQUAL(ncells, int(cells->size()));
- ALE::ISieveVisitor::PointRetriever<Mesh::sieve_type> pV(sieve->getMaxConeSize());
+ ALE::ISieveVisitor::PointRetriever<SieveSubMesh::sieve_type> pV(sieve->getMaxConeSize());
int i = 0;
- for (Mesh::label_sequence::iterator c_iter=cells->begin(); c_iter != cellsEnd; ++c_iter) {
+ for (SieveMesh::label_sequence::iterator c_iter=cells->begin(); c_iter != cellsEnd; ++c_iter) {
sieve->cone(*c_iter, pV);
- const Mesh::point_type *cone = pV.getPoints();
+ const SieveSubMesh::point_type *cone = pV.getPoints();
CPPUNIT_ASSERT_EQUAL(ncorners, (int) pV.getSize());
for(int p = 0; p < pV.getSize(); ++p, ++i) {
CPPUNIT_ASSERT_EQUAL(cellsE[i], cone[p]);
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestVertexFilterVecNorm.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -14,19 +14,24 @@
#include "TestVertexFilterVecNorm.hh" // Implementation of class methods
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/meshio/VertexFilterVecNorm.hh"
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+#include "pylith/topology/Field.hh" // USES Field
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::meshio::TestVertexFilterVecNorm );
// ----------------------------------------------------------------------
+typedef pylith::topology::Field<pylith::topology::Mesh> MeshField;
+
+// ----------------------------------------------------------------------
// Test constructor
void
pylith::meshio::TestVertexFilterVecNorm::testConstructor(void)
{ // testConstructor
- VertexFilterVecNorm filter;
+ VertexFilterVecNorm<MeshField> filter;
} // testConstructor
// ----------------------------------------------------------------------
@@ -34,18 +39,23 @@
void
pylith::meshio::TestVertexFilterVecNorm::testFilter(void)
{ // testFilter
+ typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+ typedef pylith::topology::Mesh::RealSection RealSection;
+
const char* filename = "data/tri3.mesh";
const int fiberDim = 2;
const int nvertices = 4;
- const char* fieldName = "field data";
- const VectorFieldEnum fieldType = VECTOR_FIELD;
+ const std::string label = "field data";
+ const topology::FieldBase::VectorFieldEnum fieldType =
+ topology::FieldBase::VECTOR;
const double fieldValues[] = {
1.1, 1.2,
2.1, 2.2,
3.1, 3.2,
4.1, 4.2
};
- const VectorFieldEnum fieldTypeE = SCALAR_FIELD;
+ const topology::FieldBase::VectorFieldEnum fieldTypeE =
+ topology::FieldBase::SCALAR;
const int fiberDimE = 1;
const double fieldValuesE[] = {
sqrt(pow(1.1, 2) + pow(1.2, 2)),
@@ -55,43 +65,49 @@
};
MeshIOAscii iohandler;
- ALE::Obj<Mesh> mesh;
+ topology::Mesh mesh;
iohandler.filename(filename);
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
// Set vertex field
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const Mesh::label_sequence::iterator verticesEnd = vertices->end();
+ MeshField field(mesh);
+ field.newSection(topology::FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.vectorFieldType(fieldType);
+ field.label(label.c_str());
- ALE::Obj<real_section_type> field =
- new real_section_type(mesh->comm(), mesh->debug());
- field->setChart(mesh->getSieve()->getChart());
- field->setFiberDimension(vertices, fiberDim);
- mesh->allocate(field);
-
+ const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const SieveMesh::label_sequence::iterator verticesEnd = vertices->end();
+
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
CPPUNIT_ASSERT_EQUAL(nvertices, int(vertices->size()));
-
int ipt = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++ipt) {
const double* values = &fieldValues[ipt*fiberDim];
- field->updatePoint(*v_iter, values);
+ section->updatePoint(*v_iter, values);
} // for
- VertexFilterVecNorm filter;
- VectorFieldEnum fieldTypeF = OTHER_FIELD;
- const ALE::Obj<real_section_type>& fieldF =
- filter.filter(&fieldTypeF, field, mesh);
+ VertexFilterVecNorm<MeshField> filter;
+ const MeshField& fieldF = filter.filter(field);
+ const ALE::Obj<RealSection>& sectionF = fieldF.section();
+ CPPUNIT_ASSERT(!sectionF.isNull());
- CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldTypeF);
+ CPPUNIT_ASSERT_EQUAL(fieldTypeE, fieldF.vectorFieldType());
+ CPPUNIT_ASSERT_EQUAL(label, std::string(fieldF.label()));
+
ipt = 0;
- for (Mesh::label_sequence::iterator v_iter=vertices->begin();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
v_iter != verticesEnd;
++v_iter, ++ipt) {
- CPPUNIT_ASSERT_EQUAL(fiberDimE, fieldF->getFiberDimension(*v_iter));
- const double* values = fieldF->restrictPoint(*v_iter);
+ CPPUNIT_ASSERT_EQUAL(fiberDimE, sectionF->getFiberDimension(*v_iter));
+ const double* values = sectionF->restrictPoint(*v_iter);
CPPUNIT_ASSERT(0 != values);
const double tolerance = 1.0e-06;
for (int i=0; i < fiberDimE; ++i)
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKData.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKData.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKData.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -13,7 +13,7 @@
#if !defined(pylith_meshio_datawritervtkdata_hh)
#define pylith_meshio_datawritervtkdata_hh
-#include "pylith/utils/vectorfields.hh" // USES VectorFieldEnum
+#include "pylith/topology/FieldBase.hh" // USES VectorFieldEnum
namespace pylith {
namespace meshio {
@@ -39,7 +39,7 @@
struct FieldStruct {
char* name; ///< Name of field
- VectorFieldEnum field_type; ///< Type of field.
+ topology::FieldBase::VectorFieldEnum field_type; ///< Type of field.
int fiber_dim; ///< Fiber dimension for field.
}; // FieldStruct
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -43,9 +43,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshHex8::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshHex8::_vertexField0[] = {
1.1, 2.2, 3.3,
@@ -76,9 +76,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshHex8::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshHex8::_cellField0[] = {
1.1, 2.2, 3.3,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -39,9 +39,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshQuad4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshQuad4::_vertexField0[] = {
1.1, 2.2,
@@ -62,9 +62,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshQuad4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshQuad4::_cellField0[] = {
1.1, 2.2,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -43,9 +43,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshTet4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshTet4::_vertexField0[] = {
1.1, 2.2, 3.3,
@@ -72,9 +72,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshTet4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshTet4::_cellField0[] = {
1.1, 2.2, 3.3,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataBCMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -43,9 +43,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshTri3::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshTri3::_vertexField0[] = {
1.1, 2.2,
@@ -64,9 +64,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataBCMeshTri3::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
};
const double pylith::meshio::DataWriterVTKDataBCMeshTri3::_cellField0[] = {
1.1, 2.2,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshHex8::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshHex8::_vertexField0[] = {
1.1, 2.2, 3.3,
@@ -65,9 +65,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshHex8::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshHex8::_cellField0[] = {
1.1, 2.2, 3.3,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshQuad4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshQuad4::_vertexField0[] = {
1.1, 2.2,
@@ -61,9 +61,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshQuad4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshQuad4::_cellField0[] = {
1.1, 2.2,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshTet4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshTet4::_vertexField0[] = {
1.1, 2.2, 3.3,
@@ -63,9 +63,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshTet4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshTet4::_cellField0[] = {
1.1, 2.2, 3.3,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataFaultMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshTri3::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshTri3::_vertexField0[] = {
1.1, 2.2,
@@ -61,9 +61,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataFaultMeshTri3::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
};
const double pylith::meshio::DataWriterVTKDataFaultMeshTri3::_cellField0[] = {
1.1, 2.2,
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,156 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataMatMeshHex8.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshHex8::_meshFilename =
+ "data/hex8.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshHex8::_cellsLabel =
+ "material-id";
+const int pylith::meshio::DataWriterVTKDataMatMeshHex8::_labelId = 0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshHex8::_faultLabel =
+ "fault";
+const int pylith::meshio::DataWriterVTKDataMatMeshHex8::_faultId = 100;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshHex8::_timestepFilename =
+ "hex8_mat.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshHex8::_vertexFilename =
+ "hex8_mat_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshHex8::_cellFilename =
+ "hex8_mat_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataMatMeshHex8::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshHex8::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataMatMeshHex8::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshHex8::_numVertices = 20;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshHex8::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshHex8::_vertexField0[] = {
+ 1.1, 2.2, 3.3,
+ 4.4, 5.5, 6.6,
+ 7.7, 8.8, 9.9,
+ 10.1, 11.2, 12.3,
+ 1.2, 2.3, 3.4,
+ 4.5, 5.6, 6.7,
+ 7.8, 8.9, 9.0,
+ 10.2, 11.3, 12.4,
+ 1.3, 2.4, 3.5,
+ 4.6, 5.7, 6.8,
+ 7.9, 8.0, 9.1,
+ 10.2, 11.3, 12.4,
+ 13.5, 14.6, 15.7,
+ 16.8, 17.9, 18.1,
+ 19.2, 20.3, 21.4,
+ 22.5, 23.6, 24.7,
+ 25.5, 26.6, 27.7,
+ 28.8, 29.9, 30.0,
+ 31.1, 32.2, 33.3,
+ 34.4, 35.5, 36.6
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshHex8::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8,
+ 10.0, 12.1, 11.1, 13.1, 14.1, 15.1, 16.1, 17.1,
+ 18.1, 19.1, 20.1, 21.1
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshHex8::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 1.3, 2.4,
+ 3.5, 4.6,
+ 5.7, 6.8,
+ 7.9, 8.0,
+ 1.3, 2.4,
+ 3.5, 4.6,
+ 5.7, 6.8,
+ 8.0, 1.4,
+ 2.5, 3.6,
+ 4.8, 1.5,
+ 2.6, 3.7,
+ 4.8, 5.9,
+ 1.1, 1.2,
+ 2.1, 2.2,
+ 3.1, 3.2,
+ 4.1, 4.2,
+};
+
+const int pylith::meshio::DataWriterVTKDataMatMeshHex8::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshHex8::_numCells = 1;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshHex8::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshHex8::_cellField0[] = {
+ 1.1, 2.2, 3.3,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshHex8::_cellField1[] = {
+ 2.1,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshHex8::_cellField2[] = {
+ 1.2, 2.3, 3.4, 4.5, 5.6, 6.7,
+};
+
+pylith::meshio::DataWriterVTKDataMatMeshHex8::DataWriterVTKDataMatMeshHex8(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ cellsLabel = const_cast<char*>(_cellsLabel);
+ labelId = _labelId;
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ numVertices = _numVertices;
+ assert(3 == numVertexFields);
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ numCells = _numCells;
+ assert(3 == numCellFields);
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataMatMeshHex8::~DataWriterVTKDataMatMeshHex8(void)
+{}
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatamatmeshhex8_hh)
+#define pylith_meshio_datawritervtkdatamatmeshhex8_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataMatMeshHex8;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataMatMeshHex8 : public DataWriterVTKData
+{ // DataWriterVTKDataMatMeshHex8
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataMatMeshHex8(void);
+
+ /// Destructor
+ ~DataWriterVTKDataMatMeshHex8(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _cellsLabel; ///< Label defining subset of cells.
+ static const int _labelId; /// Value for label defining subset of cells.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataMatMeshHex8
+
+#endif // pylith_meshio_datawritervtkdatamatmeshhex8_hh
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataMatMeshLine2.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshLine2::_meshFilename =
+ "data/line2.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshLine2::_cellsLabel =
+ "material-id";
+const int pylith::meshio::DataWriterVTKDataMatMeshLine2::_labelId = 0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshLine2::_faultLabel =
+ "fault";
+const int pylith::meshio::DataWriterVTKDataMatMeshLine2::_faultId = 100;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshLine2::_timestepFilename =
+ "line2_mat.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshLine2::_vertexFilename =
+ "line2_mat_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshLine2::_cellFilename =
+ "line2_mat_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataMatMeshLine2::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshLine2::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataMatMeshLine2::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshLine2::_numVertices = 5;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshLine2::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 1 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshLine2::_vertexField0[] = {
+ 1.1, 2.2, 3.3, 4.4, 5.5
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshLine2::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshLine2::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.1, 10.2
+};
+
+const int pylith::meshio::DataWriterVTKDataMatMeshLine2::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshLine2::_numCells = 1;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshLine2::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 1 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 1 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshLine2::_cellField0[] = {
+ 1.1,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshLine2::_cellField1[] = {
+ 2.1,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshLine2::_cellField2[] = {
+ 1.2,
+};
+
+pylith::meshio::DataWriterVTKDataMatMeshLine2::DataWriterVTKDataMatMeshLine2(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ cellsLabel = const_cast<char*>(_cellsLabel);
+ labelId = _labelId;
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ numVertices = _numVertices;
+ assert(3 == numVertexFields);
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ numCells = _numCells;
+ assert(3 == numCellFields);
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataMatMeshLine2::~DataWriterVTKDataMatMeshLine2(void)
+{}
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatamatmeshline2_hh)
+#define pylith_meshio_datawritervtkdatamatmeshline2_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataMatMeshLine2;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataMatMeshLine2 : public DataWriterVTKData
+{ // DataWriterVTKDataMatMeshLine2
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataMatMeshLine2(void);
+
+ /// Destructor
+ ~DataWriterVTKDataMatMeshLine2(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _cellsLabel; ///< Label defining subset of cells.
+ static const int _labelId; /// Value for label defining subset of cells.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataMatMeshLine2
+
+#endif // pylith_meshio_datawritervtkdatamatmeshline2_hh
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataMatMeshQuad4.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshQuad4::_meshFilename =
+ "data/quad4.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshQuad4::_cellsLabel =
+ "material-id";
+const int pylith::meshio::DataWriterVTKDataMatMeshQuad4::_labelId = 2;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshQuad4::_timestepFilename =
+ "quad4_mat.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshQuad4::_vertexFilename =
+ "quad4_mat_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshQuad4::_cellFilename =
+ "quad4_mat_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataMatMeshQuad4::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshQuad4::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataMatMeshQuad4::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshQuad4::_numVertices = 6;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshQuad4::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshQuad4::_vertexField0[] = {
+ 1.1, 2.2,
+ 3.3, 4.4,
+ 5.5, 6.6,
+ 7.7, 8.8,
+ 9.9, 10.1,
+ 11.2, 12.3,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshQuad4::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5, 7.6
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshQuad4::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.8, 7.6,
+ 6.5, 5.4
+};
+
+const int pylith::meshio::DataWriterVTKDataMatMeshQuad4::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshQuad4::_numCells = 1;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshQuad4::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshQuad4::_cellField0[] = {
+ 1.1, 2.2,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshQuad4::_cellField1[] = {
+ 2.1,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshQuad4::_cellField2[] = {
+ 1.2, 2.3, 3.4,
+};
+
+pylith::meshio::DataWriterVTKDataMatMeshQuad4::DataWriterVTKDataMatMeshQuad4(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ cellsLabel = const_cast<char*>(_cellsLabel);
+ labelId = _labelId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ assert(3 == numVertexFields);
+ numVertices = _numVertices;
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ assert(3 == numCellFields);
+ numCells = _numCells;
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataMatMeshQuad4::~DataWriterVTKDataMatMeshQuad4(void)
+{}
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatamatmeshquad4_hh)
+#define pylith_meshio_datawritervtkdatamatmeshquad4_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataMatMeshQuad4;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataMatMeshQuad4 : public DataWriterVTKData
+{ // DataWriterVTKDataMatMeshQuad4
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataMatMeshQuad4(void);
+
+ /// Destructor
+ ~DataWriterVTKDataMatMeshQuad4(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _cellsLabel; ///< Label defining subset of cells.
+ static const int _labelId; /// Value for label defining subset of cells.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataMatMeshQuad4
+
+#endif // pylith_meshio_datawritervtkdatamatmeshquad4_hh
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,138 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataMatMeshTet4.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTet4::_meshFilename =
+ "data/tet4.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTet4::_cellsLabel =
+ "material-id";
+const int pylith::meshio::DataWriterVTKDataMatMeshTet4::_labelId = 1;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTet4::_faultLabel =
+ "fault";
+const int pylith::meshio::DataWriterVTKDataMatMeshTet4::_faultId = 100;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTet4::_timestepFilename =
+ "tet4_mat.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTet4::_vertexFilename =
+ "tet4_mat_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTet4::_cellFilename =
+ "tet4_mat_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataMatMeshTet4::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTet4::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataMatMeshTet4::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshTet4::_numVertices = 11;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshTet4::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTet4::_vertexField0[] = {
+ 1.1, 2.2, 3.3,
+ 4.4, 5.5, 6.6,
+ 7.7, 8.8, 9.9,
+ 10.0, 11.1, 12.2,
+ 13.3, 14.4, 15.5,
+ 16.6, 17.7, 18.8,
+ 19.9, 20.0, 21.1,
+ 22.2, 23.3, 24.4,
+ 25.5, 26.6, 27.7,
+ 28.8, 29.9, 30.0,
+ 31.1, 32.2, 33.3,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTet4::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8, 10.9, 11.0, 12.1
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTet4::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.0, 10.1,
+ 11.2, 12.3,
+ 13.4, 14.5,
+ 15.6, 16.7,
+ 17.8, 18.9,
+ 19.0, 20.1,
+ 21.2, 22.3
+};
+
+const int pylith::meshio::DataWriterVTKDataMatMeshTet4::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshTet4::_numCells = 2;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshTet4::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTet4::_cellField0[] = {
+ 1.1, 2.2, 3.3,
+ 4.4, 5.5, 6.6,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTet4::_cellField1[] = {
+ 2.1, 3.2
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTet4::_cellField2[] = {
+ 1.2, 2.3, 3.4, 4.5, 5.6, 6.7,
+ 7.8, 8.9, 9.0, 10.1, 11.2, 12.3,
+};
+
+pylith::meshio::DataWriterVTKDataMatMeshTet4::DataWriterVTKDataMatMeshTet4(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ cellsLabel = const_cast<char*>(_cellsLabel);
+ labelId = _labelId;
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ assert(3 == numVertexFields);
+ numVertices = _numVertices;
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ assert(3 == numCellFields);
+ numCells = _numCells;
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataMatMeshTet4::~DataWriterVTKDataMatMeshTet4(void)
+{}
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatamatmeshtet4_hh)
+#define pylith_meshio_datawritervtkdatamatmeshtet4_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataMatMeshTet4;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataMatMeshTet4 : public DataWriterVTKData
+{ // DataWriterVTKDataMatMeshTet4
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataMatMeshTet4(void);
+
+ /// Destructor
+ ~DataWriterVTKDataMatMeshTet4(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _cellsLabel; ///< Label defining subset of cells.
+ static const int _labelId; /// Value for label defining subset of cells.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataMatMeshTet4
+
+#endif // pylith_meshio_datawritervtkdatamatmeshtet4_hh
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataMatMeshTri3.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTri3::_meshFilename =
+ "data/tri3.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTri3::_cellsLabel =
+ "material-id";
+const int pylith::meshio::DataWriterVTKDataMatMeshTri3::_labelId = 0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTri3::_faultLabel =
+ "fault";
+const int pylith::meshio::DataWriterVTKDataMatMeshTri3::_faultId = 100;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTri3::_timestepFilename =
+ "tri3_mat.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTri3::_vertexFilename =
+ "tri3_mat_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTri3::_cellFilename =
+ "tri3_mat_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataMatMeshTri3::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataMatMeshTri3::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataMatMeshTri3::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshTri3::_numVertices = 8;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshTri3::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTri3::_vertexField0[] = {
+ 1.1, 2.2,
+ 3.3, 4.4,
+ 5.5, 6.6,
+ 7.7, 8.8,
+ 9.9, 10.0,
+ 11.1, 12.2,
+ 13.3, 14.4,
+ 15.5, 16.6,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTri3::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTri3::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.0, 10.1,
+ 11.2, 12.3,
+ 13.4, 14.5,
+ 15.6, 16.7
+};
+
+const int pylith::meshio::DataWriterVTKDataMatMeshTri3::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataMatMeshTri3::_numCells = 1;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataMatMeshTri3::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTri3::_cellField0[] = {
+ 1.1, 2.2,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTri3::_cellField1[] = {
+ 2.1,
+};
+const double pylith::meshio::DataWriterVTKDataMatMeshTri3::_cellField2[] = {
+ 1.2, 2.3, 3.4,
+};
+
+pylith::meshio::DataWriterVTKDataMatMeshTri3::DataWriterVTKDataMatMeshTri3(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ cellsLabel = const_cast<char*>(_cellsLabel);
+ labelId = _labelId;
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ numVertices = _numVertices;
+ assert(3 == numVertexFields);
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ numCells = _numCells;
+ assert(3 == numCellFields);
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataMatMeshTri3::~DataWriterVTKDataMatMeshTri3(void)
+{}
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMatMeshTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,76 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatamatmeshtri3_hh)
+#define pylith_meshio_datawritervtkdatamatmeshtri3_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataMatMeshTri3;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataMatMeshTri3 : public DataWriterVTKData
+{ // DataWriterVTKDataMatMeshTri3
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataMatMeshTri3(void);
+
+ /// Destructor
+ ~DataWriterVTKDataMatMeshTri3(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _cellsLabel; ///< Label defining subset of cells.
+ static const int _labelId; /// Value for label defining subset of cells.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataMatMeshTri3
+
+#endif // pylith_meshio_datawritervtkdatamatmeshtri3_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshHex8::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataMeshHex8::_vertexField0[] = {
1.1, 2.2, 3.3,
@@ -99,9 +99,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshHex8::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
};
const double pylith::meshio::DataWriterVTKDataMeshHex8::_cellField0[] = {
1.1, 2.2, 3.3,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshLine2::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 1 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 1 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataMeshLine2::_vertexField0[] = {
1.1, 2.2, 3.3, 4.4, 5.5
@@ -63,9 +63,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshLine2::_cellFields[] = {
- { "traction", VECTOR_FIELD, 1 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 1 },
+ { "traction", topology::FieldBase::VECTOR, 1 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 1 },
};
const double pylith::meshio::DataWriterVTKDataMeshLine2::_cellField0[] = {
1.1, 2.2, 3.3
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -36,9 +36,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshQuad4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataMeshQuad4::_vertexField0[] = {
1.1, 2.2,
@@ -65,9 +65,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshQuad4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
};
const double pylith::meshio::DataWriterVTKDataMeshQuad4::_cellField0[] = {
1.1, 2.2,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshTet4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataMeshTet4::_vertexField0[] = {
1.1, 2.2, 3.3,
@@ -79,9 +79,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshTet4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
};
const double pylith::meshio::DataWriterVTKDataMeshTet4::_cellField0[] = {
1.1, 2.2, 3.3,
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -40,9 +40,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshTri3::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
};
const double pylith::meshio::DataWriterVTKDataMeshTri3::_vertexField0[] = {
1.1, 2.2,
@@ -71,9 +71,9 @@
const pylith::meshio::DataWriterVTKData::FieldStruct
pylith::meshio::DataWriterVTKDataMeshTri3::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
};
const double pylith::meshio::DataWriterVTKDataMeshTri3::_cellField0[] = {
1.1, 2.2,
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,156 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include "DataWriterVTKDataSubMeshHex8.hh"
-
-#include <assert.h> // USES assert()
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_meshFilename =
- "data/hex8.mesh";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellsLabel =
- "material-id";
-const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_labelId = 0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_faultLabel =
- "fault";
-const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_faultId = 100;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_timestepFilename =
- "hex8_sub.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexFilename =
- "hex8_sub_vertex.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellFilename =
- "hex8_sub_cell.vtk";
-
-const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_time = 1.0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_timeFormat =
- "%3.1f";
-
-const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numVertexFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numVertices = 20;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexField0[] = {
- 1.1, 2.2, 3.3,
- 4.4, 5.5, 6.6,
- 7.7, 8.8, 9.9,
- 10.1, 11.2, 12.3,
- 1.2, 2.3, 3.4,
- 4.5, 5.6, 6.7,
- 7.8, 8.9, 9.0,
- 10.2, 11.3, 12.4,
- 1.3, 2.4, 3.5,
- 4.6, 5.7, 6.8,
- 7.9, 8.0, 9.1,
- 10.2, 11.3, 12.4,
- 13.5, 14.6, 15.7,
- 16.8, 17.9, 18.1,
- 19.2, 20.3, 21.4,
- 22.5, 23.6, 24.7,
- 25.5, 26.6, 27.7,
- 28.8, 29.9, 30.0,
- 31.1, 32.2, 33.3,
- 34.4, 35.5, 36.6
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexField1[] = {
- 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8,
- 10.0, 12.1, 11.1, 13.1, 14.1, 15.1, 16.1, 17.1,
- 18.1, 19.1, 20.1, 21.1
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexField2[] = {
- 1.2, 2.3,
- 3.4, 4.5,
- 5.6, 6.7,
- 7.8, 8.9,
- 1.3, 2.4,
- 3.5, 4.6,
- 5.7, 6.8,
- 7.9, 8.0,
- 1.3, 2.4,
- 3.5, 4.6,
- 5.7, 6.8,
- 8.0, 1.4,
- 2.5, 3.6,
- 4.8, 1.5,
- 2.6, 3.7,
- 4.8, 5.9,
- 1.1, 1.2,
- 2.1, 2.2,
- 3.1, 3.2,
- 4.1, 4.2,
-};
-
-const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numCellFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numCells = 1;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellField0[] = {
- 1.1, 2.2, 3.3,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellField1[] = {
- 2.1,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellField2[] = {
- 1.2, 2.3, 3.4, 4.5, 5.6, 6.7,
-};
-
-pylith::meshio::DataWriterVTKDataSubMeshHex8::DataWriterVTKDataSubMeshHex8(void)
-{ // constructor
- meshFilename = const_cast<char*>(_meshFilename);
- cellsLabel = const_cast<char*>(_cellsLabel);
- labelId = _labelId;
- faultLabel = const_cast<char*>(_faultLabel);
- faultId = _faultId;
-
- timestepFilename = const_cast<char*>(_timestepFilename);
- vertexFilename = const_cast<char*>(_vertexFilename);
- cellFilename = const_cast<char*>(_cellFilename);
-
- time = _time;
- timeFormat = const_cast<char*>(_timeFormat);
-
- numVertexFields = _numVertexFields;
- numVertices = _numVertices;
- assert(3 == numVertexFields);
- vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
- vertexFields[0] = const_cast<double*>(_vertexField0);
- vertexFields[1] = const_cast<double*>(_vertexField1);
- vertexFields[2] = const_cast<double*>(_vertexField2);
-
- numCellFields = _numCellFields;
- numCells = _numCells;
- assert(3 == numCellFields);
- cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
- cellFields[0] = const_cast<double*>(_cellField0);
- cellFields[1] = const_cast<double*>(_cellField1);
- cellFields[2] = const_cast<double*>(_cellField2);
-} // constructor
-
-pylith::meshio::DataWriterVTKDataSubMeshHex8::~DataWriterVTKDataSubMeshHex8(void)
-{}
-
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,137 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataSubMeshHex8.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_meshFilename =
+ "data/hex8.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_bcLabel =
+ "top";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_faultLabel = 0;
+const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_faultId = 0;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_timestepFilename =
+ "hex8_surf.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexFilename =
+ "hex8_surf_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellFilename =
+ "hex8_surf_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshHex8::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numVertices = 12;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexField0[] = {
+ 1.1, 2.2, 3.3,
+ 4.4, 5.5, 6.6,
+ 7.7, 8.8, 9.9,
+ 10.1, 11.2, 12.3,
+ 1.2, 2.3, 3.4,
+ 4.5, 5.6, 6.7,
+ 7.8, 8.9, 9.0,
+ 10.2, 11.3, 12.4,
+ 1.3, 2.4, 3.5,
+ 4.6, 5.7, 6.8,
+ 7.9, 8.1, 9.2,
+ 10.3, 11.4, 12.5,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8, 10.9, 11.8, 12.7, 13.6
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 1.3, 2.4,
+ 3.5, 4.6,
+ 5.7, 6.8,
+ 7.9, 8.0,
+ 8.1, 8.2,
+ 9.2, 9.3,
+ 10.4, 10.5,
+ 11.5, 11.6,
+};
+
+const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshHex8::_numCells = 2;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellField0[] = {
+ 1.1, 2.2, 3.3,
+ 4.4, 5.5, 6.6
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellField1[] = {
+ 2.1, 3.2,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshHex8::_cellField2[] = {
+ 1.2, 2.3, 3.4, 4.5, 5.6, 6.7,
+ 7.8, 8.9, 9.0, 10.1, 11.2, 12.3
+};
+
+pylith::meshio::DataWriterVTKDataSubMeshHex8::DataWriterVTKDataSubMeshHex8(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ bcLabel = const_cast<char*>(_bcLabel);
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ numVertices = _numVertices;
+ assert(3 == numVertexFields);
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ numCells = _numCells;
+ assert(3 == numCellFields);
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataSubMeshHex8::~DataWriterVTKDataSubMeshHex8(void)
+{}
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,76 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_datawritervtkdatasubmeshhex8_hh)
-#define pylith_meshio_datawritervtkdatasubmeshhex8_hh
-
-#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
-
-namespace pylith {
- namespace meshio {
- class DataWriterVTKDataSubMeshHex8;
- } // meshio
-} // pylith
-
-class pylith::meshio::DataWriterVTKDataSubMeshHex8 : public DataWriterVTKData
-{ // DataWriterVTKDataSubMeshHex8
-
-public:
-
- /// Constructor
- DataWriterVTKDataSubMeshHex8(void);
-
- /// Destructor
- ~DataWriterVTKDataSubMeshHex8(void);
-
-private:
-
- static const char* _meshFilename; ///< Name of mesh file.
- static const char* _cellsLabel; ///< Label defining subset of cells.
- static const int _labelId; /// Value for label defining subset of cells.
- static const char* _faultLabel; ///< Name of group of vertices for fault.
- static const int _faultId; ///< Material identifier for fault.
-
- static const char* _timestepFilename; ///< Name of VTK file without fields.
- static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
- static const char* _cellFilename; ///< Name of VTK file for cell fields.
-
- static const double _time; ///< Time for fields.
- static const char* _timeFormat; ///< Format for time stamp.
-
- /// @name Vertex field information.
- //@{
- static const int _numVertexFields; ///< Number of vertex fields.
- static const int _numVertices; ///< Number of vertices.
- static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
-
- static const double _vertexField0[]; ///< Values for vertex field 0.
- static const double _vertexField1[]; ///< Values for vertex field 1.
- static const double _vertexField2[]; ///< Values for vertex field 2.
- //@}
-
- /// @name Cell field information.
- //@{
- static const int _numCellFields; ///< Number of cell fields.
- static const int _numCells; ///< Number of cells.
- static const FieldStruct _cellFields[]; ///< Array of cell fields.
-
- static const double _cellField0[]; ///< Values for cell field 0.
- static const double _cellField1[]; ///< Values for cell field 1.
- static const double _cellField2[]; ///< Values for cell field 2.
- //@}
-
-}; // DataWriterVTKDataSubMeshHex8
-
-#endif // pylith_meshio_datawritervtkdatasubmeshhex8_hh
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshHex8.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatasubmeshhex8_hh)
+#define pylith_meshio_datawritervtkdatasubmeshhex8_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataSubMeshHex8;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataSubMeshHex8 : public DataWriterVTKData
+{ // DataWriterVTKDataSubMeshHex8
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataSubMeshHex8(void);
+
+ /// Destructor
+ ~DataWriterVTKDataSubMeshHex8(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _bcLabel; ///< Label defining boundary vertices.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataSubMeshHex8
+
+#endif // pylith_meshio_datawritervtkdatasubmeshhex8_hh
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,120 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include "DataWriterVTKDataSubMeshLine2.hh"
-
-#include <assert.h> // USES assert()
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_meshFilename =
- "data/line2.mesh";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellsLabel =
- "material-id";
-const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_labelId = 0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_faultLabel =
- "fault";
-const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_faultId = 100;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_timestepFilename =
- "line2_sub.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexFilename =
- "line2_sub_vertex.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellFilename =
- "line2_sub_cell.vtk";
-
-const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_time = 1.0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_timeFormat =
- "%3.1f";
-
-const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numVertexFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numVertices = 5;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 1 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexField0[] = {
- 1.1, 2.2, 3.3, 4.4, 5.5
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexField1[] = {
- 2.1, 3.2, 4.3, 5.4, 6.5
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexField2[] = {
- 1.2, 2.3,
- 3.4, 4.5,
- 5.6, 6.7,
- 7.8, 8.9,
- 9.1, 10.2
-};
-
-const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numCellFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numCells = 1;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellFields[] = {
- { "traction", VECTOR_FIELD, 1 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 1 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellField0[] = {
- 1.1,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellField1[] = {
- 2.1,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellField2[] = {
- 1.2,
-};
-
-pylith::meshio::DataWriterVTKDataSubMeshLine2::DataWriterVTKDataSubMeshLine2(void)
-{ // constructor
- meshFilename = const_cast<char*>(_meshFilename);
- cellsLabel = const_cast<char*>(_cellsLabel);
- labelId = _labelId;
- faultLabel = const_cast<char*>(_faultLabel);
- faultId = _faultId;
-
- timestepFilename = const_cast<char*>(_timestepFilename);
- vertexFilename = const_cast<char*>(_vertexFilename);
- cellFilename = const_cast<char*>(_cellFilename);
-
- time = _time;
- timeFormat = const_cast<char*>(_timeFormat);
-
- numVertexFields = _numVertexFields;
- numVertices = _numVertices;
- assert(3 == numVertexFields);
- vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
- vertexFields[0] = const_cast<double*>(_vertexField0);
- vertexFields[1] = const_cast<double*>(_vertexField1);
- vertexFields[2] = const_cast<double*>(_vertexField2);
-
- numCellFields = _numCellFields;
- numCells = _numCells;
- assert(3 == numCellFields);
- cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
- cellFields[0] = const_cast<double*>(_cellField0);
- cellFields[1] = const_cast<double*>(_cellField1);
- cellFields[2] = const_cast<double*>(_cellField2);
-} // constructor
-
-pylith::meshio::DataWriterVTKDataSubMeshLine2::~DataWriterVTKDataSubMeshLine2(void)
-{}
-
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,122 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataSubMeshLine2.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_meshFilename =
+ "data/line2.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_bcLabel =
+ "bc1";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_faultLabel =
+ "fault";
+const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_faultId = 100;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_timestepFilename =
+ "line2_surf.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexFilename =
+ "line2_surf_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellFilename =
+ "line2_surf_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshLine2::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numVertices = 5;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexField0[] = {
+ 1.1, 2.2,
+ 3.3, 4.4,
+ 5.5, 6.6,
+ 7.7, 8.8,
+ 9.9, 10.0,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.0, 10.1,
+};
+
+const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshLine2::_numCells = 1;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellField0[] = {
+ 1.1, 2.2,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellField1[] = {
+ 2.1,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshLine2::_cellField2[] = {
+ 1.2, 2.3, 3.4,
+};
+
+pylith::meshio::DataWriterVTKDataSubMeshLine2::DataWriterVTKDataSubMeshLine2(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ bcLabel = const_cast<char*>(_bcLabel);
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ numVertices = _numVertices;
+ assert(3 == numVertexFields);
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ numCells = _numCells;
+ assert(3 == numCellFields);
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataSubMeshLine2::~DataWriterVTKDataSubMeshLine2(void)
+{}
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,76 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_datawritervtkdatasubmeshline2_hh)
-#define pylith_meshio_datawritervtkdatasubmeshline2_hh
-
-#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
-
-namespace pylith {
- namespace meshio {
- class DataWriterVTKDataSubMeshLine2;
- } // meshio
-} // pylith
-
-class pylith::meshio::DataWriterVTKDataSubMeshLine2 : public DataWriterVTKData
-{ // DataWriterVTKDataSubMeshLine2
-
-public:
-
- /// Constructor
- DataWriterVTKDataSubMeshLine2(void);
-
- /// Destructor
- ~DataWriterVTKDataSubMeshLine2(void);
-
-private:
-
- static const char* _meshFilename; ///< Name of mesh file.
- static const char* _cellsLabel; ///< Label defining subset of cells.
- static const int _labelId; /// Value for label defining subset of cells.
- static const char* _faultLabel; ///< Name of group of vertices for fault.
- static const int _faultId; ///< Material identifier for fault.
-
- static const char* _timestepFilename; ///< Name of VTK file without fields.
- static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
- static const char* _cellFilename; ///< Name of VTK file for cell fields.
-
- static const double _time; ///< Time for fields.
- static const char* _timeFormat; ///< Format for time stamp.
-
- /// @name Vertex field information.
- //@{
- static const int _numVertexFields; ///< Number of vertex fields.
- static const int _numVertices; ///< Number of vertices.
- static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
-
- static const double _vertexField0[]; ///< Values for vertex field 0.
- static const double _vertexField1[]; ///< Values for vertex field 1.
- static const double _vertexField2[]; ///< Values for vertex field 2.
- //@}
-
- /// @name Cell field information.
- //@{
- static const int _numCellFields; ///< Number of cell fields.
- static const int _numCells; ///< Number of cells.
- static const FieldStruct _cellFields[]; ///< Array of cell fields.
-
- static const double _cellField0[]; ///< Values for cell field 0.
- static const double _cellField1[]; ///< Values for cell field 1.
- static const double _cellField2[]; ///< Values for cell field 2.
- //@}
-
-}; // DataWriterVTKDataSubMeshLine2
-
-#endif // pylith_meshio_datawritervtkdatasubmeshline2_hh
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshLine2.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatasubmeshline2_hh)
+#define pylith_meshio_datawritervtkdatasubmeshline2_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataSubMeshLine2;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataSubMeshLine2 : public DataWriterVTKData
+{ // DataWriterVTKDataSubMeshLine2
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataSubMeshLine2(void);
+
+ /// Destructor
+ ~DataWriterVTKDataSubMeshLine2(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _bcLabel; ///< Label defining boundary vertices.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataSubMeshLine2
+
+#endif // pylith_meshio_datawritervtkdatasubmeshline2_hh
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,120 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include "DataWriterVTKDataSubMeshQuad4.hh"
-
-#include <assert.h> // USES assert()
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_meshFilename =
- "data/quad4.mesh";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellsLabel =
- "material-id";
-const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_labelId = 2;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_timestepFilename =
- "quad4_sub.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexFilename =
- "quad4_sub_vertex.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellFilename =
- "quad4_sub_cell.vtk";
-
-const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_time = 1.0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_timeFormat =
- "%3.1f";
-
-const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numVertexFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numVertices = 6;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexField0[] = {
- 1.1, 2.2,
- 3.3, 4.4,
- 5.5, 6.6,
- 7.7, 8.8,
- 9.9, 10.1,
- 11.2, 12.3,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexField1[] = {
- 2.1, 3.2, 4.3, 5.4, 6.5, 7.6
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexField2[] = {
- 1.2, 2.3,
- 3.4, 4.5,
- 5.6, 6.7,
- 7.8, 8.9,
- 9.8, 7.6,
- 6.5, 5.4
-};
-
-const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numCellFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numCells = 1;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellField0[] = {
- 1.1, 2.2,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellField1[] = {
- 2.1,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellField2[] = {
- 1.2, 2.3, 3.4,
-};
-
-pylith::meshio::DataWriterVTKDataSubMeshQuad4::DataWriterVTKDataSubMeshQuad4(void)
-{ // constructor
- meshFilename = const_cast<char*>(_meshFilename);
- cellsLabel = const_cast<char*>(_cellsLabel);
- labelId = _labelId;
-
- timestepFilename = const_cast<char*>(_timestepFilename);
- vertexFilename = const_cast<char*>(_vertexFilename);
- cellFilename = const_cast<char*>(_cellFilename);
-
- time = _time;
- timeFormat = const_cast<char*>(_timeFormat);
-
- numVertexFields = _numVertexFields;
- assert(3 == numVertexFields);
- numVertices = _numVertices;
- vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
- vertexFields[0] = const_cast<double*>(_vertexField0);
- vertexFields[1] = const_cast<double*>(_vertexField1);
- vertexFields[2] = const_cast<double*>(_vertexField2);
-
- numCellFields = _numCellFields;
- assert(3 == numCellFields);
- numCells = _numCells;
- cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
- cellFields[0] = const_cast<double*>(_cellField0);
- cellFields[1] = const_cast<double*>(_cellField1);
- cellFields[2] = const_cast<double*>(_cellField2);
-} // constructor
-
-pylith::meshio::DataWriterVTKDataSubMeshQuad4::~DataWriterVTKDataSubMeshQuad4(void)
-{}
-
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,120 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataSubMeshQuad4.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_meshFilename =
+ "data/quad4.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_bcLabel =
+ "bc3";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_timestepFilename =
+ "quad4_surf.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexFilename =
+ "quad4_surf_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellFilename =
+ "quad4_surf_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshQuad4::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numVertices = 6;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexField0[] = {
+ 1.1, 2.2,
+ 3.3, 4.4,
+ 5.5, 6.6,
+ 7.7, 8.8,
+ 9.9, 10.0,
+ 11.1, 12.2,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5, 7.6,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.1, 10.2,
+ 11.3, 12.4,
+};
+
+const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshQuad4::_numCells = 2;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellField0[] = {
+ 1.1, 2.2,
+ 3.3, 4.4,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellField1[] = {
+ 2.1, 3.2,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshQuad4::_cellField2[] = {
+ 1.2, 2.3, 3.4,
+ 4.5, 5.6, 6.7,
+};
+
+pylith::meshio::DataWriterVTKDataSubMeshQuad4::DataWriterVTKDataSubMeshQuad4(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ bcLabel = const_cast<char*>(_bcLabel);
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ assert(3 == numVertexFields);
+ numVertices = _numVertices;
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ assert(3 == numCellFields);
+ numCells = _numCells;
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataSubMeshQuad4::~DataWriterVTKDataSubMeshQuad4(void)
+{}
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,74 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_datawritervtkdatasubmeshquad4_hh)
-#define pylith_meshio_datawritervtkdatasubmeshquad4_hh
-
-#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
-
-namespace pylith {
- namespace meshio {
- class DataWriterVTKDataSubMeshQuad4;
- } // meshio
-} // pylith
-
-class pylith::meshio::DataWriterVTKDataSubMeshQuad4 : public DataWriterVTKData
-{ // DataWriterVTKDataSubMeshQuad4
-
-public:
-
- /// Constructor
- DataWriterVTKDataSubMeshQuad4(void);
-
- /// Destructor
- ~DataWriterVTKDataSubMeshQuad4(void);
-
-private:
-
- static const char* _meshFilename; ///< Name of mesh file.
- static const char* _cellsLabel; ///< Label defining subset of cells.
- static const int _labelId; /// Value for label defining subset of cells.
-
- static const char* _timestepFilename; ///< Name of VTK file without fields.
- static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
- static const char* _cellFilename; ///< Name of VTK file for cell fields.
-
- static const double _time; ///< Time for fields.
- static const char* _timeFormat; ///< Format for time stamp.
-
- /// @name Vertex field information.
- //@{
- static const int _numVertexFields; ///< Number of vertex fields.
- static const int _numVertices; ///< Number of vertices.
- static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
-
- static const double _vertexField0[]; ///< Values for vertex field 0.
- static const double _vertexField1[]; ///< Values for vertex field 1.
- static const double _vertexField2[]; ///< Values for vertex field 2.
- //@}
-
- /// @name Cell field information.
- //@{
- static const int _numCellFields; ///< Number of cell fields.
- static const int _numCells; ///< Number of cells.
- static const FieldStruct _cellFields[]; ///< Array of cell fields.
-
- static const double _cellField0[]; ///< Values for cell field 0.
- static const double _cellField1[]; ///< Values for cell field 1.
- static const double _cellField2[]; ///< Values for cell field 2.
- //@}
-
-}; // DataWriterVTKDataSubMeshQuad4
-
-#endif // pylith_meshio_datawritervtkdatasubmeshquad4_hh
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshQuad4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatasubmeshquad4_hh)
+#define pylith_meshio_datawritervtkdatasubmeshquad4_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataSubMeshQuad4;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataSubMeshQuad4 : public DataWriterVTKData
+{ // DataWriterVTKDataSubMeshQuad4
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataSubMeshQuad4(void);
+
+ /// Destructor
+ ~DataWriterVTKDataSubMeshQuad4(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _bcLabel; ///< Label defining group of vertices for bc.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataSubMeshQuad4
+
+#endif // pylith_meshio_datawritervtkdatasubmeshquad4_hh
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,138 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include "DataWriterVTKDataSubMeshTet4.hh"
-
-#include <assert.h> // USES assert()
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_meshFilename =
- "data/tet4.mesh";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellsLabel =
- "material-id";
-const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_labelId = 1;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_faultLabel =
- "fault";
-const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_faultId = 100;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_timestepFilename =
- "tet4_sub.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexFilename =
- "tet4_sub_vertex.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellFilename =
- "tet4_sub_cell.vtk";
-
-const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_time = 1.0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_timeFormat =
- "%3.1f";
-
-const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numVertexFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numVertices = 11;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexField0[] = {
- 1.1, 2.2, 3.3,
- 4.4, 5.5, 6.6,
- 7.7, 8.8, 9.9,
- 10.0, 11.1, 12.2,
- 13.3, 14.4, 15.5,
- 16.6, 17.7, 18.8,
- 19.9, 20.0, 21.1,
- 22.2, 23.3, 24.4,
- 25.5, 26.6, 27.7,
- 28.8, 29.9, 30.0,
- 31.1, 32.2, 33.3,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexField1[] = {
- 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8, 10.9, 11.0, 12.1
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexField2[] = {
- 1.2, 2.3,
- 3.4, 4.5,
- 5.6, 6.7,
- 7.8, 8.9,
- 9.0, 10.1,
- 11.2, 12.3,
- 13.4, 14.5,
- 15.6, 16.7,
- 17.8, 18.9,
- 19.0, 20.1,
- 21.2, 22.3
-};
-
-const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numCellFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numCells = 2;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellFields[] = {
- { "traction", VECTOR_FIELD, 3 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 6 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellField0[] = {
- 1.1, 2.2, 3.3,
- 4.4, 5.5, 6.6,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellField1[] = {
- 2.1, 3.2
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellField2[] = {
- 1.2, 2.3, 3.4, 4.5, 5.6, 6.7,
- 7.8, 8.9, 9.0, 10.1, 11.2, 12.3,
-};
-
-pylith::meshio::DataWriterVTKDataSubMeshTet4::DataWriterVTKDataSubMeshTet4(void)
-{ // constructor
- meshFilename = const_cast<char*>(_meshFilename);
- cellsLabel = const_cast<char*>(_cellsLabel);
- labelId = _labelId;
- faultLabel = const_cast<char*>(_faultLabel);
- faultId = _faultId;
-
- timestepFilename = const_cast<char*>(_timestepFilename);
- vertexFilename = const_cast<char*>(_vertexFilename);
- cellFilename = const_cast<char*>(_cellFilename);
-
- time = _time;
- timeFormat = const_cast<char*>(_timeFormat);
-
- numVertexFields = _numVertexFields;
- assert(3 == numVertexFields);
- numVertices = _numVertices;
- vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
- vertexFields[0] = const_cast<double*>(_vertexField0);
- vertexFields[1] = const_cast<double*>(_vertexField1);
- vertexFields[2] = const_cast<double*>(_vertexField2);
-
- numCellFields = _numCellFields;
- assert(3 == numCellFields);
- numCells = _numCells;
- cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
- cellFields[0] = const_cast<double*>(_cellField0);
- cellFields[1] = const_cast<double*>(_cellField1);
- cellFields[2] = const_cast<double*>(_cellField2);
-} // constructor
-
-pylith::meshio::DataWriterVTKDataSubMeshTet4::~DataWriterVTKDataSubMeshTet4(void)
-{}
-
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,123 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataSubMeshTet4.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_meshFilename =
+ "data/tet4.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_bcLabel =
+ "boundary";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_faultLabel = 0;
+const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_faultId = 0;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_timestepFilename =
+ "tet4_surf.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexFilename =
+ "tet4_surf_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellFilename =
+ "tet4_surf_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTet4::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numVertices = 5;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexField0[] = {
+ 1.1, 2.2, 3.3,
+ 4.4, 5.5, 6.6,
+ 7.7, 8.8, 9.9,
+ 10.0, 11.1, 12.2,
+ 13.3, 14.4, 15.5,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.0, 10.1,
+};
+
+const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshTet4::_numCells = 2;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 3 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 6 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellField0[] = {
+ 1.1, 2.2, 3.3,
+ 4.4, 5.5, 6.6,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellField1[] = {
+ 2.1, 3.2
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTet4::_cellField2[] = {
+ 1.2, 2.3, 3.4, 4.5, 5.6, 6.7,
+ 7.8, 8.9, 9.0, 10.1, 11.2, 12.3,
+};
+
+pylith::meshio::DataWriterVTKDataSubMeshTet4::DataWriterVTKDataSubMeshTet4(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ bcLabel = const_cast<char*>(_bcLabel);
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ assert(3 == numVertexFields);
+ numVertices = _numVertices;
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ assert(3 == numCellFields);
+ numCells = _numCells;
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataSubMeshTet4::~DataWriterVTKDataSubMeshTet4(void)
+{}
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,76 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_datawritervtkdatasubmeshtet4_hh)
-#define pylith_meshio_datawritervtkdatasubmeshtet4_hh
-
-#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
-
-namespace pylith {
- namespace meshio {
- class DataWriterVTKDataSubMeshTet4;
- } // meshio
-} // pylith
-
-class pylith::meshio::DataWriterVTKDataSubMeshTet4 : public DataWriterVTKData
-{ // DataWriterVTKDataSubMeshTet4
-
-public:
-
- /// Constructor
- DataWriterVTKDataSubMeshTet4(void);
-
- /// Destructor
- ~DataWriterVTKDataSubMeshTet4(void);
-
-private:
-
- static const char* _meshFilename; ///< Name of mesh file.
- static const char* _cellsLabel; ///< Label defining subset of cells.
- static const int _labelId; /// Value for label defining subset of cells.
- static const char* _faultLabel; ///< Name of group of vertices for fault.
- static const int _faultId; ///< Material identifier for fault.
-
- static const char* _timestepFilename; ///< Name of VTK file without fields.
- static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
- static const char* _cellFilename; ///< Name of VTK file for cell fields.
-
- static const double _time; ///< Time for fields.
- static const char* _timeFormat; ///< Format for time stamp.
-
- /// @name Vertex field information.
- //@{
- static const int _numVertexFields; ///< Number of vertex fields.
- static const int _numVertices; ///< Number of vertices.
- static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
-
- static const double _vertexField0[]; ///< Values for vertex field 0.
- static const double _vertexField1[]; ///< Values for vertex field 1.
- static const double _vertexField2[]; ///< Values for vertex field 2.
- //@}
-
- /// @name Cell field information.
- //@{
- static const int _numCellFields; ///< Number of cell fields.
- static const int _numCells; ///< Number of cells.
- static const FieldStruct _cellFields[]; ///< Array of cell fields.
-
- static const double _cellField0[]; ///< Values for cell field 0.
- static const double _cellField1[]; ///< Values for cell field 1.
- static const double _cellField2[]; ///< Values for cell field 2.
- //@}
-
-}; // DataWriterVTKDataSubMeshTet4
-
-#endif // pylith_meshio_datawritervtkdatasubmeshtet4_hh
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTet4.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatasubmeshtet4_hh)
+#define pylith_meshio_datawritervtkdatasubmeshtet4_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataSubMeshTet4;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataSubMeshTet4 : public DataWriterVTKData
+{ // DataWriterVTKDataSubMeshTet4
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataSubMeshTet4(void);
+
+ /// Destructor
+ ~DataWriterVTKDataSubMeshTet4(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _bcLabel; ///< Label defining boundary vertices.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataSubMeshTet4
+
+#endif // pylith_meshio_datawritervtkdatasubmeshtet4_hh
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,130 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#include "DataWriterVTKDataSubMeshTri3.hh"
-
-#include <assert.h> // USES assert()
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_meshFilename =
- "data/tri3.mesh";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellsLabel =
- "material-id";
-const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_labelId = 0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_faultLabel =
- "fault";
-const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_faultId = 100;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_timestepFilename =
- "tri3_sub.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexFilename =
- "tri3_sub_vertex.vtk";
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellFilename =
- "tri3_sub_cell.vtk";
-
-const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_time = 1.0;
-
-const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_timeFormat =
- "%3.1f";
-
-const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numVertexFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numVertices = 8;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexFields[] = {
- { "displacements", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", OTHER_FIELD, 2 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexField0[] = {
- 1.1, 2.2,
- 3.3, 4.4,
- 5.5, 6.6,
- 7.7, 8.8,
- 9.9, 10.0,
- 11.1, 12.2,
- 13.3, 14.4,
- 15.5, 16.6,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexField1[] = {
- 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexField2[] = {
- 1.2, 2.3,
- 3.4, 4.5,
- 5.6, 6.7,
- 7.8, 8.9,
- 9.0, 10.1,
- 11.2, 12.3,
- 13.4, 14.5,
- 15.6, 16.7
-};
-
-const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numCellFields = 3;
-const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numCells = 1;
-
-const pylith::meshio::DataWriterVTKData::FieldStruct
-pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellFields[] = {
- { "traction", VECTOR_FIELD, 2 },
- { "pressure", SCALAR_FIELD, 1 },
- { "other", TENSOR_FIELD, 3 },
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellField0[] = {
- 1.1, 2.2,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellField1[] = {
- 2.1,
-};
-const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellField2[] = {
- 1.2, 2.3, 3.4,
-};
-
-pylith::meshio::DataWriterVTKDataSubMeshTri3::DataWriterVTKDataSubMeshTri3(void)
-{ // constructor
- meshFilename = const_cast<char*>(_meshFilename);
- cellsLabel = const_cast<char*>(_cellsLabel);
- labelId = _labelId;
- faultLabel = const_cast<char*>(_faultLabel);
- faultId = _faultId;
-
- timestepFilename = const_cast<char*>(_timestepFilename);
- vertexFilename = const_cast<char*>(_vertexFilename);
- cellFilename = const_cast<char*>(_cellFilename);
-
- time = _time;
- timeFormat = const_cast<char*>(_timeFormat);
-
- numVertexFields = _numVertexFields;
- numVertices = _numVertices;
- assert(3 == numVertexFields);
- vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
- vertexFields[0] = const_cast<double*>(_vertexField0);
- vertexFields[1] = const_cast<double*>(_vertexField1);
- vertexFields[2] = const_cast<double*>(_vertexField2);
-
- numCellFields = _numCellFields;
- numCells = _numCells;
- assert(3 == numCellFields);
- cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
- cellFields[0] = const_cast<double*>(_cellField0);
- cellFields[1] = const_cast<double*>(_cellField1);
- cellFields[2] = const_cast<double*>(_cellField2);
-} // constructor
-
-pylith::meshio::DataWriterVTKDataSubMeshTri3::~DataWriterVTKDataSubMeshTri3(void)
-{}
-
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#include "DataWriterVTKDataSubMeshTri3.hh"
+
+#include <assert.h> // USES assert()
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_meshFilename =
+ "data/tri3.mesh";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_bcLabel =
+ "bc";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_faultLabel =
+ "fault";
+const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_faultId = 100;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_timestepFilename =
+ "tri3_surf.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexFilename =
+ "tri3_surf_vertex.vtk";
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellFilename =
+ "tri3_surf_cell.vtk";
+
+const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_time = 1.0;
+
+const char* pylith::meshio::DataWriterVTKDataSubMeshTri3::_timeFormat =
+ "%3.1f";
+
+const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numVertexFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numVertices = 8;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexFields[] = {
+ { "displacements", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::OTHER, 2 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexField0[] = {
+ 1.1, 2.2,
+ 3.3, 4.4,
+ 5.5, 6.6,
+ 7.7, 8.8,
+ 9.9, 10.0,
+ 11.1, 12.2,
+ 13.3, 14.4,
+ 15.5, 16.6,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexField1[] = {
+ 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7, 9.8,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_vertexField2[] = {
+ 1.2, 2.3,
+ 3.4, 4.5,
+ 5.6, 6.7,
+ 7.8, 8.9,
+ 9.0, 10.1,
+ 11.2, 12.3,
+ 13.4, 14.5,
+ 15.6, 16.7,
+};
+
+const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numCellFields = 3;
+const int pylith::meshio::DataWriterVTKDataSubMeshTri3::_numCells = 1;
+
+const pylith::meshio::DataWriterVTKData::FieldStruct
+pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellFields[] = {
+ { "traction", topology::FieldBase::VECTOR, 2 },
+ { "pressure", topology::FieldBase::SCALAR, 1 },
+ { "other", topology::FieldBase::TENSOR, 3 },
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellField0[] = {
+ 1.1, 2.2,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellField1[] = {
+ 2.1,
+};
+const double pylith::meshio::DataWriterVTKDataSubMeshTri3::_cellField2[] = {
+ 1.2, 2.3, 3.4,
+};
+
+pylith::meshio::DataWriterVTKDataSubMeshTri3::DataWriterVTKDataSubMeshTri3(void)
+{ // constructor
+ meshFilename = const_cast<char*>(_meshFilename);
+ bcLabel = const_cast<char*>(_bcLabel);
+ faultLabel = const_cast<char*>(_faultLabel);
+ faultId = _faultId;
+
+ timestepFilename = const_cast<char*>(_timestepFilename);
+ vertexFilename = const_cast<char*>(_vertexFilename);
+ cellFilename = const_cast<char*>(_cellFilename);
+
+ time = _time;
+ timeFormat = const_cast<char*>(_timeFormat);
+
+ numVertexFields = _numVertexFields;
+ numVertices = _numVertices;
+ assert(3 == numVertexFields);
+ vertexFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_vertexFields);
+ vertexFields[0] = const_cast<double*>(_vertexField0);
+ vertexFields[1] = const_cast<double*>(_vertexField1);
+ vertexFields[2] = const_cast<double*>(_vertexField2);
+
+ numCellFields = _numCellFields;
+ numCells = _numCells;
+ assert(3 == numCellFields);
+ cellFieldsInfo = const_cast<DataWriterVTKData::FieldStruct*>(_cellFields);
+ cellFields[0] = const_cast<double*>(_cellField0);
+ cellFields[1] = const_cast<double*>(_cellField1);
+ cellFields[2] = const_cast<double*>(_cellField2);
+} // constructor
+
+pylith::meshio::DataWriterVTKDataSubMeshTri3::~DataWriterVTKDataSubMeshTri3(void)
+{}
+
+
+// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,76 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_meshio_datawritervtkdatasubmeshtri3_hh)
-#define pylith_meshio_datawritervtkdatasubmeshtri3_hh
-
-#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
-
-namespace pylith {
- namespace meshio {
- class DataWriterVTKDataSubMeshTri3;
- } // meshio
-} // pylith
-
-class pylith::meshio::DataWriterVTKDataSubMeshTri3 : public DataWriterVTKData
-{ // DataWriterVTKDataSubMeshTri3
-
-public:
-
- /// Constructor
- DataWriterVTKDataSubMeshTri3(void);
-
- /// Destructor
- ~DataWriterVTKDataSubMeshTri3(void);
-
-private:
-
- static const char* _meshFilename; ///< Name of mesh file.
- static const char* _cellsLabel; ///< Label defining subset of cells.
- static const int _labelId; /// Value for label defining subset of cells.
- static const char* _faultLabel; ///< Name of group of vertices for fault.
- static const int _faultId; ///< Material identifier for fault.
-
- static const char* _timestepFilename; ///< Name of VTK file without fields.
- static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
- static const char* _cellFilename; ///< Name of VTK file for cell fields.
-
- static const double _time; ///< Time for fields.
- static const char* _timeFormat; ///< Format for time stamp.
-
- /// @name Vertex field information.
- //@{
- static const int _numVertexFields; ///< Number of vertex fields.
- static const int _numVertices; ///< Number of vertices.
- static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
-
- static const double _vertexField0[]; ///< Values for vertex field 0.
- static const double _vertexField1[]; ///< Values for vertex field 1.
- static const double _vertexField2[]; ///< Values for vertex field 2.
- //@}
-
- /// @name Cell field information.
- //@{
- static const int _numCellFields; ///< Number of cell fields.
- static const int _numCells; ///< Number of cells.
- static const FieldStruct _cellFields[]; ///< Array of cell fields.
-
- static const double _cellField0[]; ///< Values for cell field 0.
- static const double _cellField1[]; ///< Values for cell field 1.
- static const double _cellField2[]; ///< Values for cell field 2.
- //@}
-
-}; // DataWriterVTKDataSubMeshTri3
-
-#endif // pylith_meshio_datawritervtkdatasubmeshtri3_hh
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/DataWriterVTKDataSubMeshTri3.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+//
+// ======================================================================
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ======================================================================
+//
+
+#if !defined(pylith_meshio_datawritervtkdatasubmeshtri3_hh)
+#define pylith_meshio_datawritervtkdatasubmeshtri3_hh
+
+#include "DataWriterVTKData.hh" // ISA DataWriterVTKData
+
+namespace pylith {
+ namespace meshio {
+ class DataWriterVTKDataSubMeshTri3;
+ } // meshio
+} // pylith
+
+class pylith::meshio::DataWriterVTKDataSubMeshTri3 : public DataWriterVTKData
+{ // DataWriterVTKDataSubMeshTri3
+
+public:
+
+ /// Constructor
+ DataWriterVTKDataSubMeshTri3(void);
+
+ /// Destructor
+ ~DataWriterVTKDataSubMeshTri3(void);
+
+private:
+
+ static const char* _meshFilename; ///< Name of mesh file.
+ static const char* _bcLabel; ///< Label defining boundary vertices.
+ static const char* _faultLabel; ///< Name of group of vertices for fault.
+ static const int _faultId; ///< Material identifier for fault.
+
+ static const char* _timestepFilename; ///< Name of VTK file without fields.
+ static const char* _vertexFilename; ///< Name of VTK file for vertex fields.
+ static const char* _cellFilename; ///< Name of VTK file for cell fields.
+
+ static const double _time; ///< Time for fields.
+ static const char* _timeFormat; ///< Format for time stamp.
+
+ /// @name Vertex field information.
+ //@{
+ static const int _numVertexFields; ///< Number of vertex fields.
+ static const int _numVertices; ///< Number of vertices.
+ static const FieldStruct _vertexFields[]; ///< Array of vertex fields.
+
+ static const double _vertexField0[]; ///< Values for vertex field 0.
+ static const double _vertexField1[]; ///< Values for vertex field 1.
+ static const double _vertexField2[]; ///< Values for vertex field 2.
+ //@}
+
+ /// @name Cell field information.
+ //@{
+ static const int _numCellFields; ///< Number of cell fields.
+ static const int _numCells; ///< Number of cells.
+ static const FieldStruct _cellFields[]; ///< Array of cell fields.
+
+ static const double _cellField0[]; ///< Values for cell field 0.
+ static const double _cellField1[]; ///< Values for cell field 1.
+ static const double _cellField2[]; ///< Values for cell field 2.
+ //@}
+
+}; // DataWriterVTKDataSubMeshTri3
+
+#endif // pylith_meshio_datawritervtkdatasubmeshtri3_hh
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -45,21 +45,36 @@
hex8_t10.vtk \
hex8_vertex_t10.vtk \
hex8_cell_t10.vtk \
- line2_sub_t10.vtk \
- line2_sub_vertex_t10.vtk \
- line2_sub_cell_t10.vtk \
- tri3_sub_t10.vtk \
- tri3_sub_vertex_t10.vtk \
- tri3_sub_cell_t10.vtk \
- quad4_sub_t10.vtk \
- quad4_sub_vertex_t10.vtk \
- quad4_sub_cell_t10.vtk \
- tet4_sub_t10.vtk \
- tet4_sub_vertex_t10.vtk \
- tet4_sub_cell_t10.vtk \
- hex8_sub_t10.vtk \
- hex8_sub_vertex_t10.vtk \
- hex8_sub_cell_t10.vtk \
+ line2_mat_t10.vtk \
+ line2_mat_vertex_t10.vtk \
+ line2_mat_cell_t10.vtk \
+ tri3_mat_t10.vtk \
+ tri3_mat_vertex_t10.vtk \
+ tri3_mat_cell_t10.vtk \
+ quad4_mat_t10.vtk \
+ quad4_mat_vertex_t10.vtk \
+ quad4_mat_cell_t10.vtk \
+ tet4_mat_t10.vtk \
+ tet4_mat_vertex_t10.vtk \
+ tet4_mat_cell_t10.vtk \
+ hex8_mat_t10.vtk \
+ hex8_mat_vertex_t10.vtk \
+ hex8_mat_cell_t10.vtk \
+ line2_surf_t10.vtk \
+ line2_surf_vertex_t10.vtk \
+ line2_surf_cell_t10.vtk \
+ tri3_surf_t10.vtk \
+ tri3_surf_vertex_t10.vtk \
+ tri3_surf_cell_t10.vtk \
+ quad4_surf_t10.vtk \
+ quad4_surf_vertex_t10.vtk \
+ quad4_surf_cell_t10.vtk \
+ tet4_surf_t10.vtk \
+ tet4_surf_vertex_t10.vtk \
+ tet4_surf_cell_t10.vtk \
+ hex8_surf_t10.vtk \
+ hex8_surf_vertex_t10.vtk \
+ hex8_surf_cell_t10.vtk \
tri3_fault_t10.vtk \
tri3_fault_vertex_t10.vtk \
tri3_fault_cell_t10.vtk \
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/hex8_mat_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,34 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 16 double
+-1 -1 -1
+-1 1 -1
+0 -1 -1
+0 1 -1
+1 -1 -1
+1 1 -1
+-1 -1 1
+-1 1 1
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+0 -1 -1
+0 1 -1
+0 -1 1
+0 1 1
+CELLS 1 9
+8 2 4 5 3 8 10 11 9
+CELL_TYPES 1
+12
+CELL_DATA 1
+VECTORS traction double
+1.1 2.2 3.3
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+SCALARS other double 6
+LOOKUP_TABLE default
+1.2 2.3 3.4 4.5 5.6 6.7
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/hex8_mat_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,25 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 16 double
+-1 -1 -1
+-1 1 -1
+0 -1 -1
+0 1 -1
+1 -1 -1
+1 1 -1
+-1 -1 1
+-1 1 1
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+0 -1 -1
+0 1 -1
+0 -1 1
+0 1 1
+CELLS 1 9
+8 2 4 5 3 8 10 11 9
+CELL_TYPES 1
+12
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/hex8_mat_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_mat_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,79 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 16 double
+-1 -1 -1
+-1 1 -1
+0 -1 -1
+0 1 -1
+1 -1 -1
+1 1 -1
+-1 -1 1
+-1 1 1
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+0 -1 -1
+0 1 -1
+0 -1 1
+0 1 1
+CELLS 1 9
+8 2 4 5 3 8 10 11 9
+CELL_TYPES 1
+12
+POINT_DATA 16
+VECTORS displacements double
+1.1 2.2 3.3
+4.4 5.5 6.6
+7.7 8.8 9.9
+10.1 11.2 12.3
+1.2 2.3 3.4
+4.5 5.6 6.7
+7.8 8.9 9
+10.2 11.3 12.4
+1.3 2.4 3.5
+4.6 5.7 6.8
+7.9 8 9.1
+10.2 11.3 12.4
+13.5 14.6 15.7
+16.8 17.9 18.1
+19.2 20.3 21.4
+22.5 23.6 24.7
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+4.3
+5.4
+6.5
+7.6
+8.7
+9.8
+10
+12.1
+11.1
+13.1
+14.1
+15.1
+16.1
+17.1
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
+3.4 4.5
+5.6 6.7
+7.8 8.9
+1.3 2.4
+3.5 4.6
+5.7 6.8
+7.9 8
+1.3 2.4
+3.5 4.6
+5.7 6.8
+8 1.4
+2.5 3.6
+4.8 1.5
+2.6 3.7
+4.8 5.9
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_cell_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_cell_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,34 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 16 double
--1 -1 -1
--1 1 -1
-0 -1 -1
-0 1 -1
-1 -1 -1
-1 1 -1
--1 -1 1
--1 1 1
-0 -1 1
-0 1 1
-1 -1 1
-1 1 1
-0 -1 -1
-0 1 -1
-0 -1 1
-0 1 1
-CELLS 1 9
-8 2 4 5 3 8 10 11 9
-CELL_TYPES 1
-12
-CELL_DATA 1
-VECTORS traction double
-1.1 2.2 3.3
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-SCALARS other double 6
-LOOKUP_TABLE default
-1.2 2.3 3.4 4.5 5.6 6.7
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,25 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 16 double
--1 -1 -1
--1 1 -1
-0 -1 -1
-0 1 -1
-1 -1 -1
-1 1 -1
--1 -1 1
--1 1 1
-0 -1 1
-0 1 1
-1 -1 1
-1 1 1
-0 -1 -1
-0 1 -1
-0 -1 1
-0 1 1
-CELLS 1 9
-8 2 4 5 3 8 10 11 9
-CELL_TYPES 1
-12
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_vertex_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_vertex_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_sub_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,79 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 16 double
--1 -1 -1
--1 1 -1
-0 -1 -1
-0 1 -1
-1 -1 -1
-1 1 -1
--1 -1 1
--1 1 1
-0 -1 1
-0 1 1
-1 -1 1
-1 1 1
-0 -1 -1
-0 1 -1
-0 -1 1
-0 1 1
-CELLS 1 9
-8 2 4 5 3 8 10 11 9
-CELL_TYPES 1
-12
-POINT_DATA 16
-VECTORS displacements double
-1.1 2.2 3.3
-4.4 5.5 6.6
-7.7 8.8 9.9
-10.1 11.2 12.3
-1.2 2.3 3.4
-4.5 5.6 6.7
-7.8 8.9 9
-10.2 11.3 12.4
-1.3 2.4 3.5
-4.6 5.7 6.8
-7.9 8 9.1
-10.2 11.3 12.4
-13.5 14.6 15.7
-16.8 17.9 18.1
-19.2 20.3 21.4
-22.5 23.6 24.7
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-3.2
-4.3
-5.4
-6.5
-7.6
-8.7
-9.8
-10
-12.1
-11.1
-13.1
-14.1
-15.1
-16.1
-17.1
-SCALARS other double 2
-LOOKUP_TABLE default
-1.2 2.3
-3.4 4.5
-5.6 6.7
-7.8 8.9
-1.3 2.4
-3.5 4.6
-5.7 6.8
-7.9 8
-1.3 2.4
-3.5 4.6
-5.7 6.8
-8 1.4
-2.5 3.6
-4.8 1.5
-2.6 3.7
-4.8 5.9
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/hex8_surf_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,29 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 -1 1
+-1 1 1
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+CELLS 2 10
+4 2 3 1 0
+4 4 5 3 2
+CELL_TYPES 2
+9
+9
+CELL_DATA 2
+VECTORS traction double
+1.1 2.2 3.3
+4.4 5.5 6.6
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+SCALARS other double 6
+LOOKUP_TABLE default
+1.2 2.3 3.4 4.5 5.6 6.7
+7.8 8.9 9 10.1 11.2 12.3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/hex8_surf_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,17 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 -1 1
+-1 1 1
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+CELLS 2 10
+4 2 3 1 0
+4 4 5 3 2
+CELL_TYPES 2
+9
+9
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/hex8_surf_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/hex8_surf_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,41 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 -1 1
+-1 1 1
+0 -1 1
+0 1 1
+1 -1 1
+1 1 1
+CELLS 2 10
+4 2 3 1 0
+4 4 5 3 2
+CELL_TYPES 2
+9
+9
+POINT_DATA 6
+VECTORS displacements double
+7.8 8.9 9
+10.2 11.3 12.4
+1.3 2.4 3.5
+4.6 5.7 6.8
+7.9 8.1 9.2
+10.3 11.4 12.5
+SCALARS pressure double 1
+LOOKUP_TABLE default
+8.7
+9.8
+10.9
+11.8
+12.7
+13.6
+SCALARS other double 2
+LOOKUP_TABLE default
+5.7 6.8
+7.9 8
+8.1 8.2
+9.2 9.3
+10.4 10.5
+11.5 11.6
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/line2_mat_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,22 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 4 double
+-1 0.0 0.0
+0 0.0 0.0
+1 0.0 0.0
+0 0.0 0.0
+CELLS 1 3
+2 0 3
+CELL_TYPES 1
+3
+CELL_DATA 1
+VECTORS traction double
+1.1 0.0 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+SCALARS other double 1
+LOOKUP_TABLE default
+1.2
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/line2_mat_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,13 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 4 double
+-1 0.0 0.0
+0 0.0 0.0
+1 0.0 0.0
+0 0.0 0.0
+CELLS 1 3
+2 0 3
+CELL_TYPES 1
+3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/line2_mat_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_mat_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 4 double
+-1 0.0 0.0
+0 0.0 0.0
+1 0.0 0.0
+0 0.0 0.0
+CELLS 1 3
+2 0 3
+CELL_TYPES 1
+3
+POINT_DATA 4
+VECTORS displacements double
+1.1 0.0 0.0
+2.2 0.0 0.0
+3.3 0.0 0.0
+4.4 0.0 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+4.3
+5.4
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
+3.4 4.5
+5.6 6.7
+7.8 8.9
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_cell_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_cell_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,22 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 4 double
--1 0.0 0.0
-0 0.0 0.0
-1 0.0 0.0
-0 0.0 0.0
-CELLS 1 3
-2 0 3
-CELL_TYPES 1
-3
-CELL_DATA 1
-VECTORS traction double
-1.1 0.0 0.0
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-SCALARS other double 1
-LOOKUP_TABLE default
-1.2
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,13 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 4 double
--1 0.0 0.0
-0 0.0 0.0
-1 0.0 0.0
-0 0.0 0.0
-CELLS 1 3
-2 0 3
-CELL_TYPES 1
-3
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_vertex_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_vertex_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_sub_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 4 double
--1 0.0 0.0
-0 0.0 0.0
-1 0.0 0.0
-0 0.0 0.0
-CELLS 1 3
-2 0 3
-CELL_TYPES 1
-3
-POINT_DATA 4
-VECTORS displacements double
-1.1 0.0 0.0
-2.2 0.0 0.0
-3.3 0.0 0.0
-4.4 0.0 0.0
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-3.2
-4.3
-5.4
-SCALARS other double 2
-LOOKUP_TABLE default
-1.2 2.3
-3.4 4.5
-5.6 6.7
-7.8 8.9
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/line2_surf_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,18 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 1 double
+-1 0.0 0.0
+CELLS 1 2
+1 0
+CELL_TYPES 1
+-1
+CELL_DATA 1
+VECTORS traction double
+1.1 2.2 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+VECTORS other double
+1.2 2.3 3.4
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/line2_surf_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,10 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 1 double
+-1 0.0 0.0
+CELLS 1 2
+1 0
+CELL_TYPES 1
+-1
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/line2_surf_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/line2_surf_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,19 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 1 double
+-1 0.0 0.0
+CELLS 1 2
+1 0
+CELL_TYPES 1
+-1
+POINT_DATA 1
+VECTORS displacements double
+1.1 2.2 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/quad4_mat_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,23 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 -1 0.0
+-1 1 0.0
+0 -1 0.0
+0 1 0.0
+1 -1 0.0
+1 1 0.0
+CELLS 1 5
+4 2 4 5 3
+CELL_TYPES 1
+9
+CELL_DATA 1
+VECTORS traction double
+1.1 2.2 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+VECTORS other double
+1.2 2.3 3.4
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/quad4_mat_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,15 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 -1 0.0
+-1 1 0.0
+0 -1 0.0
+0 1 0.0
+1 -1 0.0
+1 1 0.0
+CELLS 1 5
+4 2 4 5 3
+CELL_TYPES 1
+9
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/quad4_mat_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_mat_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,39 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 -1 0.0
+-1 1 0.0
+0 -1 0.0
+0 1 0.0
+1 -1 0.0
+1 1 0.0
+CELLS 1 5
+4 2 4 5 3
+CELL_TYPES 1
+9
+POINT_DATA 6
+VECTORS displacements double
+1.1 2.2 0.0
+3.3 4.4 0.0
+5.5 6.6 0.0
+7.7 8.8 0.0
+9.9 10.1 0.0
+11.2 12.3 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+4.3
+5.4
+6.5
+7.6
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
+3.4 4.5
+5.6 6.7
+7.8 8.9
+9.8 7.6
+6.5 5.4
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_cell_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_cell_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,23 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 6 double
--1 -1 0.0
--1 1 0.0
-0 -1 0.0
-0 1 0.0
-1 -1 0.0
-1 1 0.0
-CELLS 1 5
-4 2 4 5 3
-CELL_TYPES 1
-9
-CELL_DATA 1
-VECTORS traction double
-1.1 2.2 0.0
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-VECTORS other double
-1.2 2.3 3.4
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,15 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 6 double
--1 -1 0.0
--1 1 0.0
-0 -1 0.0
-0 1 0.0
-1 -1 0.0
-1 1 0.0
-CELLS 1 5
-4 2 4 5 3
-CELL_TYPES 1
-9
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_vertex_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_vertex_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_sub_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,39 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 6 double
--1 -1 0.0
--1 1 0.0
-0 -1 0.0
-0 1 0.0
-1 -1 0.0
-1 1 0.0
-CELLS 1 5
-4 2 4 5 3
-CELL_TYPES 1
-9
-POINT_DATA 6
-VECTORS displacements double
-1.1 2.2 0.0
-3.3 4.4 0.0
-5.5 6.6 0.0
-7.7 8.8 0.0
-9.9 10.1 0.0
-11.2 12.3 0.0
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-3.2
-4.3
-5.4
-6.5
-7.6
-SCALARS other double 2
-LOOKUP_TABLE default
-1.2 2.3
-3.4 4.5
-5.6 6.7
-7.8 8.9
-9.8 7.6
-6.5 5.4
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/quad4_surf_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,25 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 3 double
+-1 -1 0.0
+0 -1 0.0
+1 -1 0.0
+CELLS 2 6
+2 0 1
+2 1 2
+CELL_TYPES 2
+3
+3
+CELL_DATA 2
+VECTORS traction double
+1.1 2.2 0.0
+3.3 4.4 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+VECTORS other double
+1.2 2.3 3.4
+4.5 5.6 6.7
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/quad4_surf_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,14 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 3 double
+-1 -1 0.0
+0 -1 0.0
+1 -1 0.0
+CELLS 2 6
+2 0 1
+2 1 2
+CELL_TYPES 2
+3
+3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/quad4_surf_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/quad4_surf_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,29 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 3 double
+-1 -1 0.0
+0 -1 0.0
+1 -1 0.0
+CELLS 2 6
+2 0 1
+2 1 2
+CELL_TYPES 2
+3
+3
+POINT_DATA 3
+VECTORS displacements double
+1.1 2.2 0.0
+5.5 6.6 0.0
+9.9 10 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+4.3
+6.5
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
+5.6 6.7
+9.1 10.2
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tet4_mat_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,31 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 8 double
+-1 0 0
+0 -1 0
+0 0 1
+0 1 0
+1 0 0
+0 -1 0
+0 0 1
+0 1 0
+CELLS 2 10
+4 1 2 3 0
+4 5 7 6 4
+CELL_TYPES 2
+10
+10
+CELL_DATA 2
+VECTORS traction double
+1.1 2.2 3.3
+4.4 5.5 6.6
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+SCALARS other double 6
+LOOKUP_TABLE default
+1.2 2.3 3.4 4.5 5.6 6.7
+7.8 8.9 9 10.1 11.2 12.3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tet4_mat_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,19 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 8 double
+-1 0 0
+0 -1 0
+0 0 1
+0 1 0
+1 0 0
+0 -1 0
+0 0 1
+0 1 0
+CELLS 2 10
+4 1 2 3 0
+4 5 7 6 4
+CELL_TYPES 2
+10
+10
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tet4_mat_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_mat_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,49 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 8 double
+-1 0 0
+0 -1 0
+0 0 1
+0 1 0
+1 0 0
+0 -1 0
+0 0 1
+0 1 0
+CELLS 2 10
+4 1 2 3 0
+4 5 7 6 4
+CELL_TYPES 2
+10
+10
+POINT_DATA 8
+VECTORS displacements double
+1.1 2.2 3.3
+4.4 5.5 6.6
+7.7 8.8 9.9
+10 11.1 12.2
+13.3 14.4 15.5
+16.6 17.7 18.8
+19.9 20 21.1
+22.2 23.3 24.4
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+4.3
+5.4
+6.5
+7.6
+8.7
+9.8
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
+3.4 4.5
+5.6 6.7
+7.8 8.9
+9 10.1
+11.2 12.3
+13.4 14.5
+15.6 16.7
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_cell_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_cell_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,31 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 8 double
--1 0 0
-0 -1 0
-0 0 1
-0 1 0
-1 0 0
-0 -1 0
-0 0 1
-0 1 0
-CELLS 2 10
-4 1 2 3 0
-4 5 7 6 4
-CELL_TYPES 2
-10
-10
-CELL_DATA 2
-VECTORS traction double
-1.1 2.2 3.3
-4.4 5.5 6.6
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-3.2
-SCALARS other double 6
-LOOKUP_TABLE default
-1.2 2.3 3.4 4.5 5.6 6.7
-7.8 8.9 9 10.1 11.2 12.3
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,19 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 8 double
--1 0 0
-0 -1 0
-0 0 1
-0 1 0
-1 0 0
-0 -1 0
-0 0 1
-0 1 0
-CELLS 2 10
-4 1 2 3 0
-4 5 7 6 4
-CELL_TYPES 2
-10
-10
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_vertex_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_vertex_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_sub_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,49 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 8 double
--1 0 0
-0 -1 0
-0 0 1
-0 1 0
-1 0 0
-0 -1 0
-0 0 1
-0 1 0
-CELLS 2 10
-4 1 2 3 0
-4 5 7 6 4
-CELL_TYPES 2
-10
-10
-POINT_DATA 8
-VECTORS displacements double
-1.1 2.2 3.3
-4.4 5.5 6.6
-7.7 8.8 9.9
-10 11.1 12.2
-13.3 14.4 15.5
-16.6 17.7 18.8
-19.9 20 21.1
-22.2 23.3 24.4
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-3.2
-4.3
-5.4
-6.5
-7.6
-8.7
-9.8
-SCALARS other double 2
-LOOKUP_TABLE default
-1.2 2.3
-3.4 4.5
-5.6 6.7
-7.8 8.9
-9 10.1
-11.2 12.3
-13.4 14.5
-15.6 16.7
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tet4_surf_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,27 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 4 double
+-1 0 0
+0 -1 0
+0 1 0
+1 0 0
+CELLS 2 8
+3 0 2 1
+3 1 2 3
+CELL_TYPES 2
+5
+5
+CELL_DATA 2
+VECTORS traction double
+1.1 2.2 3.3
+4.4 5.5 6.6
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+SCALARS other double 6
+LOOKUP_TABLE default
+1.2 2.3 3.4 4.5 5.6 6.7
+7.8 8.9 9 10.1 11.2 12.3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tet4_surf_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,15 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 4 double
+-1 0 0
+0 -1 0
+0 1 0
+1 0 0
+CELLS 2 8
+3 0 2 1
+3 1 2 3
+CELL_TYPES 2
+5
+5
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tet4_surf_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tet4_surf_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,33 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 4 double
+-1 0 0
+0 -1 0
+0 1 0
+1 0 0
+CELLS 2 8
+3 0 2 1
+3 1 2 3
+CELL_TYPES 2
+5
+5
+POINT_DATA 4
+VECTORS displacements double
+1.1 2.2 3.3
+4.4 5.5 6.6
+10 11.1 12.2
+13.3 14.4 15.5
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+5.4
+6.5
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
+3.4 4.5
+7.8 8.9
+9 10.1
Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3.mesh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3.mesh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3.mesh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,6 +16,15 @@
// \ | | /
// 4-6-1
//
+// Mesh with fault (Sieve labels)
+// 7-9-4
+// / | | \
+// / | | \
+// 2 0 | | 1 5
+// \ | | /
+// \ | | /
+// 6-8-3
+//
mesh = {
dimension = 2
use-index-zero = true
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tri3_mat_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,23 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 0 0.0
+0 -1 0.0
+0 1 0.0
+1 0 0.0
+0 -1 0.0
+0 1 0.0
+CELLS 1 4
+3 1 3 2
+CELL_TYPES 1
+5
+CELL_DATA 1
+VECTORS traction double
+1.1 2.2 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+VECTORS other double
+1.2 2.3 3.4
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tri3_mat_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,15 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 0 0.0
+0 -1 0.0
+0 1 0.0
+1 0 0.0
+0 -1 0.0
+0 1 0.0
+CELLS 1 4
+3 1 3 2
+CELL_TYPES 1
+5
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tri3_mat_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_mat_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,39 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 6 double
+-1 0 0.0
+0 -1 0.0
+0 1 0.0
+1 0 0.0
+0 -1 0.0
+0 1 0.0
+CELLS 1 4
+3 1 3 2
+CELL_TYPES 1
+5
+POINT_DATA 6
+VECTORS displacements double
+1.1 2.2 0.0
+3.3 4.4 0.0
+5.5 6.6 0.0
+7.7 8.8 0.0
+9.9 10 0.0
+11.1 12.2 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+3.2
+4.3
+5.4
+6.5
+7.6
+SCALARS other double 2
+LOOKUP_TABLE default
+1.2 2.3
+3.4 4.5
+5.6 6.7
+7.8 8.9
+9 10.1
+11.2 12.3
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_cell_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_cell_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,23 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 6 double
--1 0 0.0
-0 -1 0.0
-0 1 0.0
-1 0 0.0
-0 -1 0.0
-0 1 0.0
-CELLS 1 4
-3 1 3 2
-CELL_TYPES 1
-5
-CELL_DATA 1
-VECTORS traction double
-1.1 2.2 0.0
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-VECTORS other double
-1.2 2.3 3.4
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,15 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 6 double
--1 0 0.0
-0 -1 0.0
-0 1 0.0
-1 0 0.0
-0 -1 0.0
-0 1 0.0
-CELLS 1 4
-3 1 3 2
-CELL_TYPES 1
-5
Deleted: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_vertex_t10.vtk
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_vertex_t10.vtk 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_sub_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,39 +0,0 @@
-# vtk DataFile Version 2.0
-Simplicial Mesh Example
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 6 double
--1 0 0.0
-0 -1 0.0
-0 1 0.0
-1 0 0.0
-0 -1 0.0
-0 1 0.0
-CELLS 1 4
-3 1 3 2
-CELL_TYPES 1
-5
-POINT_DATA 6
-VECTORS displacements double
-1.1 2.2 0.0
-3.3 4.4 0.0
-5.5 6.6 0.0
-7.7 8.8 0.0
-9.9 10 0.0
-11.1 12.2 0.0
-SCALARS pressure double 1
-LOOKUP_TABLE default
-2.1
-3.2
-4.3
-5.4
-6.5
-7.6
-SCALARS other double 2
-LOOKUP_TABLE default
-1.2 2.3
-3.4 4.5
-5.6 6.7
-7.8 8.9
-9 10.1
-11.2 12.3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_cell_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tri3_surf_cell_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_cell_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_cell_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,19 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 2 double
+0 -1 0.0
+1 0 0.0
+CELLS 1 3
+2 0 1
+CELL_TYPES 1
+3
+CELL_DATA 1
+VECTORS traction double
+1.1 2.2 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+2.1
+VECTORS other double
+1.2 2.3 3.4
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tri3_surf_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,11 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 2 double
+0 -1 0.0
+1 0 0.0
+CELLS 1 3
+2 0 1
+CELL_TYPES 1
+3
Copied: short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_vertex_t10.vtk (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/meshio/data/tri3_surf_vertex_t10.vtk)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_vertex_t10.vtk (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/data/tri3_surf_vertex_t10.vtk 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,23 @@
+# vtk DataFile Version 2.0
+Simplicial Mesh Example
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 2 double
+0 -1 0.0
+1 0 0.0
+CELLS 1 3
+2 0 1
+CELL_TYPES 1
+3
+POINT_DATA 2
+VECTORS displacements double
+3.3 4.4 0.0
+7.7 8.8 0.0
+SCALARS pressure double 1
+LOOKUP_TABLE default
+3.2
+5.4
+SCALARS other double 2
+LOOKUP_TABLE default
+3.4 4.5
+7.8 8.9
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -21,20 +21,30 @@
# Primary source files
testtopology_SOURCES = \
- TestField.cc \
- TestFieldUniform.cc \
- TestFieldsManager.cc \
TestMesh.cc \
TestMeshOps.cc \
+ TestSubMesh.cc \
+ TestFieldMesh.cc \
+ TestFieldSubMesh.cc \
+ TestFieldsMesh.cc \
+ TestFieldsSubMesh.cc \
+ TestSolutionFields.cc \
+ TestJacobian.cc \
test_topology.cc
+
noinst_HEADERS = \
- TestField.hh \
- TestFieldUniform.hh \
- TestFieldsManager.hh \
TestMesh.hh \
- TestMeshOps.hh
+ TestSubMesh.hh \
+ TestMeshOps.hh \
+ TestFieldMesh.hh \
+ TestFieldSubMesh.hh \
+ TestFieldsMesh.hh \
+ TestFieldsSubMesh.hh \
+ TestSolutionFields.hh \
+ TestJacobian.hh
+
# Source files associated with testing data
testtopology_SOURCES +=
@@ -54,8 +64,11 @@
testtopology_LDADD += -lnetcdf_c++ -lnetcdf
endif
-noinst_tmp =
+noinst_tmp = \
+ jacobian.mat \
+ jacobian.mat.info
CLEANFILES = $(noinst_tmp)
+
# End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/topology/TestField.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestField.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestField.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,622 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestField.hh" // Implementation of class methods
-#include "pylith/topology/Field.hh" // USES Field
-
-#include "pylith/topology/Mesh.hh" // USES Mesh
-#include "pylith/utils/array.hh" // USES double_array
-
-#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestField );
-
-// ----------------------------------------------------------------------
-namespace pylith {
- namespace topology {
- namespace _TestField {
- const int cellDim = 2;
- const int nvertices = 4;
- const int ncells = 1;
- const int ncorners = 4;
- const int cells[] = { 0, 1, 2, 3 };
- const double coordinates[] = {
- 0.0, 0.0,
- 1.0, 0.0,
- 0.0, 1.0,
- 1.0, 1.0,
- };
- } // _TestField
- } // topology
-} // pylith
-
-// ----------------------------------------------------------------------
-// Test constructor.
-void
-pylith::topology::TestField::testConstructor(void)
-{ // testConstructor
- Mesh mesh;
- Field field(mesh.sieveMesh());
-
- CPPUNIT_ASSERT(!field._mesh.isNull());
-} // testConstructor
-
-// ----------------------------------------------------------------------
-// Test section().
-void
-pylith::topology::TestField::testSection(void)
-{ // testSection
- Mesh mesh;
- Field field(mesh.sieveMesh());
-
- const ALE::Obj<SieveMesh::real_section_type>& section = field.section();
- CPPUNIT_ASSERT(section.isNull());
-
- field.newSection();
- CPPUNIT_ASSERT(!section.isNull());
-} // testSection
-
-// ----------------------------------------------------------------------
-// Test name().
-void
-pylith::topology::TestField::testName(void)
-{ // testName
- Mesh mesh;
- Field field(mesh.sieveMesh());
-
- CPPUNIT_ASSERT_EQUAL(std::string("unknown"), std::string(field.name()));
-
- const std::string name = "field A";
- field.name(name.c_str());
- CPPUNIT_ASSERT_EQUAL(name, std::string(field.name()));
-} // testName
-
-// ----------------------------------------------------------------------
-// Test vectorFieldType().
-void
-pylith::topology::TestField::testVectorFieldType(void)
-{ // testVectorFieldType
- Mesh mesh;
- Field field(mesh.sieveMesh());
-
- CPPUNIT_ASSERT_EQUAL(Field::OTHER, field.vectorFieldType());
-
- const Field::VectorFieldEnum ftype = Field::TENSOR;
- field.vectorFieldType(ftype);
- CPPUNIT_ASSERT_EQUAL(ftype, field.vectorFieldType());
-} // testVectorFieldType
-
-// ----------------------------------------------------------------------
-// Test spaceDim().
-void
-pylith::topology::TestField::testSpaceDim(void)
-{ // testSpaceDim
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- Field field(mesh.sieveMesh());
-
- std::cout << "MESH DIM: " << mesh.sieveMesh()->getDimension() << std::endl;
-
- CPPUNIT_ASSERT_EQUAL(_TestField::cellDim, field.spaceDim());
-} // testSpaceDim
-
-// ----------------------------------------------------------------------
-// Test scale().
-void
-pylith::topology::TestField::testScale(void)
-{ // testScale
- Mesh mesh;
- Field field(mesh.sieveMesh());
-
- CPPUNIT_ASSERT_EQUAL(1.0, field.scale());
-
- const double scale = 4.0;
- field.scale(scale);
- CPPUNIT_ASSERT_EQUAL(scale, field.scale());
-} // testScale
-
-// ----------------------------------------------------------------------
-// Test addDimensionOkay().
-void
-pylith::topology::TestField::testAddDimensionOkay(void)
-{ // testAddDimensionOkay
- Mesh mesh;
- Field field(mesh.sieveMesh());
-
- CPPUNIT_ASSERT_EQUAL(false, field.addDimensionOkay());
-
- field.addDimensionOkay(true);
- CPPUNIT_ASSERT_EQUAL(true, field.addDimensionOkay());
-} // testAddDimensionOkay
-
-// ----------------------------------------------------------------------
-// Test copyLayout().
-void
-pylith::topology::TestField::testCopyLayout(void)
-{ // testCopyLayout
- const int fiberDim = 3;
- const int nconstraints[] = { 0, 2, 1, 3 };
- const int constraints[] = {
- // 0
- 0, 3, // 1
- 2, // 2
- 0, 1, 2, // 3
- };
-
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
-
- // Create field with atlas to use to create new field
- Field fieldSrc(sieveMesh);
- { // Setup source field
- fieldSrc.newSection();
- const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
- const int spaceDim = _TestField::cellDim;
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- int iV=0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter)
- section->addConstraintDimension(*v_iter, nconstraints[iV++]);
- sieveMesh->allocate(section);
- } // Setup source field
-
- Field field(sieveMesh);
- field.copyLayout(fieldSrc);
-
- const ALE::Obj<SieveRealSection>& section = field.section();
- int iV = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(nconstraints[iV++],
- section->getConstraintDimension(*v_iter));
- } // for
-} // testCopyLayout
-
-// ----------------------------------------------------------------------
-// Test clear().
-void
-pylith::topology::TestField::testClear(void)
-{ // testClear
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- Field field(mesh.sieveMesh());
-
- field.scale(2.0);
- field.vectorFieldType(Field::TENSOR);
- field.addDimensionOkay(true);
-
- field.clear();
-
- CPPUNIT_ASSERT_EQUAL(1.0, field._scale);
- CPPUNIT_ASSERT_EQUAL(Field::OTHER, field._vecFieldType);
- CPPUNIT_ASSERT_EQUAL(false, field._dimensionsOkay);
-} // testClear
-
-// ----------------------------------------------------------------------
-// Test zero().
-void
-pylith::topology::TestField::testZero(void)
-{ // testZero
- const int fiberDim = 3;
- const double scale = 2.0;
- const double valuesNondim[] = {
- 1.1, 2.2, 3.3,
- 1.2, 2.3, 3.4,
- 1.3, 2.4, 3.5,
- 1.4, 2.5, 3.6,
- };
-
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
-
- Field field(sieveMesh);
- field.newSection();
- const ALE::Obj<SieveRealSection>& section = field.section();
- const int spaceDim = _TestField::cellDim;
-
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
-
- double_array values(fiberDim);
- int i = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- for (int iDim=0; iDim < fiberDim; ++iDim)
- values[iDim] = valuesNondim[i++];
- section->updatePoint(*v_iter, &values[0]);
- } // for
-
- field.zero();
-
- const double tolerance = 1.0e-6;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- section->restrictPoint(*v_iter, &values[0], values.size());
- for (int iDim=0; iDim < fiberDim; ++iDim) {
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[iDim], tolerance);
- } // for
- } // for
-} // testZero
-
-// ----------------------------------------------------------------------
-// Test complete().
-void
-pylith::topology::TestField::testComplete(void)
-{ // testComplete
- const int fiberDim = 3;
- const double scale = 2.0;
- const double valuesNondim[] = {
- 1.1, 2.2, 3.3,
- 1.2, 2.3, 3.4,
- 1.3, 2.4, 3.5,
- 1.4, 2.5, 3.6,
- };
-
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
-
- Field field(sieveMesh);
- field.newSection();
- const ALE::Obj<SieveRealSection>& section = field.section();
- const int spaceDim = _TestField::cellDim;
-
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
-
- double_array values(fiberDim);
- int i = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- for (int iDim=0; iDim < fiberDim; ++iDim)
- values[iDim] = valuesNondim[i++];
- section->updatePoint(*v_iter, &values[0]);
- } // for
-
- field.complete();
-
- // Expect no change for this serial test
- i = 0;
- const double tolerance = 1.0e-6;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- section->restrictPoint(*v_iter, &values[0], values.size());
- for (int iDim=0; iDim < fiberDim; ++iDim) {
- CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
- } // for
- } // for
-} // testComplete
-
-// ----------------------------------------------------------------------
-// Test copy().
-void
-pylith::topology::TestField::testCopy(void)
-{ // testCopy
- const int fiberDim = 3;
- const double scale = 2.0;
- const double valuesNondim[] = {
- 1.1, 2.2, 3.3,
- 1.2, 2.3, 3.4,
- 1.3, 2.4, 3.5,
- 1.4, 2.5, 3.6,
- };
-
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
-
- Field fieldSrc(sieveMesh);
- { // Setup source field
- fieldSrc.newSection();
- const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
- const int spaceDim = _TestField::cellDim;
-
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
-
- double_array values(fiberDim);
- int i = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- for (int iDim=0; iDim < fiberDim; ++iDim)
- values[iDim] = valuesNondim[i++];
- section->updatePoint(*v_iter, &values[0]);
- } // for
- } // Setup source field
-
- Field field(sieveMesh);
- field.newSection();
- const ALE::Obj<SieveRealSection>& section = field.section();
- { // Setup destination field
- const int spaceDim = _TestField::cellDim;
-
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
- } // Setup destination field
-
- field.copy(fieldSrc);
-
- int i = 0;
- double_array values(fiberDim);
- const double tolerance = 1.0e-6;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- section->restrictPoint(*v_iter, &values[0], values.size());
- for (int iDim=0; iDim < fiberDim; ++iDim) {
- CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
- } // for
- } // for
-} // testCopy
-
-// ----------------------------------------------------------------------
-// Test operator+=().
-void
-pylith::topology::TestField::testOperatorAdd(void)
-{ // testOperateAdd
- const int fiberDim = 3;
- const double scale = 2.0;
- const double valuesA[] = {
- 1.1, 2.2, 3.3,
- 1.2, 2.3, 3.4,
- 1.3, 2.4, 3.5,
- 1.4, 2.5, 3.6,
- };
- const double valuesB[] = {
- 10.1, 20.2, 30.3,
- 10.2, 20.3, 30.4,
- 10.3, 20.4, 30.5,
- 10.4, 20.5, 30.6,
- };
-
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
-
- Field fieldSrc(sieveMesh);
- { // Setup source field
- fieldSrc.newSection();
- const ALE::Obj<SieveRealSection>& section = fieldSrc.section();
- const int spaceDim = _TestField::cellDim;
-
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
-
- double_array values(fiberDim);
- int i = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- for (int iDim=0; iDim < fiberDim; ++iDim)
- values[iDim] = valuesA[i++];
- section->updatePoint(*v_iter, &values[0]);
- } // for
- } // Setup source field
-
- Field field(sieveMesh);
- field.newSection();
- const ALE::Obj<SieveRealSection>& section = field.section();
- { // Setup destination field
- const int spaceDim = _TestField::cellDim;
-
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
-
- double_array values(fiberDim);
- int i = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- for (int iDim=0; iDim < fiberDim; ++iDim)
- values[iDim] = valuesB[i++];
- section->updatePoint(*v_iter, &values[0]);
- } // for
- } // Setup destination field
-
- field += fieldSrc;
-
- int i = 0;
- double_array values(fiberDim);
- const double tolerance = 1.0e-6;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- section->restrictPoint(*v_iter, &values[0], values.size());
- for (int iDim=0; iDim < fiberDim; ++iDim) {
- const double valueE = valuesA[i] + valuesB[i];
- ++i;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[iDim], tolerance);
- } // for
- } // for
-} // testOperateAdd
-
-// ----------------------------------------------------------------------
-// Test dimensionalize().
-void
-pylith::topology::TestField::testDimensionalize(void)
-{ // testDimensionalize
- const int fiberDim = 3;
- const double scale = 2.0;
- const double valuesNondim[] = {
- 1.1, 2.2, 3.3,
- 1.2, 2.3, 3.4,
- 1.3, 2.4, 3.5,
- 1.4, 2.5, 3.6,
- };
-
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
- Field field(sieveMesh);
- field.newSection();
- const ALE::Obj<SieveRealSection>& section = field.section();
- const int spaceDim = _TestField::cellDim;
-
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
-
- double_array values(fiberDim);
- int i = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- for (int iDim=0; iDim < fiberDim; ++iDim)
- values[iDim] = valuesNondim[i++];
- section->updatePoint(*v_iter, &values[0]);
- } // for
-
- field.scale(scale);
- field.addDimensionOkay(true);
- field.dimensionalize();
-
- i = 0;
- const double tolerance = 1.0e-6;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- section->restrictPoint(*v_iter, &values[0], values.size());
- for (int iDim=0; iDim < fiberDim; ++iDim) {
- const double valueE = valuesNondim[i++]*scale;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[iDim], tolerance);
- } // for
- } // for
-
-} // testDimensionalize
-
-// ----------------------------------------------------------------------
-// Test view().
-void
-pylith::topology::TestField::testView(void)
-{ // testView
- const int fiberDim = 3;
- const double scale = 2.0;
- const double valuesNondim[] = {
- 1.1, 2.2, 3.3,
- 1.2, 2.3, 3.4,
- 1.3, 2.4, 3.5,
- 1.4, 2.5, 3.6,
- };
-
- Mesh mesh(PETSC_COMM_WORLD, _TestField::cellDim);
- _buildMesh(&mesh);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
- const ALE::Obj<SieveMesh::label_sequence>& vertices =
- sieveMesh->depthStratum(0);
-
- Field field(sieveMesh);
- field.newSection();
- const ALE::Obj<SieveRealSection>& section = field.section();
- const int spaceDim = _TestField::cellDim;
-
- section->setChart(SieveMesh::real_section_type::chart_type(
- *std::min_element(vertices->begin(), vertices->end()),
- *std::max_element(vertices->begin(), vertices->end())+1));
- section->setFiberDimension(vertices, fiberDim);
- sieveMesh->allocate(section);
-
- double_array values(fiberDim);
- int i = 0;
- for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- for (int iDim=0; iDim < fiberDim; ++iDim)
- values[iDim] = valuesNondim[i++];
- section->updatePoint(*v_iter, &values[0]);
- } // for
-
- field.view("Testing view");
-} // testView
-
-// ----------------------------------------------------------------------
-void
-pylith::topology::TestField::_buildMesh(Mesh* mesh)
-{ // _buildMesh
- assert(0 != mesh);
-
- const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
-
- ALE::Obj<SieveMesh::sieve_type> sieve =
- new SieveMesh::sieve_type(sieveMesh->comm());
- CPPUNIT_ASSERT(!sieve.isNull());
-
- ALE::Obj<ALE::Mesh::sieve_type> s =
- new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
-
- const int cellDim = _TestField::cellDim;
- const int ncells = _TestField::ncells;
- const int* cells = _TestField::cells;
- const int nvertices = _TestField::nvertices;
- const int ncorners = _TestField::ncorners;
- const int spaceDim = _TestField::cellDim;
- const double* coordinates = _TestField::coordinates;
- const bool interpolate = false;
- ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, ncells, (int*) cells,
- nvertices, interpolate,
- ncorners);
- std::map<SieveMesh::point_type,SieveMesh::point_type> renumbering;
- ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
- sieveMesh->setSieve(sieve);
- sieveMesh->stratify();
- ALE::SieveBuilder<SieveMesh>::buildCoordinates(sieveMesh, spaceDim,
- coordinates);
-
-} // _buildMesh
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/topology/TestField.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestField.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestField.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,124 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/topology/TestField.hh
- *
- * @brief C++ unit testing for Field.
- */
-
-#if !defined(pylith_topology_testfield_hh)
-#define pylith_topology_testfield_hh
-
-// Include directives ---------------------------------------------------
-#include <cppunit/extensions/HelperMacros.h>
-
-// Forward declarations -------------------------------------------------
-/// Namespace for pylith package
-namespace pylith {
- namespace topology {
- class TestField;
-
- class Field;
- class Mesh;
- } // topology
-} // pylith
-
-// TestField -------------------------------------------------------------
-/// C++ unit testing for Field.
-class pylith::topology::TestField : public CppUnit::TestFixture
-{ // class TestField
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestField );
-
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testSection );
- CPPUNIT_TEST( testName );
- CPPUNIT_TEST( testVectorFieldType );
- CPPUNIT_TEST( testSpaceDim );
- CPPUNIT_TEST( testScale );
- CPPUNIT_TEST( testAddDimensionOkay );
- CPPUNIT_TEST( testCopyLayout );
- CPPUNIT_TEST( testClear );
- CPPUNIT_TEST( testZero );
- CPPUNIT_TEST( testComplete );
- CPPUNIT_TEST( testCopy );
- CPPUNIT_TEST( testOperatorAdd );
- CPPUNIT_TEST( testDimensionalize );
- CPPUNIT_TEST( testView );
-
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Test constructor.
- void testConstructor(void);
-
- /// Test newSection() and section().
- void testSection(void);
-
- /// Test name().
- void testName(void);
-
- /// Test vectorFieldType().
- void testVectorFieldType(void);
-
- /// Test spaceDim().
- void testSpaceDim(void);
-
- /// Test scale().
- void testScale(void);
-
- /// Test addDimensionOkay().
- void testAddDimensionOkay(void);
-
- /// Test copyLayout().
- void testCopyLayout(void);
-
- /// Test clear().
- void testClear(void);
-
- /// Test zero().
- void testZero(void);
-
- /// Test complete().
- void testComplete(void);
-
- /// Test copy().
- void testCopy(void);
-
- /// Test operator+=().
- void testOperatorAdd(void);
-
- /// Test dimensionalize().
- void testDimensionalize(void);
-
- /// Test view().
- void testView(void);
-
-// PRIVATE METHODS /////////////////////////////////////////////////////
-private :
-
- /** Build mesh.
- *
- * @param mesh Finite-element mesh.
- */
- void _buildMesh(Mesh* mesh);
-
-}; // class TestField
-
-#endif // pylith_topology_testfield_hh
-
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,942 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestFieldMesh.hh" // Implementation of class methods
+
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Mesh.hh" // USES Mesh
+
+#include "pylith/utils/array.hh" // USES double_array
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldMesh );
+
+// ----------------------------------------------------------------------
+namespace pylith {
+ namespace topology {
+ namespace _TestFieldMesh {
+ const int cellDim = 2;
+ const int nvertices = 4;
+ const int ncells = 1;
+ const int ncorners = 4;
+ const int cells[] = { 0, 1, 2, 3 };
+ const double coordinates[] = {
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 0.0, 1.0,
+ 1.0, 1.0,
+ };
+ } // _TestFieldMesh
+ } // topology
+} // pylith
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestFieldMesh::testConstructor(void)
+{ // testConstructor
+ Mesh mesh;
+ Field<Mesh> field(mesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test section().
+void
+pylith::topology::TestFieldMesh::testSection(void)
+{ // testSection
+ Mesh mesh;
+ Field<Mesh> field(mesh);
+
+ mesh.createSieveMesh();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(section.isNull());
+} // testSection
+
+// ----------------------------------------------------------------------
+// Test mesh().
+void
+pylith::topology::TestFieldMesh::testMesh(void)
+{ // testMesh
+ Mesh mesh;
+ _buildMesh(&mesh);
+ Field<Mesh> field(mesh);
+
+ const Mesh& mesh2 = field.mesh();
+ CPPUNIT_ASSERT_EQUAL(_TestFieldMesh::cellDim, mesh2.dimension());
+} // testMesh
+
+// ----------------------------------------------------------------------
+// Test label().
+void
+pylith::topology::TestFieldMesh::testLabel(void)
+{ // testLabel
+ const std::string label = "velocity";
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ Field<Mesh> field(mesh);
+
+ field.label(label.c_str());
+ CPPUNIT_ASSERT_EQUAL(label, std::string(field.label()));
+} // testLabel
+
+// ----------------------------------------------------------------------
+// Test vectorFieldType().
+void
+pylith::topology::TestFieldMesh::testVectorFieldType(void)
+{ // testVectorFieldType
+} // testVectorFieldType
+
+// ----------------------------------------------------------------------
+// Test scale().
+void
+pylith::topology::TestFieldMesh::testScale(void)
+{ // testScale
+} // testScale
+
+// ----------------------------------------------------------------------
+// Test addDimensionsOkay().
+void
+pylith::topology::TestFieldMesh::testAddDimensionsOkay(void)
+{ // testAddDimensionsOkay
+} // testAddDimensionsOkay
+
+// ----------------------------------------------------------------------
+// Test spaceDim().
+void
+pylith::topology::TestFieldMesh::testSpaceDim(void)
+{ // testSpaceDim
+ Mesh mesh;
+ _buildMesh(&mesh);
+ Field<Mesh> field(mesh);
+
+ CPPUNIT_ASSERT_EQUAL(_TestFieldMesh::cellDim, field.spaceDim());
+} // testSpaceDim
+
+// ----------------------------------------------------------------------
+// Test newSection().
+void
+pylith::topology::TestFieldMesh::testNewSection(void)
+{ // testNewSection
+ Mesh mesh;
+ _buildMesh(&mesh);
+
+ Field<Mesh> field(mesh);
+ field.newSection();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+} // testNewSection
+
+// ----------------------------------------------------------------------
+// Test newSection(points).
+void
+pylith::topology::TestFieldMesh::testNewSectionPoints(void)
+{ // testNewSectionPoints
+ const int fiberDim = 2;
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ Field<Mesh> field(mesh);
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testNewSectionPoints
+
+// ----------------------------------------------------------------------
+// Test newSection(domain).
+void
+pylith::topology::TestFieldMesh::testNewSectionDomain(void)
+{ // testNewSectionDomain
+ const int fiberDim = 2;
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testNewSectionDomain
+
+// ----------------------------------------------------------------------
+// Test newSection(chart).
+void
+pylith::topology::TestFieldMesh::testNewSectionChart(void)
+{ // testNewSectionChart
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ // Create field with atlas to use to create new field
+ Field<Mesh> fieldSrc(mesh);
+ fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ const ALE::Obj<Mesh::RealSection>& sectionSrc = fieldSrc.section();
+ CPPUNIT_ASSERT(!sectionSrc.isNull());
+ const Mesh::RealSection::chart_type& chart = sectionSrc->getChart();
+
+ Field<Mesh> field(mesh);
+ field.newSection(chart, fiberDim);
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testNewSectionChart
+
+// ----------------------------------------------------------------------
+// Test newSection(field).
+void
+pylith::topology::TestFieldMesh::testNewSectionField(void)
+{ // testNewSectionField
+ const int fiberDim = 3;
+ const int nconstraints[] = { 0, 2, 1, 3 };
+ const int constraints[] = {
+ // 0
+ 0, 2, // 1
+ 2, // 2
+ 0, 1, 2, // 3
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ // Create field with atlas to use to create new field
+ Field<Mesh> fieldSrc(mesh);
+ { // Setup source field
+ fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ const ALE::Obj<Mesh::RealSection>& section = fieldSrc.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int iV=0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ section->addConstraintDimension(*v_iter, nconstraints[iV++]);
+ fieldSrc.allocate();
+
+ int index = 0;
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter, index += nconstraints[i++])
+ section->setConstraintDof(*v_iter, &constraints[index]);
+ fieldSrc.zero();
+ fieldSrc.createScatter();
+ } // Setup source field
+
+ Field<Mesh> field(mesh);
+ field.newSection(fieldSrc);
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int iV = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+ CPPUNIT_ASSERT_EQUAL(nconstraints[iV++],
+ section->getConstraintDimension(*v_iter));
+ } // for
+
+ // Verify vector scatter was also copied.
+ CPPUNIT_ASSERT_EQUAL(fieldSrc._scatter, field._scatter);
+} // testNewSectionField
+
+// ----------------------------------------------------------------------
+// Test clear().
+void
+pylith::topology::TestFieldMesh::testClear(void)
+{ // testClear
+ Mesh mesh(_TestFieldMesh::cellDim);
+ Field<Mesh> field(mesh);
+
+ field.scale(2.0);
+ field.vectorFieldType(Field<Mesh>::TENSOR);
+ field.addDimensionOkay(true);
+
+ field.clear();
+
+ CPPUNIT_ASSERT_EQUAL(1.0, field._scale);
+ CPPUNIT_ASSERT_EQUAL(Field<Mesh>::OTHER, field._vecFieldType);
+ CPPUNIT_ASSERT_EQUAL(false, field._dimensionsOkay);
+} // testClear
+
+// ----------------------------------------------------------------------
+// Test allocate().
+void
+pylith::topology::TestFieldMesh::testAllocate(void)
+{ // testAllocate
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ const double tolerance = 1.0e-6;
+ i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
+ } // for
+ } // for
+} // testAllocate
+
+// ----------------------------------------------------------------------
+// Test zero().
+void
+pylith::topology::TestFieldMesh::testZero(void)
+{ // testZero
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.zero();
+
+ const double tolerance = 1.0e-6;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[iDim], tolerance);
+ } // for
+ } // for
+} // testZero
+
+// ----------------------------------------------------------------------
+// Test complete().
+void
+pylith::topology::TestFieldMesh::testComplete(void)
+{ // testComplete
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.complete();
+
+ // Expect no change for this serial test
+ i = 0;
+ const double tolerance = 1.0e-6;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
+ } // for
+ } // for
+} // testComplete
+
+// ----------------------------------------------------------------------
+// Test copy().
+void
+pylith::topology::TestFieldMesh::testCopy(void)
+{ // testCopy
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<Mesh> fieldSrc(mesh);
+ { // Setup source field
+ fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ fieldSrc.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = fieldSrc.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+ } // Setup source field
+
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ field.copy(fieldSrc);
+
+ int i = 0;
+ double_array values(fiberDim);
+ const double tolerance = 1.0e-6;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
+ } // for
+ } // for
+} // testCopy
+
+// ----------------------------------------------------------------------
+// Test operator+=().
+void
+pylith::topology::TestFieldMesh::testOperatorAdd(void)
+{ // testOperateAdd
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesA[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+ const double valuesB[] = {
+ 10.1, 20.2, 30.3,
+ 10.2, 20.3, 30.4,
+ 10.3, 20.4, 30.5,
+ 10.4, 20.5, 30.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<Mesh> fieldSrc(mesh);
+ { // Setup source field
+ fieldSrc.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ fieldSrc.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = fieldSrc.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesA[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+ } // Setup source field
+
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ { // Setup destination field
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesB[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+ } // Setup destination field
+
+ field += fieldSrc;
+
+ int i = 0;
+ double_array values(fiberDim);
+ const double tolerance = 1.0e-6;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ const double valueE = valuesA[i] + valuesB[i];
+ ++i;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[iDim], tolerance);
+ } // for
+ } // for
+} // testOperateAdd
+
+// ----------------------------------------------------------------------
+// Test dimensionalize().
+void
+pylith::topology::TestFieldMesh::testDimensionalize(void)
+{ // testDimensionalize
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.scale(scale);
+ field.addDimensionOkay(true);
+ field.dimensionalize();
+
+ i = 0;
+ const double tolerance = 1.0e-6;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ const double valueE = valuesNondim[i++]*scale;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[iDim], tolerance);
+ } // for
+ } // for
+
+} // testDimensionalize
+
+// ----------------------------------------------------------------------
+// Test view().
+void
+pylith::topology::TestFieldMesh::testView(void)
+{ // testView
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.view("Testing view");
+} // testView
+
+// ----------------------------------------------------------------------
+// Test createVector().
+void
+pylith::topology::TestFieldMesh::testCreateVector(void)
+{ // testCreateVector
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const int sizeE = vertices->size() * fiberDim;
+
+ field.createVector();
+
+ CPPUNIT_ASSERT(0 != field._vector);
+ int size = 0;
+ VecGetSize(field._vector, &size);
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+
+ // Make sure we can do multiple calls to createVector().
+ field.createVector();
+ CPPUNIT_ASSERT(0 != field._vector);
+} // testCreateVector
+
+// ----------------------------------------------------------------------
+// Test vector().
+void
+pylith::topology::TestFieldMesh::testVector(void)
+{ // testVector
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+
+ CPPUNIT_ASSERT(0 == field._vector);
+ field.createVector();
+ CPPUNIT_ASSERT(0 != field._vector);
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const PetscVec vec = field.vector();
+ CPPUNIT_ASSERT_EQUAL(field._vector, vec);
+ int size = 0;
+ VecGetSize(vec, &size);
+ const int sizeE = vertices->size() * fiberDim;
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+} // testVector
+
+// ----------------------------------------------------------------------
+// Test createScatter().
+void
+pylith::topology::TestFieldMesh::testCreateScatter(void)
+{ // testCreateScatter
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+
+ CPPUNIT_ASSERT(0 == field._scatter);
+ field.createScatter();
+ CPPUNIT_ASSERT(0 != field._scatter);
+
+ // Make sure we can do multiple calls to createScatter().
+ field.createScatter();
+ CPPUNIT_ASSERT(0 != field._scatter);
+
+ Field<Mesh> fieldB(mesh);
+ fieldB.newSection(field);
+ CPPUNIT_ASSERT_EQUAL(fieldB._scatter, field._scatter);
+} // testCreateScatter
+
+// ----------------------------------------------------------------------
+// Test scatterSectionToVector().
+void
+pylith::topology::TestFieldMesh::testScatterSectionToVector(void)
+{ // testScatterSectionToVector
+ const int fiberDim = 3;
+ const double valuesE[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesE[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.createScatter();
+ CPPUNIT_ASSERT(0 != field._scatter);
+ field.createVector();
+ field.scatterSectionToVector();
+ const PetscVec vec = field.vector();
+ CPPUNIT_ASSERT(0 != vec);
+ int size = 0;
+ VecGetSize(vec, &size);
+ double* valuesVec = 0;
+ VecGetArray(vec, &valuesVec);
+
+ const double tolerance = 1.0e-06;
+ const int sizeE = vertices->size() * fiberDim;
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+ for (int i=0; i < sizeE; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesE[i], valuesVec[i], tolerance);
+ VecRestoreArray(vec, &valuesVec);
+} // testScatterSectionToVector
+
+// ----------------------------------------------------------------------
+// Test scatterVectorToSection().
+void
+pylith::topology::TestFieldMesh::testScatterVectorToSection(void)
+{ // testScatterVectorToSection
+ const int fiberDim = 3;
+ const double valuesE[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ 1.4, 2.5, 3.6,
+ };
+
+ Mesh mesh;
+ _buildMesh(&mesh);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ Field<Mesh> field(mesh);
+ field.newSection(Field<Mesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<Mesh::RealSection>& section = field.section();
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+
+ field.createScatter();
+ CPPUNIT_ASSERT(0 != field._scatter);
+ field.createVector();
+ const PetscVec vec = field.vector();
+ CPPUNIT_ASSERT(0 != vec);
+ int size = 0;
+ VecGetSize(vec, &size);
+ double* valuesVec = 0;
+ VecGetArray(vec, &valuesVec);
+
+ const double tolerance = 1.0e-06;
+ const int sizeE = vertices->size() * fiberDim;
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+ for (int i=0; i < sizeE; ++i)
+ valuesVec[i] = valuesE[i];
+ VecRestoreArray(vec, &valuesVec);
+
+ field.createScatter();
+ field.scatterVectorToSection();
+ CPPUNIT_ASSERT(0 != field._scatter);
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], fiberDim);
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesE[i++], values[iDim], tolerance);
+ } // for
+
+} // testScatterVectorToSection
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestFieldMesh::_buildMesh(Mesh* mesh)
+{ // _buildMesh
+ assert(0 != mesh);
+
+ mesh->createSieveMesh(_TestFieldMesh::cellDim);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh->sieveMesh();
+
+ ALE::Obj<Mesh::SieveMesh::sieve_type> sieve =
+ new Mesh::SieveMesh::sieve_type(sieveMesh->comm());
+ CPPUNIT_ASSERT(!sieve.isNull());
+
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
+ const int cellDim = _TestFieldMesh::cellDim;
+ const int ncells = _TestFieldMesh::ncells;
+ const int* cells = _TestFieldMesh::cells;
+ const int nvertices = _TestFieldMesh::nvertices;
+ const int ncorners = _TestFieldMesh::ncorners;
+ const int spaceDim = _TestFieldMesh::cellDim;
+ const double* coordinates = _TestFieldMesh::coordinates;
+ const bool interpolate = false;
+ ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, ncells, (int*) cells,
+ nvertices, interpolate,
+ ncorners);
+ std::map<Mesh::SieveMesh::point_type,Mesh::SieveMesh::point_type> renumbering;
+ ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
+ sieveMesh->setSieve(sieve);
+ sieveMesh->stratify();
+ ALE::SieveBuilder<Mesh::SieveMesh>::buildCoordinates(sieveMesh, spaceDim,
+ coordinates);
+
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh->coordsys(&cs);
+} // _buildMesh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldMesh.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,167 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestFieldMesh.hh
+ *
+ * @brief C++ unit testing for Field.
+ */
+
+#if !defined(pylith_topology_testfieldmesh_hh)
+#define pylith_topology_testfieldmesh_hh
+
+// Include directives ---------------------------------------------------
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+
+// Forward declarations -------------------------------------------------
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestFieldMesh;
+ } // topology
+} // pylith
+
+// TestFieldMesh -------------------------------------------------------------
+/// C++ unit testing for Field.
+class pylith::topology::TestFieldMesh : public CppUnit::TestFixture
+{ // class TestFieldMesh
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestFieldMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testMesh );
+ CPPUNIT_TEST( testLabel );
+ CPPUNIT_TEST( testVectorFieldType );
+ CPPUNIT_TEST( testScale );
+ CPPUNIT_TEST( testAddDimensionsOkay );
+ CPPUNIT_TEST( testSpaceDim );
+ CPPUNIT_TEST( testNewSection );
+ CPPUNIT_TEST( testNewSectionPoints );
+ CPPUNIT_TEST( testNewSectionDomain );
+ CPPUNIT_TEST( testNewSectionChart );
+ CPPUNIT_TEST( testNewSectionField );
+ CPPUNIT_TEST( testClear );
+ CPPUNIT_TEST( testAllocate );
+ CPPUNIT_TEST( testZero );
+ CPPUNIT_TEST( testComplete );
+ CPPUNIT_TEST( testCopy );
+ CPPUNIT_TEST( testOperatorAdd );
+ CPPUNIT_TEST( testDimensionalize );
+ CPPUNIT_TEST( testView );
+ CPPUNIT_TEST( testCreateVector );
+ CPPUNIT_TEST( testVector );
+ CPPUNIT_TEST( testCreateScatter );
+ CPPUNIT_TEST( testScatterSectionToVector );
+ CPPUNIT_TEST( testScatterVectorToSection );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test section().
+ void testSection(void);
+
+ /// Test mesh().
+ void testMesh(void);
+
+ /// Test label().
+ void testLabel(void);
+
+ /// Test vectorFieldType().
+ void testVectorFieldType(void);
+
+ /// Test scale().
+ void testScale(void);
+
+ /// Test addDimensionsOkay().
+ void testAddDimensionsOkay(void);
+
+ /// Test spaceDim().
+ void testSpaceDim(void);
+
+ /// Test newSection().
+ void testNewSection(void);
+
+ /// Test newSection(points).
+ void testNewSectionPoints(void);
+
+ /// Test newSection(domain).
+ void testNewSectionDomain(void);
+
+ /// Test newSection(chart).
+ void testNewSectionChart(void);
+
+ /// Test newSection(field).
+ void testNewSectionField(void);
+
+ /// Test clear().
+ void testClear(void);
+
+ /// Test allocate().
+ void testAllocate(void);
+
+ /// Test zero().
+ void testZero(void);
+
+ /// Test complete().
+ void testComplete(void);
+
+ /// Test copy().
+ void testCopy(void);
+
+ /// Test operator+=().
+ void testOperatorAdd(void);
+
+ /// Test dimensionalize().
+ void testDimensionalize(void);
+
+ /// Test view().
+ void testView(void);
+
+ /// Test createVector().
+ void testCreateVector(void);
+
+ /// Test vector().
+ void testVector(void);
+
+ /// Test createScatter().
+ void testCreateScatter(void);
+
+ /// Test scatterSectionToVector().
+ void testScatterSectionToVector(void);
+
+ /// Test scatterVectorToSection().
+ void testScatterVectorToSection(void);
+
+// PRIVATE METHODS /////////////////////////////////////////////////////
+private :
+
+ /** Build mesh.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ static
+ void _buildMesh(Mesh* mesh);
+
+}; // class TestFieldMesh
+
+#endif // pylith_topology_testfieldmesh_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,949 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestFieldSubMesh.hh" // Implementation of class methods
+
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+
+#include "pylith/utils/array.hh" // USES double_array
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldSubMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
+namespace pylith {
+ namespace topology {
+ namespace _TestFieldSubMesh {
+ const int cellDim = 2;
+ const int nvertices = 4;
+ const int ncells = 2;
+ const int ncorners = 3;
+ const int cells[] = {
+ 0, 1, 3,
+ 0, 3, 2,
+ };
+ const double coordinates[] = {
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 0.0, 1.0,
+ 1.0, 1.0,
+ };
+ const char* label = "bc";
+ const int groupSize = 3;
+ const int groupVertices[] = {
+ 1, 2, 3
+ };
+ const int submeshVertices[] = {
+ 3, 4, 5
+ };
+ } // _TestFieldSubMesh
+ } // topology
+} // pylith
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestFieldSubMesh::testConstructor(void)
+{ // testConstructor
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test newSection().
+void
+pylith::topology::TestFieldSubMesh::testSection(void)
+{ // testSection
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(section.isNull());
+} // testSection
+
+// ----------------------------------------------------------------------
+// Test mesh().
+void
+pylith::topology::TestFieldSubMesh::testMesh(void)
+{ // testMesh
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+
+ const SubMesh& mesh2 = field.mesh();
+ CPPUNIT_ASSERT_EQUAL(_TestFieldSubMesh::cellDim-1, mesh2.dimension());
+} // testMesh
+
+// ----------------------------------------------------------------------
+// Test spaceDim().
+void
+pylith::topology::TestFieldSubMesh::testSpaceDim(void)
+{ // testSpaceDim
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+
+ CPPUNIT_ASSERT_EQUAL(_TestFieldSubMesh::cellDim, field.spaceDim());
+} // testSpaceDim
+
+// ----------------------------------------------------------------------
+// Test newSection().
+void
+pylith::topology::TestFieldSubMesh::testNewSection(void)
+{ // testNewSection
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+
+ field.newSection();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+} // testNewSection
+
+// ----------------------------------------------------------------------
+// Test newSection(points).
+void
+pylith::topology::TestFieldSubMesh::testNewSectionPoints(void)
+{ // testNewSectionPoints
+ const int fiberDim = 2;
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ Field<SubMesh> field(submesh);
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ field.newSection(vertices, fiberDim);
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testNewSectionPoints
+
+// ----------------------------------------------------------------------
+// Test newSection(domain).
+void
+pylith::topology::TestFieldSubMesh::testNewSectionDomain(void)
+{ // testNewSectionDomain
+ const int fiberDim = 2;
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testNewSectionDomain
+
+// ----------------------------------------------------------------------
+// Test newSection(chart).
+void
+pylith::topology::TestFieldSubMesh::testNewSectionChart(void)
+{ // testNewSectionChart
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ // Create field with atlas to use to create new field
+ Field<SubMesh> fieldSrc(submesh);
+ fieldSrc.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ const ALE::Obj<SubMesh::RealSection>& sectionSrc = fieldSrc.section();
+ CPPUNIT_ASSERT(!sectionSrc.isNull());
+ const SubMesh::RealSection::chart_type& chart = sectionSrc->getChart();
+
+ Field<SubMesh> field(submesh);
+ field.newSection(chart, fiberDim);
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testNewSectionChart
+
+// ----------------------------------------------------------------------
+// Test newSection(field).
+void
+pylith::topology::TestFieldSubMesh::testNewSectionField(void)
+{ // testNewSectionField
+ const int fiberDim = 3;
+ const int nconstraints[] = { 0, 2, 1, 3 };
+ const int constraints[] = {
+ // 0
+ 0, 2, // 1
+ 2, // 2
+ 0, 1, 2, // 3
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ // Create field with atlas to use to create new field
+ Field<SubMesh> fieldSrc(submesh);
+ { // Setup source field
+ fieldSrc.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ const ALE::Obj<SubMesh::RealSection>& section = fieldSrc.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int iV=0;
+
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ section->addConstraintDimension(*v_iter, nconstraints[iV++]);
+ fieldSrc.allocate();
+
+ int index = 0;
+ int i = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter, index += nconstraints[i++])
+ section->setConstraintDof(*v_iter, &constraints[index]);
+ fieldSrc.zero();
+ } // Setup source field
+
+
+ Field<SubMesh> field(submesh);
+ field.newSection(fieldSrc);
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ int iV = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+ CPPUNIT_ASSERT_EQUAL(nconstraints[iV++],
+ section->getConstraintDimension(*v_iter));
+ } // for
+} // testNewSectionField
+
+// ----------------------------------------------------------------------
+// Test clear().
+void
+pylith::topology::TestFieldSubMesh::testClear(void)
+{ // testClear
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+
+ field.scale(2.0);
+ field.vectorFieldType(Field<SubMesh>::TENSOR);
+ field.addDimensionOkay(true);
+
+ field.clear();
+
+ CPPUNIT_ASSERT_EQUAL(1.0, field._scale);
+ CPPUNIT_ASSERT_EQUAL(Field<SubMesh>::OTHER, field._vecFieldType);
+ CPPUNIT_ASSERT_EQUAL(false, field._dimensionsOkay);
+} // testClear
+
+// ----------------------------------------------------------------------
+// Test allocate().
+void
+pylith::topology::TestFieldSubMesh::testAllocate(void)
+{ // testAllocate
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ const double tolerance = 1.0e-6;
+ i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
+ } // for
+ } // for
+} // testAllocate
+
+// ----------------------------------------------------------------------
+// Test zero().
+void
+pylith::topology::TestFieldSubMesh::testZero(void)
+{ // testZero
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.zero();
+
+ const double tolerance = 1.0e-6;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, values[iDim], tolerance);
+ } // for
+ } // for
+} // testZero
+
+// ----------------------------------------------------------------------
+// Test complete().
+void
+pylith::topology::TestFieldSubMesh::testComplete(void)
+{ // testComplete
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.complete();
+
+ // Expect no change for this serial test
+ i = 0;
+ const double tolerance = 1.0e-6;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
+ } // for
+ } // for
+} // testComplete
+
+// ----------------------------------------------------------------------
+// Test copy().
+void
+pylith::topology::TestFieldSubMesh::testCopy(void)
+{ // testCopy
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<SubMesh> fieldSrc(submesh);
+ { // Setup source field
+ fieldSrc.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ fieldSrc.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = fieldSrc.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+ } // Setup source field
+
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ field.copy(fieldSrc);
+
+ int i = 0;
+ double_array values(fiberDim);
+ const double tolerance = 1.0e-6;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesNondim[i++], values[iDim], tolerance);
+ } // for
+ } // for
+} // testCopy
+
+// ----------------------------------------------------------------------
+// Test operator+=().
+void
+pylith::topology::TestFieldSubMesh::testOperatorAdd(void)
+{ // testOperateAdd
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesA[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+ const double valuesB[] = {
+ 10.1, 20.2, 30.3,
+ 10.2, 20.3, 30.4,
+ 10.3, 20.4, 30.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ Field<SubMesh> fieldSrc(submesh);
+ { // Setup source field
+ fieldSrc.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ fieldSrc.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = fieldSrc.section();
+ CPPUNIT_ASSERT(!section.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesA[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+ } // Setup source field
+
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ { // Setup destination field
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesB[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+ } // Setup destination field
+
+ field += fieldSrc;
+
+ int i = 0;
+ double_array values(fiberDim);
+ const double tolerance = 1.0e-6;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ const double valueE = valuesA[i] + valuesB[i];
+ ++i;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[iDim], tolerance);
+ } // for
+ } // for
+} // testOperateAdd
+
+// ----------------------------------------------------------------------
+// Test dimensionalize().
+void
+pylith::topology::TestFieldSubMesh::testDimensionalize(void)
+{ // testDimensionalize
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.scale(scale);
+ field.addDimensionOkay(true);
+ field.dimensionalize();
+
+ i = 0;
+ const double tolerance = 1.0e-6;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], values.size());
+ for (int iDim=0; iDim < fiberDim; ++iDim) {
+ const double valueE = valuesNondim[i++]*scale;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valueE, values[iDim], tolerance);
+ } // for
+ } // for
+
+} // testDimensionalize
+
+// ----------------------------------------------------------------------
+// Test view().
+void
+pylith::topology::TestFieldSubMesh::testView(void)
+{ // testView
+ const int fiberDim = 3;
+ const double scale = 2.0;
+ const double valuesNondim[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ const ALE::Obj<SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ Field<SubMesh> field(submesh);
+ field.newSection(Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesNondim[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.view("Testing view");
+} // testView
+
+// ----------------------------------------------------------------------
+// Test createVector().
+void
+pylith::topology::TestFieldSubMesh::testCreateVector(void)
+{ // testCreateVector
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+ field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+
+ const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SubMesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const int sizeE = vertices->size() * fiberDim;
+
+ field.createVector();
+
+ CPPUNIT_ASSERT(0 != field._vector);
+ int size = 0;
+ VecGetSize(field._vector, &size);
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+
+ // Make sure we can do multiple calls to createVector().
+ field.createVector();
+ CPPUNIT_ASSERT(0 != field._vector);
+} // testCreateVector
+
+// ----------------------------------------------------------------------
+// Test vector().
+void
+pylith::topology::TestFieldSubMesh::testVector(void)
+{ // testVector
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+
+ Field<SubMesh> field(submesh);
+ field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+
+ CPPUNIT_ASSERT(0 == field._vector);
+ field.createVector();
+ CPPUNIT_ASSERT(0 != field._vector);
+
+ const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SubMesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const PetscVec vec = field.vector();
+ CPPUNIT_ASSERT_EQUAL(field._vector, vec);
+ int size = 0;
+ VecGetSize(vec, &size);
+ const int sizeE = vertices->size() * fiberDim;
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+} // testVector
+
+// ----------------------------------------------------------------------
+// Test createScatter().
+void
+pylith::topology::TestFieldSubMesh::testCreateScatter(void)
+{ // testCreateScatter
+ const int fiberDim = 3;
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+ field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+
+ CPPUNIT_ASSERT(0 == field._scatter);
+ field.createScatter();
+ CPPUNIT_ASSERT(0 != field._scatter);
+
+ // Make sure we can do multiple calls to createScatter().
+ field.createScatter();
+ CPPUNIT_ASSERT(0 != field._scatter);
+} // testCreateScatter
+
+// ----------------------------------------------------------------------
+// Test scatterSectionToVector().
+void
+pylith::topology::TestFieldSubMesh::testScatterSectionToVector(void)
+{ // testScatterSectionToVector
+ const int fiberDim = 3;
+ const double valuesE[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+ const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
+ field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ const ALE::Obj<SubMesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+
+ double_array values(fiberDim);
+ int i = 0;
+ for (SubMesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ values[iDim] = valuesE[i++];
+ section->updatePoint(*v_iter, &values[0]);
+ } // for
+
+ field.createVector();
+ field.createScatter();
+ field.scatterSectionToVector();
+ CPPUNIT_ASSERT(0 != field._scatter);
+ const PetscVec vec = field.vector();
+ CPPUNIT_ASSERT(0 != vec);
+ int size = 0;
+ VecGetSize(vec, &size);
+ const int sizeE = vertices->size() * fiberDim;
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+
+ double* valuesVec = 0;
+ VecGetArray(vec, &valuesVec);
+
+ const double tolerance = 1.0e-06;
+ for (int i=0; i < sizeE; ++i)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesE[i], valuesVec[i], tolerance);
+ VecRestoreArray(vec, &valuesVec);
+} // testScatterSectionToVector
+
+// ----------------------------------------------------------------------
+// Test scatterVectorToSection().
+void
+pylith::topology::TestFieldSubMesh::testScatterVectorToSection(void)
+{ // testScatterVectorToSection
+ const int fiberDim = 3;
+ const double valuesE[] = {
+ 1.1, 2.2, 3.3,
+ 1.2, 2.3, 3.4,
+ 1.3, 2.4, 3.5,
+ };
+
+ Mesh mesh;
+ SubMesh submesh;
+ _buildMesh(&mesh, &submesh);
+ Field<SubMesh> field(submesh);
+ field.newSection(FieldBase::VERTICES_FIELD, fiberDim);
+ field.allocate();
+ field.createVector();
+
+ const ALE::Obj<SubMesh::SieveMesh>& sieveMesh = submesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SubMesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+
+ const PetscVec vec = field.vector();
+ CPPUNIT_ASSERT(0 != vec);
+ int size = 0;
+ VecGetSize(vec, &size);
+ const int sizeE = vertices->size() * fiberDim;
+ CPPUNIT_ASSERT_EQUAL(sizeE, size);
+
+ const double tolerance = 1.0e-06;
+ double* valuesVec = 0;
+ VecGetArray(vec, &valuesVec);
+ for (int i=0; i < sizeE; ++i)
+ valuesVec[i] = valuesE[i];
+ VecRestoreArray(vec, &valuesVec);
+
+ field.createScatter();
+ field.scatterVectorToSection();
+ CPPUNIT_ASSERT(0 != field._scatter);
+
+ double_array values(fiberDim);
+ int i = 0;
+ const ALE::Obj<SubMesh::RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ for (SubMesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter) {
+ section->restrictPoint(*v_iter, &values[0], fiberDim);
+ for (int iDim=0; iDim < fiberDim; ++iDim)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesE[i++], values[iDim], tolerance);
+ } // for
+} // testScatterVectorToSection
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestFieldSubMesh::_buildMesh(Mesh* mesh,
+ SubMesh* submesh)
+{ // _buildMesh
+ assert(0 != mesh);
+ assert(0 != submesh);
+
+ mesh->createSieveMesh(_TestFieldSubMesh::cellDim);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+
+ ALE::Obj<Mesh::SieveMesh::sieve_type> sieve =
+ new Mesh::SieveMesh::sieve_type(sieveMesh->comm());
+ CPPUNIT_ASSERT(!sieve.isNull());
+
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+ CPPUNIT_ASSERT(!s.isNull());
+
+ const int cellDim = _TestFieldSubMesh::cellDim;
+ const int ncells = _TestFieldSubMesh::ncells;
+ const int* cells = _TestFieldSubMesh::cells;
+ const int nvertices = _TestFieldSubMesh::nvertices;
+ const int ncorners = _TestFieldSubMesh::ncorners;
+ const int spaceDim = _TestFieldSubMesh::cellDim;
+ const double* coordinates = _TestFieldSubMesh::coordinates;
+ const bool interpolate = false;
+ ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, ncells, (int*) cells,
+ nvertices, interpolate,
+ ncorners);
+ std::map<Mesh::SieveMesh::point_type,Mesh::SieveMesh::point_type> renumbering;
+ ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
+ sieveMesh->setSieve(sieve);
+ sieveMesh->stratify();
+ ALE::SieveBuilder<SieveMesh>::buildCoordinates(sieveMesh, spaceDim,
+ coordinates);
+
+ typedef Mesh::SieveMesh::int_section_type::chart_type chart_type;
+ const ALE::Obj<SieveMesh::int_section_type>& groupField =
+ sieveMesh->getIntSection(_TestFieldSubMesh::label);
+ assert(!groupField.isNull());
+
+ const int numPoints = _TestFieldSubMesh::groupSize;
+ const int numVertices = sieveMesh->depthStratum(0)->size();
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ groupField->setChart(chart_type(numCells, numCells+numVertices));
+ for(int i=0; i < numPoints; ++i)
+ groupField->setFiberDimension(numCells+_TestFieldSubMesh::groupVertices[i],
+ 1);
+ sieveMesh->allocate(groupField);
+
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh->coordsys(&cs);
+
+ submesh->createSubMesh(*mesh, _TestFieldSubMesh::label);
+} // _buildMesh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldSubMesh.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldSubMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,154 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestfieldsubmeshSubMesh.hh
+ *
+ * @brief C++ unit testing for Field.
+ */
+
+#if !defined(pylith_topology_testfieldsubmesh_hh)
+#define pylith_topology_testfieldsubmesh_hh
+
+// Include directives ---------------------------------------------------
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+
+// Forward declarations -------------------------------------------------
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestFieldSubMesh;
+ } // topology
+} // pylith
+
+// TestFieldSubMesh -----------------------------------------------------
+/// C++ unit testing for Field.
+class pylith::topology::TestFieldSubMesh : public CppUnit::TestFixture
+{ // class TestFieldSubMesh
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestFieldSubMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testSection );
+ CPPUNIT_TEST( testMesh );
+ CPPUNIT_TEST( testSpaceDim );
+ CPPUNIT_TEST( testNewSection );
+ CPPUNIT_TEST( testNewSectionPoints );
+ CPPUNIT_TEST( testNewSectionDomain );
+ CPPUNIT_TEST( testNewSectionChart );
+ CPPUNIT_TEST( testNewSectionField );
+ CPPUNIT_TEST( testClear );
+ CPPUNIT_TEST( testAllocate );
+ CPPUNIT_TEST( testZero );
+ CPPUNIT_TEST( testComplete );
+ CPPUNIT_TEST( testCopy );
+ CPPUNIT_TEST( testOperatorAdd );
+ CPPUNIT_TEST( testDimensionalize );
+ CPPUNIT_TEST( testView );
+ CPPUNIT_TEST( testCreateVector );
+ CPPUNIT_TEST( testVector );
+ CPPUNIT_TEST( testCreateScatter );
+ CPPUNIT_TEST( testScatterSectionToVector );
+ CPPUNIT_TEST( testScatterVectorToSection );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test section().
+ void testSection(void);
+
+ /// Test mesh().
+ void testMesh(void);
+
+ /// Test spaceDim().
+ void testSpaceDim(void);
+
+ /// Test newSection().
+ void testNewSection(void);
+
+ /// Test newSection(points).
+ void testNewSectionPoints(void);
+
+ /// Test newSection(domain).
+ void testNewSectionDomain(void);
+
+ /// Test newSection(chart).
+ void testNewSectionChart(void);
+
+ /// Test newSection(field).
+ void testNewSectionField(void);
+
+ /// Test clear().
+ void testClear(void);
+
+ /// Test allocate().
+ void testAllocate(void);
+
+ /// Test zero().
+ void testZero(void);
+
+ /// Test complete().
+ void testComplete(void);
+
+ /// Test copy().
+ void testCopy(void);
+
+ /// Test operator+=().
+ void testOperatorAdd(void);
+
+ /// Test dimensionalize().
+ void testDimensionalize(void);
+
+ /// Test view().
+ void testView(void);
+
+ /// Test createVector().
+ void testCreateVector(void);
+
+ /// Test vector().
+ void testVector(void);
+
+ /// Test createScatter().
+ void testCreateScatter(void);
+
+ /// Test scatterSectionToVector().
+ void testScatterSectionToVector(void);
+
+ /// Test scatterVectorToSection().
+ void testScatterVectorToSection(void);
+
+// PRIVATE METHODS /////////////////////////////////////////////////////
+private :
+
+ /** Build mesh.
+ *
+ * @param mesh Finite-element mesh.
+ * @param submesh Boundary mesh.
+ */
+ static
+ void _buildMesh(Mesh* mesh,
+ SubMesh* submesh);
+
+}; // class TestFieldSubMesh
+
+#endif // pylith_topology_testfieldsubmesh_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldUniform.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldUniform.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldUniform.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -49,6 +49,7 @@
pylith::topology::TestFieldUniform::testConstructor(void)
{ // testConstructor
Mesh mesh;
+ mesh.createSieveMesh();
const int fiberDim = 4;
FieldUniform field(mesh.sieveMesh(), fiberDim);
@@ -63,7 +64,7 @@
{ // testCreateSectionPoints
const int fiberDim = 3;
- Mesh mesh(PETSC_COMM_WORLD, _TestFieldUniform::cellDim);
+ Mesh mesh;
_buildMesh(&mesh);
const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
const ALE::Obj<SieveMesh::label_sequence>& vertices =
@@ -86,7 +87,7 @@
{ // testCreateSectionChart
const int fiberDim = 2;
- Mesh mesh(PETSC_COMM_WORLD, _TestFieldUniform::cellDim);
+ Mesh mesh;
_buildMesh(&mesh);
const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
const ALE::Obj<SieveMesh::label_sequence>& vertices =
@@ -120,6 +121,7 @@
{ // _buildMesh
assert(0 != mesh);
+ mesh->createSieveMesh(_TestFieldUniform::cellDim);
const ALE::Obj<SieveMesh>& sieveMesh = mesh->sieveMesh();
ALE::Obj<SieveMesh::sieve_type> sieve =
Deleted: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,413 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-#include <portinfo>
-
-#include "TestFieldsManager.hh" // Implementation of class methods
-
-#include "pylith/topology/FieldsManager.hh" // USES FieldsManager
-
-#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-// ----------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldsManager );
-
-// ----------------------------------------------------------------------
-// Test constructor.
-void
-pylith::topology::TestFieldsManager::testConstructor(void)
-{ // testConstructor
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-} // testConstructor
-
-// ----------------------------------------------------------------------
-// Test addReal().
-void
-pylith::topology::TestFieldsManager::testAddReal(void)
-{ // testAddReal
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* label = "field";
- manager.addReal(label);
- const size_t size = 1;
- CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
-} // testAddReal
-
-// ----------------------------------------------------------------------
-// Test getReal().
-void
-pylith::topology::TestFieldsManager::testGetReal(void)
-{ // testGetReal
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* label = "field";
- manager.addReal(label);
- const ALE::Obj<real_section_type>& field = manager.getReal(label);
- CPPUNIT_ASSERT(!field.isNull());
-} // testGetReal
-
-// ----------------------------------------------------------------------
-// Test delReal().
-void
-pylith::topology::TestFieldsManager::testDelReal(void)
-{ // testDelReal
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* labelA = "field A";
- manager.addReal(labelA);
-
- const char* labelB = "field B";
- manager.addReal(labelB);
-
- size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
- manager.delReal(labelA);
- size = 1;
- CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
- const ALE::Obj<real_section_type>& field = manager.getReal(labelB);
- CPPUNIT_ASSERT(!field.isNull());
-} // testDelReal
-
-// ----------------------------------------------------------------------
-// Test setFiberDimension().
-void
-pylith::topology::TestFieldsManager::testSetFiberDimension(void)
-{ // testSetFiberDimension
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const int fiberDim = 3;
-
- const char* labelA = "field A";
- manager.addReal(labelA);
- manager.setFiberDimension(labelA, fiberDim, "vertices");
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labelA);
- CPPUNIT_ASSERT(!fieldA.isNull());
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- fieldA->allocateStorage();
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter)
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldA->getFiberDimension(*v_iter));
-
- const char* labelB = "field B";
- manager.addReal(labelB);
- manager.setFiberDimension(labelB, fiberDim, "cells");
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
- CPPUNIT_ASSERT(!fieldB.isNull());
- const ALE::Obj<Mesh::label_sequence>& cells = mesh->heightStratum(0);
- fieldB->allocateStorage();
- for (Mesh::label_sequence::iterator c_iter = cells->begin();
- c_iter != cells->end();
- ++c_iter)
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*c_iter));
-} // testSetFiberDimension
-
-// ----------------------------------------------------------------------
-// Test allocate().
-void
-pylith::topology::TestFieldsManager::testAllocate(void)
-{ // testAllocate
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const int fiberDim = 3;
-
- const char* labelA = "field A";
- manager.addReal(labelA);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labelA);
- manager.setFiberDimension(labelA, fiberDim, "vertices");
- manager.allocate(labelA);
-
- const char* labelB = "field B";
- manager.addReal(labelB);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
- manager.setFiberDimension(labelB, fiberDim, "cells");
- manager.allocate(labelB);
-} // testAllocate
-
-// ----------------------------------------------------------------------
-// Test copyLayout().
-void
-pylith::topology::TestFieldsManager::testCopyLayout(void)
-{ // testCopyLayout
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
-
- const char* labelA = "field A";
- manager.addReal(labelA);
- const int fiberDim = 3;
- const int fixedDim = 1;
- const Mesh::point_type fixedPt = offset + 2;
-
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labelA);
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDim);
- fieldA->setConstraintDimension(fixedPt, 1);
- fieldA->allocateStorage();
- fieldA->setConstraintDof(fixedPt, &fixedDim);
-
- const char* labelB = "field B";
- manager.addReal(labelB);
-
- manager.copyLayout(labelA);
-
- size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
-
- CPPUNIT_ASSERT_EQUAL(fieldA->size(), fieldB->size());
- CPPUNIT_ASSERT_EQUAL(fieldA->sizeWithBC(), fieldB->sizeWithBC());
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- if (*v_iter != fixedPt) {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, fieldB->getConstraintDimension(*v_iter));
- } else {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(1, fieldB->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fixedDim, fieldB->getConstraintDof(*v_iter)[0]);
- } // if/else
- } // for
-} // testCopyLayout
-
-// ----------------------------------------------------------------------
-// Test copyLayoutFromField().
-void
-pylith::topology::TestFieldsManager::testCopyLayoutFromField(void)
-{ // testCopyLayoutFromField
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
- const int numCells = mesh->heightStratum(0)->size();
- const int offset = numCells;
-
- const char* labelA = "field A";
- const ALE::Obj<real_section_type>& fieldA =
- new real_section_type(mesh->comm(), mesh->debug());
- const int fiberDim = 3;
- const int fixedDim = 1;
- const Mesh::point_type fixedPt = offset + 2;
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDim);
- fieldA->setConstraintDimension(fixedPt, 1);
- fieldA->allocateStorage();
- fieldA->setConstraintDof(fixedPt, &fixedDim);
-
- const char* labelB = "field B";
- manager.addReal(labelB);
- const char* labelC = "field C";
- manager.addReal(labelC);
-
- manager.copyLayout(fieldA);
-
- size_t size = 2;
- CPPUNIT_ASSERT_EQUAL(size, manager._real.size());
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labelB);
- const ALE::Obj<real_section_type>& fieldC = manager.getReal(labelC);
-
- CPPUNIT_ASSERT_EQUAL(fieldA->size(), fieldB->size());
- CPPUNIT_ASSERT_EQUAL(fieldA->sizeWithBC(), fieldB->sizeWithBC());
- for (Mesh::label_sequence::iterator v_iter = vertices->begin();
- v_iter != vertices->end();
- ++v_iter) {
- if (*v_iter != fixedPt) {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, fieldB->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldC->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(0, fieldC->getConstraintDimension(*v_iter));
- } else {
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldB->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(1, fieldB->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fixedDim, fieldB->getConstraintDof(*v_iter)[0]);
- CPPUNIT_ASSERT_EQUAL(fiberDim, fieldC->getFiberDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(1, fieldC->getConstraintDimension(*v_iter));
- CPPUNIT_ASSERT_EQUAL(fixedDim, fieldC->getConstraintDof(*v_iter)[0]);
- } // if/else
- } // for
-} // testCopyLayoutFromField
-
-// ----------------------------------------------------------------------
-// Test solutionField().
-void
-pylith::topology::TestFieldsManager::testSolutionField(void)
-{ // testSolutionField
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const std::string& name = "my solution";
- manager.addReal(name.c_str());
- manager.solutionField(name.c_str());
- CPPUNIT_ASSERT_EQUAL(name, manager._solutionName);
-} // testSolutionField
-
-// ----------------------------------------------------------------------
-// Test getSolution().
-void
-pylith::topology::TestFieldsManager::testGetSolution(void)
-{ // testGetSolution
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* labels[] = { "field A", "field B", "field C" };
- const int size = 3;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
- const int fiberDimC = 4;
-
- for (int i=0; i < size; ++i)
- manager.addReal(labels[i]);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labels[0]);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labels[1]);
- const ALE::Obj<real_section_type>& fieldC = manager.getReal(labels[2]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
- fieldC->setChart(mesh->getSieve()->getChart());
- fieldC->setFiberDimension(vertices, fiberDimC);
-
- manager.solutionField(labels[1]);
- const ALE::Obj<real_section_type>& solution = manager.getSolution();
- CPPUNIT_ASSERT_EQUAL(fiberDimB,
- solution->getFiberDimension(*(vertices->begin())));
-} // testGetSolution
-
-// ----------------------------------------------------------------------
-// Test createHistory().
-void
-pylith::topology::TestFieldsManager::testCreateHistory(void)
-{ // testCreateHistory
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* labels[] = { "field A", "field B", "field C" };
- const int totalSize = 3;
- const int historySize = 2;
-
- // Add fields
- for (int i=0; i < totalSize; ++i)
- manager.addReal(labels[i]);
-
- manager.createHistory(labels, historySize);
- for (int i=0; i < historySize; ++i)
- CPPUNIT_ASSERT_EQUAL(std::string(labels[i]), manager._history[i]);
-} // testCreateHistory
-
-// ----------------------------------------------------------------------
-// Test shiftHistory().
-void
-pylith::topology::TestFieldsManager::testShiftHistory(void)
-{ // testShiftHistory
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* fieldNames[] = { "field A", "field B" };
- const int numFields = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
-
- for (int i=0; i < numFields; ++i)
- manager.addReal(fieldNames[i]);
- manager.createHistory(fieldNames, numFields);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(fieldNames[0]);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(fieldNames[1]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
-
- manager.shiftHistory();
- const ALE::Obj<real_section_type>& testA = manager.getReal(fieldNames[0]);
- const ALE::Obj<real_section_type>& testB = manager.getReal(fieldNames[1]);
- CPPUNIT_ASSERT_EQUAL(fiberDimB,
- testA->getFiberDimension(*(vertices->begin())));
- CPPUNIT_ASSERT_EQUAL(fiberDimA,
- testB->getFiberDimension(*(vertices->begin())));
-
-} // testShiftHistory
-
-// ----------------------------------------------------------------------
-// Test getFieldByHistory().
-void
-pylith::topology::TestFieldsManager::testGetFieldByHistory(void)
-{ // testGetFieldByHistory
- ALE::Obj<Mesh> mesh;
- _initialize(&mesh);
- FieldsManager manager(mesh);
-
- const char* labels[] = { "field A", "field B" };
- const int size = 2;
- const int fiberDimA = 2;
- const int fiberDimB = 3;
-
- for (int i=0; i < size; ++i)
- manager.addReal(labels[i]);
- manager.createHistory(labels, size);
-
- const ALE::Obj<Mesh::label_sequence>& vertices = mesh->depthStratum(0);
- const ALE::Obj<real_section_type>& fieldA = manager.getReal(labels[0]);
- const ALE::Obj<real_section_type>& fieldB = manager.getReal(labels[1]);
- fieldA->setChart(mesh->getSieve()->getChart());
- fieldA->setFiberDimension(vertices, fiberDimA);
- fieldB->setChart(mesh->getSieve()->getChart());
- fieldB->setFiberDimension(vertices, fiberDimB);
-
- const ALE::Obj<real_section_type>& testA = manager.getFieldByHistory(0);
- CPPUNIT_ASSERT_EQUAL(fiberDimA,
- testA->getFiberDimension(*(vertices->begin())));
-
- const ALE::Obj<real_section_type>& testB = manager.getFieldByHistory(1);
- CPPUNIT_ASSERT_EQUAL(fiberDimB,
- testB->getFiberDimension(*(vertices->begin())));
-} // testGetFieldByHistory
-
-// ----------------------------------------------------------------------
-void
-pylith::topology::TestFieldsManager::_initialize(ALE::Obj<Mesh>* mesh) const
-{ // _initialize
- CPPUNIT_ASSERT(0 != mesh);
-
- meshio::MeshIOAscii iohandler;
- iohandler.filename("data/tri3.mesh");
- iohandler.read(mesh);
- CPPUNIT_ASSERT(!mesh->isNull());
-} // _initialize
-
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsManager.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,116 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/libtests/topology/TestFieldsManager.hh
- *
- * @brief C++ TestFieldsManager object.
- *
- * C++ unit testing for FieldsManager.
- */
-
-#if !defined(pylith_topology_testfieldsmanager_hh)
-#define pylith_topology_testfieldsmanager_hh
-
-#include <cppunit/extensions/HelperMacros.h>
-
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
-
-/// Namespace for pylith package
-namespace pylith {
- namespace topology {
- class TestFieldsManager;
-
- class FieldsManager;
- } // topology
-} // pylith
-
-/// C++ unit testing for FieldsManager.
-class pylith::topology::TestFieldsManager : public CppUnit::TestFixture
-{ // class TestFieldsManager
-
- // CPPUNIT TEST SUITE /////////////////////////////////////////////////
- CPPUNIT_TEST_SUITE( TestFieldsManager );
-
- CPPUNIT_TEST( testConstructor );
- CPPUNIT_TEST( testAddReal );
- CPPUNIT_TEST( testGetReal );
- CPPUNIT_TEST( testDelReal );
- CPPUNIT_TEST( testSetFiberDimension );
- CPPUNIT_TEST( testAllocate );
- CPPUNIT_TEST( testCopyLayout );
- CPPUNIT_TEST( testCopyLayoutFromField );
- CPPUNIT_TEST( testSolutionField );
- CPPUNIT_TEST( testGetSolution );
- CPPUNIT_TEST( testCreateHistory );
- CPPUNIT_TEST( testShiftHistory );
- CPPUNIT_TEST( testGetFieldByHistory );
-
- CPPUNIT_TEST_SUITE_END();
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /// Test constructor.
- void testConstructor(void);
-
- /// Test addReal().
- void testAddReal(void);
-
- /// Test getReal().
- void testGetReal(void);
-
- /// Test delReal().
- void testDelReal(void);
-
- /// Test setFiberDimension().
- void testSetFiberDimension(void);
-
- /// Test allocate().
- void testAllocate(void);
-
- /// Test copyLayout().
- void testCopyLayout(void);
-
- /// Test copyLayoutFromField().
- void testCopyLayoutFromField(void);
-
- /// Test solutionField().
- void testSolutionField(void);
-
- /// Test getSolution().
- void testGetSolution(void);
-
- /// Test createHistory().
- void testCreateHistory(void);
-
- /// Test shiftHistory().
- void testShiftHistory(void);
-
- /// Test getFieldByHistory().
- void testGetFieldByHistory(void);
-
- // PRIVATE METHODS ////////////////////////////////////////////////////
-private :
-
- /** Initialize FieldsManager boundary condition.
- *
- * @param mesh PETSc mesh to initialize
- */
- void _initialize(ALE::Obj<Mesh>* mesh) const;
-
-}; // class TestFieldsManager
-
-#endif // pylith_topology_fieldsmanager_hh
-
-
-// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsMesh.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,190 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestFieldsMesh.hh" // Implementation of class methods
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldsMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Fields<pylith::topology::Field<pylith::topology::Mesh> > FieldsMesh;
+typedef pylith::topology::Mesh::RealSection RealSection;
+typedef pylith::topology::Mesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestFieldsMesh::setUp(void)
+{ // setUp
+ _mesh = new Mesh;
+ meshio::MeshIOAscii importer;
+ importer.filename("data/tri3.mesh");
+ importer.read(_mesh);
+} // setUp
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestFieldsMesh::tearDown(void)
+{ // tearDown
+ delete _mesh; _mesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestFieldsMesh::testConstructor(void)
+{ // testConstructor
+ CPPUNIT_ASSERT(0 != _mesh);
+ FieldsMesh fields(*_mesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test add().
+void
+pylith::topology::TestFieldsMesh::testAdd(void)
+{ // testAdd
+ CPPUNIT_ASSERT(0 != _mesh);
+ FieldsMesh fields(*_mesh);
+
+ const char* label = "field";
+ fields.add(label, "displacement");
+ const size_t size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+} // testAdd
+
+// ----------------------------------------------------------------------
+// Test add(domain).
+void
+pylith::topology::TestFieldsMesh::testAddDomain(void)
+{ // testAddDomain
+ const int fiberDim = 3;
+
+ CPPUNIT_ASSERT(0 != _mesh);
+ FieldsMesh fields(*_mesh);
+
+ const char* label = "field";
+ fields.add(label, "velocity", Field<Mesh>::VERTICES_FIELD, fiberDim);
+ const size_t size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+
+ Field<Mesh>& field = fields.get(label);
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ field.allocate();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testAddDomain
+
+// ----------------------------------------------------------------------
+// Test del().
+void
+pylith::topology::TestFieldsMesh::testDelete(void)
+{ // testDelete
+ CPPUNIT_ASSERT(0 != _mesh);
+ FieldsMesh fields(*_mesh);
+
+ const char* labelA = "field A";
+ fields.add(labelA, "displacement");
+
+ const char* labelB = "field B";
+ fields.add(labelB, "velocity");
+
+ size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+ fields.del(labelA);
+ size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+ const Field<Mesh>& field = fields.get(labelB);
+ CPPUNIT_ASSERT_EQUAL(std::string("velocity"), std::string(field.label()));
+} // testDelete
+
+// ----------------------------------------------------------------------
+// Test get().
+void
+pylith::topology::TestFieldsMesh::testGet(void)
+{ // testGet
+ CPPUNIT_ASSERT(0 != _mesh);
+ FieldsMesh fields(*_mesh);
+
+ const char* label = "field";
+ fields.add(label, "velocity");
+ const Field<Mesh>& field = fields.get(label);
+} // testGet
+
+// ----------------------------------------------------------------------
+// Test get() const.
+void
+pylith::topology::TestFieldsMesh::testGetConst(void)
+{ // testGetConst
+ CPPUNIT_ASSERT(0 != _mesh);
+ FieldsMesh fields(*_mesh);
+
+ const char* label = "field";
+ fields.add(label, "velocity");
+
+ const FieldsMesh* fieldsPtr = &fields;
+ CPPUNIT_ASSERT(0 != fieldsPtr);
+ const Field<Mesh>& field = fieldsPtr->get(label);
+} // testGetConst
+
+// ----------------------------------------------------------------------
+// Test copyLayout().
+void
+pylith::topology::TestFieldsMesh::testCopyLayout(void)
+{ // testCopyLayout
+ const int fiberDim = 3;
+
+ CPPUNIT_ASSERT(0 != _mesh);
+ FieldsMesh fields(*_mesh);
+
+ const char* labelA = "field A";
+ fields.add(labelA, "displacement", Field<Mesh>::VERTICES_FIELD, fiberDim);
+
+ const char* labelB = "field B";
+ fields.add(labelB, "velocity");
+ Field<Mesh>& fieldA = fields.get(labelA);
+ fieldA.allocate();
+
+ fields.copyLayout(labelA);
+
+ const size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+ const Field<Mesh>& field = fields.get(labelB);
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = _mesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices
+ = sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testCopyLayout
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsMesh.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestFieldsMesh.hh
+ *
+ * @brief C++ unit testing for Fields<Mesh,Field>.
+ */
+
+#if !defined(pylith_topology_testfieldsmesh_hh)
+#define pylith_topology_testfieldsmesh_hh
+
+// Include directives ---------------------------------------------------
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/topologyfwd.hh" // forward declarations
+
+// Forward declarations -------------------------------------------------
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestFieldsMesh;
+ } // topology
+} // pylith
+
+// TestField -------------------------------------------------------------
+/// C++ unit testing for Field.
+class pylith::topology::TestFieldsMesh : public CppUnit::TestFixture
+{ // class TestField
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestFieldsMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testAdd );
+ CPPUNIT_TEST( testAddDomain );
+ CPPUNIT_TEST( testDelete );
+ CPPUNIT_TEST( testGet );
+ CPPUNIT_TEST( testGetConst );
+ CPPUNIT_TEST( testCopyLayout );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup test case.
+ void setUp(void);
+
+ /// Tear down test case.
+ void tearDown(void);
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test add().
+ void testAdd(void);
+
+ /// Test add(domain).
+ void testAddDomain(void);
+
+ /// Test delete().
+ void testDelete(void);
+
+ /// Test get().
+ void testGet(void);
+
+ /// Test get() for const Fields.
+ void testGetConst(void);
+
+ /// Test copyLayout(domain).
+ void testCopyLayout(void);
+
+// PRIVATE MEMBERS /////////////////////////////////////////////////////
+private :
+
+ Mesh* _mesh;
+
+}; // class TestFieldsMesh
+
+#endif // pylith_topology_testfieldsmesh_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsSubMesh.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,192 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestFieldsSubMesh.hh" // Implementation of class methods
+
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/Fields.hh" // USES Fields
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestFieldsSubMesh );
+
+// ----------------------------------------------------------------------
+typedef pylith::topology::Fields<pylith::topology::Field<pylith::topology::SubMesh> > FieldsSubMesh;
+typedef pylith::topology::SubMesh::RealSection RealSection;
+typedef pylith::topology::SubMesh::SieveMesh SieveMesh;
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestFieldsSubMesh::setUp(void)
+{ // setUp
+ _mesh = new Mesh;
+ meshio::MeshIOAscii importer;
+ importer.filename("data/tri3.mesh");
+ importer.read(_mesh);
+
+ _submesh = new SubMesh(*_mesh, "bc");
+} // setUp
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestFieldsSubMesh::tearDown(void)
+{ // tearDown
+ delete _mesh; _mesh = 0;
+ delete _submesh; _submesh = 0;
+} // tearDown
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestFieldsSubMesh::testConstructor(void)
+{ // testConstructor
+ CPPUNIT_ASSERT(0 != _submesh);
+ FieldsSubMesh fields(*_submesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test add().
+void
+pylith::topology::TestFieldsSubMesh::testAdd(void)
+{ // testAdd
+ CPPUNIT_ASSERT(0 != _submesh);
+ FieldsSubMesh fields(*_submesh);
+
+ const char* label = "field";
+ fields.add(label, "displacement");
+ const size_t size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+} // testAdd
+
+// ----------------------------------------------------------------------
+// Test add(domain).
+void
+pylith::topology::TestFieldsSubMesh::testAddDomain(void)
+{ // testAddDomain
+ const int fiberDim = 3;
+
+ CPPUNIT_ASSERT(0 != _submesh);
+ FieldsSubMesh fields(*_submesh);
+
+ const char* label = "field";
+ fields.add(label, "velocity", Field<SubMesh>::VERTICES_FIELD, fiberDim);
+ const size_t size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+
+ Field<SubMesh>& field = fields.get(label);
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = _submesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ field.allocate();
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testAddDomain
+
+// ----------------------------------------------------------------------
+// Test del().
+void
+pylith::topology::TestFieldsSubMesh::testDelete(void)
+{ // testDelete
+ CPPUNIT_ASSERT(0 != _submesh);
+ FieldsSubMesh fields(*_submesh);
+
+ const char* labelA = "field A";
+ fields.add(labelA, "displacement");
+
+ const char* labelB = "field B";
+ fields.add(labelB, "velocity");
+
+ size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+ fields.del(labelA);
+ size = 1;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+ const Field<SubMesh>& field = fields.get(labelB);
+} // testDelete
+
+// ----------------------------------------------------------------------
+// Test get().
+void
+pylith::topology::TestFieldsSubMesh::testGet(void)
+{ // testGet
+ CPPUNIT_ASSERT(0 != _submesh);
+ FieldsSubMesh fields(*_submesh);
+
+ const char* label = "field";
+ fields.add(label, "displacement");
+ const Field<SubMesh>& field = fields.get(label);
+} // testGet
+
+// ----------------------------------------------------------------------
+// Test get() const.
+void
+pylith::topology::TestFieldsSubMesh::testGetConst(void)
+{ // testGetConst
+ CPPUNIT_ASSERT(0 != _submesh);
+ FieldsSubMesh fields(*_submesh);
+
+ const char* label = "field";
+ fields.add(label, "displacement");
+
+ const FieldsSubMesh* fieldsPtr = &fields;
+ CPPUNIT_ASSERT(0 != fieldsPtr);
+ const Field<SubMesh>& field = fieldsPtr->get(label);
+} // testGetConst
+
+// ----------------------------------------------------------------------
+// Test copyLayout().
+void
+pylith::topology::TestFieldsSubMesh::testCopyLayout(void)
+{ // testCopyLayout
+ const int fiberDim = 3;
+
+ CPPUNIT_ASSERT(0 != _submesh);
+ FieldsSubMesh fields(*_submesh);
+
+ const char* labelA = "field A";
+ fields.add(labelA, "velocity", Field<SubMesh>::VERTICES_FIELD, fiberDim);
+
+ const char* labelB = "field B";
+ fields.add(labelB, "displacement");
+ Field<SubMesh>& fieldA = fields.get(labelA);
+ fieldA.allocate();
+
+ fields.copyLayout(labelA);
+
+ const size_t size = 2;
+ CPPUNIT_ASSERT_EQUAL(size, fields._fields.size());
+ const Field<SubMesh>& field = fields.get(labelB);
+ const ALE::Obj<RealSection>& section = field.section();
+ CPPUNIT_ASSERT(!section.isNull());
+ const ALE::Obj<SieveMesh>& sieveMesh = _submesh->sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ const ALE::Obj<SieveMesh::label_sequence>& vertices
+ = sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ for (SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(fiberDim, section->getFiberDimension(*v_iter));
+} // testCopyLayout
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestFieldsSubMesh.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestFieldsSubMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestFieldsSubMesh.hh
+ *
+ * @brief C++ unit testing for Fields<Mesh,Field>.
+ */
+
+#if !defined(pylith_topology_testfieldssubmesh_hh)
+#define pylith_topology_testfieldssubmesh_hh
+
+// Include directives ---------------------------------------------------
+#include <cppunit/extensions/HelperMacros.h>
+
+// Forward declarations -------------------------------------------------
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestFieldsSubMesh;
+
+ class Mesh;
+ class SubMesh;
+ } // topology
+} // pylith
+
+// TestField -------------------------------------------------------------
+/// C++ unit testing for Field.
+class pylith::topology::TestFieldsSubMesh : public CppUnit::TestFixture
+{ // class TestField
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestFieldsSubMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testAdd );
+ CPPUNIT_TEST( testAddDomain );
+ CPPUNIT_TEST( testDelete );
+ CPPUNIT_TEST( testGet );
+ CPPUNIT_TEST( testGetConst );
+ CPPUNIT_TEST( testCopyLayout );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Setup test case.
+ void setUp(void);
+
+ /// Tear down test case.
+ void tearDown(void);
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test add().
+ void testAdd(void);
+
+ /// Test add(domain).
+ void testAddDomain(void);
+
+ /// Test delete().
+ void testDelete(void);
+
+ /// Test get().
+ void testGet(void);
+
+ /// Test get() for const Fields.
+ void testGetConst(void);
+
+ /// Test copyLayout(domain).
+ void testCopyLayout(void);
+
+// PRIVATE MEMBERS /////////////////////////////////////////////////////
+private :
+
+ Mesh* _mesh;
+ SubMesh* _submesh;
+
+}; // class TestFieldsSubMesh
+
+#endif // pylith_topology_testfieldssubmesh_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestJacobian.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,130 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestJacobian.hh" // Implementation of class methods
+
+#include "pylith/topology/Jacobian.hh" // USES Jacobian
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/Field.hh" // USES Field
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestJacobian );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestJacobian::testConstructor(void)
+{ // testConstructor
+ Mesh mesh;
+ SolutionFields fields(mesh);
+ _initialize(&mesh, &fields);
+ Jacobian jacobian(fields);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test matrix().
+void
+pylith::topology::TestJacobian::testMatrix(void)
+{ // testMatrix
+ Mesh mesh;
+ SolutionFields fields(mesh);
+ _initialize(&mesh, &fields);
+ Jacobian jacobian(fields);
+
+ const PetscMat matrix = jacobian.matrix();
+ CPPUNIT_ASSERT(0 != matrix);
+} // testMatrix
+
+// ----------------------------------------------------------------------
+// Test assemble().
+void
+pylith::topology::TestJacobian::testAssemble(void)
+{ // testAssemble
+ Mesh mesh;
+ SolutionFields fields(mesh);
+ _initialize(&mesh, &fields);
+ Jacobian jacobian(fields);
+
+ jacobian.assemble("flush_assembly");
+ jacobian.assemble("final_assembly");
+} // testAssemble
+
+// ----------------------------------------------------------------------
+// Test zero().
+void
+pylith::topology::TestJacobian::testZero(void)
+{ // testZero
+ Mesh mesh;
+ SolutionFields fields(mesh);
+ _initialize(&mesh, &fields);
+ Jacobian jacobian(fields);
+
+ jacobian.zero();
+} // testZero
+
+// ----------------------------------------------------------------------
+// Test view().
+void
+pylith::topology::TestJacobian::testView(void)
+{ // testView
+ Mesh mesh;
+ SolutionFields fields(mesh);
+ _initialize(&mesh, &fields);
+ Jacobian jacobian(fields);
+
+ jacobian.assemble("final_assembly");
+
+ jacobian.view();
+} // testView
+
+// ----------------------------------------------------------------------
+// Test write().
+void
+pylith::topology::TestJacobian::testWrite(void)
+{ // testWrite
+ Mesh mesh;
+ SolutionFields fields(mesh);
+ _initialize(&mesh, &fields);
+ Jacobian jacobian(fields);
+
+ jacobian.assemble("final_assembly");
+
+ jacobian.write("jacobian.mat");
+} // testWrite
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestJacobian::_initialize(Mesh* mesh,
+ SolutionFields* fields) const
+{ // _initialize
+ CPPUNIT_ASSERT(0 != mesh);
+
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename("data/tri3.mesh");
+ iohandler.read(mesh);
+
+ fields->add("disp t+dt", "displacement");
+ fields->solutionName("disp t+dt");
+ Field<Mesh>& solution = fields->solution();
+ solution.newSection(FieldBase::VERTICES_FIELD, mesh->dimension());
+ solution.allocate();
+ solution.zero();
+} // _initialize
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestJacobian.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestJacobian.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestJacobian.hh
+ *
+ * @brief C++ TestJacobian object.
+ *
+ * C++ unit testing for Jacobian.
+ */
+
+#if !defined(pylith_topology_testjacobian_hh)
+#define pylith_topology_testjacobian_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/topologyfwd.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestJacobian;
+ } // topology
+} // pylith
+
+/// C++ unit testing for Jacobian.
+class pylith::topology::TestJacobian : public CppUnit::TestFixture
+{ // class TestJacobian
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestJacobian );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testMatrix );
+ CPPUNIT_TEST( testAssemble );
+ CPPUNIT_TEST( testZero );
+ CPPUNIT_TEST( testView );
+ CPPUNIT_TEST( testWrite );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test matrix().
+ void testMatrix(void);
+
+ /// Test assemble().
+ void testAssemble(void);
+
+ /// Test zero().
+ void testZero(void);
+
+ /// Test view().
+ void testView(void);
+
+ /// Test write().
+ void testWrite(void);
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Initialize mesh for Jacobian.
+ *
+ * @param mesh Finite-element mesh.
+ * @param fields Solution fields.
+ */
+ void _initialize(Mesh* mesh,
+ SolutionFields* fields) const;
+
+}; // class TestJacobian
+
+#endif // pylith_topology_jacobian_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,18 +26,50 @@
pylith::topology::TestMesh::testConstructor(void)
{ // testConstructor
Mesh mesh;
+ CPPUNIT_ASSERT(mesh._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(0, mesh.dimension());
+ CPPUNIT_ASSERT_EQUAL(false, mesh.debug());
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh.comm());
+
+ Mesh mesh2(2);
+ CPPUNIT_ASSERT(!mesh2._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(2, mesh2.dimension());
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh2.comm());
+
+ Mesh mesh3(1, PETSC_COMM_SELF);
+ CPPUNIT_ASSERT(!mesh3._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(1, mesh3.dimension());
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_SELF, mesh3.comm());
} // testConstructor
// ----------------------------------------------------------------------
+// Test createSieveMesh().
+void
+pylith::topology::TestMesh::testCreateSieveMesh(void)
+{ // testCreateSieveMesh
+ Mesh mesh;
+ CPPUNIT_ASSERT(mesh._mesh.isNull());
+
+ int dim = 2;
+ mesh.createSieveMesh(dim);
+ CPPUNIT_ASSERT(!mesh._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(dim, mesh.dimension());
+
+ dim = 1;
+ mesh.createSieveMesh(dim);
+ CPPUNIT_ASSERT(!mesh._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(dim, mesh.dimension());
+} // testCreateMeshSieve
+
+// ----------------------------------------------------------------------
// Test sieveMesh().
void
pylith::topology::TestMesh::testSieveMesh(void)
{ // testSieveMesh
const int dim = 2;
-
- Mesh mesh(PETSC_COMM_WORLD, dim);
+ Mesh mesh(dim);
- const ALE::Obj<SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
CPPUNIT_ASSERT(!sieveMesh.isNull());
CPPUNIT_ASSERT_EQUAL(dim, sieveMesh->getDimension());
} // testSieveMesh
@@ -58,6 +90,43 @@
} // testCoordsys
// ----------------------------------------------------------------------
+// Test debug().
+void
+pylith::topology::TestMesh::testDebug(void)
+{ // testDebug
+ Mesh mesh;
+ CPPUNIT_ASSERT_EQUAL(false, mesh.debug());
+
+ mesh.debug(true);
+ CPPUNIT_ASSERT_EQUAL(true, mesh.debug());
+} // testDebug
+
+// ----------------------------------------------------------------------
+// Test dimension().
+void
+pylith::topology::TestMesh::testDimension(void)
+{ // testDimension
+ Mesh mesh;
+ CPPUNIT_ASSERT_EQUAL(0, mesh.dimension());
+
+ const int dim = 2;
+ Mesh mesh2(dim);
+ CPPUNIT_ASSERT_EQUAL(dim, mesh2.dimension());
+} // testDimension
+
+// ----------------------------------------------------------------------
+// Test comm().
+void
+pylith::topology::TestMesh::testComm(void)
+{ // testComm
+ Mesh mesh;
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh.comm());
+
+ mesh.comm(PETSC_COMM_SELF);
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_SELF, mesh.comm());
+} // testComm
+
+// ----------------------------------------------------------------------
// Test initialize().
void
pylith::topology::TestMesh::testInitialize(void)
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -41,8 +41,12 @@
CPPUNIT_TEST_SUITE( TestMesh );
CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testCreateSieveMesh );
CPPUNIT_TEST( testSieveMesh );
CPPUNIT_TEST( testCoordsys );
+ CPPUNIT_TEST( testDebug );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testComm );
CPPUNIT_TEST( testInitialize );
CPPUNIT_TEST_SUITE_END();
@@ -53,12 +57,24 @@
/// Test constructor.
void testConstructor(void);
+ /// Test createSieveMesh().
+ void testCreateSieveMesh(void);
+
/// Test sieveMesh().
void testSieveMesh(void);
/// Test coordsys().
void testCoordsys(void);
+ /// Test debug().
+ void testDebug(void);
+
+ /// Test dimension().
+ void testDimension(void);
+
+ /// Test comm().
+ void testComm(void);
+
/// Test initialize().
void testInitialize(void);
Modified: short/3D/PyLith/trunk/unittests/libtests/topology/TestMeshOps.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestMeshOps.cc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestMeshOps.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,8 +16,8 @@
#include "pylith/topology/MeshOps.hh" // USES MeshOps
+#include "pylith/topology/Mesh.hh" // USES Mesh
#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
-#include "pylith/utils/sievetypes.hh" // USES PETSc Mesh
// ----------------------------------------------------------------------
CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestMeshOps );
@@ -27,12 +27,11 @@
void
pylith::topology::TestMeshOps::testCheckMaterialIds(void)
{ // testCheckMaterialIds
- ALE::Obj<Mesh> mesh;
+ Mesh mesh;
meshio::MeshIOAscii iohandler;
iohandler.filename("data/tri3.mesh");
iohandler.read(&mesh);
- CPPUNIT_ASSERT(!mesh.isNull());
const int numMaterials = 2;
int materialIds[numMaterials];
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,159 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestSolutionFields.hh" // Implementation of class methods
+
+#include "pylith/topology/SolutionFields.hh" // USES SolutionFields
+
+#include "pylith/meshio/MeshIOAscii.hh" // USES MeshIOAscii
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestSolutionFields );
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestSolutionFields::testConstructor(void)
+{ // testConstructor
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test solutionName().
+void
+pylith::topology::TestSolutionFields::testSolutionName(void)
+{ // testSolutionName
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const std::string& name = "my solution";
+ manager.add(name.c_str(), "displacement");
+ manager.solutionName(name.c_str());
+ CPPUNIT_ASSERT_EQUAL(name, manager._solutionName);
+} // testSolutionName
+
+// ----------------------------------------------------------------------
+// Test solution().
+void
+pylith::topology::TestSolutionFields::testSolution(void)
+{ // testSolution
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const char* labels[] = { "field A", "field B", "field C" };
+ const int size = 3;
+ const int fiberDimA = 2;
+ const int fiberDimB = 3;
+ const int fiberDimC = 4;
+
+ for (int i=0; i < size; ++i)
+ manager.add(labels[i], "displacement");
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ Field<Mesh>& fieldA = manager.get(labels[0]);
+ Field<Mesh>& fieldB = manager.get(labels[1]);
+ Field<Mesh>& fieldC = manager.get(labels[2]);
+ fieldA.newSection(vertices, fiberDimA);
+
+ const ALE::Obj<Mesh::RealSection>& section = fieldA.section();
+ const Mesh::RealSection::chart_type& chart = section->getChart();
+ fieldB.newSection(chart, fiberDimB);
+ fieldC.newSection(chart, fiberDimC);
+
+ manager.solutionName(labels[1]);
+ const Field<Mesh>& solution = manager.solution();
+ const ALE::Obj<Mesh::RealSection>& sectionSoln = solution.section();
+ CPPUNIT_ASSERT_EQUAL(fiberDimB,
+ sectionSoln->getFiberDimension(*(vertices->begin())));
+} // testSolution
+
+// ----------------------------------------------------------------------
+// Test createHistory().
+void
+pylith::topology::TestSolutionFields::testCreateHistory(void)
+{ // testCreateHistory
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const char* labels[] = { "field A", "field B", "field C" };
+ const int totalSize = 3;
+ const int historySize = 2;
+
+ // Add fields
+ for (int i=0; i < totalSize; ++i)
+ manager.add(labels[i], "displacement");
+
+ manager.createHistory(labels, historySize);
+ for (int i=0; i < historySize; ++i)
+ CPPUNIT_ASSERT_EQUAL(std::string(labels[i]), manager._history[i]);
+} // testCreateHistory
+
+// ----------------------------------------------------------------------
+// Test shiftHistory().
+void
+pylith::topology::TestSolutionFields::testShiftHistory(void)
+{ // testShiftHistory
+ Mesh mesh;
+ _initialize(&mesh);
+ SolutionFields manager(mesh);
+
+ const char* fieldNames[] = { "field A", "field B" };
+ const int numFields = 2;
+ const int fiberDimA = 2;
+ const int fiberDimB = 3;
+
+ for (int i=0; i < numFields; ++i)
+ manager.add(fieldNames[i], "displacement");
+ manager.createHistory(fieldNames, numFields);
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ Field<Mesh>& fieldA = manager.get(fieldNames[0]);
+ Field<Mesh>& fieldB = manager.get(fieldNames[1]);
+ fieldA.newSection(vertices, fiberDimA);
+ fieldB.newSection(vertices, fiberDimB);
+
+ manager.shiftHistory();
+ const Field<Mesh>& testA = manager.get(fieldNames[0]);
+ const ALE::Obj<Mesh::RealSection>& sectionA = testA.section();
+ const Field<Mesh>& testB = manager.get(fieldNames[1]);
+ const ALE::Obj<Mesh::RealSection>& sectionB = testB.section();
+ CPPUNIT_ASSERT_EQUAL(fiberDimB,
+ sectionA->getFiberDimension(*(vertices->begin())));
+ CPPUNIT_ASSERT_EQUAL(fiberDimA,
+ sectionB->getFiberDimension(*(vertices->begin())));
+
+} // testShiftHistory
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestSolutionFields::_initialize(Mesh* mesh) const
+{ // _initialize
+ CPPUNIT_ASSERT(0 != mesh);
+
+ meshio::MeshIOAscii iohandler;
+ iohandler.filename("data/tri3.mesh");
+ iohandler.read(mesh);
+} // _initialize
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSolutionFields.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestSolutionFields.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,85 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestSolutionFields.hh
+ *
+ * @brief C++ TestSolutionFields object.
+ *
+ * C++ unit testing for SolutionFields.
+ */
+
+#if !defined(pylith_topology_testsolutionfields_hh)
+#define pylith_topology_testsolutionfields_hh
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "pylith/topology/topologyfwd.hh"
+
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestSolutionFields;
+ } // topology
+} // pylith
+
+/// C++ unit testing for SolutionFields.
+class pylith::topology::TestSolutionFields : public CppUnit::TestFixture
+{ // class TestSolutionFields
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestSolutionFields );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testSolutionName );
+ CPPUNIT_TEST( testSolution );
+ CPPUNIT_TEST( testCreateHistory );
+ CPPUNIT_TEST( testShiftHistory );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test solutionName().
+ void testSolutionName(void);
+
+ /// Test solution().
+ void testSolution(void);
+
+ /// Test createHistory().
+ void testCreateHistory(void);
+
+ /// Test shiftHistory().
+ void testShiftHistory(void);
+
+ /// Test getFieldByHistory().
+ void testGetFieldByHistory(void);
+
+ // PRIVATE METHODS ////////////////////////////////////////////////////
+private :
+
+ /** Initialize mesh for SolutionFields.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ void _initialize(Mesh* mesh) const;
+
+}; // class TestSolutionFields
+
+#endif // pylith_topology_solutionfields_hh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSubMesh.cc)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.cc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,256 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+#include <portinfo>
+
+#include "TestSubMesh.hh" // Implementation of class methods
+
+#include "pylith/topology/Mesh.hh" // USES Mesh
+#include "pylith/topology/SubMesh.hh" // USES SubMesh
+
+#include "spatialdata/geocoords/CSCart.hh" // USES CSCart
+
+// ----------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION( pylith::topology::TestSubMesh );
+
+// ----------------------------------------------------------------------
+namespace pylith {
+ namespace topology {
+ namespace _TestSubMesh {
+ const int cellDim = 2;
+ const int nvertices = 4;
+ const int ncells = 2;
+ const int ncorners = 3;
+ const int cells[] = {
+ 0, 1, 3,
+ 0, 3, 2,
+ };
+ const double coordinates[] = {
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 0.0, 1.0,
+ 1.0, 1.0,
+ };
+ const char* label = "bc";
+ const int groupSize = 3;
+ const int groupVertices[] = {
+ 1, 2, 3
+ };
+ const int submeshVertices[] = {
+ 3, 4, 5
+ };
+ } // _TestSubMesh
+ } // topology
+} // pylith
+
+// ----------------------------------------------------------------------
+// Test constructor.
+void
+pylith::topology::TestSubMesh::testConstructor(void)
+{ // testConstructor
+ SubMesh mesh;
+ CPPUNIT_ASSERT(mesh._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(0, mesh.dimension());
+ CPPUNIT_ASSERT_EQUAL(false, mesh.debug());
+ CPPUNIT_ASSERT_EQUAL(0, mesh.comm());
+} // testConstructor
+
+// ----------------------------------------------------------------------
+// Test constructor w/mesh.
+void
+pylith::topology::TestSubMesh::testConstructorMesh(void)
+{ // testConstructorMesh
+ Mesh mesh2D;
+ _buildMesh(&mesh2D);
+
+ SubMesh mesh(mesh2D, _TestSubMesh::label);
+ CPPUNIT_ASSERT(!mesh._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(_TestSubMesh::cellDim-1, mesh.dimension());
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh.comm());
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const int nvertices = _TestSubMesh::groupSize;
+ CPPUNIT_ASSERT_EQUAL(size_t(nvertices), vertices->size());
+ int iV = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(_TestSubMesh::submeshVertices[iV++], *v_iter);
+} // testConstructorMesh
+
+// ----------------------------------------------------------------------
+// Test sieveMesh().
+void
+pylith::topology::TestSubMesh::testSieveMesh(void)
+{ // testSieveMesh
+ Mesh mesh2D;
+ _buildMesh(&mesh2D);
+
+ SubMesh mesh(mesh2D, _TestSubMesh::label);
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ CPPUNIT_ASSERT(!sieveMesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(_TestSubMesh::cellDim-1, mesh.dimension());
+} // testSieveMesh
+
+// ----------------------------------------------------------------------
+// Test createSubMesh().
+void
+pylith::topology::TestSubMesh::testCreateSubMesh(void)
+{ // testCreateSubMesh
+ Mesh mesh2D;
+ _buildMesh(&mesh2D);
+
+ SubMesh mesh;
+ mesh.createSubMesh(mesh2D, _TestSubMesh::label);
+ CPPUNIT_ASSERT(!mesh._mesh.isNull());
+ CPPUNIT_ASSERT_EQUAL(_TestSubMesh::cellDim-1, mesh.dimension());
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh.comm());
+
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh.sieveMesh();
+ const ALE::Obj<Mesh::SieveMesh::label_sequence>& vertices =
+ sieveMesh->depthStratum(0);
+ CPPUNIT_ASSERT(!vertices.isNull());
+ const int nvertices = _TestSubMesh::groupSize;
+ CPPUNIT_ASSERT_EQUAL(size_t(nvertices), vertices->size());
+ int iV = 0;
+ for (Mesh::SieveMesh::label_sequence::iterator v_iter=vertices->begin();
+ v_iter != vertices->end();
+ ++v_iter)
+ CPPUNIT_ASSERT_EQUAL(_TestSubMesh::submeshVertices[iV++], *v_iter);
+} // testCreateSubMesh
+
+// ----------------------------------------------------------------------
+// Test coordsys().
+void
+pylith::topology::TestSubMesh::testCoordsys(void)
+{ // testCoordsys
+ Mesh mesh2D;
+ _buildMesh(&mesh2D);
+
+ SubMesh mesh(mesh2D, _TestSubMesh::label);
+
+ CPPUNIT_ASSERT_EQUAL(_TestSubMesh::cellDim, mesh.coordsys()->spaceDim());
+} // testCoordsys
+
+// ----------------------------------------------------------------------
+// Test debug().
+void
+pylith::topology::TestSubMesh::testDebug(void)
+{ // testDebug
+ SubMesh mesh;
+ CPPUNIT_ASSERT_EQUAL(false, mesh.debug());
+
+ mesh.debug(true);
+ CPPUNIT_ASSERT_EQUAL(true, mesh.debug());
+} // testDebug
+
+// ----------------------------------------------------------------------
+// Test dimension().
+void
+pylith::topology::TestSubMesh::testDimension(void)
+{ // testDimension
+ SubMesh mesh;
+ CPPUNIT_ASSERT_EQUAL(0, mesh.dimension());
+
+ Mesh mesh2D;
+ _buildMesh(&mesh2D);
+ SubMesh mesh2(mesh2D, _TestSubMesh::label);
+ CPPUNIT_ASSERT_EQUAL(_TestSubMesh::cellDim-1, mesh2.dimension());
+} // testDimension
+
+// ----------------------------------------------------------------------
+// Test comm().
+void
+pylith::topology::TestSubMesh::testComm(void)
+{ // testComm
+ SubMesh mesh;
+ CPPUNIT_ASSERT_EQUAL(0, mesh.comm());
+
+ Mesh mesh2D;
+ _buildMesh(&mesh2D);
+ mesh.createSubMesh(mesh2D, _TestSubMesh::label);
+
+ CPPUNIT_ASSERT_EQUAL(PETSC_COMM_WORLD, mesh.comm());
+} // testComm
+
+// ----------------------------------------------------------------------
+// Test initialize().
+void
+pylith::topology::TestSubMesh::testInitialize(void)
+{ // testInitialize
+ Mesh mesh2D;
+ _buildMesh(&mesh2D);
+ SubMesh mesh(mesh2D, _TestSubMesh::label);
+
+ mesh.initialize();
+} // testInitialize
+
+// ----------------------------------------------------------------------
+void
+pylith::topology::TestSubMesh::_buildMesh(Mesh* mesh)
+{ // _buildMesh
+ assert(0 != mesh);
+
+ mesh->createSieveMesh(_TestSubMesh::cellDim);
+ const ALE::Obj<Mesh::SieveMesh>& sieveMesh = mesh->sieveMesh();
+
+ ALE::Obj<Mesh::SieveMesh::sieve_type> sieve =
+ new Mesh::SieveMesh::sieve_type(sieveMesh->comm());
+ CPPUNIT_ASSERT(!sieve.isNull());
+
+ ALE::Obj<ALE::Mesh::sieve_type> s =
+ new ALE::Mesh::sieve_type(sieve->comm(), sieve->debug());
+
+ const int cellDim = _TestSubMesh::cellDim;
+ const int ncells = _TestSubMesh::ncells;
+ const int* cells = _TestSubMesh::cells;
+ const int nvertices = _TestSubMesh::nvertices;
+ const int ncorners = _TestSubMesh::ncorners;
+ const int spaceDim = _TestSubMesh::cellDim;
+ const double* coordinates = _TestSubMesh::coordinates;
+ const bool interpolate = false;
+ ALE::SieveBuilder<ALE::Mesh>::buildTopology(s, cellDim, ncells, (int*) cells,
+ nvertices, interpolate,
+ ncorners);
+ std::map<Mesh::SieveMesh::point_type,Mesh::SieveMesh::point_type> renumbering;
+ ALE::ISieveConverter::convertSieve(*s, *sieve, renumbering);
+ sieveMesh->setSieve(sieve);
+ sieveMesh->stratify();
+ ALE::SieveBuilder<Mesh::SieveMesh>::buildCoordinates(sieveMesh, spaceDim,
+ coordinates);
+
+ spatialdata::geocoords::CSCart cs;
+ cs.setSpaceDim(spaceDim);
+ cs.initialize();
+ mesh->coordsys(&cs);
+
+ typedef Mesh::IntSection::chart_type chart_type;
+ const ALE::Obj<Mesh::IntSection>& groupField =
+ sieveMesh->getIntSection(_TestSubMesh::label);
+ assert(!groupField.isNull());
+
+ const int numPoints = _TestSubMesh::groupSize;
+ const int numVertices = sieveMesh->depthStratum(0)->size();
+ const int numCells = sieveMesh->heightStratum(0)->size();
+ groupField->setChart(chart_type(numCells, numCells+numVertices));
+ for(int i=0; i < numPoints; ++i)
+ groupField->setFiberDimension(numCells+_TestSubMesh::groupVertices[i], 1);
+ sieveMesh->allocate(groupField);
+
+} // _buildMesh
+
+
+// End of file
Copied: short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/libtests/topology/TestSubMesh.hh)
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh (rev 0)
+++ short/3D/PyLith/trunk/unittests/libtests/topology/TestSubMesh.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//
+// ----------------------------------------------------------------------
+//
+// Brad T. Aagaard
+// U.S. Geological Survey
+//
+// {LicenseText}
+//
+// ----------------------------------------------------------------------
+//
+
+/**
+ * @file unittests/libtests/topology/TestSubMesh.hh
+ *
+ * @brief C++ unit testing for Mesh.
+ */
+
+#if !defined(pylith_topology_testsubmesh_hh)
+#define pylith_topology_testsubmesh_hh
+
+// Include directives ---------------------------------------------------
+#include <cppunit/extensions/HelperMacros.h>
+
+// Forward declarations -------------------------------------------------
+/// Namespace for pylith package
+namespace pylith {
+ namespace topology {
+ class TestSubMesh;
+
+ class Mesh;
+ } // topology
+} // pylith
+
+// TestSubMesh -------------------------------------------------------------
+/// C++ unit testing for Mesh.
+class pylith::topology::TestSubMesh : public CppUnit::TestFixture
+{ // class TestSubMesh
+
+ // CPPUNIT TEST SUITE /////////////////////////////////////////////////
+ CPPUNIT_TEST_SUITE( TestSubMesh );
+
+ CPPUNIT_TEST( testConstructor );
+ CPPUNIT_TEST( testConstructorMesh );
+ CPPUNIT_TEST( testSieveMesh );
+ CPPUNIT_TEST( testCreateSubMesh );
+ CPPUNIT_TEST( testCoordsys );
+ CPPUNIT_TEST( testDebug );
+ CPPUNIT_TEST( testDimension );
+ CPPUNIT_TEST( testComm );
+ CPPUNIT_TEST( testInitialize );
+
+ CPPUNIT_TEST_SUITE_END();
+
+ // PUBLIC METHODS /////////////////////////////////////////////////////
+public :
+
+ /// Test constructor.
+ void testConstructor(void);
+
+ /// Test constructor w/mesh.
+ void testConstructorMesh(void);
+
+ /// Test sieveMesh().
+ void testSieveMesh(void);
+
+ /// Test createSubMesh.
+ void testCreateSubMesh(void);
+
+ /// Test coordsys().
+ void testCoordsys(void);
+
+ /// Test debug().
+ void testDebug(void);
+
+ /// Test dimension().
+ void testDimension(void);
+
+ /// Test comm().
+ void testComm(void);
+
+ /// Test initialize().
+ void testInitialize(void);
+
+// PRIVATE METHODS /////////////////////////////////////////////////////
+private :
+
+ /** Build mesh.
+ *
+ * @param mesh Finite-element mesh.
+ */
+ static
+ void _buildMesh(Mesh* mesh);
+
+}; // class TestSubMesh
+
+#endif // pylith_topology_testsubmesh_hh
+
+
+// End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,6 +16,7 @@
feassemble \
materials \
meshio \
+ mpi \
problems \
topology \
utils
Modified: short/3D/PyLith/trunk/unittests/pytests/bc/TestAbsorbingDampers.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/bc/TestAbsorbingDampers.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/bc/TestAbsorbingDampers.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -26,7 +26,7 @@
def test_implementsIntegrator(self):
"""
- Test to make sure AbsorbingDampers satisfies constraint requirements.
+ Test to make sure AbsorbingDampers satisfies integrator requirements.
"""
bc = AbsorbingDampers()
from pylith.feassemble.Integrator import implementsIntegrator
@@ -53,10 +53,7 @@
(mesh, bc, fields) = self._initialize()
- self.assertNotEqual(None, bc.cppHandle)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No testing of result.
return
@@ -77,7 +74,7 @@
"""
(mesh, bc, fields) = self._initialize()
- self.assertEqual(1.0e+30, bc.stableTimeStep())
+ self.assertEqual(1.0e+30, bc.stableTimeStep(mesh))
return
@@ -108,12 +105,11 @@
"""
(mesh, bc, fields) = self._initialize()
- residual = fields.getReal("residual")
+ residual = fields.get("residual")
t = 0.02
bc.integrateResidual(residual, t, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No testing of result.
return
@@ -127,15 +123,14 @@
(mesh, bc, fields) = self._initialize()
- jacobian = mesh.createMatrix(fields.getReal("residual"))
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(jacobian)
+ from pylith.topology.Jacobian import Jacobian
+ jacobian = Jacobian(fields)
+ jacobian.zero()
t = 0.24
bc.integrateJacobian(jacobian, t, fields)
self.assertEqual(False, bc.needNewJacobian())
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No testing of result.
return
@@ -153,8 +148,7 @@
totalTime = 5
bc.poststep(t, dt, totalTime, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No testing of result.
return
@@ -168,8 +162,7 @@
(mesh, bc, fields) = self._initialize()
bc.finalize()
- # We should really add something here to check to make sure things
- # actually initialized correctly.
+ # No testing of result.
return
@@ -179,43 +172,47 @@
"""
Initialize AbsorbingDampers boundary condition.
"""
- from pylith.bc.AbsorbingDampers import AbsorbingDampers
- bc = AbsorbingDampers()
- bc._configure()
- bc.id = 0
- bc.label = "bc"
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ db = SimpleDB()
+ db.inventory.label = "TestAbsorbingDampers tri3"
+ db.inventory.iohandler.inventory.filename = \
+ "data/elasticplanestrain.spatialdb"
+ db.inventory.iohandler._configure()
+ db._configure()
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature1Din2D import Quadrature1Din2D
- quadrature = Quadrature1Din2D()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell._configure()
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
quadrature._configure()
- quadrature.cell = cell
- bc.quadrature = quadrature
- from spatialdata.spatialdb.SimpleDB import SimpleDB
- db = SimpleDB()
- db._configure()
- db.label = "TestAbsorbingDampers tri3"
- db.iohandler.filename = "data/elasticplanestrain.spatialdb"
- db.initialize()
- bc.db = db
+ from pylith.bc.AbsorbingDampers import AbsorbingDampers
+ bc = AbsorbingDampers()
+ bc.inventory.quadrature = quadrature
+ bc.inventory.db = db
+ bc.inventory.id = 0
+ bc.inventory.label = "bc"
+ bc._configure()
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
- cs.spaceDim = 2
+ cs.inventory.spaceDim = 2
+ cs._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
bc.preinitialize(mesh)
@@ -223,20 +220,21 @@
bc.timeStep(0.01)
# Setup fields
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
- fields.addReal("residual")
- fields.addReal("solution")
- fields.addReal("dispT")
- fields.addReal("dispTmdt")
- fields.solutionField("solution")
- fields.createHistory(["solution", "dispT", "dispTmdt"])
- fields.setFiberDimension("residual", cs.spaceDim)
- fields.allocate("residual")
- fields.copyLayout("residual")
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
+ fields.add("residual", "residual")
+ fields.add("disp(t+dt)", "displacement")
+ fields.add("disp(t)", "displacement")
+ fields.add("disp(t-dt)", "displacement")
+ fields.solutionName("disp(t+dt)")
+ fields.createHistory(["disp(t+dt)", "disp(t)", "disp(t-dt)"])
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(fields.getReal("residual"))
+ residual = fields.get("residual")
+ residual.newSection(residual.VERTICES_FIELD, cs.spaceDim())
+ residual.allocate()
+ residual.zero()
+
+ fields.copyLayout("residual")
return (mesh, bc, fields)
Copied: short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBC.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/bc/TestDirichletBC.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBC.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBC.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,199 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/bc/TestDirichletBC.py
+
+## @brief Unit testing of DirichletBC object.
+
+import unittest
+
+from pylith.bc.DirichletBC import DirichletBC
+
+# ----------------------------------------------------------------------
+class TestDirichletBC(unittest.TestCase):
+ """
+ Unit testing of DirichletBC object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ from pylith.bc.DirichletBC import DirichletBC
+ bc = DirichletBC()
+ return
+
+
+ def test_implementsConstraint(self):
+ """
+ Test to make sure DirichletBC satisfies constraint requirements.
+ """
+ bc = DirichletBC()
+ from pylith.feassemble.Constraint import implementsConstraint
+ print dir(bc)
+ self.failUnless(implementsConstraint(bc))
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+
+ WARNING: This is not a rigorous test of initialize() because we
+ don't verify the results.
+ """
+
+ (mesh, bc, field) = self._initialize()
+
+ # We should really add something here to check to make sure things
+ # actually initialized correctly
+ return
+
+
+ def test_setConstraintSizes(self):
+ """
+ Test setConstraintSizes().
+
+ WARNING: This is not a rigorous test of setConstraintSizes() because we
+ don't verify the results.
+ """
+
+ (mesh, bc, field) = self._initialize()
+
+ bc.setConstraintSizes(field)
+
+ # We should really add something here to check to make sure things
+ # actually initialized correctly
+ return
+
+
+ def test_setConstraints(self):
+ """
+ Test setConstraints().
+
+ WARNING: This is not a rigorous test of setConstraints() because we
+ don't verify the results.
+ """
+
+ (mesh, bc, field) = self._initialize()
+ bc.setConstraintSizes(field)
+ field.allocate()
+ bc.setConstraints(field)
+
+ # We should really add something here to check to make sure things
+ # actually initialized correctly
+ return
+
+
+ def test_useSolnIncr(self):
+ """
+ Test useSolnIncr().
+ """
+ (mesh, bc, field) = self._initialize()
+ bc.useSolnIncr(True)
+ return
+
+
+ def test_setField(self):
+ """
+ Test setField().
+
+ WARNING: This is not a rigorous test of setField() because we
+ don't verify the results.
+ """
+
+ (mesh, bc, field) = self._initialize()
+ bc.setConstraintSizes(field)
+ field.allocate()
+ bc.setConstraints(field)
+ t = 1.0
+ bc.setField(t, field)
+
+ # We should really add something here to check to make sure things
+ # actually initialized correctly
+ return
+
+
+ def test_finalize(self):
+ """
+ Test finalize().
+
+ WARNING: This is not a rigorous test of finalize() because we
+ neither set the input fields or verify the results.
+ """
+ (mesh, bc, field) = self._initialize()
+ bc.finalize()
+
+ # We should really add something here to check to make sure things
+ # actually initialized correctly.
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _initialize(self):
+ """
+ Initialize DirichletBC boundary condition.
+ """
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ db = SimpleDB()
+ db.inventory.label = "TestDirichletBC tri3"
+ db.inventory.iohandler.inventory.filename = "data/tri3.spatialdb"
+ db.inventory.iohandler._configure()
+ db._configure()
+
+ from pylith.bc.FixedDOFDB import FixedDOFDB
+ dbRate = FixedDOFDB()
+ dbRate.inventory.label = "TestDirichletBC rate tri3"
+ dbRate._configure()
+
+ from pylith.bc.DirichletBC import DirichletBC
+ bc = DirichletBC()
+ bc.inventory.label = "bc"
+ bc.inventory.fixedDOF = [1]
+ from pyre.units.time import second
+ bc.inventory.tRef = -1.0*second
+ bc.inventory.db = db
+ bc.inventory.dbRate = dbRate
+ bc._configure()
+
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ mesh = importer.read(normalizer, debug=False, interpolate=False)
+
+ bc.preinitialize(mesh)
+ bc.initialize(totalTime=0.0, numTimeSteps=1, normalizer=normalizer)
+
+ # Setup field
+ from pylith.topology.Field import MeshField
+ field = MeshField(mesh)
+ field.newSection(field.VERTICES_FIELD, cs.spaceDim())
+ field.allocate()
+
+ field.zero()
+
+ return (mesh, bc, field)
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBoundary.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBoundary.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletBoundary.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,8 +29,8 @@
Test to make sure DirichletBoundary satisfies constraint requirements.
"""
bc = DirichletBoundary()
- from pylith.feassemble.Constraint import implementsConstraint
- self.failUnless(implementsConstraint(bc))
+ from pylith.feassemble.Constraint import Constraint
+ self.failUnless(isinstance(bc, Constraint))
return
@@ -51,10 +51,8 @@
don't verify the results.
"""
- (mesh, bc, fields) = self._initialize()
+ (mesh, bc, field) = self._initialize()
- self.assertNotEqual(None, bc.cppHandle)
-
# We should really add something here to check to make sure things
# actually initialized correctly
return
@@ -68,8 +66,7 @@
don't verify the results.
"""
- (mesh, bc, fields) = self._initialize()
- field = fields.getReal("field")
+ (mesh, bc, field) = self._initialize()
bc.setConstraintSizes(field)
# We should really add something here to check to make sure things
@@ -85,10 +82,9 @@
don't verify the results.
"""
- (mesh, bc, fields) = self._initialize()
- field = fields.getReal("field")
+ (mesh, bc, field) = self._initialize()
bc.setConstraintSizes(field)
- mesh.allocateRealSection(field)
+ field.allocate()
bc.setConstraints(field)
# We should really add something here to check to make sure things
@@ -100,7 +96,7 @@
"""
Test useSolnIncr().
"""
- (mesh, bc, fields) = self._initialize()
+ (mesh, bc, field) = self._initialize()
bc.useSolnIncr(True)
return
@@ -113,10 +109,9 @@
don't verify the results.
"""
- (mesh, bc, fields) = self._initialize()
- field = fields.getReal("field")
+ (mesh, bc, field) = self._initialize()
bc.setConstraintSizes(field)
- mesh.allocateRealSection(field)
+ field.allocate()
bc.setConstraints(field)
t = 1.0
bc.setField(t, field)
@@ -133,7 +128,7 @@
WARNING: This is not a rigorous test of finalize() because we
neither set the input fields or verify the results.
"""
- (mesh, bc, fields) = self._initialize()
+ (mesh, bc, field) = self._initialize()
bc.finalize()
# We should really add something here to check to make sure things
@@ -147,46 +142,48 @@
"""
Initialize DirichletBoundary boundary condition.
"""
- from pylith.bc.DirichletBoundary import DirichletBoundary
- bc = DirichletBoundary()
- bc._configure()
- bc.output._configure()
- bc.output.writer._configure()
- bc.label = "bc"
- bc.fixedDOF = [1]
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.spaceDim = 2
- from pyre.units.time import second
- bc.tRef = -1.0*second
-
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ mesh = importer.read(normalizer, debug=False, interpolate=False)
+
from spatialdata.spatialdb.SimpleDB import SimpleDB
db = SimpleDB()
+ db.inventory.label = "TestDirichletBoundary tri3"
+ db.inventory.iohandler.inventory.filename = "data/tri3.spatialdb"
+ db.inventory.iohandler._configure()
db._configure()
- db.label = "TestDirichletBoundary tri3"
- db.iohandler.filename = "data/tri3.spatialdb"
- db.initialize()
- bc.db = db
from pylith.bc.FixedDOFDB import FixedDOFDB
dbRate = FixedDOFDB()
+ dbRate.inventory.label = "TestDirichletBoundary rate tri3"
dbRate._configure()
- dbRate.label = "TestDirichletBoundary rate tri3"
- dbRate.initialize()
- bc.dbRate = dbRate
- from spatialdata.geocoords.CSCart import CSCart
- cs = CSCart()
- cs.spaceDim = 2
+ bc.inventory.db = db
+ bc.inventory.dbRate = dbRate
+
+ from pylith.bc.DirichletBoundary import DirichletBoundary
+ bc = DirichletBoundary()
+ bc.inventory.output._configure()
+ bc.output.writer._configure()
+ bc.label = "bc"
+ bc.fixedDOF = [1]
+ bc._configure()
+
+ from pyre.units.time import second
+ bc.tRef = -1.0*second
+
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
normalizer.initialize()
- from pylith.meshio.MeshIOAscii import MeshIOAscii
- importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
- mesh = importer.read(normalizer, debug=False, interpolate=False)
-
bc.preinitialize(mesh)
bc.initialize(totalTime=0.0, numTimeSteps=1, normalizer=normalizer)
@@ -200,7 +197,7 @@
import pylith.topology.topology as bindings
bindings.zeroRealSection(fields.getReal("field"))
- return (mesh, bc, fields)
+ return (mesh, bc, field)
# End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletPoints.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletPoints.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/bc/TestDirichletPoints.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,205 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/bc/TestDirichletPoints.py
-
-## @brief Unit testing of DirichletPoints object.
-
-import unittest
-
-from pylith.bc.DirichletPoints import DirichletPoints
-
-# ----------------------------------------------------------------------
-class TestDirichletPoints(unittest.TestCase):
- """
- Unit testing of DirichletPoints object.
- """
-
- def test_implementsConstraint(self):
- """
- Test to make sure DirichletPoints satisfies constraint requirements.
- """
- bc = DirichletPoints()
- from pylith.feassemble.Constraint import implementsConstraint
- self.failUnless(implementsConstraint(bc))
- return
-
-
- def test_constructor(self):
- """
- Test constructor.
- """
- from pylith.bc.DirichletPoints import DirichletPoints
- bc = DirichletPoints()
- return
-
-
- def test_initialize(self):
- """
- Test initialize().
-
- WARNING: This is not a rigorous test of initialize() because we
- don't verify the results.
- """
-
- (mesh, bc, fields) = self._initialize()
-
- self.assertNotEqual(None, bc.cppHandle)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
- return
-
-
- def test_setConstraintSizes(self):
- """
- Test setConstraintSizes().
-
- WARNING: This is not a rigorous test of setConstraintSizes() because we
- don't verify the results.
- """
-
- (mesh, bc, fields) = self._initialize()
- field = fields.getReal("field")
- bc.setConstraintSizes(field)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
- return
-
-
- def test_setConstraints(self):
- """
- Test setConstraints().
-
- WARNING: This is not a rigorous test of setConstraints() because we
- don't verify the results.
- """
-
- (mesh, bc, fields) = self._initialize()
- field = fields.getReal("field")
- bc.setConstraintSizes(field)
- mesh.allocateRealSection(field)
- bc.setConstraints(field)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
- return
-
-
- def test_useSolnIncr(self):
- """
- Test useSolnIncr().
- """
- (mesh, bc, fields) = self._initialize()
- bc.useSolnIncr(True)
- return
-
-
- def test_setField(self):
- """
- Test setField().
-
- WARNING: This is not a rigorous test of setField() because we
- don't verify the results.
- """
-
- (mesh, bc, fields) = self._initialize()
- field = fields.getReal("field")
- bc.setConstraintSizes(field)
- mesh.allocateRealSection(field)
- bc.setConstraints(field)
- t = 1.0
- bc.setField(t, field)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
- return
-
-
- def test_finalize(self):
- """
- Test finalize().
-
- WARNING: This is not a rigorous test of finalize() because we
- neither set the input fields or verify the results.
- """
- (mesh, bc, fields) = self._initialize()
- bc.finalize()
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _initialize(self):
- """
- Initialize DirichletPoints boundary condition.
- """
- from pylith.bc.DirichletPoints import DirichletPoints
- bc = DirichletPoints()
- bc._configure()
- bc.id = 0
- bc.label = "bc"
- bc.fixedDOF = [1]
-
- from pyre.units.time import second
- bc.tRef = -1.0*second
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
- db = SimpleDB()
- db._configure()
- db.label = "TestDirichletPoints tri3"
- db.iohandler.filename = "data/tri3.spatialdb"
- db.initialize()
- bc.db = db
-
- from pylith.bc.FixedDOFDB import FixedDOFDB
- dbRate = FixedDOFDB()
- dbRate._configure()
- dbRate.label = "TestDirichletPoints rate tri3"
- dbRate.initialize()
- bc.dbRate = dbRate
-
- from spatialdata.geocoords.CSCart import CSCart
- cs = CSCart()
- cs.spaceDim = 2
-
- from spatialdata.units.Nondimensional import Nondimensional
- normalizer = Nondimensional()
- normalizer.initialize()
-
- from pylith.meshio.MeshIOAscii import MeshIOAscii
- importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
- mesh = importer.read(normalizer, debug=False, interpolate=False)
-
- bc.preinitialize(mesh)
- bc.initialize(totalTime=0.0, numTimeSteps=1, normalizer=normalizer)
-
- # Setup fields
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
- fields.addReal("field")
- fields.setFiberDimension("field", cs.spaceDim)
- fields.allocate("field")
-
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(fields.getReal("field"))
-
- return (mesh, bc, fields)
-
-
-# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/bc/TestNeumann.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/bc/TestNeumann.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/bc/TestNeumann.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -53,10 +53,7 @@
(mesh, bc, fields) = self._initialize()
- self.assertNotEqual(None, bc.cppHandle)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No testing of result.
return
@@ -77,7 +74,7 @@
"""
(mesh, bc, fields) = self._initialize()
- self.assertEqual(1.0e+30, bc.stableTimeStep())
+ self.assertEqual(1.0e+30, bc.stableTimeStep(mesh))
return
@@ -108,12 +105,11 @@
"""
(mesh, bc, fields) = self._initialize()
- residual = fields.getReal("residual")
+ residual = fields.get("residual")
t = 0.02
bc.integrateResidual(residual, t, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No testing of result.
return
@@ -126,12 +122,14 @@
(mesh, bc, fields) = self._initialize()
- jacobian = mesh.createMatrix(fields.getReal("residual"))
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(jacobian)
+ from pylith.topology.Jacobian import Jacobian
+ jacobian = Jacobian(fields)
+ jacobian.zero()
t = 0.24
bc.integrateJacobian(jacobian, t, fields)
+ self.assertEqual(False, bc.needNewJacobian())
+ # No testing of result.
return
@@ -149,8 +147,7 @@
totalTime = 5
bc.poststep(t, dt, totalTime, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No testing of result.
return
@@ -164,8 +161,7 @@
(mesh, bc, fields) = self._initialize()
bc.finalize()
- # We should really add something here to check to make sure things
- # actually initialized correctly.
+ # No testing of result.
return
@@ -175,44 +171,49 @@
"""
Initialize Neumann boundary condition.
"""
- from pylith.bc.Neumann import Neumann
- bc = Neumann()
- bc._configure()
- bc.output._configure()
- bc.output.writer._configure()
- bc.label = "bc"
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ db = SimpleDB()
+ db._configure()
+ db.inventory.label = "TestNeumann tri3"
+ db.inventory.iohandler.inventory.filename = "data/tri3-tractions.spatialdb"
+ db.inventory.iohandler._configure()
+ db._configure()
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature1Din2D import Quadrature1Din2D
- quadrature = Quadrature1Din2D()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell._configure()
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
quadrature._configure()
- quadrature.cell = cell
- bc.quadrature = quadrature
+
+ from pylith.bc.Neumann import Neumann
+ bc = Neumann()
+ bc.inventory.quadrature = quadrature
+ bc.inventory.db = db
+ bc.inventory.label = "bc"
+ bc.inventory.output.inventory.writer._configure()
+ bc.inventory.output._configure()
+ bc._configure()
- from spatialdata.spatialdb.SimpleDB import SimpleDB
- db = SimpleDB()
- db._configure()
- db.label = "TestNeumann tri3"
- db.iohandler.filename = "data/tri3-tractions.spatialdb"
- db.initialize()
- bc.db = db
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
- cs.spaceDim = 2
+ cs.inventory.spaceDim = 2
+ cs._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
bc.preinitialize(mesh)
@@ -220,17 +221,19 @@
bc.timeStep(0.01)
# Setup fields
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
- fields.addReal("residual")
- fields.addReal("dispTBctpdt")
- fields.addReal("dispIncr")
- fields.setFiberDimension("residual", cs.spaceDim)
- fields.allocate("residual")
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
+ fields.add("residual", "residual")
+ fields.add("disp(t), bc(t+dt)", "displacement")
+ fields.add("dispIncr(t->t+dt)", "displacement")
+ fields.solutionName("dispIncr(t->t+dt)")
+
+ residual = fields.get("residual")
+ residual.newSection(residual.VERTICES_FIELD, cs.spaceDim())
+ residual.allocate()
+ residual.zero()
+
fields.copyLayout("residual")
-
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(fields.getReal("dispIncr"))
return (mesh, bc, fields)
Modified: short/3D/PyLith/trunk/unittests/pytests/bc/testbc.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/bc/testbc.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/bc/testbc.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -56,11 +56,11 @@
suite = unittest.TestSuite()
- from TestDirichletBoundary import TestDirichletBoundary
- suite.addTest(unittest.makeSuite(TestDirichletBoundary))
+ from TestDirichletBC import TestDirichletBC
+ suite.addTest(unittest.makeSuite(TestDirichletBC))
- from TestDirichletPoints import TestDirichletPoints
- suite.addTest(unittest.makeSuite(TestDirichletPoints))
+ #from TestDirichletBoundary import TestDirichletBoundary
+ #suite.addTest(unittest.makeSuite(TestDirichletBoundary))
from TestAbsorbingDampers import TestAbsorbingDampers
suite.addTest(unittest.makeSuite(TestAbsorbingDampers))
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/TestBruneSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestBruneSlipFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestBruneSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,11 +29,18 @@
Test constructor.
"""
slipFn = BruneSlipFn()
- slipFn._createCppHandle()
- self.failIfEqual(None, slipFn.cppHandle)
return
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ slipFn = BruneSlipFn()
+ slipFn._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -42,28 +49,36 @@
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioFinalSlip = SimpleIOAscii()
- ioFinalSlip.filename = "finalslip.spatialdb"
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
- dbFinalSlip.iohandler = ioFinalSlip
- dbFinalSlip.label = "final slip"
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
- ioPeakRate = SimpleIOAscii()
- ioPeakRate.filename = "peakrate.spatialdb"
- dbPeakRate = SimpleDB()
- dbPeakRate.iohandler = ioPeakRate
- dbPeakRate.label = "peak rate"
+ ioRiseTime = SimpleIOAscii()
+ ioRiseTime.inventory.filename = "risetime.spatialdb"
+ ioRiseTime._configure()
+ dbRiseTime = SimpleDB()
+ dbRiseTime.inventory.iohandler = ioRiseTime
+ dbRiseTime.inventory.label = "rise time"
+ dbRiseTime._configure()
slipFn = BruneSlipFn()
- slipFn.slip = dbFinalSlip
- slipFn.slipTime = dbSlipTime
- slipFn.slipRate = dbPeakRate
+ slipFn.inventory.dbslip = dbFinalSlip
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn.inventory.dbRiseTime = dbRiseTime
+ slipFn._configure()
slipFn.preinitialize()
+ slipFn.verifyConfiguration()
slipFn.initialize()
return
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestConstRateSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,11 +29,18 @@
Test constructor.
"""
slipFn = ConstRateSlipFn()
- slipFn._createCppHandle()
- self.failIfEqual(None, slipFn.cppHandle)
return
+ def test_configure(self):
+ """
+ Test _configure().
+ """
+ slipFn = ConstRateSlipFn()
+ slipFn._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -42,21 +49,27 @@
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioSlipRate = SimpleIOAscii()
- ioSlipRate.filename = "sliprate.spatialdb"
+ ioSlipRate.inventory.filename = "sliprate.spatialdb"
+ ioSlipRate._configure()
dbSlipRate = SimpleDB()
- dbSlipRate.iohandler = ioSlipRate
- dbSlipRate.label = "slip rate"
+ dbSlipRate.inventory.iohandler = ioSlipRate
+ dbSlipRate.inventory.label = "slip rate"
+ dbSlipRate._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
slipFn = ConstRateSlipFn()
- slipFn.slipRate = dbSlipRate
- slipFn.slipTime = dbSlipTime
+ slipFn.inventory.dbSlipRate = dbSlipRate
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn._configure()
slipFn.preinitialize()
+ slipFn.verifyConfiguration()
slipFn.initialize()
return
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestEqKinSrc.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,11 +29,18 @@
Test constructor.
"""
eqsrc = EqKinSrc()
- eqsrc._createCppHandle()
- self.failIfEqual(None, eqsrc.cppHandle)
return
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ eqsrc = EqKinSrc()
+ eqsrc._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -43,33 +50,33 @@
from pyre.units.time import second
ioFinalSlip = SimpleIOAscii()
- ioFinalSlip.filename = "finalslip.spatialdb"
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
- dbFinalSlip.iohandler = ioFinalSlip
- dbFinalSlip.label = "final slip"
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
- ioPeakRate = SimpleIOAscii()
- ioPeakRate.filename = "peakrate.spatialdb"
- dbPeakRate = SimpleDB()
- dbPeakRate.iohandler = ioPeakRate
- dbPeakRate.label = "peak rate"
-
- from pylith.faults.BruneSlipFn import BruneSlipFn
- slipfn = BruneSlipFn()
- slipfn.slip = dbFinalSlip
- slipfn.slipTime = dbSlipTime
- slipfn.slipRate = dbPeakRate
+ from pylith.faults.StepSlipFn import StepSlipFn
+ slipfn = StepSlipFn()
+ slipfn.inventory.dbSlip = dbFinalSlip
+ slipfn.inventory.dbSlipTime = dbSlipTime
+ slipfn._configure()
eqsrc = EqKinSrc()
- eqsrc.originTime = 5.3*second
- eqsrc.slipfn = slipfn
+ eqsrc.inventory.originTime = 5.3*second
+ eqsrc.inventory.slipfn = slipfn
+ eqsrc._configure()
eqsrc.preinitialize()
+ eqsrc.verifyConfiguration()
eqsrc.initialize()
return
Deleted: short/3D/PyLith/trunk/unittests/pytests/faults/TestFault.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestFault.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestFault.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/faults/TestFault.py
-
-## @brief Unit testing of Fault object.
-
-import unittest
-
-from pylith.faults.Fault import Fault
-
-# ----------------------------------------------------------------------
-class TestFault(unittest.TestCase):
- """
- Unit testing of Fault object.
- """
-
- def test_constructor(self):
- """
- Test constructor.
- """
- fault = Fault()
- self.assertEqual(None, fault.cppHandle)
- return
-
-
-# End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesive.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/faults/TestFaultCohesive.py
-
-## @brief Unit testing of Fault object.
-
-import unittest
-
-from pylith.faults.FaultCohesive import FaultCohesive
-
-# ----------------------------------------------------------------------
-class TestFaultCohesive(unittest.TestCase):
- """
- Unit testing of Fault object.
- """
-
- def test_constructor(self):
- """
- Test constructor.
- """
- fault = FaultCohesive()
- self.assertEqual(None, fault.cppHandle)
- return
-
-
- def test_useFaultMesh(self):
- """
- Test useFaultMesh().
- """
- fault = FaultCohesive()
- fault._configure()
- self.assertEqual(False, fault.useFaultMesh)
-
- fault.useFaultMesh = True;
- self.assertEqual(True, fault.useFaultMesh)
- return
-
-
- def test_faultMeshFilename(self):
- """
- Test faultMeshFilename().
- """
- fault = FaultCohesive()
- fault._configure()
- self.assertEqual("fault.inp", fault.faultMeshFilename)
-
- filename = "SanAndreas.inp"
- fault.faultMeshFilename = filename
- self.assertEqual(filename, fault.faultMeshFilename)
- return
-
-
-# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesiveKin.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesiveKin.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestFaultCohesiveKin.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -27,28 +27,60 @@
Unit testing of Fault object.
"""
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ fault = FaultCohesiveKin()
+ return
+
+
+ def test_configure(self):
+ """
+ Test _configure().
+ """
+ fault = FaultCohesiveKin()
+ fault._configure()
+ return
+
+
def test_implementsIntegrator(self):
"""
Test to make sure FaultCohesiveKin satisfies integrator requirements.
"""
fault = FaultCohesiveKin()
- fault._configure()
from pylith.feassemble.Integrator import implementsIntegrator
self.failUnless(implementsIntegrator(fault))
return
- def test_constructor(self):
+ def test_useFaultMesh(self):
"""
- Test constructor.
+ Test useFaultMesh().
"""
fault = FaultCohesiveKin()
fault._configure()
- fault._createCppHandle()
- self.failIfEqual(None, fault.cppHandle)
+
+ fault.useFaultMesh(True);
+
+ # No test of result
return
+ def test_faultMeshFilename(self):
+ """
+ Test faultMeshFilename().
+ """
+ fault = FaultCohesiveKin()
+ fault._configure()
+
+ filename = "SanAndreas.inp"
+ fault.faultMeshFilename(filename)
+
+ # No test of result
+ return
+
+
def test_adjustTopology(self):
"""
Test adjustTopology().
@@ -57,22 +89,24 @@
neither set the input fields or verify the results.
"""
cs = CSCart()
- cs.spaceDim = 2
+ cs.inventory.spaceDim = 2
+ cs._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
fault = FaultCohesiveKin()
+ fault.inventory.matId = 10
+ fault.inventory.faultLabel = "fault"
fault._configure()
- fault.id = 10
- fault.label = "fault"
fault.adjustTopology(mesh)
@@ -101,8 +135,9 @@
"""
dt = 2.4
(mesh, fault, fields) = self._initialize()
- fault.timeStep = dt
- self.assertEqual(dt, fault.timeStep)
+ fault.timeStep(dt)
+
+ # No test of result
return
@@ -112,7 +147,7 @@
"""
(mesh, fault, fields) = self._initialize()
- self.assertEqual(1.0e+30, fault.stableTimeStep())
+ self.assertEqual(1.0e+30, fault.stableTimeStep(mesh))
return
@@ -146,7 +181,7 @@
"""
(mesh, fault, fields) = self._initialize()
- residual = fields.getReal("residual")
+ residual = fields.get("residual")
t = 1.0
fault.integrateResidual(residual, t, fields)
@@ -164,9 +199,9 @@
"""
(mesh, fault, fields) = self._initialize()
- jacobian = mesh.createMatrix(fields.getReal("residual"))
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(jacobian)
+ from pylith.topology.Jacobian import Jacobian
+ jacobian = Jacobian(fields)
+ jacobian.zero()
t = 1.0
fault.integrateJacobian(jacobian, t, fields)
self.assertEqual(False, fault.needNewJacobian())
@@ -186,7 +221,7 @@
(mesh, fault, fields) = self._initialize()
t = 0.50
- residual = fields.getReal("residual")
+ residual = fields.get("residual")
fault.integrateResidual(residual, t, fields)
dt = 0.1
@@ -224,75 +259,81 @@
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
# Setup mesh
cs = CSCart()
- cs.spaceDim = 2
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
# Setup quadrature
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature1Din2D import Quadrature1Din2D
- quadrature = Quadrature1Din2D()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell._configure()
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
quadrature._configure()
- quadrature.cell = cell
# Setup earthquake source
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioFinalSlip = SimpleIOAscii()
- ioFinalSlip.filename = "data/tri3_finalslip.spatialdb"
+ ioFinalSlip.inventory.filename = "data/tri3_finalslip.spatialdb"
+ ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
- dbFinalSlip.iohandler = ioFinalSlip
- dbFinalSlip.label = "final slip"
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "data/tri3_sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "data/tri3_sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
- ioPeakRate = SimpleIOAscii()
- ioPeakRate.filename = "data/tri3_peakrate.spatialdb"
- dbPeakRate = SimpleDB()
- dbPeakRate.iohandler = ioPeakRate
- dbPeakRate.label = "peak rate"
-
- from pylith.faults.BruneSlipFn import BruneSlipFn
- slipfn = BruneSlipFn()
- slipfn.slip = dbFinalSlip
- slipfn.slipTime = dbSlipTime
- slipfn.slipRate = dbPeakRate
+ from pylith.faults.StepSlipFn import StepSlipFn
+ slipfn = StepSlipFn()
+ slipfn.inventory.dbSlip = dbFinalSlip
+ slipfn.inventory.dbSlipTime = dbSlipTime
+ slipfn._configure()
ioMatDB = SimpleIOAscii()
- ioMatDB.filename = "data/bulkprops_2d.spatialdb"
+ ioMatDB.inventory.filename = "data/bulkprops_2d.spatialdb"
+ ioMatDB._configure()
dbMat = SimpleDB()
- dbMat.iohandler = ioMatDB
- dbMat.label = "bulk properties"
+ dbMat.inventory.iohandler = ioMatDB
+ dbMat.inventory.label = "bulk properties"
+ dbMat._configure()
# Setup fault
fault = FaultCohesiveKin()
+ fault.inventory.output.inventory.writer._configure()
+ fault.inventory.output._configure()
+ fault.inventory.matId = 10
+ fault.inventory.faultLabel = "fault"
+ fault.inventory.upDir = [0, 0, 1]
+ fault.inventory.normalDir = [1, 0, 0]
+ fault.inventory.quadrature = quadrature
+ fault.inventory.matDB = dbMat
fault._configure()
- fault.output._configure()
- fault.output.writer._configure()
- fault.id = 10
- fault.label = "fault"
- fault.upDir = [0, 0, 1]
- fault.normalDir = [1, 0, 0]
- fault.quadrature = quadrature
eqsrc = fault.eqsrcs.components()[0]
- eqsrc.originTime = 1.23*second
- eqsrc.slipfn = slipfn
- fault.matDB = dbMat
+ eqsrc.inventory.originTime = 1.23*second
+ eqsrc.inventory.slipfn = slipfn
+ eqsrc._configure()
+
fault.adjustTopology(mesh)
fault.preinitialize(mesh)
fault.timeStep(dt)
@@ -301,18 +342,17 @@
fault.initialize(totalTime=0.0*s, numTimeSteps=1, normalizer=normalizer)
# Setup fields
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
- fields.addReal("residual")
- fields.addReal("solution")
- fields.addReal("disp")
- fields.solutionField("solution")
- fields.setFiberDimension("residual", cs.spaceDim)
- fields.allocate("residual")
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
+ fields.add("residual", "residual")
+ fields.add("solution", "displacement")
+ fields.add("disp", "displacement")
+ fields.solutionName("solution")
+ residual = fields.get("residual")
+ residual.newSection(residual.VERTICES_FIELD, cs.spaceDim())
+ residual.allocate()
+ residual.zero()
fields.copyLayout("residual")
-
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(fields.getReal("residual"))
return (mesh, fault, fields)
Copied: short/3D/PyLith/trunk/unittests/pytests/faults/TestLiuCosSlipFn.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/faults/TestLiuCosSlipFn.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestLiuCosSlipFn.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestLiuCosSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/faults/TestLiuCosSlipFn.py
+
+## @brief Unit testing of LiuCosSlipFn object.
+
+import unittest
+
+from pylith.faults.LiuCosSlipFn import LiuCosSlipFn
+
+# ----------------------------------------------------------------------
+class TestLiuCosSlipFn(unittest.TestCase):
+ """
+ Unit testing of LiuCosSlipFn object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ slipFn = LiuCosSlipFn()
+ return
+
+
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ slipFn = LiuCosSlipFn()
+ slipFn._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+
+ ioFinalSlip = SimpleIOAscii()
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
+ dbFinalSlip = SimpleDB()
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
+
+ ioSlipTime = SimpleIOAscii()
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
+ dbSlipTime = SimpleDB()
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
+
+ ioRiseTime = SimpleIOAscii()
+ ioRiseTime.inventory.filename = "risetime.spatialdb"
+ ioRiseTime._configure()
+ dbRiseTime = SimpleDB()
+ dbRiseTime.inventory.iohandler = ioRiseTime
+ dbRiseTime.inventory.label = "rise time"
+ dbRiseTime._configure()
+
+ slipFn = LiuCosSlipFn()
+ slipFn.inventory.dbslip = dbFinalSlip
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn.inventory.dbRiseTime = dbRiseTime
+ slipFn._configure()
+ slipFn.preinitialize()
+ slipFn.verifyConfiguration()
+ slipFn.initialize()
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/TestStepSlipFn.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,11 +29,18 @@
Test constructor.
"""
slipFn = StepSlipFn()
- slipFn._createCppHandle()
- self.failIfEqual(None, slipFn.cppHandle)
return
+ def test_configure(self):
+ """
+ Test constructor.
+ """
+ slipFn = StepSlipFn()
+ slipFn._configure()
+ return
+
+
def test_initialize(self):
"""
Test initialize().
@@ -42,21 +49,27 @@
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioFinalSlip = SimpleIOAscii()
- ioFinalSlip.filename = "finalslip.spatialdb"
+ ioFinalSlip.inventory.filename = "finalslip.spatialdb"
+ ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
- dbFinalSlip.iohandler = ioFinalSlip
- dbFinalSlip.label = "final slip"
+ dbFinalSlip.inventory.iohandler = ioFinalSlip
+ dbFinalSlip.inventory.label = "final slip"
+ dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
- ioSlipTime.filename = "sliptime.spatialdb"
+ ioSlipTime.inventory.filename = "sliptime.spatialdb"
+ ioSlipTime._configure()
dbSlipTime = SimpleDB()
- dbSlipTime.iohandler = ioSlipTime
- dbSlipTime.label = "slip time"
+ dbSlipTime.inventory.iohandler = ioSlipTime
+ dbSlipTime.inventory.label = "slip time"
+ dbSlipTime._configure()
slipFn = StepSlipFn()
- slipFn.slip = dbFinalSlip
- slipFn.slipTime = dbSlipTime
+ slipFn.inventory.dbSlip = dbFinalSlip
+ slipFn.inventory.dbSlipTime = dbSlipTime
+ slipFn._configure()
slipFn.preinitialize()
+ slipFn.verifyConfiguration()
slipFn.initialize()
return
Modified: short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/faults/testfaults.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -56,24 +56,21 @@
suite = unittest.TestSuite()
- from TestBruneSlipFn import TestBruneSlipFn
- suite.addTest(unittest.makeSuite(TestBruneSlipFn))
+ from TestStepSlipFn import TestStepSlipFn
+ suite.addTest(unittest.makeSuite(TestStepSlipFn))
from TestConstRateSlipFn import TestConstRateSlipFn
suite.addTest(unittest.makeSuite(TestConstRateSlipFn))
- from TestStepSlipFn import TestStepSlipFn
- suite.addTest(unittest.makeSuite(TestStepSlipFn))
+ from TestBruneSlipFn import TestBruneSlipFn
+ suite.addTest(unittest.makeSuite(TestBruneSlipFn))
+ from TestLiuCosSlipFn import TestLiuCosSlipFn
+ suite.addTest(unittest.makeSuite(TestLiuCosSlipFn))
+
from TestEqKinSrc import TestEqKinSrc
suite.addTest(unittest.makeSuite(TestEqKinSrc))
- from TestFault import TestFault
- suite.addTest(unittest.makeSuite(TestFault))
-
- from TestFaultCohesive import TestFaultCohesive
- suite.addTest(unittest.makeSuite(TestFaultCohesive))
-
from TestFaultCohesiveKin import TestFaultCohesiveKin
suite.addTest(unittest.makeSuite(TestFaultCohesiveKin))
Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,48 +24,9 @@
TestFIATLagrange.py \
TestFIATSimplex.py \
TestCellGeometry.py \
- TestQuadrature.py \
- TestIntegrator.py \
+ TestMeshQuadrature.py \
TestElasticityExplicit.py \
TestElasticityImplicit.py
-# module
-subpkgpyexec_LTLIBRARIES = testfeassemblemodule.la
-testfeassemblemodule_la_LDFLAGS = -module -avoid-version \
- $(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-
-dist_testfeassemblemodule_la_SOURCES = \
- testfeassemble.pyxe.src \
- TestQuadrature.hh \
- TestQuadrature.icc
-
-nodist_testfeassemblemodule_la_SOURCES = \
- testfeassemble.pyxe \
- testfeassemble.c testfeassemble_embed.cpp testfeassemble_embed.h
-
-testfeassemblemodule_la_LIBADD = \
- $(PETSC_LIB)
-if NO_UNDEFINED
-testfeassemblemodule_la_LIBADD += \
- $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
-endif
-
-INCLUDES += -I$(PYTHON_INCDIR) $(PETSC_INCLUDE)
-
-testfeassemble.pyx testfeassemble_embed.cpp testfeassemble_embed.h: testfeassemble.pyxe
- pyrexembed testfeassemble.pyxe
-testfeassemble.pyxe: $(srcdir)/testfeassemble.pyxe.src
- cp $(srcdir)/testfeassemble.pyxe.src $@
-testfeassemble_embed.cpp: testfeassemble_embed.h
-testfeassemble_embed.h: testfeassemble.pyx
-
-.pyx.c:
- pyrexc $<
-
-CLEANFILES = \
- testfeassemble.pyxe testfeassemble.pyx testfeassemble.c *_embed.* \
- $(am__installdirs)/testfeassemblemodule.*
-
-
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestCellGeometry.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestCellGeometry.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestCellGeometry.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,18 +17,7 @@
import unittest
import numpy
-from pylith.feassemble.geometry.GeometryPoint1D import GeometryPoint1D
-from pylith.feassemble.geometry.GeometryPoint2D import GeometryPoint2D
-from pylith.feassemble.geometry.GeometryPoint3D import GeometryPoint3D
-from pylith.feassemble.geometry.GeometryLine1D import GeometryLine1D
-from pylith.feassemble.geometry.GeometryLine2D import GeometryLine2D
-from pylith.feassemble.geometry.GeometryLine3D import GeometryLine3D
-from pylith.feassemble.geometry.GeometryTri2D import GeometryTri2D
-from pylith.feassemble.geometry.GeometryTri3D import GeometryTri3D
-from pylith.feassemble.geometry.GeometryQuad2D import GeometryQuad2D
-from pylith.feassemble.geometry.GeometryQuad3D import GeometryQuad3D
-from pylith.feassemble.geometry.GeometryTet3D import GeometryTet3D
-from pylith.feassemble.geometry.GeometryHex3D import GeometryHex3D
+from pylith.feassemble.CellGeometry import GeometryPoint1D
# ----------------------------------------------------------------------
@@ -43,41 +32,9 @@
"""
geometry = GeometryPoint1D()
- self.failIfEqual(None, geometry.cppHandle)
+ self.assertEqual(0, geometry.cellDim())
+ self.assertEqual(1, geometry.spaceDim())
- geometry = GeometryPoint2D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryPoint3D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryLine1D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryLine2D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryLine3D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryTri2D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryTri3D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryQuad2D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryQuad3D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryTet3D()
- self.failIfEqual(None, geometry.cppHandle)
-
- geometry = GeometryHex3D()
- self.failIfEqual(None, geometry.cppHandle)
-
return
Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityExplicit.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityExplicit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityExplicit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,100 +38,99 @@
def test_preinitialize(self):
"""
Test preiniitlaize().
+
+ WARNING: This is not a rigorous test of preinitialize() because we
+ neither set the input fields or verify the results.
"""
- from spatialdata.units.Nondimensional import Nondimensional
- normalizer = Nondimensional()
- normalizer.initialize()
+ (mesh, integrator) = self._preinitialize()
- # Setup mesh
- cs = CSCart()
- cs.spaceDim = 2
- from pylith.meshio.MeshIOAscii import MeshIOAscii
- importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
- mesh = importer.read(normalizer, debug=False, interpolate=False)
+ # No test of result.
+ return
- # Setup material
- from pylith.feassemble.FIATSimplex import FIATSimplex
- cell = FIATSimplex()
- cell.shape = "triangle"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature2D import Quadrature2D
- quadrature = Quadrature2D()
- quadrature._configure()
- quadrature.cell = cell
- minJacobian = 4.0e-02;
- quadrature.minJacobian = minJacobian
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
- from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
- iohandler = SimpleIOAscii()
- iohandler.filename = "data/elasticplanestrain.spatialdb"
- db = SimpleDB()
- db.label = "elastic plane strain"
- db.iohandler = iohandler
- initialStateDB = None
- from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
- material = ElasticPlaneStrain()
- material.id = 0
- material.label = "elastic plane strain"
- material.db = db
- material.quadrature = quadrature
- material.initialStateDB = initialStateDB
- from pylith.meshio.OutputMatElastic import OutputMatElastic
- material.output = OutputMatElastic()
- material.output._configure()
- material.output.writer._configure()
+ def test_verifyConfiguration(self):
+ """
+ Test verifyConfiguration().
- integrator = ElasticityExplicit()
- integrator.preinitialize(mesh, material)
- self.assertEqual(mesh, integrator.mesh)
- self.assertEqual(minJacobian, integrator.quadrature.minJacobian)
+ WARNING: This is not a rigorous test of verifyConfiguration()
+ because we neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ integrator.verifyConfiguration()
+
+ # No test of result.
return
-
+
+ def test_initialize(self):
+ """
+ Test initialize().
+
+ WARNING: This is not a rigorous test of initialize() because we
+ neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ # No test of result.
+ return
+
+
def test_timeStep(self):
"""
Test timeStep().
+
+ WARNING: This is not a rigorous test of timeStep() because we
+ neither set the input fields or verify the results.
"""
dt = 2.3
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
integrator.timeStep(dt)
+
+ # No test of result.
return
-
+
def test_stableTimeStep(self):
"""
Test stableTimeStep().
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- self.assertEqual(1.0e+30, integrator.stableTimeStep())
+ self.assertEqual(1.0e+30, integrator.stableTimeStep(mesh))
return
-
+
def test_needNewJacobian(self):
"""
Test needNewJacobian().
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
self.assertEqual(True, integrator.needNewJacobian())
return
-
+
def test_useSolnIncr(self):
"""
Test useSolnIncr().
+
+ WARNING: This is not a rigorous test of useSolnIncr() because we
+ neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
try:
integrator.useSolnIncr(True)
self.failIf(True)
except:
self.failIf(False)
+
+ # No test of result.
return
@@ -139,42 +138,42 @@
"""
Test integrateResidual().
- WARNING: This is not a rigorous test of integrateResidual() because we
- neither set the input fields or verify the results.
+ WARNING: This is not a rigorous test of integrateResidual()
+ because we neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- residual = fields.getReal("residual")
-
- t = 0.45
+ residual = fields.get("residual")
+ t = 3.4
integrator.integrateResidual(residual, t, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No test of result.
return
-
+
def test_integrateJacobian(self):
"""
Test integrateJacobian().
- WARNING: This is not a rigorous test of integrateJacobian() because we
- neither set the input fields or verify the results.
+ WARNING: This is not a rigorous test of integrateJacobian()
+ because we neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- jacobian = mesh.createMatrix(fields.getReal("residual"))
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(jacobian)
- t = 0.145
+ from pylith.topology.Jacobian import Jacobian
+ jacobian = Jacobian(fields)
+ jacobian.zero()
+ t = 7.3
+ self.assertEqual(True, integrator.needNewJacobian())
integrator.integrateJacobian(jacobian, t, fields)
self.assertEqual(False, integrator.needNewJacobian())
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
+
+ # No test of result.
return
-
+
def test_poststep(self):
"""
Test poststep().
@@ -182,86 +181,69 @@
WARNING: This is not a rigorous test of poststep() because we
neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- t = 3.45
-
- residual = fields.getReal("residual")
- integrator.integrateResidual(residual, t, fields)
-
- dt = 0.02
- totalTime = 5.0
+ t = 7.3
+ dt = 0.1
+ totalTime = 23.0
integrator.poststep(t, dt, totalTime, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No test of result
return
-
- def test_finalize(self):
- """
- Test finalize().
- WARNING: This is not a rigorous test of finalize() because we
- neither set the input fields or verify the results.
- """
- (mesh, integrator, fields) = self._initialize()
-
- integrator.finalize()
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
- def _initialize(self):
+ def _preinitialize(self):
"""
- Initialize integrator.
+ Setup mesh and integrator and preinitialize integrator.
"""
- dt = 2.3
-
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
# Setup mesh
cs = CSCart()
- cs.spaceDim = 2
+ cs.inventory.spaceDim = 2
+ cs._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
# Setup material
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "triangle"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature2D import Quadrature2D
- quadrature = Quadrature2D()
+ cell.inventory.shape = "triangle"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell._configure()
+ from pylith.feassemble.Quadrature import MeshQuadrature
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
quadrature._configure()
- quadrature.cell = cell
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
- iohandler.filename = "data/elasticplanestrain.spatialdb"
+ iohandler.inventory.filename = "data/elasticplanestrain.spatialdb"
+ iohandler._configure()
db = SimpleDB()
- db.label = "elastic plane strain"
- db.iohandler = iohandler
- initialStateDB = None
+ db.inventory.label = "elastic plane strain"
+ db.inventory.iohandler = iohandler
+ db._configure()
from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
material = ElasticPlaneStrain()
- material.id = 0
- material.label = "elastic plane strain"
- material.db = db
- material.initialStateDB = initialStateDB
- material.quadrature = quadrature
+ material.inventory.label = "elastic plane strain"
+ material.inventory.id = 0
+ material.inventory.dbProperties = db
+ material.inventory.quadrature = quadrature
+ material._configure()
+
from pylith.meshio.OutputMatElastic import OutputMatElastic
material.output = OutputMatElastic()
material.output._configure()
@@ -270,27 +252,40 @@
# Setup integrator
integrator = ElasticityExplicit()
integrator.preinitialize(mesh, material)
+ return (mesh, integrator)
+
+
+ def _initialize(self, mesh, integrator):
+ """
+ Initialize integrator.
+ """
+ dt = 2.3
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
from pyre.units.time import s
- integrator.initialize(totalTime=0.0*s, numTimeSteps=1, normalizer=normalizer)
+ integrator.initialize(totalTime=0.0*s, numTimeSteps=1,
+ normalizer=normalizer)
integrator.timeStep(dt)
# Setup fields
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
- fields.addReal("residual")
- fields.addReal("solution")
- fields.addReal("dispT")
- fields.addReal("dispTmdt")
- fields.createHistory(["solution", "dispT", "dispTmdt"])
- fields.solutionField("solution")
- fields.setFiberDimension("residual", cs.spaceDim)
- fields.allocate("residual")
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
+ fields.add("residual", "residual")
+ fields.add("disp(t+dt)", "displacement")
+ fields.add("disp(t)", "displacement")
+ fields.add("disp(t-dt)", "displacement")
+ fields.solutionName("disp(t+dt)")
+
+ residual = fields.get("residual")
+ residual.newSection(residual.VERTICES_FIELD, mesh.coordsys().spaceDim())
+ residual.allocate()
fields.copyLayout("residual")
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(fields.getReal("residual"))
-
- return (mesh, integrator, fields)
+ residual.zero()
+ return fields
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityImplicit.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityImplicit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestElasticityImplicit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -38,96 +38,95 @@
def test_preinitialize(self):
"""
Test preiniitlaize().
+
+ WARNING: This is not a rigorous test of preinitialize() because we
+ neither set the input fields or verify the results.
"""
- from spatialdata.units.Nondimensional import Nondimensional
- normalizer = Nondimensional()
- normalizer.initialize()
+ (mesh, integrator) = self._preinitialize()
- # Setup mesh
- cs = CSCart()
- cs.spaceDim = 2
- from pylith.meshio.MeshIOAscii import MeshIOAscii
- importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
- mesh = importer.read(normalizer, debug=False, interpolate=False)
+ # No test of result.
+ return
- # Setup material
- from pylith.feassemble.FIATSimplex import FIATSimplex
- cell = FIATSimplex()
- cell.shape = "triangle"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature2D import Quadrature2D
- quadrature = Quadrature2D()
- quadrature._configure()
- quadrature.cell = cell
- minJacobian = 4.0e-02;
- quadrature.minJacobian = minJacobian
-
- from spatialdata.spatialdb.SimpleDB import SimpleDB
- from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
- iohandler = SimpleIOAscii()
- iohandler.filename = "data/elasticplanestrain.spatialdb"
- db = SimpleDB()
- db.label = "elastic plane strain"
- db.iohandler = iohandler
- initialStateDB = None
- from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
- material = ElasticPlaneStrain()
- material.id = 0
- material.label = "elastic plane strain"
- material.db = db
- material.initialStateDB = initialStateDB
- material.quadrature = quadrature
- from pylith.meshio.OutputMatElastic import OutputMatElastic
- material.output = OutputMatElastic()
- material.output._configure()
- material.output.writer._configure()
+ def test_verifyConfiguration(self):
+ """
+ Test verifyConfiguration().
- integrator = ElasticityImplicit()
- integrator.preinitialize(mesh, material)
- self.assertEqual(mesh, integrator.mesh)
- self.assertEqual(minJacobian, integrator.quadrature.minJacobian)
+ WARNING: This is not a rigorous test of verifyConfiguration()
+ because we neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ integrator.verifyConfiguration()
+
+ # No test of result.
return
-
+
+ def test_initialize(self):
+ """
+ Test initialize().
+
+ WARNING: This is not a rigorous test of initialize() because we
+ neither set the input fields or verify the results.
+ """
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
+ # No test of result.
+ return
+
+
def test_timeStep(self):
"""
Test timeStep().
+
+ WARNING: This is not a rigorous test of timeStep() because we
+ neither set the input fields or verify the results.
"""
dt = 2.3
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
integrator.timeStep(dt)
+
+ # No test of result.
return
-
+
def test_stableTimeStep(self):
"""
Test stableTimeStep().
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- self.assertEqual(1.0e+30, integrator.stableTimeStep())
+ self.assertEqual(1.0e+30, integrator.stableTimeStep(mesh))
return
-
+
def test_needNewJacobian(self):
"""
Test needNewJacobian().
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
self.assertEqual(True, integrator.needNewJacobian())
return
-
+
def test_useSolnIncr(self):
"""
Test useSolnIncr().
+
+ WARNING: This is not a rigorous test of useSolnIncr() because we
+ neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
+
integrator.useSolnIncr(True)
+
+ # No test of result.
return
@@ -135,41 +134,42 @@
"""
Test integrateResidual().
- WARNING: This is not a rigorous test of integrateResidual() because we
- neither set the input fields or verify the results.
+ WARNING: This is not a rigorous test of integrateResidual()
+ because we neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- residual = fields.getReal("residual")
+ residual = fields.get("residual")
t = 3.4
integrator.integrateResidual(residual, t, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No test of result.
return
-
+
def test_integrateJacobian(self):
"""
Test integrateJacobian().
- WARNING: This is not a rigorous test of integrateJacobian() because we
- neither set the input fields or verify the results.
+ WARNING: This is not a rigorous test of integrateJacobian()
+ because we neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- jacobian = mesh.createMatrix(fields.getReal("residual"))
- import pylith.utils.petsc as petsc
- petsc.mat_setzero(jacobian)
+ from pylith.topology.Jacobian import Jacobian
+ jacobian = Jacobian(fields)
+ jacobian.zero()
t = 7.3
+ self.assertEqual(True, integrator.needNewJacobian())
integrator.integrateJacobian(jacobian, t, fields)
self.assertEqual(False, integrator.needNewJacobian())
-
- # We should really add something here to check to make sure things
- # actually initialized correctly
+
+ # No test of result.
return
-
+
def test_poststep(self):
"""
Test poststep().
@@ -177,86 +177,69 @@
WARNING: This is not a rigorous test of poststep() because we
neither set the input fields or verify the results.
"""
- (mesh, integrator, fields) = self._initialize()
+ (mesh, integrator) = self._preinitialize()
+ fields = self._initialize(mesh, integrator)
- t = 0.27
-
- residual = fields.getReal("residual")
- integrator.integrateResidual(residual, t, fields)
-
- dt = 0.01
- totalTime = 10
+ t = 7.3
+ dt = 0.1
+ totalTime = 23.0
integrator.poststep(t, dt, totalTime, fields)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No test of result
return
-
- def test_finalize(self):
- """
- Test finalize().
- WARNING: This is not a rigorous test of finalize() because we
- neither set the input fields or verify the results.
- """
- (mesh, integrator, fields) = self._initialize()
-
- integrator.finalize()
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
# PRIVATE METHODS ////////////////////////////////////////////////////
- def _initialize(self):
+ def _preinitialize(self):
"""
- Initialize integrator.
+ Setup mesh and integrator and preinitialize integrator.
"""
- dt = 2.3
-
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
# Setup mesh
cs = CSCart()
- cs.spaceDim = 2
+ cs.inventory.spaceDim = 2
+ cs._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
# Setup material
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "triangle"
- cell.degree = 1
- cell.order = 1
- from pylith.feassemble.quadrature.Quadrature2D import Quadrature2D
- quadrature = Quadrature2D()
+ cell.inventory.shape = "triangle"
+ cell.inventory.degree = 1
+ cell.inventory.order = 1
+ cell._configure()
+ from pylith.feassemble.Quadrature import MeshQuadrature
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
quadrature._configure()
- quadrature.cell = cell
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
- iohandler.filename = "data/elasticplanestrain.spatialdb"
+ iohandler.inventory.filename = "data/elasticplanestrain.spatialdb"
+ iohandler._configure()
db = SimpleDB()
- db.label = "elastic plane strain"
- db.iohandler = iohandler
- initialStateDB = None
+ db.inventory.label = "elastic plane strain"
+ db.inventory.iohandler = iohandler
+ db._configure()
from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
material = ElasticPlaneStrain()
- material.id = 0
- material.label = "elastic plane strain"
- material.db = db
- material.initialStateDB = initialStateDB
- material.quadrature = quadrature
+ material.inventory.label = "elastic plane strain"
+ material.inventory.id = 0
+ material.inventory.dbProperties = db
+ material.inventory.quadrature = quadrature
+ material._configure()
+
from pylith.meshio.OutputMatElastic import OutputMatElastic
material.output = OutputMatElastic()
material.output._configure()
@@ -265,24 +248,39 @@
# Setup integrator
integrator = ElasticityImplicit()
integrator.preinitialize(mesh, material)
+ return (mesh, integrator)
+
+
+ def _initialize(self, mesh, integrator):
+ """
+ Initialize integrator.
+ """
+ dt = 2.3
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
from pyre.units.time import s
- integrator.initialize(totalTime=0.0*s, numTimeSteps=1, normalizer=normalizer)
+ integrator.initialize(totalTime=0.0*s, numTimeSteps=1,
+ normalizer=normalizer)
integrator.timeStep(dt)
# Setup fields
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
- fields.addReal("residual")
- fields.addReal("dispTBctpdt")
- fields.solutionField("dispTBctpdt")
- fields.setFiberDimension("residual", cs.spaceDim)
- fields.allocate("residual")
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
+ fields.add("residual", "residual")
+ fields.add("disp(t), bc(t+dt)", "displacement")
+ fields.add("dispIncr(t->t+dt)", "displacement increment")
+ fields.solutionName("dispIncr(t->t+dt)")
+
+ residual = fields.get("residual")
+ residual.newSection(residual.VERTICES_FIELD, mesh.coordsys().spaceDim())
+ residual.allocate()
fields.copyLayout("residual")
- import pylith.topology.topology as bindings
- bindings.zeroRealSection(fields.getReal("residual"))
-
- return (mesh, integrator, fields)
+ residual.zero()
+ return fields
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATLagrange.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATLagrange.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATLagrange.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -369,7 +369,7 @@
cellE = Line2()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryLine1D import GeometryLine1D
+ from pylith.feassemble.CellGeometry import GeometryLine1D
self.failUnless(isinstance(cell.geometry, GeometryLine1D))
return
@@ -387,7 +387,7 @@
cellE = Line3()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryLine2D import GeometryLine2D
+ from pylith.feassemble.CellGeometry import GeometryLine2D
self.failUnless(isinstance(cell.geometry, GeometryLine2D))
return
@@ -405,7 +405,7 @@
cellE = Quad4()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryQuad2D import GeometryQuad2D
+ from pylith.feassemble.CellGeometry import GeometryQuad2D
self.failUnless(isinstance(cell.geometry, GeometryQuad2D))
return
@@ -423,7 +423,7 @@
cellE = Hex8()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryHex3D import GeometryHex3D
+ from pylith.feassemble.CellGeometry import GeometryHex3D
self.failUnless(isinstance(cell.geometry, GeometryHex3D))
return
Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestFIATSimplex.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -311,7 +311,7 @@
cellE = Line2()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryLine1D import GeometryLine1D
+ from pylith.feassemble.CellGeometry import GeometryLine1D
self.failUnless(isinstance(cell.geometry, GeometryLine1D))
return
@@ -328,7 +328,7 @@
cellE = Line3()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryLine2D import GeometryLine2D
+ from pylith.feassemble.CellGeometry import GeometryLine2D
self.failUnless(isinstance(cell.geometry, GeometryLine2D))
return
@@ -345,7 +345,7 @@
cellE = Tri3()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryTri2D import GeometryTri2D
+ from pylith.feassemble.CellGeometry import GeometryTri2D
self.failUnless(isinstance(cell.geometry, GeometryTri2D))
return
@@ -362,7 +362,7 @@
cellE = Tet4()
self._checkVals(cellE, cell)
- from pylith.feassemble.geometry.GeometryTet3D import GeometryTet3D
+ from pylith.feassemble.CellGeometry import GeometryTet3D
self.failUnless(isinstance(cell.geometry, GeometryTet3D))
return
Deleted: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestIntegrator.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,43 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/feassemble/TestIntegrator.py
-
-## @brief Unit testing of Python Integrator object.
-
-import unittest
-from pylith.feassemble.Integrator import Integrator
-
-# ----------------------------------------------------------------------
-class TestIntegrator(unittest.TestCase):
- """
- Unit testing of Python Integrator object.
- """
-
- def test_constructor(self):
- """
- Test constructor.
- """
- i = Integrator()
- return
-
-
- def test_finalize(self):
- """
- Test constructor.
- """
- i = Integrator()
- i.finalize()
- return
-
-
-# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestMeshQuadrature.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/feassemble/TestMeshQuadrature.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestMeshQuadrature.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestMeshQuadrature.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,260 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/feassemble/TestMeshQuadrature.py
+
+## @brief Unit testing of Python MeshQuadrature object.
+
+import unittest
+import numpy
+
+from pylith.feassemble.Quadrature import MeshQuadrature
+from pylith.feassemble.FIATSimplex import FIATSimplex
+from pylith.feassemble.FIATLagrange import FIATLagrange
+
+# ----------------------------------------------------------------------
+def N0(p):
+ return -0.5*p*(1.0-p)
+
+def N0p(p):
+ return -0.5*(1.0-p) + 0.5*p
+
+def N1(p):
+ return 0.5*p*(1.0+p)
+
+def N1p(p):
+ return +0.5*(1.0+p) + 0.5*p
+
+def N2(p):
+ return (1.0-p**2)
+
+def N2p(p):
+ return -2.0*p
+
+# ----------------------------------------------------------------------
+class TestMeshQuadrature(unittest.TestCase):
+ """
+ Unit testing of Python MeshQuadrature object.
+ """
+
+ def test_minJacobian(self):
+ """
+ Test minJacobian().
+ """
+ minJacobian = 4.0e-02;
+ q = MeshQuadrature()
+ q.minJacobian(minJacobian)
+ self.assertEqual(minJacobian, q.minJacobian())
+ return
+
+
+ def test_checkConditioning(self):
+ """
+ Test checkConditioning().
+ """
+ q = MeshQuadrature()
+
+ flag = False # default
+ self.assertEqual(flag, q.checkConditioning())
+
+ flag = True
+ q.checkConditioning(flag)
+ self.assertEqual(flag, q.checkConditioning())
+
+ flag = False
+ q.checkConditioning(flag)
+ self.assertEqual(flag, q.checkConditioning())
+
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ cell = FIATSimplex()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 2
+ cell.inventory.order = 2
+ cell._configure()
+
+ verticesE = numpy.array([ [-1.0], [1.0], [0.0] ])
+ quadPtsE = numpy.array( [[-1.0/3**0.5],
+ [+1.0/3**0.5]],
+ dtype=numpy.float64 )
+ quadWtsE = numpy.array( [1.0, 1.0], dtype=numpy.float64 )
+
+ # Compute basis functions and derivatives at quadrature points
+ basisE = numpy.zeros( (2, 3), dtype=numpy.float64)
+ basisDerivE = numpy.zeros( (2, 3, 1), dtype=numpy.float64)
+ iQuad = 0
+ for q in quadPtsE:
+ basisE[iQuad] = numpy.array([N0(q), N1(q), N2(q)],
+ dtype=numpy.float64).reshape( (3,) )
+ deriv = numpy.array([[N0p(q)], [N1p(q)], [N2p(q)]],
+ dtype=numpy.float64)
+ basisDerivE[iQuad] = deriv.reshape((3, 1))
+ iQuad += 1
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim=1)
+ quadrature.initialize()
+
+ self.assertEqual(1, quadrature.cellDim())
+ self.assertEqual(1, quadrature.spaceDim())
+ self.assertEqual(3, quadrature.numBasis())
+ self.assertEqual(2, quadrature.numQuadPts())
+
+ from pylith.utils.testarray import test_double
+ from pylith.utils.utils import TestArray_checkDouble
+
+ self.assertTrue(TestArray_checkDouble(basisE.ravel(),
+ quadrature.basis()))
+ self.assertTrue(TestArray_checkDouble(basisDerivE.ravel(),
+ quadrature.basisDerivRef()))
+ self.assertTrue(TestArray_checkDouble(quadPtsE.ravel(),
+ quadrature.quadPtsRef()))
+ self.assertTrue(TestArray_checkDouble(quadWtsE.ravel(),
+ quadrature.quadWts()))
+ return
+
+
+ def test_simplex1D(self):
+ """
+ Test setup of quadrature for simplex cells for a 1-D problem.
+ """
+ spaceDim = 1
+
+ cell = FIATSimplex()
+ cell.inventory.shape = "line"
+ cell._configure()
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(1, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(2, quadrature.numBasis())
+ return
+
+
+ def test_simplex2D(self):
+ """
+ Test setup of quadrature for simplex cells for a 2-D problem.
+ """
+ spaceDim = 2
+
+ cell = FIATSimplex()
+ cell.inventory.shape = "triangle"
+ cell._configure()
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(2, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(3, quadrature.numBasis())
+ return
+
+
+ def test_simplex3D(self):
+ """
+ Test setup of quadrature for simplex cells for a 3-D problem.
+ """
+ spaceDim = 3
+
+ cell = FIATSimplex()
+ cell.inventory.shape = "tetrahedron"
+ cell._configure()
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(3, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(4, quadrature.numBasis())
+ return
+
+
+ def test_lagrange1D(self):
+ """
+ Test setup of quadrature for Lagrange cells for a 1-D problem.
+ """
+ spaceDim = 1
+
+ cell = FIATLagrange()
+ cell.inventory.dimension = 1
+ cell._configure()
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(1, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(2, quadrature.numBasis())
+ return
+
+
+ def test_lagrange2D(self):
+ """
+ Test setup of quadrature for Lagrange cells for a 2-D problem.
+ """
+ spaceDim = 2
+
+ cell = FIATLagrange()
+ cell.inventory.dimension = 2
+ cell._configure()
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(2, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(4, quadrature.numBasis())
+ return
+
+
+ def test_lagrange3D(self):
+ """
+ Test setup of quadrature for Lagrange cells for a 3-D problem.
+ """
+ spaceDim = 3
+
+ cell = FIATLagrange()
+ cell.inventory.dimension = 3
+ cell._configure()
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(3, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(8, quadrature.numBasis())
+ return
+
+
+# End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.hh 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,101 +0,0 @@
-// -*- C++ -*-
-//
-// ----------------------------------------------------------------------
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ----------------------------------------------------------------------
-//
-
-/**
- * @file unittests/pytests/feassemble/TestQuadrature.hh
- *
- * @brief C++ TestQuadrature object
- *
- * Helper class for unit testing of Python Quadrature.
- */
-
-#if !defined(pylith_feassemble_pytestquadrature_hh)
-#define pylith_feassemble_pytestquadrature_hh
-
-#include "pylith/feassemble/Quadrature.hh"
-#include "pylith/feassemble/CellGeometry.hh"
-
-/// Namespace for spatialdata package
-namespace pylith {
- namespace feassemble {
- class TestQuadrature;
- } // feassemble
-} // pylith
-
-/// Helper class for unit testing of Python Quadrature
-class pylith::feassemble::TestQuadrature
-{ // class TestQuadrature
-
- // PUBLIC METHODS /////////////////////////////////////////////////////
-public :
-
- /** Get number of dimensions in reference cell.
- *
- * @returns Number of dimensions
- */
- static int cellDim(const Quadrature& q);
-
- /** Get number of vertices in cell.
- *
- * @returns Number of vertices
- */
- static int numBasis(const Quadrature& q);
-
- /** Get number of quadrature points.
- *
- * @returns Number of points
- */
- static int numQuadPts(const Quadrature& q);
-
- /** Get number of dimensions in coordinates of cell vertices.
- *
- * @returns Number of dimensions
- */
- static int spaceDim(const Quadrature& q);
-
- /** Get vertices in reference cell.
- *
- * @returns Array of coordinates of vertices in reference cell.
- */
- static const double* vertices(const Quadrature& q);
-
- /** Get basis functions evaluated at quadrature points.
- *
- * @returns Array of basis functions evaluated at quadrature points
- */
- static const double* basis(const Quadrature& q);
-
- /** Get derivatives of basis functions evaluated at quadrature points.
- *
- * @returns Array of derivatives of basis fns evaluated at quad pts
- */
- static const double* basisDeriv(const Quadrature& q);
-
- /** Get coordinates of quadrature points in reference cell.
- *
- * @returns Array of coordinates of quadrature points
- */
- static const double* quadPtsRef(const Quadrature& q);
-
- /** Get weights of quadrature points.
- *
- * @returns Array of weights of quadrature points
- */
- static const double* quadWts(const Quadrature& q);
-
-}; // class TestQuadrature
-
-#include "TestQuadrature.icc" // inline methods
-
-#endif // pylith_feassemble_pytestquadrature_hh
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.icc 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,82 +0,0 @@
-// -*- C++ -*-
-//
-// ======================================================================
-//
-// Brad T. Aagaard
-// U.S. Geological Survey
-//
-// {LicenseText}
-//
-// ======================================================================
-//
-
-#if !defined(pylith_feassemble_pytestquadrature_hh)
-#error "TestQuadrature.icc must be included only from TestQuadrature.hh"
-#else
-
-// Get number of dimensions in reference cell.
-inline
-int
-pylith::feassemble::TestQuadrature::cellDim(const Quadrature& q) {
- return q._cellDim;
-}
-
-// Get number of vertices in cell.
-inline
-int
-pylith::feassemble::TestQuadrature::numBasis(const Quadrature& q) {
- return q._numBasis;
-}
-
-// Get number of quadrature points.
-inline
-int
-pylith::feassemble::TestQuadrature::numQuadPts(const Quadrature& q) {
- return q._numQuadPts;
-}
-
-// Get number of dimensions in coordinates of cell vertices.
-inline
-int
-pylith::feassemble::TestQuadrature::spaceDim(const Quadrature& q) {
- return q._spaceDim;
-}
-
-// Get coordinates of vertices in reference cell.
-inline
-const double*
-pylith::feassemble::TestQuadrature::vertices(const Quadrature& q) {
- return &q._geometry->vertices()[0];
-}
-
-// Get basis functions evaluated at quadrature points.
-inline
-const double*
-pylith::feassemble::TestQuadrature::basis(const Quadrature& q) {
- return &q._basis[0];
-}
-
-// Get derivatives of basis functions evaluated at quadrature points.
-inline
-const double*
-pylith::feassemble::TestQuadrature::basisDeriv(const Quadrature& q) {
- return &q._basisDerivRef[0];
-}
-
-// Get coordinates of quadrature points
-inline
-const double*
-pylith::feassemble::TestQuadrature::quadPtsRef(const Quadrature& q) {
- return &q._quadPtsRef[0];
-}
-
-// Get weights of quadrature points
-inline
-const double*
-pylith::feassemble::TestQuadrature::quadWts(const Quadrature& q) {
- return &q._quadWts[0];
-}
-
-#endif
-
-// End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestQuadrature.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,173 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/feassemble/TestQuadrature.py
-
-## @brief Unit testing of Python Quadrature object.
-
-import unittest
-import numpy
-
-from pylith.feassemble.quadrature.Quadrature0D import Quadrature0D
-from pylith.feassemble.quadrature.Quadrature1D import Quadrature1D
-from pylith.feassemble.quadrature.Quadrature1Din2D import Quadrature1Din2D
-from pylith.feassemble.quadrature.Quadrature1Din3D import Quadrature1Din3D
-from pylith.feassemble.quadrature.Quadrature2D import Quadrature2D
-from pylith.feassemble.quadrature.Quadrature2Din3D import Quadrature2Din3D
-from pylith.feassemble.quadrature.Quadrature3D import Quadrature3D
-
-
-# ----------------------------------------------------------------------
-def N0(p):
- return -0.5*p*(1.0-p)
-
-def N0p(p):
- return -0.5*(1.0-p) + 0.5*p
-
-def N1(p):
- return 0.5*p*(1.0+p)
-
-def N1p(p):
- return +0.5*(1.0+p) + 0.5*p
-
-def N2(p):
- return (1.0-p**2)
-
-def N2p(p):
- return -2.0*p
-
-# ----------------------------------------------------------------------
-class TestQuadrature(unittest.TestCase):
- """
- Unit testing of Python Quadrature object.
- """
-
- def test_minJacobian(self):
- """
- Test minJacobian attribute.
- """
- minJacobian = 4.0e-02;
- q = Quadrature1D()
- q.minJacobian = minJacobian
- self.assertEqual(minJacobian, q.minJacobian)
- return
-
-
- def test_initialize(self):
- """
- Test initialize().
- """
- from pylith.feassemble.FIATSimplex import FIATSimplex
- cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 2
- cell.order = 2
-
- verticesE = numpy.array([ [-1.0], [1.0], [0.0] ])
- quadPtsE = numpy.array( [[-1.0/3**0.5],
- [+1.0/3**0.5]],
- dtype=numpy.float64 )
- quadWtsE = numpy.array( [1.0, 1.0], dtype=numpy.float64 )
-
- # Compute basis functions and derivatives at quadrature points
- basisE = numpy.zeros( (2, 3), dtype=numpy.float64)
- basisDerivE = numpy.zeros( (2, 3, 1), dtype=numpy.float64)
- iQuad = 0
- for q in quadPtsE:
- basisE[iQuad] = numpy.array([N0(q), N1(q), N2(q)],
- dtype=numpy.float64).reshape( (3,) )
- deriv = numpy.array([[N0p(q)], [N1p(q)], [N2p(q)]],
- dtype=numpy.float64)
- basisDerivE[iQuad] = deriv.reshape((3, 1))
- iQuad += 1
-
- quadrature = Quadrature1D()
- quadrature._configure()
- quadrature.cell = cell
-
- quadrature.preinitialize()
- quadrature.initialize()
-
- from pylith.utils.testarray import test_double
- import pylith.feassemble.testfeassemble as testmodule
-
- vertices = testmodule.vertices(quadrature.cppHandle)
- test_double(self, verticesE, numpy.array(vertices))
-
- basis = testmodule.basis(quadrature.cppHandle)
- test_double(self, basisE, numpy.array(basis))
-
- basisDeriv = testmodule.basisDeriv(quadrature.cppHandle)
- test_double(self, basisDerivE, numpy.array(basisDeriv))
-
- quadWts = testmodule.quadWts(quadrature.cppHandle)
- test_double(self, quadWtsE, numpy.array(quadWts))
-
- quadPts = testmodule.quadPtsRef(quadrature.cppHandle)
- test_double(self, quadPtsE, numpy.array(quadPts))
-
- from pylith.feassemble.geometry.GeometryLine1D import GeometryLine1D
- self.failUnless(isinstance(quadrature.cell.geometry, GeometryLine1D))
-
- return
-
-
- def test_constructors(self):
- """
- Test constructors for quadrature objects.
- """
- q = Quadrature0D()
- q._createCppHandle()
- self.assertEqual(1, q.spaceDim)
- self.assertEqual(0, q.cellDim)
- self.failIfEqual(None, q.cppHandle)
-
- q = Quadrature1D()
- q._createCppHandle()
- self.assertEqual(1, q.spaceDim)
- self.assertEqual(1, q.cellDim)
- self.failIfEqual(None, q.cppHandle)
-
- q = Quadrature1Din2D()
- q._createCppHandle()
- self.assertEqual(2, q.spaceDim)
- self.assertEqual(1, q.cellDim)
- self.failIfEqual(None, q.cppHandle)
-
- q = Quadrature1Din3D()
- q._createCppHandle()
- self.assertEqual(3, q.spaceDim)
- self.assertEqual(1, q.cellDim)
- self.failIfEqual(None, q.cppHandle)
-
- q = Quadrature2D()
- q._createCppHandle()
- self.assertEqual(2, q.spaceDim)
- self.assertEqual(2, q.cellDim)
- self.failIfEqual(None, q.cppHandle)
-
- q = Quadrature2Din3D()
- q._createCppHandle()
- self.assertEqual(3, q.spaceDim)
- self.assertEqual(2, q.cellDim)
- self.failIfEqual(None, q.cppHandle)
-
- q = Quadrature3D()
- q._createCppHandle()
- self.assertEqual(3, q.spaceDim)
- self.assertEqual(3, q.cellDim)
- self.failIfEqual(None, q.cppHandle)
-
- return
-
-
-# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/feassemble/TestSubMeshQuadrature.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/feassemble/TestSubMeshQuadrature.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/TestSubMeshQuadrature.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/TestSubMeshQuadrature.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,218 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/feassemble/TestSubMeshQuadrature.py
+
+## @brief Unit testing of Python SubMeshQuadrature object.
+
+import unittest
+import numpy
+
+from pylith.feassemble.Quadrature import SubMeshQuadrature
+from pylith.feassemble.FIATSimplex import FIATSimplex
+from pylith.feassemble.FIATLagrange import FIATLagrange
+
+# ----------------------------------------------------------------------
+def N0(p):
+ return -0.5*p*(1.0-p)
+
+def N0p(p):
+ return -0.5*(1.0-p) + 0.5*p
+
+def N1(p):
+ return 0.5*p*(1.0+p)
+
+def N1p(p):
+ return +0.5*(1.0+p) + 0.5*p
+
+def N2(p):
+ return (1.0-p**2)
+
+def N2p(p):
+ return -2.0*p
+
+# ----------------------------------------------------------------------
+class TestSubMeshQuadrature(unittest.TestCase):
+ """
+ Unit testing of Python SubMeshQuadrature object.
+ """
+
+ def test_minJacobian(self):
+ """
+ Test minJacobian().
+ """
+ minJacobian = 4.0e-02;
+ q = SubMeshQuadrature()
+ q.minJacobian(minJacobian)
+ self.assertEqual(minJacobian, q.minJacobian())
+ return
+
+
+ def test_checkConditioning(self):
+ """
+ Test checkConditioning().
+ """
+ q = SubMeshQuadrature()
+
+ flag = False # default
+ self.assertEqual(flag, q.checkConditioning())
+
+ flag = True
+ q.checkConditioning(flag)
+ self.assertEqual(flag, q.checkConditioning())
+
+ flag = False
+ q.checkConditioning(flag)
+ self.assertEqual(flag, q.checkConditioning())
+
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ cell = FIATSimplex()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 2
+ cell.inventory.order = 2
+ cell._configure()
+
+ verticesE = numpy.array([ [-1.0], [1.0], [0.0] ])
+ quadPtsE = numpy.array( [[-1.0/3**0.5],
+ [+1.0/3**0.5]],
+ dtype=numpy.float64 )
+ quadWtsE = numpy.array( [1.0, 1.0], dtype=numpy.float64 )
+
+ # Compute basis functions and derivatives at quadrature points
+ basisE = numpy.zeros( (2, 3), dtype=numpy.float64)
+ basisDerivE = numpy.zeros( (2, 3, 1), dtype=numpy.float64)
+ iQuad = 0
+ for q in quadPtsE:
+ basisE[iQuad] = numpy.array([N0(q), N1(q), N2(q)],
+ dtype=numpy.float64).reshape( (3,) )
+ deriv = numpy.array([[N0p(q)], [N1p(q)], [N2p(q)]],
+ dtype=numpy.float64)
+ basisDerivE[iQuad] = deriv.reshape((3, 1))
+ iQuad += 1
+
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim=2)
+ quadrature.initialize()
+
+ self.assertEqual(1, quadrature.cellDim())
+ self.assertEqual(2, quadrature.spaceDim())
+ self.assertEqual(3, quadrature.numBasis())
+ self.assertEqual(2, quadrature.numQuadPts())
+
+ from pylith.utils.testarray import test_double
+ from pylith.utils.utils import TestArray_checkDouble
+
+ self.assertTrue(TestArray_checkDouble(basisE.ravel(),
+ quadrature.basis()))
+ self.assertTrue(TestArray_checkDouble(basisDerivE.ravel(),
+ quadrature.basisDerivRef()))
+ self.assertTrue(TestArray_checkDouble(quadPtsE.ravel(),
+ quadrature.quadPtsRef()))
+ self.assertTrue(TestArray_checkDouble(quadWtsE.ravel(),
+ quadrature.quadWts()))
+ return
+
+
+ def test_simplex1D(self):
+ """
+ Test setup of quadrature for simplex cells for a 1-D problem in 2-D space.
+ """
+ spaceDim = 2
+
+ cell = FIATSimplex()
+ cell.inventory.shape = "line"
+ cell._configure()
+
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(1, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(2, quadrature.numBasis())
+ return
+
+
+ def test_simplex2D(self):
+ """
+ Test setup of quadrature for simplex cells for a 2-D problem in 3-D space.
+ """
+ spaceDim = 3
+
+ cell = FIATSimplex()
+ cell.inventory.shape = "triangle"
+ cell._configure()
+
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(2, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(3, quadrature.numBasis())
+ return
+
+
+ def test_lagrange1D(self):
+ """
+ Test setup of quadrature for Lagrange cells for a 1-D problem in 2-D space.
+ """
+ spaceDim = 2
+
+ cell = FIATLagrange()
+ cell.inventory.dimension = 1
+ cell._configure()
+
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(1, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(2, quadrature.numBasis())
+ return
+
+
+ def test_lagrange2D(self):
+ """
+ Test setup of quadrature for Lagrange cells for a 2-D problem in 3-D space.
+ """
+ spaceDim = 3
+
+ cell = FIATLagrange()
+ cell.inventory.dimension = 2
+ cell._configure()
+
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ quadrature.preinitialize(spaceDim)
+ self.assertEqual(2, quadrature.cellDim())
+ self.assertEqual(spaceDim, quadrature.spaceDim())
+ self.assertEqual(4, quadrature.numBasis())
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/feassemble/testfeassemble.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -63,18 +63,18 @@
from TestFIATLagrange import TestFIATLagrange
suite.addTest(unittest.makeSuite(TestFIATLagrange))
- from TestQuadrature import TestQuadrature
- suite.addTest(unittest.makeSuite(TestQuadrature))
+ from TestMeshQuadrature import TestMeshQuadrature
+ suite.addTest(unittest.makeSuite(TestMeshQuadrature))
- from TestIntegrator import TestIntegrator
- suite.addTest(unittest.makeSuite(TestIntegrator))
+ from TestSubMeshQuadrature import TestSubMeshQuadrature
+ suite.addTest(unittest.makeSuite(TestSubMeshQuadrature))
+ from TestElasticityImplicit import TestElasticityImplicit
+ suite.addTest(unittest.makeSuite(TestElasticityImplicit))
+
from TestElasticityExplicit import TestElasticityExplicit
suite.addTest(unittest.makeSuite(TestElasticityExplicit))
- from TestElasticityImplicit import TestElasticityImplicit
- suite.addTest(unittest.makeSuite(TestElasticityImplicit))
-
return suite
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticIsotropic3D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,35 +24,52 @@
Unit testing of ElasticIsotropic3D object.
"""
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ self.material = ElasticIsotropic3D()
+ return
+
+
def test_constructor(self):
"""
Test constructor.
"""
- from pylith.materials.ElasticIsotropic3D import ElasticIsotropic3D
- material = ElasticIsotropic3D()
- material._createCppHandle()
- self.assertNotEqual(None, material.cppHandle)
+ self.assertEqual(3, self.material.dimension())
return
- def test_dimension(self):
+ def test_useElasticBehavior(self):
"""
- Test dimension().
+ Test useElasticBehavior().
"""
- material = ElasticIsotropic3D()
- material._createCppHandle()
- self.assertEqual(3, material.dimension)
+ self.material.useElasticBehavior(False)
return
- def test_useElasticBehavior(self):
+ def testHasStateVars(self):
+ self.failIf(self.material.hasStateVars())
+ return
+
+
+ def testTensorSize(self):
+ self.assertEqual(6, self.material.tensorSize())
+ return
+
+
+ def testNeedNewJacobian(self):
"""
- Test useElasticBehavior().
+ Test needNewJacobian().
"""
- material = ElasticIsotropic3D()
- material._createCppHandle()
- material.useElasticBehavior(False)
+ # Default should be False.
+ self.failIf(self.material.needNewJacobian())
+
+ # Changing time step should not require new Jacobian.
+ self.material.timeStep(1.0)
+ self.material.timeStep(2.0)
+ self.failIf(self.material.needNewJacobian())
return
+
-
# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticMaterial.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/materials/TestElasticMaterial.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticMaterial.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticMaterial.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/materials/TestElasticMaterial.py
+
+## @brief Unit testing of Material object.
+
+import unittest
+
+# ----------------------------------------------------------------------
+class TestElasticMaterial(unittest.TestCase):
+ """
+ Unit testing of ElasticMaterial object.
+ """
+
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ from pylith.materials.ElasticStrain1D import ElasticStrain1D
+ self.material = ElasticStrain1D()
+ return
+
+
+ def testDBInitialStress(self):
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+ iohandler = SimpleIOAscii()
+ iohandler.inventory.filename = "data/matinitialize.spatialdb"
+ iohandler._configure()
+ db = SimpleDB()
+ db.inventory.label = "material properties"
+ db.inventory.iohandler = iohandler
+ db._configure()
+
+ self.material.dbInitialStress(db)
+
+ # No test of result.
+ return
+
+
+ def testDBInitialStrain(self):
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+ iohandler = SimpleIOAscii()
+ iohandler.inventory.filename = "data/matinitialize.spatialdb"
+ iohandler._configure()
+ db = SimpleDB()
+ db.inventory.label = "material properties"
+ db.inventory.iohandler = iohandler
+ db._configure()
+
+ self.material.dbInitialStrain(db)
+
+ # No test of result.
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStrain.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,34 +24,52 @@
Unit testing of ElasticPlaneStrain object.
"""
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ self.material = ElasticPlaneStrain()
+ return
+
+
def test_constructor(self):
"""
Test constructor.
"""
- material = ElasticPlaneStrain()
- material._createCppHandle()
- self.assertNotEqual(None, material.cppHandle)
+ self.assertEqual(2, self.material.dimension())
return
- def test_dimension(self):
+ def test_useElasticBehavior(self):
"""
- Test dimension().
+ Test useElasticBehavior().
"""
- material = ElasticPlaneStrain()
- material._createCppHandle()
- self.assertEqual(2, material.dimension)
+ self.material.useElasticBehavior(False)
return
- def test_useElasticBehavior(self):
+ def testHasStateVars(self):
+ self.failIf(self.material.hasStateVars())
+ return
+
+
+ def testTensorSize(self):
+ self.assertEqual(3, self.material.tensorSize())
+ return
+
+
+ def testNeedNewJacobian(self):
"""
- Test useElasticBehavior().
+ Test needNewJacobian().
"""
- material = ElasticPlaneStrain()
- material._createCppHandle()
- material.useElasticBehavior(False)
+ # Default should be False.
+ self.failIf(self.material.needNewJacobian())
+
+ # Changing time step should not require new Jacobian.
+ self.material.timeStep(1.0)
+ self.material.timeStep(2.0)
+ self.failIf(self.material.needNewJacobian())
return
+
-
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticPlaneStress.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,34 +24,52 @@
Unit testing of ElasticPlaneStress object.
"""
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ self.material = ElasticPlaneStress()
+ return
+
+
def test_constructor(self):
"""
Test constructor.
"""
- material = ElasticPlaneStress()
- material._createCppHandle()
- self.assertNotEqual(None, material.cppHandle)
+ self.assertEqual(2, self.material.dimension())
return
- def test_dimension(self):
+ def test_useElasticBehavior(self):
"""
- Test dimension().
+ Test useElasticBehavior().
"""
- material = ElasticPlaneStress()
- material._createCppHandle()
- self.assertEqual(2, material.dimension)
+ self.material.useElasticBehavior(False)
return
- def test_useElasticBehavior(self):
+ def testHasStateVars(self):
+ self.failIf(self.material.hasStateVars())
+ return
+
+
+ def testTensorSize(self):
+ self.assertEqual(3, self.material.tensorSize())
+ return
+
+
+ def testNeedNewJacobian(self):
"""
- Test useElasticBehavior().
+ Test needNewJacobian().
"""
- material = ElasticPlaneStress()
- material._createCppHandle()
- material.useElasticBehavior(False)
+ # Default should be False.
+ self.failIf(self.material.needNewJacobian())
+
+ # Changing time step should not require new Jacobian.
+ self.material.timeStep(1.0)
+ self.material.timeStep(2.0)
+ self.failIf(self.material.needNewJacobian())
return
+
-
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStrain1D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,34 +24,52 @@
Unit testing of ElasticStrain1D object.
"""
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ self.material = ElasticStrain1D()
+ return
+
+
def test_constructor(self):
"""
Test constructor.
"""
- material = ElasticStrain1D()
- material._createCppHandle()
- self.assertNotEqual(None, material.cppHandle)
+ self.assertEqual(1, self.material.dimension())
return
- def test_dimension(self):
+ def test_useElasticBehavior(self):
"""
- Test dimension().
+ Test useElasticBehavior().
"""
- material = ElasticStrain1D()
- material._createCppHandle()
- self.assertEqual(1, material.dimension)
+ self.material.useElasticBehavior(False)
return
- def test_useElasticBehavior(self):
+ def testHasStateVars(self):
+ self.failIf(self.material.hasStateVars())
+ return
+
+
+ def testTensorSize(self):
+ self.assertEqual(1, self.material.tensorSize())
+ return
+
+
+ def testNeedNewJacobian(self):
"""
- Test useElasticBehavior().
+ Test needNewJacobian().
"""
- material = ElasticStrain1D()
- material._createCppHandle()
- material.useElasticBehavior(False)
+ # Default should be False.
+ self.failIf(self.material.needNewJacobian())
+
+ # Changing time step should not require new Jacobian.
+ self.material.timeStep(1.0)
+ self.material.timeStep(2.0)
+ self.failIf(self.material.needNewJacobian())
return
+
-
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestElasticStress1D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,34 +24,52 @@
Unit testing of ElasticStress1D object.
"""
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ self.material = ElasticStress1D()
+ return
+
+
def test_constructor(self):
"""
Test constructor.
"""
- material = ElasticStress1D()
- material._createCppHandle()
- self.assertNotEqual(None, material.cppHandle)
+ self.assertEqual(1, self.material.dimension())
return
- def test_dimension(self):
+ def test_useElasticBehavior(self):
"""
- Test dimension().
+ Test useElasticBehavior().
"""
- material = ElasticStress1D()
- material._createCppHandle()
- self.assertEqual(1, material.dimension)
+ self.material.useElasticBehavior(False)
return
- def test_useElasticBehavior(self):
+ def testHasStateVars(self):
+ self.failIf(self.material.hasStateVars())
+ return
+
+
+ def testTensorSize(self):
+ self.assertEqual(1, self.material.tensorSize())
+ return
+
+
+ def testNeedNewJacobian(self):
"""
- Test useElasticBehavior().
+ Test needNewJacobian().
"""
- material = ElasticStress1D()
- material._createCppHandle()
- material.useElasticBehavior(False)
+ # Default should be False.
+ self.failIf(self.material.needNewJacobian())
+
+ # Changing time step should not require new Jacobian.
+ self.material.timeStep(1.0)
+ self.material.timeStep(2.0)
+ self.failIf(self.material.needNewJacobian())
return
+
-
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestMaterial.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -22,64 +22,157 @@
Unit testing of Material object.
"""
- def test_initialize(self):
+ def setUp(self):
"""
- Test initialize().
+ Setup test subject.
+ """
+ from pylith.materials.ElasticStrain1D import ElasticStrain1D
+ self.material = ElasticStrain1D()
+ return
+
+ def testId(self):
+ """
+ Test id().
+ """
+ id = 1234
+ self.material.id(id)
+ self.assertEqual(id, self.material.id())
+ return
+
+
+ def testLabel(self):
+ """
+ Test label().
+ """
+ label = "material abc"
+ self.material.label(label)
+ self.assertEqual(label, self.material.label())
+ return
+
+
+ def testTimeStep(self):
+ """
+ Test timeStep().
+ """
+ dt = 0.5
+ self.material.timeStep(dt)
+ self.assertEqual(dt, self.material.timeStep())
+ return
+
+
+ def testDBProperties(self):
+ """
+ Test dbProperties().
+ """
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+ iohandler = SimpleIOAscii()
+ iohandler.inventory.filename = "data/matinitialize.spatialdb"
+ iohandler._configure()
+ db = SimpleDB()
+ db.inventory.label = "material properties"
+ db.inventory.iohandler = iohandler
+ db._configure()
+
+ self.material.dbProperties(db)
+
+ # No test of result.
+ return
+
+
+ def testDBInitialState(self):
+ """
+ Test dbInitialState().
+ """
+ from spatialdata.spatialdb.SimpleDB import SimpleDB
+ from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
+ iohandler = SimpleIOAscii()
+ iohandler.inventory.filename = "data/matinitialize.spatialdb"
+ iohandler._configure()
+ db = SimpleDB()
+ db.inventory.label = "material properties"
+ db.inventory.iohandler = iohandler
+ db._configure()
+
+ self.material.dbInitialState(db)
+
+ # No test of result.
+ return
+
+
+ def testNormalizer(self):
+ """
+ Test normalizer().
+ """
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+
+ self.material.normalizer(normalizer)
+
+ # No test of result.
+ return
+
+
+ def test_preinitialize(self):
+ """
+ Test preinitialize().
+
WARNING: This is not a rigorous test of initialize() because we
don't verify the results.
"""
- from pylith.materials.ElasticStrain1D import ElasticStrain1D
- material = ElasticStrain1D()
-
- from pylith.feassemble.quadrature.Quadrature1D import Quadrature1D
- quadrature = Quadrature1D()
- quadrature._configure()
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "line"
- cell.order = 1
- cell.degree = 1
- quadrature.cell = cell
- quadrature.minJacobian = 1.0e-4
- quadrature.preinitialize()
- material.quadrature = quadrature
+ cell.inventory.shape = "line"
+ cell.inventory.order = 1
+ cell.inventory.degree = 1
+ cell._configure()
+ from pylith.feassemble.Quadrature import MeshQuadrature
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature.inventory.minJacobian = 1.0e-4
+ quadrature._configure()
+
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
- iohandler.filename = "data/matinitialize.spatialdb"
+ iohandler.inventory.filename = "data/matinitialize.spatialdb"
+ iohandler._configure()
db = SimpleDB()
- db.label = "material properties"
- db.iohandler = iohandler
- initialStateDB = None
- material.db = db
- material.label = "my material"
- material.id = 54
- material.initialStateDB = initialStateDB
+ db.inventory.label = "material properties"
+ db.inventory.iohandler = iohandler
+ db._configure()
+ from pylith.materials.ElasticStrain1D import ElasticStrain1D
+ material = ElasticStrain1D()
+ material.inventory.quadrature = quadrature
+ material.inventory.dbProperties = db
+ material.inventory.label = "my material"
+ material.inventory.id = 54
+ material._configure()
+
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
- cs.spaceDim = 1
+ cs.inventory.spaceDim = 1
+ cs._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/twoelems.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/twoelems.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
- material.preinitialize()
- from pyre.units.time import second
- totalTime = 0.0*second
- numTimeSteps = 1
- material.initialize(mesh, totalTime, numTimeSteps, normalizer)
+ material.preinitialize(mesh)
- # We should really add something here to check to make sure things
- # actually initialized correctly
+ # No test of result.
return
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/TestMaxwellIsotropic3D.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,35 +24,52 @@
Unit testing of MaxwellIsotropic3D object.
"""
+ def setUp(self):
+ """
+ Setup test subject.
+ """
+ self.material = MaxwellIsotropic3D()
+ return
+
+
def test_constructor(self):
"""
Test constructor.
"""
- from pylith.materials.MaxwellIsotropic3D import MaxwellIsotropic3D
- material = MaxwellIsotropic3D()
- material._createCppHandle()
- self.assertNotEqual(None, material.cppHandle)
+ self.assertEqual(3, self.material.dimension())
return
- def test_dimension(self):
+ def test_useElasticBehavior(self):
"""
- Test dimension().
+ Test useElasticBehavior().
"""
- material = MaxwellIsotropic3D()
- material._createCppHandle()
- self.assertEqual(3, material.dimension)
+ self.material.useElasticBehavior(False)
return
- def test_useElasticBehavior(self):
+ def testHasStateVars(self):
+ self.failUnless(self.material.hasStateVars())
+ return
+
+
+ def testTensorSize(self):
+ self.assertEqual(6, self.material.tensorSize())
+ return
+
+
+ def testNeedNewJacobian(self):
"""
- Test useElasticBehavior().
+ Test needNewJacobian().
"""
- material = MaxwellIsotropic3D()
- material._createCppHandle()
- material.useElasticBehavior(False)
+ # Default should be False.
+ self.failIf(self.material.needNewJacobian())
+
+ # Changing time step should not require new Jacobian.
+ self.material.timeStep(1.0)
+ self.material.timeStep(2.0)
+ self.failUnless(self.material.needNewJacobian())
return
+
-
# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/materials/testmaterials.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -56,11 +56,11 @@
suite = unittest.TestSuite()
- from TestMaterial import TestMaterial
- suite.addTest(unittest.makeSuite(TestMaterial))
+ from TestElasticStrain1D import TestElasticStrain1D
+ suite.addTest(unittest.makeSuite(TestElasticStrain1D))
- from TestElasticIsotropic3D import TestElasticIsotropic3D
- suite.addTest(unittest.makeSuite(TestElasticIsotropic3D))
+ from TestElasticStress1D import TestElasticStress1D
+ suite.addTest(unittest.makeSuite(TestElasticStress1D))
from TestElasticPlaneStrain import TestElasticPlaneStrain
suite.addTest(unittest.makeSuite(TestElasticPlaneStrain))
@@ -68,18 +68,21 @@
from TestElasticPlaneStress import TestElasticPlaneStress
suite.addTest(unittest.makeSuite(TestElasticPlaneStress))
- from TestElasticStrain1D import TestElasticStrain1D
- suite.addTest(unittest.makeSuite(TestElasticStrain1D))
+ from TestElasticIsotropic3D import TestElasticIsotropic3D
+ suite.addTest(unittest.makeSuite(TestElasticIsotropic3D))
- from TestElasticStress1D import TestElasticStress1D
- suite.addTest(unittest.makeSuite(TestElasticStress1D))
-
from TestMaxwellIsotropic3D import TestMaxwellIsotropic3D
suite.addTest(unittest.makeSuite(TestMaxwellIsotropic3D))
- from TestGenMaxwellIsotropic3D import TestGenMaxwellIsotropic3D
- suite.addTest(unittest.makeSuite(TestGenMaxwellIsotropic3D))
+ #from TestGenMaxwellIsotropic3D import TestGenMaxwellIsotropic3D
+ #suite.addTest(unittest.makeSuite(TestGenMaxwellIsotropic3D))
+ from TestMaterial import TestMaterial
+ suite.addTest(unittest.makeSuite(TestMaterial))
+
+ from TestElasticMaterial import TestElasticMaterial
+ suite.addTest(unittest.makeSuite(TestElasticMaterial))
+
from TestHomogeneous import TestHomogeneous
suite.addTest(unittest.makeSuite(TestHomogeneous))
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,8 +15,8 @@
SUBDIRS = data
-TESTS = testdriver.py
-dist_check_SCRIPTS = testdriver.py
+TESTS = testmeshio.py
+dist_check_SCRIPTS = testmeshio.py
TESTS_ENVIRONMENT = $(PYTHON)
@@ -30,8 +30,8 @@
TestOutputSolnSubset.py
if ENABLE_CUBIT
- TESTS += testdriver_cubit.py
- dist_check_SCRIPTS += testdriver_cubit.py
+ TESTS += testcubit.py
+ dist_check_SCRIPTS += testcubit.py
endif
noinst_tmp = \
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestCellFilterAvg.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,10 +16,11 @@
import unittest
-from pylith.meshio.CellFilterAvg import CellFilterAvg
+from pylith.meshio.CellFilterAvgMesh import CellFilterAvgMesh
+from pylith.meshio.CellFilterAvgSubMesh import CellFilterAvgSubMesh
# ----------------------------------------------------------------------
-class TestCellFilterAvg(unittest.TestCase):
+class TestCellFilterAvgMesh(unittest.TestCase):
"""
Unit testing of Python CellFilterAvg object.
"""
@@ -28,7 +29,7 @@
"""
Test constructor.
"""
- filter = CellFilterAvg()
+ filter = CellFilterAvgMesh()
filter._configure()
return
@@ -37,24 +38,25 @@
"""
Test constructor.
"""
- from pylith.feassemble.quadrature.Quadrature1D import Quadrature1D
+ spaceDim = 1
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 2
- cell.order = 2
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 2
+ cell.inventory.order = 2
+ cell._configure()
- quadrature = Quadrature1D()
+ from pylith.feassemble.Quadrature import MeshQuadrature
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
quadrature._configure()
- quadrature.cell = cell
- quadrature.preinitialize()
+ quadrature.preinitialize(spaceDim)
quadrature.initialize()
- filter = CellFilterAvg()
+ filter = CellFilterAvgMesh()
filter._configure()
filter.initialize(quadrature)
- self.assertNotEqual(None, filter.cppHandle)
return
@@ -62,9 +64,59 @@
"""
Test factory method.
"""
- from pylith.meshio.CellFilterAvg import output_cell_filter
+ from pylith.meshio.CellFilterAvgMesh import output_cell_filter
filter = output_cell_filter()
return
+# ----------------------------------------------------------------------
+class TestCellFilterAvgSubMesh(unittest.TestCase):
+ """
+ Unit testing of Python CellFilterAvg object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ filter = CellFilterAvgSubMesh()
+ filter._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test constructor.
+ """
+ spaceDim = 2
+
+ from pylith.feassemble.FIATSimplex import FIATSimplex
+ cell = FIATSimplex()
+ cell.inventory.shape = "line"
+ cell.inventory.degree = 2
+ cell.inventory.order = 2
+ cell._configure()
+
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+ quadrature.preinitialize(spaceDim)
+ quadrature.initialize()
+
+ filter = CellFilterAvgSubMesh()
+ filter._configure()
+ filter.initialize(quadrature)
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.CellFilterAvgSubMesh import output_cell_filter
+ filter = output_cell_filter()
+ return
+
+
# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/meshio/TestDataWriterVTK.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestDataWriterVTK.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestDataWriterVTK.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestDataWriterVTK.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,134 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/meshio/TestDataWriterVTK.py
+
+## @brief Unit testing of Python DataWriterVTK object.
+
+import unittest
+
+from pylith.meshio.DataWriterVTKMesh import DataWriterVTKMesh
+from pylith.meshio.DataWriterVTKSubMesh import DataWriterVTKSubMesh
+from pylith.meshio.DataWriterVTKSubSubMesh import DataWriterVTKSubSubMesh
+
+# ----------------------------------------------------------------------
+class TestDataWriterVTKMesh(unittest.TestCase):
+ """
+ Unit testing of Python DataWriterVTKMesh object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ filter = DataWriterVTKMesh()
+ filter._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test constructor.
+ """
+ filter = DataWriterVTKMesh()
+ filter._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ filter.initialize(normalizer)
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.DataWriterVTKMesh import output_data_writer
+ filter = output_data_writer()
+ return
+
+
+# ----------------------------------------------------------------------
+class TestDataWriterVTKSubMesh(unittest.TestCase):
+ """
+ Unit testing of Python DataWriterVTK object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ filter = DataWriterVTKSubMesh()
+ filter._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test constructor.
+ """
+ filter = DataWriterVTKSubMesh()
+ filter._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ filter.initialize(normalizer)
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.DataWriterVTKSubMesh import output_data_writer
+ filter = output_data_writer()
+ return
+
+
+# ----------------------------------------------------------------------
+class TestDataWriterVTKSubSubMesh(unittest.TestCase):
+ """
+ Unit testing of Python DataWriterVTK object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ filter = DataWriterVTKSubSubMesh()
+ filter._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test constructor.
+ """
+ filter = DataWriterVTKSubSubMesh()
+ filter._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ filter.initialize(normalizer)
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.DataWriterVTKSubSubMesh import output_data_writer
+ filter = output_data_writer()
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOAscii.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -28,10 +28,7 @@
"""
Test constructor.
"""
- iohandler = MeshIOAscii()
- iohandler._configure()
- iohandler._sync()
- self.assertNotEqual(None, iohandler.cppHandle)
+ io = MeshIOAscii()
return
@@ -39,10 +36,11 @@
"""
Test filename().
"""
- iohandler = MeshIOAscii()
value = "hi.txt"
- iohandler.filename = value
- self.assertEqual(value, iohandler.filename)
+
+ io = MeshIOAscii()
+ io.filename(value)
+ self.assertEqual(value, io.filename())
return
@@ -50,25 +48,26 @@
"""
Test write() and read().
"""
- iohandler = MeshIOAscii()
filenameIn = "data/mesh2Din3D.txt"
filenameOut = "data/mesh2Din3D_test.txt"
+
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs._configure()
+
+ io = MeshIOAscii()
+ io.inventory.filename = filenameIn
+ io.inventory.coordsys = cs
+ io._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
- from spatialdata.geocoords.CSCart import CSCart
- iohandler.filename = filenameIn
- iohandler.coordsys = CSCart()
- mesh = iohandler.read(normalizer, debug=False, interpolate=False)
+ mesh = io.read(normalizer, debug=False, interpolate=False)
- self.assertEqual(2, mesh.dimension())
+ io.filename(filenameOut)
+ io.write(mesh)
- iohandler.filename = filenameOut
- iohandler.write(mesh)
-
-
fileE = open(filenameIn, "r")
linesE = fileE.readlines()
fileE.close()
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOCubit.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOCubit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOCubit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,10 +29,7 @@
"""
Test constructor.
"""
- iohandler = MeshIOCubit()
- iohandler._configure()
- iohandler._sync()
- self.assertNotEqual(None, iohandler.cppHandle)
+ io = MeshIOCubit()
return
@@ -40,10 +37,11 @@
"""
Test filename().
"""
- iohandler = MeshIOCubit()
value = "hi.txt"
- iohandler.filename = value
- self.assertEqual(value, iohandler.filename)
+
+ io = MeshIOCubit()
+ io.filename(value)
+ self.assertEqual(value, io.filename())
return
@@ -51,27 +49,27 @@
"""
Test read().
"""
- from spatialdata.geocoords.CSCart import CSCart
-
- # For now, we only test reading the file.
- iohandler = MeshIOCubit()
-
filenameIn = "data/twohex8.exo"
filenameOut = "data/twohex8_test.txt"
filenameE = "data/twohex8.txt"
+
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs._configure()
+
+ # For now, we only test reading the file.
+ io = MeshIOCubit()
+ io.inventory.filename = filenameIn
+ io._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
- iohandler.filename = filenameIn
- iohandler.coordsys = CSCart()
- mesh = iohandler.read(normalizer, debug=False, interpolate=False)
- self.assertEqual(3, mesh.dimension())
+ mesh = io.read(normalizer, debug=False, interpolate=False)
testhandler = MeshIOAscii()
- testhandler.filename = filenameOut
- testhandler.coordsys = CSCart()
+ testhandler.filename(filenameOut)
+ testhandler.coordsys = cs
testhandler.write(mesh)
fileE = open(filenameE, "r")
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOLagrit.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOLagrit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestMeshIOLagrit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -29,10 +29,7 @@
"""
Test constructor.
"""
- iohandler = MeshIOLagrit()
- iohandler._configure()
- iohandler._sync()
- self.assertNotEqual(None, iohandler.cppHandle)
+ io = MeshIOLagrit()
return
@@ -40,14 +37,14 @@
"""
Test filename().
"""
- iohandler = MeshIOLagrit()
- iohandler._configure()
valueGmv = "hi.txt"
valuePset = "hi2.txt"
- iohandler.filenameGmv = valueGmv
- iohandler.filenamePset = valuePset
- self.assertEqual(valueGmv, iohandler.filenameGmv)
- self.assertEqual(valuePset, iohandler.filenamePset)
+
+ io = MeshIOLagrit()
+ io.filenameGmv(valueGmv)
+ io.filenamePset(valuePset)
+ self.assertEqual(valueGmv, io.filenameGmv())
+ self.assertEqual(valuePset, io.filenamePset())
return
@@ -55,31 +52,30 @@
"""
Test read().
"""
+ filenameGmvIn = "data/cube2_ascii.gmv"
+ filenamePsetIn = "data/cube2_ascii.pset"
+ filenameOut = "data/cube2_test.txt"
+ filenameE = "data/cube2.txt"
+
from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs._configure()
# For now, we only test reading the file. We would like to write
# the file and compare against the original.
- iohandler = MeshIOLagrit()
- iohandler._configure()
+ io = MeshIOLagrit()
+ io.inventory.filenameGmv = filenameGmvIn
+ io.inventory.filenamePset = filenamePsetIn
+ io._configure()
- filenameGmvIn = "data/cube2_ascii.gmv"
- filenamePsetIn = "data/cube2_ascii.pset"
- filenameOut = "data/cube2_test.txt"
- filenameE = "data/cube2.txt"
-
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
- iohandler.filenameGmv = filenameGmvIn
- iohandler.filenamePset = filenamePsetIn
- iohandler.coordsys = CSCart()
- mesh = iohandler.read(normalizer, debug=False, interpolate=False)
- self.assertEqual(3, mesh.dimension())
+ mesh = io.read(normalizer, debug=False, interpolate=False)
testhandler = MeshIOAscii()
- testhandler.filename = filenameOut
- testhandler.coordsys = CSCart()
+ testhandler.filename(filenameOut)
+ testhandler.coordsys = cs
testhandler.write(mesh)
fileE = open(filenameE, "r")
Deleted: short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManager.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManager.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManager.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,328 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/meshio/TestOutputManager.py
-
-## @brief Unit testing of Python OutputManager object.
-
-import unittest
-
-from pylith.meshio.OutputManager import OutputManager
-
-# ----------------------------------------------------------------------
-class TestProvider(object):
-
- def __init__(self):
- """
- Constructor.
- """
- self.availableFields = \
- {'vertex': \
- {'info': ["vertex info"],
- 'data': ["vertex data 1",
- "vertex data 2"]},
- 'cell': \
- {'info': ["cell info"],
- 'data': ["cell data"]}}
-
- from pylith.meshio.MeshIOAscii import MeshIOAscii
- iohandler = MeshIOAscii()
- filename = "data/twohex8.txt"
-
- from spatialdata.units.Nondimensional import Nondimensional
- normalizer = Nondimensional()
- normalizer.initialize()
-
- from spatialdata.geocoords.CSCart import CSCart
- iohandler.filename = filename
- iohandler.coordsys = CSCart()
- mesh = iohandler.read(normalizer, debug=False, interpolate=False)
-
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
-
- self.mesh = mesh
- self.fields = fields
- return
-
-
- def getDataMesh(self):
- """
- Get mesh.
- """
- return (self.mesh, None, None)
-
-
- def getVertexField(self, name, fields=None):
- """
- Get vertex field.
- """
- if name == "vertex info":
- fieldType = 0
- fiberDim = 1
- elif name == "vertex data 1":
- fieldType = 1
- fiberDim = self.mesh.dimension()
- elif name == "vertex data 2":
- fieldType = 3
- fiberDim = 5
- else:
- raise ValueError("Unknown field '%s'." % name)
-
- self.fields.addReal(name)
- self.fields.setFiberDimension(name, fiberDim)
- self.fields.allocate(name)
- field = self.fields.getReal(name)
- return (field, fieldType)
-
-
- def getCellField(self, name, fields=None):
- """
- Get cell field.
- """
- if name == "cell info":
- fieldType = 0
- fiberDim = 1
- elif name == "cell data":
- fieldType = 1
- fiberDim = self.mesh.dimension()
- else:
- raise ValueError("Unknown field '%s'." % name)
-
- self.fields.addReal(name)
- self.fields.setFiberDimension(name, fiberDim, "cells")
- self.fields.allocate(name)
- field = self.fields.getReal(name)
- return (field, fieldType)
-
-
-# ----------------------------------------------------------------------
-class TestOutputManager(unittest.TestCase):
- """
- Unit testing of Python OutputManager object.
- """
-
- def setUp(self):
- from spatialdata.units.Nondimensional import Nondimensional
- self.normalizer = Nondimensional()
- self.normalizer.initialize()
- return
-
-
- def test_constructor(self):
- """
- Test constructor.
- """
- output = OutputManager()
- output._configure()
- output.writer._configure()
- return
-
-
- def test_sync(self):
- """
- Test _sync().
- """
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.writer.initialize(self.normalizer)
- output._sync()
- self.assertNotEqual(None, output.cppHandle)
- return
-
-
- def test_preinitialize(self):
- """
- Test preinitialize().
- """
- output = OutputManager()
- dataProvider = TestProvider()
- output.preinitialize(dataProvider)
-
- self.assertEqual(dataProvider, output.dataProvider)
- return
-
-
- def test_verifyConfiguration(self):
- """
- Test verifyConfiguration().
- """
- output = OutputManager()
- dataProvider = TestProvider()
- output.preinitialize(dataProvider)
-
- output.vertexInfoFields = ["vertex info"]
- output.vertexDataFields = ["vertex data 2"]
- output.cellInfoFields = []
- output.cellDataFields = ["cell data"]
- output.verifyConfiguration(dataProvider.getDataMesh())
- return
-
-
- def test_initialize(self):
- """
- Test initialize().
- """
- # No quadrature
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.writer.filename = "test.vtk"
- dataProvider = TestProvider()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer)
- self.assertNotEqual(None, output.cppHandle)
-
- # With quadrature
- from pylith.feassemble.FIATSimplex import FIATSimplex
- from pylith.feassemble.quadrature.Quadrature1D import Quadrature1D
- cell = FIATSimplex()
- cell.shape = "line"
- cell.degree = 2
- cell.order = 2
-
- quadrature = Quadrature1D()
- quadrature.cell = cell
-
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.writer.filename = "test.vtk"
- dataProvider = TestProvider()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer, quadrature)
- self.assertNotEqual(None, output.cppHandle)
- return
-
-
- def test_openclose(self):
- """
- Test open() and close().
- """
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.writer.filename = "output.vtk"
- dataProvider = TestProvider()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer)
-
- output.open(totalTime=5.0, numTimeSteps=2)
- output.close()
- return
-
-
- def test_writeInfo(self):
- """
- Test writeInfo().
- """
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.writer.filename = "output.vtk"
- output.vertexInfoFields = ["vertex info"]
- output.cellInfoFields = ["cell info"]
-
- dataProvider = TestProvider()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer)
-
- output.open(totalTime=5.0, numTimeSteps=2)
- output.writeInfo()
- output.close()
- return
-
-
- def test_writeData(self):
- """
- Test writeData().
- """
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.writer.filename = "output.vtk"
- output.writer.timeFormat = "%3.1f"
- output.vertexDataFields = ["vertex data 2",
- "vertex data 1"]
- output.cellDataFields = ["cell data"]
-
- dataProvider = TestProvider()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer)
-
- output.open(totalTime=5.0, numTimeSteps=2)
- output.writeData(2.0, dataProvider.fields)
- output.close()
- return
-
-
- def test_checkWrite(self):
- """
- Test _checkWrite().
- """
- dataProvider = TestProvider()
-
- # Default values should be true
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer)
- self.assertEqual(True, output._checkWrite(0.0))
- self.assertEqual(True, output._checkWrite(3.234e+8))
-
- # Check writing based on time
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer)
-
- output.outputFreq = "time_step"
- t = 0.0
- dt = output.dt
- self.assertEqual(True, output._checkWrite(t))
- self.assertEqual(False, output._checkWrite(t))
- self.assertEqual(False, output._checkWrite(t + 0.8*dt))
- t += dt
- self.assertEqual(True, output._checkWrite(t))
- t = 2*dt
- self.assertEqual(True, output._checkWrite(t))
-
- # Check writing based on number of steps
- output = OutputManager()
- output._configure()
- output.writer._configure()
- output.preinitialize(dataProvider)
- output.initialize(self.normalizer)
- output.outputFreq = "skip"
- output.skip = 1
- t = 0.0
- dt = 1.0
- self.assertEqual(True, output._checkWrite(t))
- t += dt
- self.assertEqual(False, output._checkWrite(t))
- t += dt
- self.assertEqual(True, output._checkWrite(t))
- output.skip = 2
- t += dt
- self.assertEqual(False, output._checkWrite(t))
- t += dt
- self.assertEqual(False, output._checkWrite(t))
- t += dt
- self.assertEqual(True, output._checkWrite(t))
-
- return
-
-
-# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestOutputManagerMesh.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerMesh.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,322 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/meshio/TestOutputManagerMesh.py
+
+## @brief Unit testing of Python OutputManagerMesh object.
+
+import unittest
+
+from pylith.meshio.OutputManagerMesh import OutputManagerMesh
+
+# ----------------------------------------------------------------------
+class TestProvider(object):
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ self.availableFields = \
+ {'vertex': \
+ {'info': ["vertex info"],
+ 'data': ["vertex data 1",
+ "vertex data 2"]},
+ 'cell': \
+ {'info': ["cell info"],
+ 'data': ["cell data"]}}
+
+ filename = "data/twohex8.txt"
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ iohandler = MeshIOAscii()
+ iohandler.inventory.filename = filename
+ from spatialdata.geocoords.CSCart import CSCart
+ iohandler.inventory.coordsys = CSCart()
+ iohandler._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+ mesh = iohandler.read(normalizer, debug=False, interpolate=False)
+
+ from pylith.topology.Fields import MeshFields
+ fields = MeshFields(mesh)
+
+ self.mesh = mesh
+ self.fields = fields
+ return
+
+
+ def getDataMesh(self):
+ """
+ Get mesh.
+ """
+ return (self.mesh, None, None)
+
+
+ def getVertexField(self, name, fields=None):
+ """
+ Get vertex field.
+ """
+ from pylith.field.field.FieldBase import SCALAR,VECTOR,OTHER
+ if name == "vertex info":
+ fieldType = FieldBase.SCALAR
+ fiberDim = 1
+ elif name == "vertex data 1":
+ fieldType = FieldBase.VECTOR
+ fiberDim = self.mesh.dimension()
+ elif name == "vertex data 2":
+ fieldType = FieldBase.OTHER
+ fiberDim = 5
+ else:
+ raise ValueError("Unknown field '%s'." % name)
+
+ self.fields.add(name, name)
+ field = self.fields.get(name)
+ field.newSection(field.VERTICES_FIELD, fiberDim)
+ field.allocate()
+ field.vectorFieldType(fieldType)
+ self.fields.setFiberDimension(name, fiberDim)
+ self.fields.allocate(name)
+ field = self.fields.getReal(name)
+ return field
+
+
+ def getCellField(self, name, fields=None):
+ """
+ Get cell field.
+ """
+ if name == "cell info":
+ fieldType = FieldBase.SCALAR
+ fiberDim = 1
+ elif name == "cell data":
+ fieldType = FieldBase.VECTOR
+ fiberDim = self.mesh.dimension()
+ else:
+ raise ValueError("Unknown field '%s'." % name)
+
+ self.fields.add(name, name)
+ field = self.fields.get(name)
+ field.newSection(field.CELLS_FIELD, fiberDim)
+ field.allocate()
+ field.vectorFieldType(fieldType)
+ return field
+
+
+# ----------------------------------------------------------------------
+class TestOutputManagerMesh(unittest.TestCase):
+ """
+ Unit testing of Python OutputManagerMesh object.
+ """
+
+ def setUp(self):
+ from spatialdata.units.Nondimensional import Nondimensional
+ self.normalizer = Nondimensional()
+ self.normalizer._configure()
+ return
+
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ output = OutputManagerMesh()
+ output.inventory.writer._configure()
+ output._configure()
+ return
+
+
+ def test_preinitialize(self):
+ """
+ Test preinitialize().
+ """
+ dataProvider = TestProvider()
+ output = OutputManagerMesh()
+ output.preinitialize(dataProvider)
+
+ self.assertEqual(dataProvider, output.dataProvider)
+ return
+
+
+ def test_verifyConfiguration(self):
+ """
+ Test verifyConfiguration().
+ """
+ dataProvider = TestProvider()
+ output = OutputManagerMesh()
+ output.preinitialize(dataProvider)
+
+ output.vertexInfoFields = ["vertex info"]
+ output.vertexDataFields = ["vertex data 2"]
+ output.cellInfoFields = []
+ output.cellDataFields = ["cell data"]
+ output.verifyConfiguration(dataProvider.getDataMesh())
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ # No quadrature
+ output = OutputManagerMesh()
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ # With quadrature
+ from pylith.feassemble.FIATLagrange import FIATLagrange
+ from pylith.feassemble.Quadrature import MeshQuadrature
+ cell = FIATLagrange()
+ cell.inventory.dimension = 3
+ cell.inventory.degree = 2
+ cell.inventory.order = 2
+ cell._configure()
+
+ quadrature = MeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ output = OutputManagerMesh()
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer, quadrature)
+ return
+
+
+ def test_openclose(self):
+ """
+ Test open() and close().
+ """
+ output = OutputManagerMesh()
+ output.inventory.writer.inventory.filename = "output.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.close()
+ return
+
+
+ def test_writeInfo(self):
+ """
+ Test writeInfo().
+ """
+ output = OutputManagerMesh()
+ output.inventory.writer.inventory.filename = "output.vtk"
+ output.inventory.writer._configure()
+ output.inventory.vertexInfoFields = ["vertex info"]
+ output.inventory.cellInfoFields = ["cell info"]
+ output._configure()
+
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.writeInfo()
+ output.close()
+ return
+
+
+ def test_writeData(self):
+ """
+ Test writeData().
+ """
+ output = OutputManagerMesh()
+ output.inventory.writer.inventory.filename = "output.vtk"
+ output.inventory.writer.inventory.timeFormat = "%3.1f"
+ output.inventory.writer._configure()
+ output.inventory.vertexDataFields = ["vertex data 2",
+ "vertex data 1"]
+ output.inventory.cellDataFields = ["cell data"]
+ output._configure()
+
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.writeData(2.0, dataProvider.fields)
+ output.close()
+ return
+
+
+ def test_checkWrite(self):
+ """
+ Test _checkWrite().
+ """
+ dataProvider = TestProvider()
+
+ # Default values should be true
+ output = OutputManagerMesh()
+ output.inventory.writer._configure()
+ output._configure()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+ self.assertEqual(True, output._checkWrite(0.0))
+ self.assertEqual(True, output._checkWrite(3.234e+8))
+
+ # Check writing based on time
+ output = OutputManagerMesh()
+ output.inventory.writer._configure()
+ output._configure()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.inventory.outputFreq = "time_step"
+ t = 0.0
+ dt = output.dtN
+ self.assertEqual(True, output._checkWrite(t))
+ self.assertEqual(False, output._checkWrite(t))
+ self.assertEqual(False, output._checkWrite(t + 0.8*dt))
+ t += dt
+ self.assertEqual(True, output._checkWrite(t))
+ t = 2*dt
+ self.assertEqual(True, output._checkWrite(t))
+
+ # Check writing based on number of steps
+ output = OutputManagerMesh()
+ output.inventory.writer._configure()
+ output.inventory.outputFreq = "skip"
+ output.inventory.skip = 1
+ output._configure()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+ t = 0.0
+ dt = 1.0
+ self.assertEqual(True, output._checkWrite(t))
+ t += dt
+ self.assertEqual(False, output._checkWrite(t))
+ t += dt
+ self.assertEqual(True, output._checkWrite(t))
+ output.inventory.skip = 2
+ t += dt
+ self.assertEqual(False, output._checkWrite(t))
+ t += dt
+ self.assertEqual(False, output._checkWrite(t))
+ t += dt
+ self.assertEqual(True, output._checkWrite(t))
+
+ return
+
+
+# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerSubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/TestOutputManagerSubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerSubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputManagerSubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,326 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/meshio/TestOutputManagerSubMesh.py
+
+## @brief Unit testing of Python OutputManagerSubMesh object.
+
+import unittest
+
+from pylith.meshio.OutputManagerSubMesh import OutputManagerSubMesh
+
+# ----------------------------------------------------------------------
+class TestProvider(object):
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ self.availableFields = \
+ {'vertex': \
+ {'info': ["vertex info"],
+ 'data': ["vertex data 1",
+ "vertex data 2"]},
+ 'cell': \
+ {'info': ["cell info"],
+ 'data': ["cell data"]}}
+
+ filename = "data/twohex8.txt"
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ iohandler = MeshIOAscii()
+ iohandler.inventory.filename = filename
+ from spatialdata.geocoords.CSCart import CSCart
+ iohandler.inventory.coordsys = CSCart()
+ iohandler._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+ mesh = iohandler.read(normalizer, debug=False, interpolate=False)
+
+ from pylith.topology.SubMesh import SubMesh
+ submesh = SubMesh(mesh, "4")
+
+ from pylith.topology.Fields import SubMeshFields
+ fields = SubMeshFields(submesh)
+
+ self.mesh = mesh
+ self.submesh = submesh
+ self.fields = fields
+ return
+
+
+ def getDataMesh(self):
+ """
+ Get mesh.
+ """
+ return (self.submesh, None, None)
+
+
+ def getVertexField(self, name, fields=None):
+ """
+ Get vertex field.
+ """
+ from pylith.field.field.FieldBase import SCALAR,VECTOR,OTHER
+ if name == "vertex info":
+ fieldType = FieldBase.SCALAR
+ fiberDim = 1
+ elif name == "vertex data 1":
+ fieldType = FieldBase.VECTOR
+ fiberDim = self.mesh.dimension()
+ elif name == "vertex data 2":
+ fieldType = FieldBase.OTHER
+ fiberDim = 5
+ else:
+ raise ValueError("Unknown field '%s'." % name)
+
+ self.fields.add(name, name)
+ field = self.fields.get(name)
+ field.newSection(field.VERTICES_FIELD, fiberDim)
+ field.allocate()
+ field.vectorFieldType(fieldType)
+ self.fields.setFiberDimension(name, fiberDim)
+ self.fields.allocate(name)
+ field = self.fields.getReal(name)
+ return field
+
+
+ def getCellField(self, name, fields=None):
+ """
+ Get cell field.
+ """
+ if name == "cell info":
+ fieldType = FieldBase.SCALAR
+ fiberDim = 1
+ elif name == "cell data":
+ fieldType = FieldBase.VECTOR
+ fiberDim = self.mesh.dimension()
+ else:
+ raise ValueError("Unknown field '%s'." % name)
+
+ self.fields.add(name, name)
+ field = self.fields.get(name)
+ field.newSection(field.CELLS_FIELD, fiberDim)
+ field.allocate()
+ field.vectorFieldType(fieldType)
+ return field
+
+
+# ----------------------------------------------------------------------
+class TestOutputManagerSubMesh(unittest.TestCase):
+ """
+ Unit testing of Python MeshOutputManager object.
+ """
+
+ def setUp(self):
+ from spatialdata.units.Nondimensional import Nondimensional
+ self.normalizer = Nondimensional()
+ self.normalizer._configure()
+ return
+
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ output = OutputManagerSubMesh()
+ output.inventory.writer._configure()
+ output._configure()
+ return
+
+
+ def test_preinitialize(self):
+ """
+ Test preinitialize().
+ """
+ dataProvider = TestProvider()
+ output = OutputManagerSubMesh()
+ output.preinitialize(dataProvider)
+
+ self.assertEqual(dataProvider, output.dataProvider)
+ return
+
+
+ def test_verifyConfiguration(self):
+ """
+ Test verifyConfiguration().
+ """
+ dataProvider = TestProvider()
+ output = OutputManagerSubMesh()
+ output.preinitialize(dataProvider)
+
+ output.vertexInfoFields = ["vertex info"]
+ output.vertexDataFields = ["vertex data 2"]
+ output.cellInfoFields = []
+ output.cellDataFields = ["cell data"]
+ output.verifyConfiguration(dataProvider.getDataMesh())
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ # No quadrature
+ output = OutputManagerSubMesh()
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ # With quadrature
+ from pylith.feassemble.FIATLagrange import FIATLagrange
+ from pylith.feassemble.Quadrature import SubMeshQuadrature
+ cell = FIATLagrange()
+ cell.inventory.dimension = 2
+ cell.inventory.degree = 2
+ cell.inventory.order = 2
+ cell._configure()
+
+ quadrature = SubMeshQuadrature()
+ quadrature.inventory.cell = cell
+ quadrature._configure()
+
+ output = OutputManagerSubMesh()
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer, quadrature)
+ return
+
+
+ def test_openclose(self):
+ """
+ Test open() and close().
+ """
+ output = OutputManagerSubMesh()
+ output.inventory.writer.inventory.filename = "output.vtk"
+ output.inventory.writer._configure()
+ output._configure()
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.close()
+ return
+
+
+ def test_writeInfo(self):
+ """
+ Test writeInfo().
+ """
+ output = OutputManagerSubMesh()
+ output.inventory.writer.inventory.filename = "output.vtk"
+ output.inventory.writer._configure()
+ output.inventory.vertexInfoFields = ["vertex info"]
+ output.inventory.cellInfoFields = ["cell info"]
+ output._configure()
+
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.writeInfo()
+ output.close()
+ return
+
+
+ def test_writeData(self):
+ """
+ Test writeData().
+ """
+ output = OutputManagerSubMesh()
+ output.inventory.writer.inventory.filename = "output.vtk"
+ output.inventory.writer.inventory.timeFormat = "%3.1f"
+ output.inventory.writer._configure()
+ output.inventory.vertexDataFields = ["vertex data 2",
+ "vertex data 1"]
+ output.inventory.cellDataFields = ["cell data"]
+ output._configure()
+
+ dataProvider = TestProvider()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.open(totalTime=5.0, numTimeSteps=2)
+ output.writeData(2.0, dataProvider.fields)
+ output.close()
+ return
+
+
+ def test_checkWrite(self):
+ """
+ Test _checkWrite().
+ """
+ dataProvider = TestProvider()
+
+ # Default values should be true
+ output = OutputManagerSubMesh()
+ output.inventory.writer._configure()
+ output._configure()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+ self.assertEqual(True, output._checkWrite(0.0))
+ self.assertEqual(True, output._checkWrite(3.234e+8))
+
+ # Check writing based on time
+ output = OutputManagerSubMesh()
+ output.inventory.writer._configure()
+ output._configure()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+
+ output.inventory.outputFreq = "time_step"
+ t = 0.0
+ dt = output.dtN
+ self.assertEqual(True, output._checkWrite(t))
+ self.assertEqual(False, output._checkWrite(t))
+ self.assertEqual(False, output._checkWrite(t + 0.8*dt))
+ t += dt
+ self.assertEqual(True, output._checkWrite(t))
+ t = 2*dt
+ self.assertEqual(True, output._checkWrite(t))
+
+ # Check writing based on number of steps
+ output = OutputManagerSubMesh()
+ output.inventory.writer._configure()
+ output.inventory.outputFreq = "skip"
+ output.inventory.skip = 1
+ output._configure()
+ output.preinitialize(dataProvider)
+ output.initialize(self.normalizer)
+ t = 0.0
+ dt = 1.0
+ self.assertEqual(True, output._checkWrite(t))
+ t += dt
+ self.assertEqual(False, output._checkWrite(t))
+ t += dt
+ self.assertEqual(True, output._checkWrite(t))
+ output.inventory.skip = 2
+ t += dt
+ self.assertEqual(False, output._checkWrite(t))
+ t += dt
+ self.assertEqual(False, output._checkWrite(t))
+ t += dt
+ self.assertEqual(True, output._checkWrite(t))
+
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnSubset.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnSubset.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestOutputSolnSubset.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -31,21 +31,23 @@
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
from spatialdata.geocoords.CSCart import CSCart
- iohandler.filename = filename
- iohandler.coordsys = CSCart()
+ iohandler.inventory.filename = filename
+ iohandler.inventory.coordsys = CSCart()
+ iohandler._configure()
mesh = iohandler.read(normalizer, debug=False, interpolate=False)
- from pylith.topology.FieldsManager import FieldsManager
- fields = FieldsManager(mesh)
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(mesh)
- name = "solution"
- fields.addReal(name)
- fields.setFiberDimension(name, mesh.dimension())
- fields.allocate(name)
- fields.solutionField(name)
+ name = "disp(t)"
+ fields.add(name, "displacement")
+ fields.solutionName(name)
+ field = fields.get(name)
+ field.newSection(field.VERTICES_FIELD, mesh.dimension())
+ field.allocate()
self.mesh = mesh
self.fields = fields
@@ -58,8 +60,8 @@
Test constructor.
"""
output = OutputSolnSubset()
+ output.inventory.writer._configure()
output._configure()
- output.writer._configure()
return
@@ -68,8 +70,8 @@
Test preinitialize().
"""
output = OutputSolnSubset()
+ output.inventory.label = "label"
output._configure()
- output.label = "label"
output.preinitialize()
self.assertEqual(output, output.dataProvider)
@@ -81,11 +83,11 @@
Test verifyConfiguration().
"""
output = OutputSolnSubset()
+ output.inventory.label = "2"
output._configure()
- output.label = "2"
output.preinitialize()
- output.vertexDataFields = ["displacements"]
+ output.vertexDataFields = ["displacement"]
output.verifyConfiguration(self.mesh)
return
@@ -95,14 +97,13 @@
Test initialize().
"""
output = OutputSolnSubset()
+ output.inventory.label = "2"
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
output._configure()
- output.label = "2"
- output.writer._configure()
- output.writer.filename = "test.vtk"
output.preinitialize()
output.initialize(self.mesh, self.normalizer)
- self.assertNotEqual(None, output.cppHandle)
return
@@ -111,10 +112,10 @@
Test open() and close().
"""
output = OutputSolnSubset()
+ output.inventory.label = "2"
+ output.inventory.writer.inventory.filename = "test.vtk"
+ output.inventory.writer._configure()
output._configure()
- output.label = "2"
- output.writer._configure()
- output.writer.filename = "test.vtk"
output.preinitialize()
output.initialize(self.mesh, self.normalizer)
@@ -130,10 +131,10 @@
Test writeInfo().
"""
output = OutputSolnSubset()
+ output.inventory.label = "2"
+ output.inventory.writer.inventory.filename = "output_sub.vtk"
+ output.inventory.writer._configure()
output._configure()
- output.label = "2"
- output.writer._configure()
- output.writer.filename = "output_sub.vtk"
output.preinitialize()
output.initialize(self.mesh, self.normalizer)
@@ -149,12 +150,12 @@
Test writeData().
"""
output = OutputSolnSubset()
+ output.inventory.label = "2"
+ output.inventory.writer.inventory.filename = "outputsub.vtk"
+ output.inventory.writer.inventory.timeFormat = "%3.1f"
+ output.inventory.writer._configure()
+ output.inventory.vertexDataFields = ["displacement"]
output._configure()
- output.label = "2"
- output.writer._configure()
- output.writer.filename = "outputsub.vtk"
- output.writer.timeFormat = "%3.1f"
- output.vertexDataFields = ["displacements"]
output.preinitialize()
output.initialize(self.mesh, self.normalizer)
Modified: short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/TestVertexFilterVecNorm.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -16,10 +16,11 @@
import unittest
-from pylith.meshio.VertexFilterVecNorm import VertexFilterVecNorm
+from pylith.meshio.VertexFilterVecNormMesh import VertexFilterVecNormMesh
+from pylith.meshio.VertexFilterVecNormSubMesh import VertexFilterVecNormSubMesh
# ----------------------------------------------------------------------
-class TestVertexFilterVecNorm(unittest.TestCase):
+class TestVertexFilterVecNormMesh(unittest.TestCase):
"""
Unit testing of Python VertexFilterVecNorm object.
"""
@@ -28,7 +29,7 @@
"""
Test constructor.
"""
- filter = VertexFilterVecNorm()
+ filter = VertexFilterVecNormMesh()
filter._configure()
return
@@ -37,10 +38,9 @@
"""
Test constructor.
"""
- filter = VertexFilterVecNorm()
+ filter = VertexFilterVecNormMesh()
filter._configure()
filter.initialize()
- self.assertNotEqual(None, filter.cppHandle)
return
@@ -48,9 +48,43 @@
"""
Test factory method.
"""
- from pylith.meshio.VertexFilterVecNorm import output_vertex_filter
+ from pylith.meshio.VertexFilterVecNormMesh import output_vertex_filter
filter = output_vertex_filter()
return
+# ----------------------------------------------------------------------
+class TestVertexFilterVecNormSubMesh(unittest.TestCase):
+ """
+ Unit testing of Python VertexFilterVecNorm object.
+ """
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ filter = VertexFilterVecNormSubMesh()
+ filter._configure()
+ return
+
+
+ def test_initialize(self):
+ """
+ Test constructor.
+ """
+ filter = VertexFilterVecNormSubMesh()
+ filter._configure()
+ filter.initialize()
+ return
+
+
+ def test_factory(self):
+ """
+ Test factory method.
+ """
+ from pylith.meshio.VertexFilterVecNormSubMesh import output_vertex_filter
+ filter = output_vertex_filter()
+ return
+
+
# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/meshio/testcubit.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/testcubit.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testcubit.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testcubit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/meshio/testmeshio.py
+
+## @brief Python application for testing meshio code.
+
+from pyre.applications.Script import Script
+
+import unittest
+
+class TestApp(Script):
+ """
+ Test application.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="testapp"):
+ """
+ Constructor.
+ """
+ Script.__init__(self, name)
+ return
+
+
+ def main(self):
+ """
+ Run the application.
+ """
+ from pylith.utils.PetscManager import PetscManager
+ manager = PetscManager()
+ manager.initialize()
+ unittest.TextTestRunner(verbosity=2).run(self._suite())
+ manager.finalize()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _suite(self):
+ """
+ Setup the test suite.
+ """
+
+ suite = unittest.TestSuite()
+
+ from TestMeshIOCubit import TestMeshIOCubit
+ suite.addTest(unittest.makeSuite(TestMeshIOCubit))
+
+ return suite
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+ app = TestApp()
+ app.run()
+
+
+# End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,84 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/meshio/testmeshio.py
-
-## @brief Python application for testing meshio code.
-
-from pyre.applications.Script import Script
-
-import unittest
-
-class TestApp(Script):
- """
- Test application.
- """
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="testapp"):
- """
- Constructor.
- """
- Script.__init__(self, name)
- return
-
-
- def main(self):
- """
- Run the application.
- """
- from pylith.utils.PetscManager import PetscManager
- manager = PetscManager()
- manager.initialize()
- unittest.TextTestRunner(verbosity=2).run(self._suite())
- manager.finalize()
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _suite(self):
- """
- Setup the test suite.
- """
-
- suite = unittest.TestSuite()
-
- from TestMeshIOAscii import TestMeshIOAscii
- suite.addTest(unittest.makeSuite(TestMeshIOAscii))
-
- from TestMeshIOLagrit import TestMeshIOLagrit
- suite.addTest(unittest.makeSuite(TestMeshIOLagrit))
-
- from TestVertexFilterVecNorm import TestVertexFilterVecNorm
- suite.addTest(unittest.makeSuite(TestVertexFilterVecNorm))
-
- from TestCellFilterAvg import TestCellFilterAvg
- suite.addTest(unittest.makeSuite(TestCellFilterAvg))
-
- from TestOutputManager import TestOutputManager
- suite.addTest(unittest.makeSuite(TestOutputManager))
-
- from TestOutputSolnSubset import TestOutputSolnSubset
- suite.addTest(unittest.makeSuite(TestOutputSolnSubset))
-
- return suite
-
-
-# ----------------------------------------------------------------------
-if __name__ == '__main__':
- app = TestApp()
- app.run()
-
-
-# End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver_cubit.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver_cubit.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testdriver_cubit.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/meshio/testmeshio.py
-
-## @brief Python application for testing meshio code.
-
-from pyre.applications.Script import Script
-
-import unittest
-
-class TestApp(Script):
- """
- Test application.
- """
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="testapp"):
- """
- Constructor.
- """
- Script.__init__(self, name)
- return
-
-
- def main(self):
- """
- Run the application.
- """
- from pylith.utils.PetscManager import PetscManager
- manager = PetscManager()
- manager.initialize()
- unittest.TextTestRunner(verbosity=2).run(self._suite())
- manager.finalize()
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _suite(self):
- """
- Setup the test suite.
- """
-
- suite = unittest.TestSuite()
-
- from TestMeshIOCubit import TestMeshIOCubit
- suite.addTest(unittest.makeSuite(TestMeshIOCubit))
-
- return suite
-
-
-# ----------------------------------------------------------------------
-if __name__ == '__main__':
- app = TestApp()
- app.run()
-
-
-# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/meshio/testmeshio.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/meshio/testmeshio.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/meshio/testmeshio.py
+
+## @brief Python application for testing meshio code.
+
+from pyre.applications.Script import Script
+
+import unittest
+
+class TestApp(Script):
+ """
+ Test application.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="testapp"):
+ """
+ Constructor.
+ """
+ Script.__init__(self, name)
+ return
+
+
+ def main(self):
+ """
+ Run the application.
+ """
+ from pylith.utils.PetscManager import PetscManager
+ manager = PetscManager()
+ manager.initialize()
+
+ unittest.TextTestRunner(verbosity=2).run(self._suite())
+
+ manager.finalize()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _suite(self):
+ """
+ Setup the test suite.
+ """
+
+ suite = unittest.TestSuite()
+
+ from TestMeshIOAscii import TestMeshIOAscii
+ suite.addTest(unittest.makeSuite(TestMeshIOAscii))
+
+ from TestMeshIOLagrit import TestMeshIOLagrit
+ suite.addTest(unittest.makeSuite(TestMeshIOLagrit))
+
+ from TestVertexFilterVecNorm import TestVertexFilterVecNormMesh
+ suite.addTest(unittest.makeSuite(TestVertexFilterVecNormMesh))
+
+ from TestVertexFilterVecNorm import TestVertexFilterVecNormSubMesh
+ suite.addTest(unittest.makeSuite(TestVertexFilterVecNormSubMesh))
+
+ from TestCellFilterAvg import TestCellFilterAvgMesh
+ suite.addTest(unittest.makeSuite(TestCellFilterAvgMesh))
+
+ from TestCellFilterAvg import TestCellFilterAvgSubMesh
+ suite.addTest(unittest.makeSuite(TestCellFilterAvgSubMesh))
+
+ from TestDataWriterVTK import TestDataWriterVTKMesh
+ suite.addTest(unittest.makeSuite(TestDataWriterVTKMesh))
+
+ from TestDataWriterVTK import TestDataWriterVTKSubMesh
+ suite.addTest(unittest.makeSuite(TestDataWriterVTKSubMesh))
+
+ from TestDataWriterVTK import TestDataWriterVTKSubSubMesh
+ suite.addTest(unittest.makeSuite(TestDataWriterVTKSubSubMesh))
+
+ from TestOutputManagerMesh import TestOutputManagerMesh
+ suite.addTest(unittest.makeSuite(TestOutputManagerMesh))
+
+ from TestOutputManagerSubMesh import TestOutputManagerSubMesh
+ suite.addTest(unittest.makeSuite(TestOutputManagerSubMesh))
+
+ from TestOutputSolnSubset import TestOutputSolnSubset
+ suite.addTest(unittest.makeSuite(TestOutputSolnSubset))
+
+ #TestOutputNeumann
+
+ #TestOutputFaultKin
+
+ #TestOutputDirichlet
+
+ return suite
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+ app = TestApp()
+ app.run()
+
+
+# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/mpi (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/mpi)
Modified: short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStep.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStep.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStep.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -30,8 +30,7 @@
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
normalizer._configure()
- normalizer._time = 2.0*second
- normalizer.initialize()
+ normalizer.setTimeScale(2.0*second)
tstep = TimeStep()
tstep._configure()
@@ -101,7 +100,8 @@
tstep._configure()
integrators = None
- self.assertEqual(0.0, tstep.timeStep(integrators))
+ mesh = None
+ self.assertEqual(0.0, tstep.timeStep(mesh, integrators))
return
@@ -113,7 +113,7 @@
self.assertEqual(0.0, tstep.currentStep())
- tstep.dt = 1.0e-4
+ tstep.dtN = 1.0e-4
self.assertEqual(1.0e-4, tstep.currentStep())
return
Modified: short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepAdapt.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepAdapt.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepAdapt.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,14 +19,13 @@
from pyre.units.time import second
-# ----------------------------------------------------------------------
class Integrator:
def __init__(self, dt):
self.dt = dt
- def stableTimeStep(self):
+ def stableTimeStep(self, mesh):
return self.dt
@@ -40,8 +39,7 @@
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
normalizer._configure()
- normalizer._time = 2.0*second
- normalizer.initialize()
+ normalizer.setTimeScale(2.0*second)
tstep = TimeStepAdapt()
tstep._configure()
@@ -57,8 +55,8 @@
"""
tstep = self.tstep
- self.assertEqual(0.0, tstep.totalTime)
- self.assertEqual(0.5, tstep.maxDt)
+ self.assertEqual(0.0, tstep.totalTimeN)
+ self.assertEqual(0.5, tstep.maxDtN)
return
@@ -70,8 +68,8 @@
self.assertEqual(1, tstep.numTimeSteps())
- tstep.totalTime = 4.0
- tstep.maxDt = 2.0
+ tstep.totalTimeN = 4.0
+ tstep.maxDtN = 2.0
self.assertEqual(3, tstep.numTimeSteps())
return
@@ -86,42 +84,43 @@
tstep.adaptSkip = 2
integrators = [Integrator(2.0),
Integrator(0.5)]
+ mesh = None
# Set time step
dt = 0.5 / 1.2
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Increase stable time step, but time step should not change (skipped)
integrators[1].dt = 0.8
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Reduce time step even if though should have skipped
integrators[1].dt = 0.2
dt = 0.2 / 1.2
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Skip adjusting time step
integrators[1].dt = 0.8
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Skip adjusting time step
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Adjust time step and stability factor
tstep.stabilityFactor = 2.0
dt = 0.8 / 2.0
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Skip adjusting time step
integrators[1].dt = 2.0
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Skip adjusting time step
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
# Adjust time step with value bigger than max
dt = 0.5
- self.assertEqual(dt, tstep.timeStep(integrators))
+ self.assertEqual(dt, tstep.timeStep(mesh, integrators))
return
@@ -131,16 +130,17 @@
Test currentStep().
"""
tstep = self.tstep
- tstep.maxDt = 10.0
- tstep.dt = tstep.maxDt
+ tstep.maxDtN = 10.0
+ tstep.dtN = tstep.maxDtN
self.assertEqual(10.0, tstep.currentStep())
integrators = [Integrator(3.0),
Integrator(2.4)]
+ mesh = None
dt = 2.4 / 1.2
- tstep.timeStep(integrators)
+ tstep.timeStep(mesh, integrators)
self.assertEqual(dt, tstep.currentStep())
return
Modified: short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUniform.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUniform.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUniform.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -17,6 +17,7 @@
import unittest
from pylith.problems.TimeStepUniform import TimeStepUniform
+from spatialdata.units.Nondimensional import Nondimensional
from pyre.units.time import second
# ----------------------------------------------------------------------
@@ -25,17 +26,32 @@
Unit testing of TimeStepUniform object.
"""
- def test_numTimeSteps(self):
+ def setUp(self):
"""
- Test numTimeSteps().
+ Setup time step object.
"""
+ normalizer = Nondimensional()
+ normalizer._configure()
+
tstep = TimeStepUniform()
tstep._configure()
+ tstep.preinitialize()
+ tstep.verifyConfiguration()
+ tstep.initialize(normalizer)
+ self.tstep = tstep
+ return
+
+ def test_numTimeSteps(self):
+ """
+ Test numTimeSteps().
+ """
+ tstep = self.tstep
+
self.assertEqual(1, tstep.numTimeSteps())
- tstep.totalTime = 4.0*second
- tstep.dt = 2.0*second
+ tstep.totalTimeN = 4.0
+ tstep.dtN = 2.0
self.assertEqual(3, tstep.numTimeSteps())
return
@@ -45,14 +61,16 @@
"""
Test timeStep().
"""
- tstep = TimeStepUniform()
- tstep._configure()
+ tstep = self.tstep
- self.assertEqual(1.0*second, tstep.timeStep(0.5*second))
+ integrators = None
+ mesh = None
- tstep.dt = 1.0e-4*second
- self.assertEqual(1.0e-4*second, tstep.timeStep(0.5*second))
+ self.assertEqual(1.0, tstep.timeStep(mesh, integrators))
+ tstep.dtN = 1.0e-4
+ self.assertEqual(1.0e-4, tstep.timeStep(mesh, integrators))
+
return
@@ -60,13 +78,12 @@
"""
Test currentStep().
"""
- tstep = TimeStepUniform()
- tstep._configure()
+ tstep = self.tstep
- self.assertEqual(1.0*second, tstep.currentStep())
+ self.assertEqual(1.0, tstep.currentStep())
- tstep.dt = 1.0e-4*second
- self.assertEqual(1.0e-4*second, tstep.currentStep())
+ tstep.dtN = 1.0e-4
+ self.assertEqual(1.0e-4, tstep.currentStep())
return
Modified: short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUser.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUser.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/problems/TestTimeStepUser.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -19,7 +19,7 @@
from pyre.units.time import second,year
-stepsE = [1.0*year, 2.0*year, 3.0*year]
+stepsE = [2*1.0, 2*2.0, 2*3.0]
# ----------------------------------------------------------------------
class TestTimeStepUser(unittest.TestCase):
@@ -31,8 +31,7 @@
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
normalizer._configure()
- normalizer._time = 2.0*second
- normalizer.initialize()
+ normalizer.setTimeScale(0.5*year)
tstep = TimeStepUser()
tstep._configure()
@@ -59,8 +58,7 @@
tstep = self.tstep
for stepE, step in zip(stepsE, tstep.steps):
- valueE = stepE.value / 2.0 # Nondimensionalize
- self.assertEqual(valueE, step)
+ self.assertEqual(stepE, step)
return
@@ -72,11 +70,11 @@
self.assertEqual(1, tstep.numTimeSteps())
- tstep.totalTime = (12.0*year).value / 2.0 # nondimensionalize
+ tstep.totalTimeN = 12.0 / 0.5 # nondimensionalize
self.assertEqual(6, tstep.numTimeSteps())
tstep.loopSteps = True
- tstep.totalTime = (7.0*year).value / 2.0 # nondimensionalize
+ tstep.totalTimeN = 7.0 / 0.5 # nondimensionalize
self.assertEqual(5, tstep.numTimeSteps())
return
@@ -87,23 +85,26 @@
"""
tstep = self.tstep
- step1 = (1.0*year).value / 2.0 # nondimensionalize
- step2 = (2.0*year).value / 2.0 # nondimensionalize
- step3 = (3.0*year).value / 2.0 # nondimensionalize
+ step1 = 1.0 / 0.5 # nondimensionalize
+ step2 = 2.0 / 0.5 # nondimensionalize
+ step3 = 3.0 / 0.5 # nondimensionalize
- self.assertEqual(step1, tstep.timeStep(0.5))
- self.assertEqual(step2, tstep.timeStep(0.5))
- self.assertEqual(step3, tstep.timeStep(0.5))
- self.assertEqual(step3, tstep.timeStep(0.5))
- self.assertEqual(step3, tstep.timeStep(0.5))
+ integrators = None
+ mesh = None
+ self.assertEqual(step1, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step2, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step3, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step3, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step3, tstep.timeStep(mesh, integrators))
+
tstep.index = 0
tstep.loopSteps = True
- self.assertEqual(step1, tstep.timeStep(0.5))
- self.assertEqual(step2, tstep.timeStep(0.5))
- self.assertEqual(step3, tstep.timeStep(0.5))
- self.assertEqual(step1, tstep.timeStep(0.5))
- self.assertEqual(step2, tstep.timeStep(0.5))
+ self.assertEqual(step1, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step2, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step3, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step1, tstep.timeStep(mesh, integrators))
+ self.assertEqual(step2, tstep.timeStep(mesh, integrators))
return
@@ -113,10 +114,12 @@
"""
tstep = self.tstep
- tstep.timeStep(0.0)
- stepE = 1.0*year
- valueE = stepE.value / 2.0 # nondimensionalize
- self.assertEqual(valueE, tstep.currentStep())
+ integrators = None
+ mesh = None
+
+ tstep.timeStep(mesh, integrators)
+ stepE = 1.0 / 0.5 # Nondimensionalize
+ self.assertEqual(stepE, tstep.currentStep())
return
Modified: short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/Makefile.am 2009-05-04 23:09:34 UTC (rev 14863)
@@ -15,8 +15,8 @@
SUBDIRS = data
-TESTS = testdriver.py
-dist_check_SCRIPTS = testdriver.py
+TESTS = testtopology.py
+dist_check_SCRIPTS = testtopology.py
TESTS_ENVIRONMENT = $(PYTHON)
@@ -28,10 +28,18 @@
noinst_PYTHON = \
TestMesh.py \
+ TestSubMesh.py \
TestFieldsManager.py \
TestMeshGenerator.py \
TestMeshGenSimple.py \
TestMeshImporter.py
+noinst_tmp = \
+ jacobian.mat \
+ jacobian.mat.info
+
+CLEANFILES = $(noinst_tmp)
+
+
# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldBase.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestFieldBase.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldBase.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldBase.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestFieldBase.py
+
+## @brief Unit testing of FieldBase object.
+
+import unittest
+
+from pylith.topology.topology import FieldBase
+
+# ----------------------------------------------------------------------
+class TestFieldBase(unittest.TestCase):
+ """
+ Unit testing of FieldBase object.
+ """
+
+ def test_vectorfield(self):
+ self.assertEqual(0, FieldBase.SCALAR)
+ self.assertEqual(1, FieldBase.VECTOR)
+ self.assertEqual(2, FieldBase.TENSOR)
+ self.assertEqual(3, FieldBase.OTHER)
+ self.assertEqual(4, FieldBase.MULTI_SCALAR)
+ self.assertEqual(5, FieldBase.MULTI_VECTOR)
+ self.assertEqual(6, FieldBase.MULTI_TENSOR)
+ self.assertEqual(7, FieldBase.MULTI_OTHER)
+ return
+
+
+ def test_domain(self):
+ self.assertEqual(0, FieldBase.VERTICES_FIELD)
+ self.assertEqual(1, FieldBase.CELLS_FIELD)
+ return
+
+
+# End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldsManager.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldsManager.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestFieldsManager.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,320 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/pytests/topology/TestFieldsManager.py
-##
-## @brief Unit testing of FieldsManager object.
-
-import unittest
-
-from pylith.topology.FieldsManager import FieldsManager
-
-# ----------------------------------------------------------------------
-class TestFieldsManager(unittest.TestCase):
- """
- Unit testing of FieldsManager object.
- """
-
- def test_constructor(self):
- """
- Test constructor.
- """
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- self.assertNotEqual(None, manager.cppHandle)
- return
-
-
- def test_addReal(self):
- """
- Test addReal().
-
- WARNING: This is not a rigorous test of addReal() because we
- don't verify the results.
- """
-
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
- manager.addReal("field")
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_getReal(self):
- """
- Test getReal().
-
- WARNING: This is not a rigorous test of getReal() because we
- don't verify the results.
- """
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
- manager.addReal("field")
-
- field = manager.getReal("field")
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_delReal(self):
- """
- Test delReal().
-
- WARNING: This is not a rigorous test of delReal() because we
- don't verify the results.
- """
-
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
- manager.addReal("field")
-
- manager.delReal("field")
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_setFiberDimension(self):
- """
- Test setFiberDimension().
-
- WARNING: This is not a rigorous test of setFiberDimension() because we
- don't verify the results.
- """
-
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- manager.addReal("field A")
- manager.setFiberDimension("field A", 3, "vertices")
-
- manager.addReal("field B")
- manager.setFiberDimension("field B", 2, "cells")
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_allocate(self):
- """
- Test allocate().
-
- WARNING: This is not a rigorous test of allocate() because we
- don't verify the results.
- """
-
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- manager.addReal("field")
- manager.setFiberDimension("field", 3, "vertices")
- manager.allocate("field")
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_copyLayout(self):
- """
- Test copyLayout().
-
- WARNING: This is not a rigorous test of copyLayout() because we
- don't verify the results.
- """
-
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
- manager.addReal("field")
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_copyLayoutFromSrc(self):
- """
- Test copyLayoutFromSrc().
-
- WARNING: This is not a rigorous test of copyLayoutFromSrc() because we
- don't verify the results.
- """
-
- mesh = self._initialize()
- field = mesh.createRealSection("field", fiberDim=3)
- mesh.allocateRealSection(field)
-
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
- manager.addReal("fieldA")
- manager.addReal("fieldB")
-
- manager.copyLayoutFromSrc(field)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_solutionField(self):
- """
- Test solutionField().
-
- WARNING: This is not a rigorous test of solutionField() because we
- don't verify the results.
- """
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- fields = ["field A", "field B", "field C"]
- for field in fields:
- manager.addReal(field)
-
- manager.solutionField("field B")
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_getSolution(self):
- """
- Test getSolution().
-
- WARNING: This is not a rigorous test of getSolution() because we
- don't verify the results.
- """
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- fields = ["field A", "field B", "field C"]
- for field in fields:
- manager.addReal(field)
-
- manager.solutionField("field B")
- solution = manager.getSolution()
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_createHistory(self):
- """
- Test createHistory().
-
- WARNING: This is not a rigorous test of createHitory() because we
- don't verify the results.
- """
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- fields = ["field A", "field B", "field C", "field D"]
- for field in fields:
- manager.addReal(field)
-
- historyFields = fields[0:2]
- manager.createHistory(historyFields)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_shiftHistory(self):
- """
- Test createHistory().
-
- WARNING: This is not a rigorous test of shitHistory() because we
- don't verify the results.
- """
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- fields = ["field A", "field B"]
- for field in fields:
- manager.addReal(field)
-
- manager.createHistory(fields)
- manager.shiftHistory()
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- def test_getFieldByHistory(self):
- """
- Test createHistory().
-
- WARNING: This is not a rigorous test of getFieldByHistory() because we
- don't verify the results.
- """
- mesh = self._initialize()
- from pylith.topology.FieldsManager import FieldsManager
- manager = FieldsManager(mesh)
-
- fields = ["field A", "field B", "field C"]
- for field in fields:
- manager.addReal(field)
-
- manager.createHistory(fields)
- for i in [0, 2, 1]:
- field = manager.getFieldByHistory(i)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _initialize(self):
- """
- Initialize mesh.
- """
- from spatialdata.geocoords.CSCart import CSCart
- cs = CSCart()
- cs.spaceDim = 2
-
- from spatialdata.units.Nondimensional import Nondimensional
- normalizer = Nondimensional()
- normalizer.initialize()
-
- from pylith.meshio.MeshIOAscii import MeshIOAscii
- importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
- mesh = importer.read(normalizer, debug=False, interpolate=False)
-
- return mesh
-
-
-# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/topology/TestJacobian.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestJacobian.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestJacobian.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestJacobian.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,137 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestJacobian.py
+
+## @brief Unit testing of Jacobian object.
+
+import unittest
+
+from pylith.topology.Jacobian import Jacobian
+
+
+# ----------------------------------------------------------------------
+class TestJacobian(unittest.TestCase):
+ """
+ Unit testing of Jacobian object.
+ """
+
+ def setUp(self):
+ """
+ Setup mesh and associated field.
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ self.mesh = importer.read(normalizer, debug=False, interpolate=False)
+
+ from pylith.topology.SolutionFields import SolutionFields
+ fields = SolutionFields(self.mesh)
+ fields.add("disp t+dt", "displacement")
+ fields.solutionName("disp t+dt")
+ solution = fields.solution()
+ solution.newSection(solution.VERTICES_FIELD, self.mesh.dimension())
+ solution.allocate()
+ solution.zero()
+
+ self.fields = fields
+ self.jacobian = Jacobian(self.fields)
+ return
+
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ return
+
+
+ def test_matrix(self):
+ """
+ Test matrix().
+
+ :WARNING: This is not a complete test of matrix(). We do not
+ verify the results.
+ """
+ matrix = self.jacobian.matrix()
+
+ # No testing of result.
+ return
+
+
+ def test_assemble(self):
+ """
+ Test assemble().
+
+ :WARNING: This is not a complete test of assemble(). We do not
+ verify the results.
+ """
+ self.jacobian.assemble("flush_assembly")
+ self.jacobian.assemble("final_assembly")
+
+ # No testing of result.
+ return
+
+
+ def test_zero(self):
+ """
+ Test zero().
+
+ :WARNING: This is not a complete test of zero(). We do not
+ verify the results.
+ """
+ self.jacobian.zero()
+
+ # No testing of result.
+ return
+
+
+ def test_view(self):
+ """
+ Test view().
+
+ :WARNING: This is not a complete test of view(). We do not
+ verify the results.
+ """
+ self.jacobian.assemble("final_assembly")
+ self.jacobian.view()
+
+ # No testing of result.
+ return
+
+
+ def test_write(self):
+ """
+ Test write().
+
+ :WARNING: This is not a complete test of write(). We do not
+ verify the results.
+ """
+ self.jacobian.assemble("final_assembly")
+ self.jacobian.write("jacobian.mat")
+
+ # No testing of result.
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -24,119 +24,136 @@
Unit testing of Mesh object.
"""
- def test_constructor(self):
+ def test_constructorA(self):
"""
Test constructor.
"""
mesh = Mesh()
+ self.assertEqual(0, mesh.dimension())
+ self.assertEqual(False, mesh.debug())
return
- def test_initialize(self):
+ def test_constructorB(self):
"""
- Test initialize().
+ Test constructor.
"""
- from spatialdata.geocoords.CSCart import CSCart
- cs = CSCart()
-
- mesh = Mesh()
- mesh.initialize(cs)
- self.assertNotEqual(None, mesh.cppHandle)
- self.assertEqual(cs, mesh.coordsys)
+ dim = 2
+ mesh = Mesh(dim=dim)
+ self.assertEqual(dim, mesh.dimension())
+ self.assertEqual(False, mesh.debug())
return
- def test_comm(self):
+ def test_constructorC(self):
"""
- Test comm().
+ Test constructor.
"""
- mesh = self._getMesh()
- comm = mesh.comm()
- import mpi
- self.assertEqual(mpi.MPI_COMM_WORLD, comm)
+ dim = 2
+ from pylith.mpi.Communicator import mpi_comm_self
+ mesh = Mesh(dim=dim, comm=mpi_comm_self())
+ self.assertEqual(dim, mesh.dimension())
+ self.assertEqual(False, mesh.debug())
return
- def test_getRealSection(self):
+ def test_createSieveMesh(self):
"""
- Test createRealSection().
-
- WARNING: This is not a rigorous test of createRealSection()
- because we don't verify the results.
+ Test createSeiveMesh().
"""
- mesh = self._getMesh()
- field = mesh.getRealSection("field")
+ mesh = Mesh()
- # We should really add something here to check to make sure things
- # actually initialized correctly.
+ mesh.createSieveMesh()
+ self.assertEqual(3, mesh.dimension())
+
+ dim = 2
+ mesh.createSieveMesh(dim)
+ self.assertEqual(dim, mesh.dimension())
return
- def test_createRealSection(self):
+ def test_coordsys(self):
"""
- Test createRealSection().
+ Test coordsys().
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
- WARNING: This is not a rigorous test of createRealSection()
- because we don't verify the results.
+ mesh = Mesh()
+ mesh.coordsys(cs)
+ self.assertEqual(cs.spaceDim(), mesh.coordsys().spaceDim())
+ return
+
+
+ def test_debug(self):
"""
- mesh = self._getMesh()
- field = mesh.createRealSection("field", fiberDim=2)
+ Test debug().
+ """
+ mesh = Mesh()
- # We should really add something here to check to make sure things
- # actually initialized correctly.
+ self.assertEqual(False, mesh.debug())
+
+ mesh.debug(True)
+ self.assertEqual(True, mesh.debug())
return
- def test_allocateRealSection(self):
+ def test_dimension(self):
"""
- Test createRealSection().
+ Test debug().
+ """
+ mesh = Mesh()
+ self.assertEqual(0, mesh.dimension())
+ return
- WARNING: This is not a rigorous test of createRealSection()
- because we don't verify the results.
+
+ def test_comm(self):
"""
- mesh = self._getMesh()
- field = mesh.createRealSection("field", fiberDim=2)
- mesh.allocateRealSection(field)
-
- # We should really add something here to check to make sure things
- # actually initialized correctly.
+ Test comm().
+ """
+ from pylith.mpi.Communicator import petsc_comm_self
+ mesh = Mesh()
+ mesh.setComm(petsc_comm_self())
+ comm = mesh.getComm()
+ self.assertEqual(0, comm.rank)
+ self.assertEqual(1, comm.size)
return
- def test_createMatrix(self):
+ def test_initialize(self):
"""
- Test createRealSection().
+ Test initialize().
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
- WARNING: This is not a rigorous test of createRealSection()
- because we don't verify the results.
+ mesh = Mesh()
+ mesh.coordsys(cs)
+ mesh.initialize()
+ return
+
+
+ def test_view(self):
"""
+ Test view().
+ """
mesh = self._getMesh()
- field = mesh.createRealSection("field", fiberDim=2)
- mesh.allocateRealSection(field)
- matrix = mesh.createMatrix(field)
- # We should really add something here to check to make sure things
- # actually initialized correctly.
+ mesh.view("Testing view")
return
def test_checkMaterialIds(self):
"""
- Test createRealSection().
+ Test checkMaterialIds().
"""
mesh = self._getMesh()
- materialIds = [4, 3]
- mesh.checkMaterialIds(materialIds)
-
- materialIds[0] = -2
- caughtError = False
- try:
- mesh.checkMaterialIds(materialIds)
- except RuntimeError:
- caughtError = True
- self.assertTrue(caughtError)
+ mesh.checkMaterialIds([3, 4])
return
+
# PRIVATE METHODS ////////////////////////////////////////////////////
def _getMesh(self):
@@ -145,16 +162,18 @@
"""
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
- cs.spaceDim = 2
+ cs.inventory.spaceDim = 2
+ cs._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
- normalizer.initialize()
+ normalizer._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
- importer.filename = "data/tri3.mesh"
- importer.coordsys = cs
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
mesh = importer.read(normalizer, debug=False, interpolate=False)
return mesh
Copied: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshField.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestMeshField.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshField.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshField.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,151 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestMeshField.py
+
+## @brief Unit testing of MeshField object.
+
+import unittest
+
+from pylith.topology.Field import MeshField
+
+# ----------------------------------------------------------------------
+class TestMeshField(unittest.TestCase):
+ """
+ Unit testing of MeshField object.
+ """
+
+ def setUp(self):
+ """
+ Setup mesh and associated field.
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ self.mesh = importer.read(normalizer, debug=False, interpolate=False)
+
+ self.field = MeshField(self.mesh)
+ return
+
+
+ def test_constructorA(self):
+ """
+ Test constructor.
+ """
+ return
+
+
+ def test_mesh(self):
+ """
+ Test mesh().
+ """
+ mesh = self.field.mesh()
+
+ self.assertEqual(2, mesh.dimension())
+ return
+
+
+ def test_label(self):
+ """
+ Test label().
+ """
+ label = "field A"
+
+ self.field.label(label)
+ self.assertEqual(label, self.field.label())
+ return
+
+
+ def test_vectorFieldType(self):
+ """
+ Test vectorFieldType().
+ """
+ fieldType = MeshField.MULTI_SCALAR
+
+ self.field.vectorFieldType(fieldType)
+ self.assertEqual(fieldType, self.field.vectorFieldType())
+ return
+
+
+ def test_scale(self):
+ """
+ Test scale().
+ """
+ scale = 2.0
+
+ self.field.scale(scale)
+ self.assertEqual(scale, self.field.scale())
+ return
+
+
+ def test_addDimensionOkay(self):
+ """
+ Test addDimensionOkay().
+ """
+ self.assertEqual(False, self.field.addDimensionOkay())
+
+ self.field.addDimensionOkay(True)
+ self.assertEqual(True, self.field.addDimensionOkay())
+ return
+
+
+ def test_spaceDim(self):
+ """
+ Test spaceDim().
+ """
+ self.assertEqual(2, self.field.spaceDim())
+ return
+
+
+ def test_newSection(self):
+ """
+ Test newSection().
+ """
+ self.field.newSection()
+
+ # No test of result
+ return
+
+
+ def test_newSectionDomain(self):
+ """
+ Test newSection(domain).
+ """
+ self.field.newSection(MeshField.VERTICES_FIELD, 4)
+
+ # No test of result
+ return
+
+
+ def test_newSectionField(self):
+ """
+ Test newSection(field).
+ """
+ fieldB = MeshField(self.mesh)
+ fieldB.newSection(self.field)
+
+ # No test of result
+ return
+
+
+# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshFields.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestMeshFields.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshFields.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshFields.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestMeshFields.py
+
+## @brief Unit testing of MeshFields object.
+
+import unittest
+
+from pylith.topology.Fields import MeshFields
+
+# ----------------------------------------------------------------------
+class TestMeshFields(unittest.TestCase):
+ """
+ Unit testing of MeshFields object.
+ """
+
+ def setUp(self):
+ """
+ Setup mesh and associated field.
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ self.mesh = importer.read(normalizer, debug=False, interpolate=False)
+
+ self.fields = MeshFields(self.mesh)
+ return
+
+
+ def test_constructorA(self):
+ """
+ Test constructor.
+ """
+ return
+
+
+ def test_mesh(self):
+ """
+ Test mesh().
+ """
+ mesh = self.fields.mesh()
+
+ self.assertEqual(2, mesh.dimension())
+ return
+
+
+ def test_add(self):
+ self.fields.add("field", "displacement")
+ field = self.fields.get("field")
+ field.newSection()
+
+ self.assertEqual(2, field.spaceDim())
+ return
+
+
+ def test_addFiberDim(self):
+ from pylith.topology.topology import FieldBase
+ self.fields.add("field", "displacement")
+ field = self.fields.get("field")
+ field.newSection(FieldBase.VERTICES_FIELD, 4)
+
+ self.assertEqual(2, field.spaceDim())
+ return
+
+
+ def test_del(self):
+ self.fields.add("field A", "A")
+ self.fields.add("field B", "B")
+ self.fields.delField("field A")
+ field = self.fields.get("field B")
+ return
+
+
+ def test_copyLayout(self):
+ from pylith.topology.topology import FieldBase
+ self.fields.add("field A", "A")
+ field = self.fields.get("field A")
+ field.newSection(FieldBase.VERTICES_FIELD, 4)
+
+ self.fields.add("field B", "B")
+ self.fields.copyLayout("field A")
+
+ # No test of result
+ return
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestMeshGenerator.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -11,7 +11,7 @@
#
## @file unittests/pytests/topology/TestMeshGenerator.py
-
+##
## @brief Unit testing of MeshGenerator object.
import unittest
Copied: short/3D/PyLith/trunk/unittests/pytests/topology/TestSolutionFields.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSolutionFields.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestSolutionFields.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestSolutionFields.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestSolutionFields.py
+
+## @brief Unit testing of SolutionFields object.
+
+import unittest
+
+from pylith.topology.SolutionFields import SolutionFields
+
+# ----------------------------------------------------------------------
+class TestSolutionFields(unittest.TestCase):
+ """
+ Unit testing of SolutionFields object.
+ """
+
+ def setUp(self):
+ """
+ Setup mesh and associated field.
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ self.mesh = importer.read(normalizer, debug=False, interpolate=False)
+
+ self.fields = SolutionFields(self.mesh)
+ return
+
+
+ def test_constructor(self):
+ """
+ Test constructor.
+ """
+ return
+
+
+ def test_solutionName(self):
+ """
+ Test mesh().
+ """
+ fields = self.fields
+ fields.add("field A", "A");
+ fields.add("field B", "B");
+ fields.add("field C", "C");
+
+ fields.solutionName("field B")
+ return
+
+
+ def test_solution(self):
+ """
+ Test solution().
+ """
+ fields = self.fields
+ fields.add("field A", "A");
+ fields.add("field B", "B");
+ fields.add("field C", "C");
+
+ fields.solutionName("field B")
+ solution = self.fields.solution()
+ return
+
+
+ def test_createHistory(self):
+ """
+ Test createHistory().
+ """
+ fields = self.fields
+ fields.add("field A", "A");
+ fields.add("field B", "B");
+ fields.add("field C", "C");
+
+ fields.createHistory(["field B", "field A", "field C"])
+ return
+
+
+ def test_shiftHistory(self):
+ """
+ Test shiftHistory().
+ """
+ fields = self.fields
+ fields.add("field A", "A");
+ fields.add("field B", "B");
+ fields.add("field C", "C");
+
+ fields.createHistory(["field B", "field A", "field C"])
+ fields.shiftHistory()
+ return
+
+
+# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/topology/TestSubMesh.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/TestSubMesh.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/TestSubMesh.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/TestSubMesh.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,143 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/pytests/topology/TestSubMesh.py
+
+## @brief Unit testing of Mesh object.
+
+import unittest
+
+from pylith.topology.SubMesh import SubMesh
+
+# ----------------------------------------------------------------------
+class TestSubMesh(unittest.TestCase):
+ """
+ Unit testing of SubMesh object.
+ """
+
+ def test_constructorA(self):
+ """
+ Test constructor.
+ """
+ mesh = SubMesh()
+ self.assertEqual(0, mesh.dimension())
+ self.assertEqual(False, mesh.debug())
+ return
+
+
+ def test_constructorB(self):
+ """
+ Test constructor.
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+ self.assertEqual(1, submesh.dimension())
+ self.assertEqual(False, mesh.debug())
+ return
+
+
+ def test_createSubMesh(self):
+ """
+ Test createSeiveMesh().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh()
+ submesh.createSubMesh(mesh, "bc")
+ self.assertEqual(1, submesh.dimension())
+ return
+
+
+ def test_coordsys(self):
+ """
+ Test coordsys().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+ self.assertEqual(2, submesh.coordsys().spaceDim())
+ return
+
+
+ def test_debug(self):
+ """
+ Test debug().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ self.assertEqual(False, submesh.debug())
+
+ submesh.debug(True)
+ self.assertEqual(True, submesh.debug())
+ return
+
+
+ def test_dimension(self):
+ """
+ Test debug().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ self.assertEqual(1, submesh.dimension())
+ return
+
+
+ def test_comm(self):
+ """
+ Test comm().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ comm = submesh.comm()
+ self.assertEqual(0, comm.rank)
+ self.assertEqual(1, comm.size)
+ return
+
+
+ def test_initialize(self):
+ """
+ Test initialize().
+ """
+ mesh = self._getMesh()
+ submesh = SubMesh(mesh, "bc")
+
+ submesh.initialize()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _getMesh(self):
+ """
+ Get mesh from file.
+ """
+ from spatialdata.geocoords.CSCart import CSCart
+ cs = CSCart()
+ cs.inventory.spaceDim = 2
+ cs._configure()
+
+ from spatialdata.units.Nondimensional import Nondimensional
+ normalizer = Nondimensional()
+ normalizer._configure()
+
+ from pylith.meshio.MeshIOAscii import MeshIOAscii
+ importer = MeshIOAscii()
+ importer.inventory.filename = "data/tri3.mesh"
+ importer.inventory.coordsys = cs
+ importer._configure()
+ mesh = importer.read(normalizer, debug=False, interpolate=False)
+
+ return mesh
+
+
+# End of file
Deleted: short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/testdriver.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -1,78 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file unittests/topology/testdriver.py
-
-## @brief Python application for testing topology code.
-
-from pyre.applications.Script import Script
-
-import unittest
-
-class TestApp(Script):
- """
- Test application.
- """
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def __init__(self, name="testapp"):
- """
- Constructor.
- """
- Script.__init__(self, name)
- return
-
-
- def main(self):
- """
- Run the application.
- """
- from pylith.utils.PetscManager import PetscManager
- manager = PetscManager()
- manager.initialize()
- unittest.TextTestRunner(verbosity=2).run(self._suite())
- manager.finalize()
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _suite(self):
- """
- Setup the test suite.
- """
-
- suite = unittest.TestSuite()
-
- from TestMesh import TestMesh
- suite.addTest(unittest.makeSuite(TestMesh))
-
- from TestMeshGenerator import TestMeshGenerator
- suite.addTest(unittest.makeSuite(TestMeshGenerator))
-
- from TestMeshImporter import TestMeshImporter
- suite.addTest(unittest.makeSuite(TestMeshImporter))
-
- from TestFieldsManager import TestFieldsManager
- suite.addTest(unittest.makeSuite(TestFieldsManager))
-
- return suite
-
-
-# ----------------------------------------------------------------------
-if __name__ == '__main__':
- app = TestApp()
- app.run()
-
-
-# End of file
Copied: short/3D/PyLith/trunk/unittests/pytests/topology/testtopology.py (from rev 14862, short/3D/PyLith/branches/pylith-swig/unittests/pytests/topology/testtopology.py)
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/topology/testtopology.py (rev 0)
+++ short/3D/PyLith/trunk/unittests/pytests/topology/testtopology.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file unittests/topology/testdriver.py
+
+## @brief Python application for testing topology code.
+
+from pyre.applications.Script import Script
+
+import unittest
+
+class TestApp(Script):
+ """
+ Test application.
+ """
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def __init__(self, name="testapp"):
+ """
+ Constructor.
+ """
+ Script.__init__(self, name)
+ return
+
+
+ def main(self):
+ """
+ Run the application.
+ """
+ from pylith.utils.PetscManager import PetscManager
+ manager = PetscManager()
+ manager.initialize()
+ unittest.TextTestRunner(verbosity=2).run(self._suite())
+ manager.finalize()
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _suite(self):
+ """
+ Setup the test suite.
+ """
+
+ suite = unittest.TestSuite()
+
+ from TestMesh import TestMesh
+ suite.addTest(unittest.makeSuite(TestMesh))
+
+ from TestSubMesh import TestSubMesh
+ suite.addTest(unittest.makeSuite(TestSubMesh))
+
+ from TestFieldBase import TestFieldBase
+ suite.addTest(unittest.makeSuite(TestFieldBase))
+
+ from TestMeshField import TestMeshField
+ suite.addTest(unittest.makeSuite(TestMeshField))
+
+ from TestMeshFields import TestMeshFields
+ suite.addTest(unittest.makeSuite(TestMeshFields))
+
+ from TestSolutionFields import TestSolutionFields
+ suite.addTest(unittest.makeSuite(TestSolutionFields))
+
+ from TestJacobian import TestJacobian
+ suite.addTest(unittest.makeSuite(TestJacobian))
+
+ from TestMeshGenerator import TestMeshGenerator
+ suite.addTest(unittest.makeSuite(TestMeshGenerator))
+
+ from TestMeshImporter import TestMeshImporter
+ suite.addTest(unittest.makeSuite(TestMeshImporter))
+
+ return suite
+
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+ app = TestApp()
+ app.run()
+
+
+# End of file
Modified: short/3D/PyLith/trunk/unittests/pytests/utils/TestEventLogger.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/utils/TestEventLogger.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/utils/TestEventLogger.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,7 +10,7 @@
# ======================================================================
#
-## @file unittests/pytests/utils/TestPescManager.py
+## @file unittests/pytests/utils/TestEventLogger.py
## @brief Unit testing of EventLogger object.
@@ -35,13 +35,13 @@
def test_className(self):
"""
- Test setClassName() and getClassName.
+ Test className().
"""
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
name = "my class"
- logger.setClassName(name)
- self.assertEqual(name, logger.getClassName())
+ logger.className(name)
+ self.assertEqual(name, logger.className())
return
@@ -51,7 +51,7 @@
"""
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("logging A")
+ logger.className("logging A")
logger.initialize()
return
@@ -62,7 +62,7 @@
"""
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("logging A")
+ logger.className("logging A")
logger.initialize()
events = ["event 1" , "event 2" , "event 3"]
@@ -80,7 +80,7 @@
"""
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("logging A")
+ logger.className("logging A")
logger.initialize()
events = ["event 1" , "event 2" , "event 3"]
for event in events:
@@ -105,7 +105,7 @@
"""
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("logging A")
+ logger.className("logging A")
logger.initialize()
stages = ["stage 1" , "stage 2" , "stage 3"]
@@ -123,7 +123,7 @@
"""
from pylith.utils.EventLogger import EventLogger
logger = EventLogger()
- logger.setClassName("logging A")
+ logger.className("logging A")
logger.initialize()
stages = ["stage 1" , "stage 2" , "stage 3"]
for stage in stages:
Modified: short/3D/PyLith/trunk/unittests/pytests/utils/TestPetscManager.py
===================================================================
--- short/3D/PyLith/trunk/unittests/pytests/utils/TestPetscManager.py 2009-05-04 22:28:54 UTC (rev 14862)
+++ short/3D/PyLith/trunk/unittests/pytests/utils/TestPetscManager.py 2009-05-04 23:09:34 UTC (rev 14863)
@@ -10,7 +10,7 @@
# ======================================================================
#
-## @file unittests/pytests/utils/TestPescManager.py
+## @file unittests/pytests/utils/TestPetscManager.py
## @brief Unit testing of PetscManager object.
More information about the CIG-COMMITS
mailing list