Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceBinaryCellFilter.hpp"
00043 #include "PlayaExceptions.hpp"
00044 #include "SundanceOrderedTuple.hpp"
00045 #include "PlayaTabs.hpp"
00046 #include "SundanceOut.hpp"
00047
00048 using namespace Sundance;
00049 using namespace Sundance;
00050 using namespace Sundance;
00051 using namespace Teuchos;
00052
00053 BinaryCellFilter::BinaryCellFilter(const CellFilter& left,
00054 const CellFilter& right,
00055 const CellFilterOpType& op)
00056 : CellFilterBase(), op_(op), left_(left), right_(right)
00057 {
00058 std::string str;
00059 switch(op)
00060 {
00061 case Union:
00062 str = "Union(";
00063 break;
00064 case Intersection:
00065 str = "Intersection(";
00066 break;
00067 default:
00068 str = "SetDifference(";
00069 }
00070
00071 setName(str + left.toString() + ", " + right.toString() + ")");
00072 }
00073
00074 int BinaryCellFilter::dimension(const Mesh& mesh) const
00075 {
00076 int d1 = left_.dimension(mesh);
00077 int d2 = right_.dimension(mesh);
00078
00079 TEUCHOS_TEST_FOR_EXCEPTION(d1 != d2, std::runtime_error,
00080 "BinaryCellFilter::dimension() mismatched dimensions. "
00081 "Left filter has dimension d1=" << d1 << " but "
00082 "right filter has dimension d2=" << d2);
00083
00084 return d1;
00085 }
00086
00087 CellSet BinaryCellFilter::internalGetCells(const Mesh& mesh) const
00088 {
00089 Tabs tab;
00090
00091 SUNDANCE_OUT(this->verb() > 2,
00092 "cell filter " << toXML().toString() << " is getting its cells for mesh "
00093 << mesh.id());
00094
00095 CellSet L = left_.getCells(mesh);
00096 CellSet R = right_.getCells(mesh);
00097
00098
00099 SUNDANCE_OUT(this->verb() > 2,
00100 "cell filter " << toXML().toString() << " is performing its operation");
00101
00102 switch(op_)
00103 {
00104 case Union:
00105 return L.setUnion(R);
00106 case Intersection:
00107 return L.setIntersection(R);
00108 case Difference:
00109 return L.setDifference(R);
00110 }
00111 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "unknown cell filter op type" << op_
00112 << " in BinaryCellFilter::internalGetCells()");
00113 return L;
00114 }
00115
00116 string BinaryCellFilter::opName() const
00117 {
00118 switch(op_)
00119 {
00120 case Union:
00121 return "UnionCellFilter";
00122 case Intersection:
00123 return "IntersectionCellFilter";
00124 case Difference:
00125 return "DifferenceCellFilter";
00126 }
00127 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "unknown cell filter op type" << op_
00128 << " in BinaryCellFilter::opName()");
00129 return "UnionCellFilter";
00130 }
00131
00132 XMLObject BinaryCellFilter::toXML() const
00133 {
00134 XMLObject rtn(opName());
00135 rtn.addChild(left_.toXML());
00136 rtn.addChild(right_.toXML());
00137 return rtn;
00138 }
00139
00140
00141 #ifdef OLD_CELL_FILTER
00142
00143 bool BinaryCellFilter::lessThan(const CellFilterStub* other) const
00144 {
00145 const BinaryCellFilter* B
00146 = dynamic_cast<const BinaryCellFilter*>(other);
00147
00148 TEUCHOS_TEST_FOR_EXCEPTION(B==0,
00149 std::logic_error,
00150 "argument " << other->toXML()
00151 << " to BinaryCellFilter::lessThan() should be "
00152 "a BinaryCellFilter pointer.");
00153
00154 return OrderedTriple<CellFilterOpType, CellFilter, CellFilter>(op_, left_, right_)
00155 < OrderedTriple<CellFilterOpType, CellFilter, CellFilter>(B->op_, B->left_, B->right_) ;
00156 }
00157
00158 #endif