00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <PDEOperatorSumExpression.hpp>
00021 #include <PDESolution.hpp>
00022
00023 #include <VectorialPDEOperator.hpp>
00024
00025 #include <Information.hpp>
00026
00027 #include <UnknownListExpression.hpp>
00028
00029 ReferenceCounting<VectorialPDEOperator>
00030 PDEOperatorSumExpression::vectorPDEOperator()
00031 {
00032 return __vectorPDEOperator;
00033 }
00034
00035 void PDEOperatorSumExpression::execute()
00036 {
00037 ReferenceCounting<UnknownListExpression> unknownListExpression
00038 = Information::instance().getUnknownList();
00039
00040 const UnknownListExpression& uList = *unknownListExpression;
00041
00042 __vectorPDEOperator = new VectorialPDEOperator(uList.size());
00043 for(PDEOperatorExpressionList::iterator i = (*__sumList).begin();
00044 i != (*__sumList).end(); ++i) {
00045 PDEOperatorExpression& theOperator = (*(*i));
00046 theOperator.execute();
00047 switch(theOperator.pdeOperatorType()) {
00048 case (PDEOperatorExpression::scalar): {
00049 PDEScalarOperatorExpression& theScalarOperator
00050 = dynamic_cast<PDEScalarOperatorExpression&>(theOperator);
00051 size_t n = uList.number(theScalarOperator.unknownName());
00052 (*__vectorPDEOperator)[n]->add(theScalarOperator.pdeOperator());
00053 break;
00054 }
00055 case (PDEOperatorExpression::vectorial): {
00056 PDEVectorialOperatorExpression& theVectorialOperator
00057 = dynamic_cast<PDEVectorialOperatorExpression&>(theOperator);
00058 typedef
00059 PDEVectorialOperatorExpression::PDEOperatorList::iterator
00060 Iterator;
00061
00062 for (Iterator i = theVectorialOperator.pdeOperatorList().begin();
00063 i != theVectorialOperator.pdeOperatorList().end(); ++i) {
00064 size_t n = uList.number((*i).first);
00065 (*__vectorPDEOperator)[n]->add((*i).second);
00066 }
00067 break;
00068 }
00069 default: {
00070 throw ErrorHandler(__FILE__,__LINE__,
00071 "not implemented",
00072 ErrorHandler::unexpected);
00073 }
00074 }
00075 }
00076
00077 for(PDEOperatorExpressionList::iterator i = (*__differenceList).begin();
00078 i != (*__differenceList).end(); ++i) {
00079 PDEOperatorExpression& theOperator = (*(*i));
00080 theOperator.execute();
00081 switch(theOperator.pdeOperatorType()) {
00082 case (PDEOperatorExpression::scalar): {
00083 PDEScalarOperatorExpression& theScalarOperator
00084 = dynamic_cast<PDEScalarOperatorExpression&>(theOperator);
00085 size_t n = uList.number(theScalarOperator.unknownName());
00086 (*__vectorPDEOperator)[n]->add(-(*theScalarOperator.pdeOperator()));
00087 break;
00088 }
00089 case (PDEOperatorExpression::vectorial): {
00090 PDEVectorialOperatorExpression& theVectorialOperator
00091 = dynamic_cast<PDEVectorialOperatorExpression&>(theOperator);
00092 typedef
00093 PDEVectorialOperatorExpression::PDEOperatorList::iterator
00094 Iterator;
00095
00096 for (Iterator i = theVectorialOperator.pdeOperatorList().begin();
00097 i != theVectorialOperator.pdeOperatorList().end(); ++i) {
00098 size_t n = uList.number((*i).first);
00099 (*__vectorPDEOperator)[n]->add(-(*(*i).second));
00100 }
00101 break;
00102 }
00103 default: {
00104 throw ErrorHandler(__FILE__,__LINE__,
00105 "not implemented",
00106 ErrorHandler::unexpected);
00107 }
00108 }
00109 }
00110 }
00111
00112 PDEOperatorSumExpression::
00113 PDEOperatorSumExpression(const PDEOperatorSumExpression& e)
00114 : Expression(e),
00115 __vectorPDEOperator(e.__vectorPDEOperator),
00116 __sumList(e.__sumList),
00117 __differenceList(e.__differenceList)
00118 {
00119 ;
00120 }
00121
00122 PDEOperatorSumExpression::PDEOperatorSumExpression()
00123 : Expression(Expression::pdeOperatorSum),
00124 __sumList(new PDEOperatorExpressionList),
00125 __differenceList(new PDEOperatorExpressionList)
00126 {
00127 ;
00128 }
00129
00130 PDEOperatorSumExpression::~PDEOperatorSumExpression()
00131 {
00132 ;
00133 }
00134
00135 void PDEOperatorSumExpression::add(ReferenceCounting<PDEOperatorSumExpression> P)
00136 {
00137 for(PDEOperatorExpressionList::iterator i = (*(*P).__sumList).begin();
00138 i != (*(*P).__sumList).end(); ++i) {
00139 (*__sumList).push_back(*i);
00140 }
00141
00142 for(PDEOperatorExpressionList::iterator i = (*(*P).__differenceList).begin();
00143 i != (*(*P).__differenceList).end(); ++i) {
00144 (*__differenceList).push_back(*i);
00145 }
00146 }
00147
00148 void PDEOperatorSumExpression::minus(ReferenceCounting<PDEOperatorSumExpression> P)
00149 {
00150 for(PDEOperatorExpressionList::iterator i = (*(*P).__sumList).begin();
00151 i != (*(*P).__sumList).end(); ++i) {
00152 (*__differenceList).push_back(*i);
00153 }
00154
00155 for(PDEOperatorExpressionList::iterator i = (*(*P).__differenceList).begin();
00156 i != (*(*P).__differenceList).end(); ++i) {
00157 (*__sumList).push_back(*i);
00158 }
00159 }
00160