1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
// This file is part of ff3d - http://www.freefem.org/ff3d
// Copyright (C) 2001, 2002, 2003 Stphane Del Pino
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// $Id: ElementaryMatrixSet.cpp,v 1.9 2006/11/24 00:05:31 delpinux Exp $
#include <ElementaryMatrixSet.hpp>
#include <Problem.hpp>
#include <PDESystem.hpp>
#include <SecondOrderOperator.hpp>
#include <VariationalOperatorAlphaDxUDxV.hpp>
#include <VariationalOperatorNuUdxV.hpp>
#include <VariationalOperatorNuDxUV.hpp>
#include <VariationalProblem.hpp>
/*!
Determines the number of needed elementary matrices for a given
PDE System at construction
*/
#define EMS(a,b) \
template <> \
ElementaryMatrixSet<TinyMatrix<a,b> >:: \
ElementaryMatrixSet(const Problem& problem) \
: __divMuGrad(false), \
__massOperator(false), \
__secondOrderOperator(false), \
__firstOrderOperator(false), \
__secondOrderOperatorList(false), \
__firstOrderUdxVList(false), \
__firstOrderDxUVList(false) \
{ \
\
switch (problem.type()) { \
case Problem::pdeProblem: { \
const PDESystem& pdeSystem = dynamic_cast<const PDESystem&>(problem); \
\
for (size_t i=0; i<pdeSystem.numberOfEquations(); ++i) { \
const PDE& pde = pdeSystem[i].pde(); \
for (size_t j=0; j<pdeSystem.numberOfEquations(); ++j) { \
const PDEOperatorSum& pdeOpSum = *(pde[j]); \
for (size_t k=0; k<pdeOpSum.numberOfOperators(); ++k) { \
switch ((*pdeOpSum[k]).type()) { \
case PDEOperator::firstorderop: { \
__firstOrderOperator = true; \
for (size_t m=0; m<3; ++m) \
__firstOrderDxUVList[m] = true; \
break; \
} \
case PDEOperator::divmugrad: { \
__divMuGrad = true; \
break; \
} \
case PDEOperator::secondorderop: { \
__secondOrderOperator = true; \
\
const SecondOrderOperator& so \
= dynamic_cast<const SecondOrderOperator&>(*pdeOpSum[k]); \
\
for (size_t m=0; m<3; ++m) \
for (size_t n=0; n<3; ++n) { \
if (so.isSet(m,n)) \
__secondOrderOperatorList(m,n) = true; \
} \
break; \
} \
case PDEOperator::massop: { \
__massOperator = true; \
break; \
} \
default: { \
throw ErrorHandler(__FILE__,__LINE__, \
"unexpected operator type", \
ErrorHandler::unexpected); \
} \
} \
} \
} \
} \
break; \
} \
case Problem::variationalProblem: { \
const VariationalProblem& P \
= dynamic_cast<const VariationalProblem&>(problem); \
for (VariationalProblem::bilinearOperatorConst_iterator \
i = P.beginBilinearOperator(); \
i != P.endBilinearOperator(); ++i) { \
switch ((*(*i)).type()) { \
case VariationalBilinearOperator::muGradUGradV: { \
__divMuGrad = true; \
break; \
} \
case VariationalBilinearOperator::alphaDxUDxV: { \
__secondOrderOperator = true; \
const VariationalAlphaDxUDxVOperator& I \
= static_cast<const VariationalAlphaDxUDxVOperator&>(*(*i)); \
__secondOrderOperatorList(I.i(), I.j()) = true; \
break; \
} \
case VariationalBilinearOperator::nuUdxV: { \
__firstOrderOperator = true; \
const VariationalNuUdxVOperator& I \
= static_cast<const VariationalNuUdxVOperator&>(*(*i)); \
__firstOrderUdxVList[I.i()] = true; \
break; \
} \
case VariationalBilinearOperator::nuDxUV: { \
__firstOrderOperator = true; \
const VariationalNuDxUVOperator& I \
= static_cast<const VariationalNuDxUVOperator&>(*(*i)); \
__firstOrderDxUVList[I.i()] = true; \
break; \
} \
case VariationalBilinearOperator::alphaUV: { \
__massOperator = true; \
break; \
} \
default: { \
throw ErrorHandler(__FILE__,__LINE__, \
"unexpected operator type", \
ErrorHandler::unexpected); \
} \
} \
} \
break; \
} \
default: { \
throw ErrorHandler(__FILE__,__LINE__, \
"unexpected problem type", \
ErrorHandler::unexpected); \
} \
} \
}
EMS(27,27); /**< Q2-Q2 */
EMS(10,10); /**< P2-P2 */
EMS(8,8); /**< Q1-Q1 */
EMS(4,4); /**< P1-P1 */
EMS(1,1); /**< Q0-Q0 P0-P0 */
|