[cig-commits] r14181 - in cs/cigma/trunk: . src tests/libcigma tests/system
luis at geodynamics.org
luis at geodynamics.org
Mon Mar 2 08:32:00 PST 2009
Author: luis
Date: 2009-03-02 08:31:59 -0800 (Mon, 02 Mar 2009)
New Revision: 14181
Modified:
cs/cigma/trunk/cscope.sh
cs/cigma/trunk/src/Residuals.cpp
cs/cigma/trunk/src/Residuals.h
cs/cigma/trunk/src/cli_compare_cmd.cpp
cs/cigma/trunk/src/cli_mesh_info_cmd.cpp
cs/cigma/trunk/src/core_writers.cpp
cs/cigma/trunk/src/core_writers.h
cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp
cs/cigma/trunk/tests/system/300-compare.sh
Log:
Synchronize changes
Modified: cs/cigma/trunk/cscope.sh
===================================================================
--- cs/cigma/trunk/cscope.sh 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/cscope.sh 2009-03-02 16:31:59 UTC (rev 14181)
@@ -1,4 +1,5 @@
#!/bin/bash
+set -x
cdirs="src"
rm -f cscope.files
for d in $cdirs; do
Modified: cs/cigma/trunk/src/Residuals.cpp
===================================================================
--- cs/cigma/trunk/src/Residuals.cpp 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/src/Residuals.cpp 2009-03-02 16:31:59 UTC (rev 14181)
@@ -63,8 +63,3 @@
return sqrt(res2);
}
-double Residuals::relative_L2() const
-{
- return sqrt(res2/vol);
-}
-
Modified: cs/cigma/trunk/src/Residuals.h
===================================================================
--- cs/cigma/trunk/src/Residuals.h 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/src/Residuals.h 2009-03-02 16:31:59 UTC (rev 14181)
@@ -23,7 +23,6 @@
double infinity_norm() const;
double L2() const;
- double relative_L2() const;
public:
Modified: cs/cigma/trunk/src/cli_compare_cmd.cpp
===================================================================
--- cs/cigma/trunk/src/cli_compare_cmd.cpp 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/src/cli_compare_cmd.cpp 2009-03-02 16:31:59 UTC (rev 14181)
@@ -69,7 +69,7 @@
;
other.add_options()
- ("quiet", "Suppress all output")
+ ("quiet", "suppress all output")
;
hidden.add_options()
@@ -255,7 +255,22 @@
TRI_LOG(outputfile);
DataPath path(outputfile);
+ const string indent(" ");
+ /* print something so user doesn't think program has stalled */
+ if (!vm.count("quiet"))
+ {
+ cout << endl;
+ cout << "First function : " << first << endl;
+ cout << "Second function : " << second << endl;
+ cout << endl;
+
+ if (op.verbose)
+ {
+ cout << "Progress of comparison" << endl;
+ }
+ }
+
/* run the comparison */
int status = op.run();
@@ -266,20 +281,10 @@
double L2_vol = L2/volume;
double L2_sqrt_vol = L2/sqrt(volume);
- if (L2 > threshold)
- {
- if (op.verbose)
- {
- cout << "Exceeding threshold " << threshold << endl;
- }
- status = 1;
- }
-
if (!vm.count("quiet"))
{
// report global error metrics
- const string indent(" ");
cout << setprecision(12);
cout << endl;
@@ -303,6 +308,16 @@
cout << endl;
}
+ if (L2 > threshold)
+ {
+ if (op.verbose)
+ {
+ cout << indent << "Exceeding threshold " << threshold << endl;
+ }
+ status = 1;
+ }
+
+
if (vm.count("output"))
{
if (op.verbose)
Modified: cs/cigma/trunk/src/cli_mesh_info_cmd.cpp
===================================================================
--- cs/cigma/trunk/src/cli_mesh_info_cmd.cpp 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/src/cli_mesh_info_cmd.cpp 2009-03-02 16:31:59 UTC (rev 14181)
@@ -45,8 +45,8 @@
("node-id", po::value<int>(&nodeid), "Show cells associated with node id")
("query-point,p", po::value<string>(&pointstr), "Query mesh for arbitrary point (use commas)")
("output-mesh,o", po::value<string>(&outputfile), "Output mesh in HDF5 format")
- ("output-centroid", po::value<string>(¢roidfile), "Output file for element centroids")
- ("output-volume", po::value<string>(&volumefile), "Output file for element volumes")
+ ("output-centroids", po::value<string>(¢roidfile), "Output file for element centroids")
+ ("output-volumes", po::value<string>(&volumefile), "Output file for element volumes")
;
args.add("mesh", -1);
}
@@ -241,7 +241,7 @@
TRI_LOG_STR(">> Writing cell volumes to file");
TRI_LOG(volumefile);
DataPath path(volumefile);
- WriteCellVolumes(path, mesh->volume, true);
+ WriteCellVolumes(path, mesh, mesh->volume, true);
cout << indent << "Saved cell volumes to '" << volumefile << "'" << endl;
}
Modified: cs/cigma/trunk/src/core_writers.cpp
===================================================================
--- cs/cigma/trunk/src/core_writers.cpp 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/src/core_writers.cpp 2009-03-02 16:31:59 UTC (rev 14181)
@@ -353,7 +353,7 @@
#endif
}
-void cigma::WriteCellVolumes(const DataPath& path, const std::valarray<double>& volume, bool overwrite)
+void cigma::WriteCellVolumes(const DataPath& path, boost::shared_ptr<MeshPart> mesh, const std::valarray<double>& volume, bool overwrite)
{
TRI_LOG_STR("cigma::WriteCellVolumes()");
TRI_LOG(path);
@@ -376,7 +376,58 @@
}
else if (wt == FileWriter::VTK_FILE_WRITER)
{
- throw cigma::Exception("WriteCellVolumes", "Not implemented for VTK files");
+ // XXX: build cell-based scalar array. (refactor common code from these WriteXXX() functions)
+ VtkWriter *vtk_writer = static_cast<VtkWriter*>(&(*writer));
+
+ assert(mesh);
+
+ int i,j;
+
+ if (location == "")
+ {
+ location = "volumes";
+ }
+
+ // coords first
+ TRI_LOG_STR(">>> Writing vtk points");
+ const int npts = mesh->coords->n_points();
+ const int ndim = mesh->coords->n_dim();
+ NodeCoordinates *nc = static_cast<NodeCoordinates*>(&(*(mesh->coords)));
+ cigma::array<double> points(npts,3);
+ points.init_value(0);
+ for (i = 0; i < npts; i++)
+ {
+ for (j = 0; j < ndim; j++)
+ {
+ points(i,j) = nc->getPoint(i,j);
+ }
+ }
+ vtk_writer->_writePoints(points._data, npts, 3);
+ points.reinit(0,0);
+
+ // cells next..
+ TRI_LOG_STR(">>> Writing vtk cells");
+ const int nel = mesh->connect->n_cells();
+ const int nno = mesh->connect->n_dofs();
+ ElementBlock *eb = static_cast<ElementBlock*>(&(*(mesh->connect)));
+ cigma::array<int> cells(nel, nno);
+ for (i = 0; i < nel; i++)
+ {
+ for (j = 0; j < nno; j++)
+ {
+ cells(i,j) = eb->getId(i,j);
+ }
+ }
+ vtk_writer->_writeCells(cells._data, nel, nno);
+ cells.reinit(0,0);
+
+ // finally, cell types
+ TRI_LOG_STR(">>> Writing vtk cell types");
+ int vtkCellType = vtkcelltype(mesh->getCellType());
+ vtk_writer->_writeCellTypes(nel, vtkCellType);
+
+ // now, the actual data (volumes)
+ vtk_writer->_writeCellData(location.c_str(), &volume[0], volume.size(), 1);
}
else if (wt == FileWriter::TEXT_FILE_WRITER)
{
@@ -478,6 +529,7 @@
valarray<double> eps;
eps.resize(residuals->epsilon.size());
+ // XXX: leave the post-processing to the vtk-residuals utility program
if (normalize)
{
TRI_LOG_STR(">> Writing out the normalized residuals");
@@ -523,11 +575,11 @@
double volume = residuals->vol;
double Linf = residuals->infinity_norm();
double L2 = residuals->L2();
- double L2_rel = residuals->relative_L2();
+ //double L2_rel = residuals->relative_L2();
double L2_vol = L2/volume;
status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "INFINITY_NORM", residuals->infinity_norm());
status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM", L2);
- status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM_RELATIVE", L2_rel);
+ //status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM_RELATIVE", L2_rel);
status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "L2_NORM_BY_VOLUME", L2_vol);
status = write_scalar_attribute<double>(h5->file, eps_loc.c_str(), "VOLUME", volume);
}
@@ -547,7 +599,8 @@
int i,j;
if (location == "")
{
- location = "residuals";
+ //location = "residuals";
+ location = "errors";
}
// coordinates first
Modified: cs/cigma/trunk/src/core_writers.h
===================================================================
--- cs/cigma/trunk/src/core_writers.h 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/src/core_writers.h 2009-03-02 16:31:59 UTC (rev 14181)
@@ -23,7 +23,7 @@
void WriteQPoints(const DataPath& path, const cigma::array<double>& w, const cigma::array<double>& x, bool overwrite=false);
void WriteDofs(const DataPath& path, boost::shared_ptr<DofHandler> dofs);
void WriteResiduals(const DataPath& path, boost::shared_ptr<Residuals> residuals, bool normalize, bool overwrite=false);
- void WriteCellVolumes(const DataPath& path, const std::valarray<double>& volume, bool overwrite=false);
+ void WriteCellVolumes(const DataPath& path, boost::shared_ptr<MeshPart> M, const std::valarray<double>& volume, bool overwrite=false);
void WriteCellCentroids(const DataPath& path, boost::shared_ptr<MeshPart> M, bool overwrite=false);
}
Modified: cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp 2009-03-02 16:31:59 UTC (rev 14181)
@@ -45,7 +45,6 @@
residuals->update(e, 2, 3);
}
CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2*8), residuals->L2(), delta);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2*8/1.0), residuals->relative_L2(), delta);
CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(3), residuals->infinity_norm(), delta);
}
Modified: cs/cigma/trunk/tests/system/300-compare.sh
===================================================================
--- cs/cigma/trunk/tests/system/300-compare.sh 2009-03-02 16:31:58 UTC (rev 14180)
+++ cs/cigma/trunk/tests/system/300-compare.sh 2009-03-02 16:31:59 UTC (rev 14181)
@@ -12,5 +12,6 @@
--second=$B/CubeFn.dat \
--second-mesh=$B/brick2.h5:/ \
--second-mesh-cell=tet4 \
+ --quiet \
$*
More information about the CIG-COMMITS
mailing list