[cig-commits] r13568 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:14:36 PST 2008
Author: luis
Date: 2008-12-09 18:14:36 -0800 (Tue, 09 Dec 2008)
New Revision: 13568
Modified:
cs/cigma/trunk/src/core_compare_op.cpp
Log:
If no integration mesh was specified, steal one from first or second
Modified: cs/cigma/trunk/src/core_compare_op.cpp
===================================================================
--- cs/cigma/trunk/src/core_compare_op.cpp 2008-12-10 02:14:34 UTC (rev 13567)
+++ cs/cigma/trunk/src/core_compare_op.cpp 2008-12-10 02:14:36 UTC (rev 13568)
@@ -28,17 +28,7 @@
void CompareOp::configure()
{
TRI_LOG_STR("CompareOp::configure");
- TRI_LOG((bool)domain_info);
- // Read integration mesh
- if (!domain)
- {
- if (domain_info)
- {
- domain = Field::NewField(domain_info);
- }
- }
-
// Read first function
if (!first)
{
@@ -49,14 +39,9 @@
string msg("First field not specified");
throw cigma::Exception("CompareOp::configure", msg);
}
-
- if (dynamic_cast<cigma::Field*>(&(*first)))
- {
- cout << "First function is a cigma::Field" << endl;
- // XXX: if domain is not set, steal mesh from first
- }
}
+ // Read second function
if (!second)
{
second = Function::NewFunction(second_info);
@@ -67,17 +52,48 @@
throw cigma::Exception("CompareOp::configure", msg);
}
- if (dynamic_cast<cigma::Field*>(&(*second)))
- {
- cout << "Second function is a Field!" << endl;
- // XXX: if domain is not set, steal mesh from second
- }
}
+ // Read integration mesh
if (!domain)
{
- string msg("Integration mesh not specified");
- throw cigma::Exception("CompareOp::configure", msg);
+ if (domain_info)
+ {
+ domain = Field::NewField(domain_info);
+ }
+ else
+ {
+ domain = shared_ptr<Field>(new Field);
+
+ if (dynamic_cast<cigma::Field*>(&(*first)))
+ {
+ // steal mesh from first
+ TRI_LOG_STR(">> domain->mesh = first->mesh");
+ Field *field = static_cast<Field*>(&(*first));
+ domain->mesh = field->mesh;
+ domain->fe = FE::New(first_info.field_info.fe_info);
+ }
+ else if (dynamic_cast<cigma::Field*>(&(*second)))
+ {
+ // steal mesh from second
+ TRI_LOG_STR(">> domain->mesh = second->mesh");
+ Field *field = static_cast<Field*>(&(*second));
+ domain->mesh = field->mesh;
+ domain->fe = FE::New(second_info.field_info.fe_info);
+ }
+ }
+
+ if (!(domain->mesh))
+ {
+ string msg("Integration mesh not specified");
+ throw cigma::Exception("CompareOp::configure", msg);
+ }
+
+ if (!(domain->fe))
+ {
+ string msg("Cell type for integration mesh not specified");
+ throw cigma::Exception("CompareOp::configure", msg);
+ }
}
assert(domain);
assert(domain->mesh);
@@ -87,32 +103,35 @@
assert(domain->fe->cell);
assert(domain->fe->quadrature);
+ // Special cases for first function
if (dynamic_cast<cigma::ZeroFn*>(&(*first)))
{
- cout << "First function is a cigma::ZeroFn" << endl;
+ TRI_LOG_STR("-- First function is a cigma::ZeroFn");
ZeroFn *fn = static_cast<ZeroFn*>(&(*first));
fn->setShape(second->n_dim(), second->n_rank());
}
else if (dynamic_cast<cigma::UnitScalarFn*>(&(*first)))
{
- cout << "First function is a cigma::UnitScalarFn" << endl;
+ TRI_LOG_STR("-- First function is a cigma::UnitScalarFn");
UnitScalarFn *fn = static_cast<UnitScalarFn*>(&(*first));
fn->setDim(second->n_dim());
}
+ // Special cases for second function
if (dynamic_cast<cigma::ZeroFn*>(&(*second)))
{
- cout << "Second function is a cigma::ZeroFn" << endl;
+ TRI_LOG_STR("-- Second function is a cigma::ZeroFn");
ZeroFn *fn = static_cast<ZeroFn*>(&(*second));
fn->setShape(first->n_dim(), first->n_rank());
}
else if (dynamic_cast<cigma::UnitScalarFn*>(&(*second)))
{
- cout << "Second function is a cigma::UnitScalarFn" << endl;
+ TRI_LOG_STR("-- Second function is a cigma::UnitScalarFn");
UnitScalarFn *fn = static_cast<UnitScalarFn*>(&(*second));
fn->setDim(first->n_dim());
}
+ // Match function dimensions
if (first->n_dim() != second->n_dim())
{
std::ostringstream stream;
@@ -122,6 +141,7 @@
throw cigma::Exception("CompareOp::configure", stream.str());
}
+ // Match function ranks
if (first->n_rank() != second->n_rank())
{
std::ostringstream stream;
More information about the CIG-COMMITS
mailing list