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
00043
00044
00045
00046
00047
00048
00049
00050 #include "SundanceTrapesoidQuadrature.hpp"
00051
00052 using namespace Sundance;
00053
00054 TrapesoidQuadrature::TrapesoidQuadrature(int resolution) :
00055 QuadratureFamilyBase(1) , resolution_(resolution) {
00056
00057 resolution_ = (resolution_<2) ? 2 : resolution_;
00058 }
00059
00060 XMLObject TrapesoidQuadrature::toXML() const
00061 {
00062 XMLObject rtn("TrapesoidQuadrature");
00063 rtn.addAttribute("order", Teuchos::toString(order()));
00064 return rtn;
00065 }
00066
00067 void TrapesoidQuadrature::getLineRule(
00068 Array<Point>& quadPoints,
00069 Array<double>& quadWeights) const {
00070
00071 int nrVirInnerPoints = resolution_ - 1;
00072 double innerWeights = 1/((double)nrVirInnerPoints);
00073
00074 int nrPoints = nrVirInnerPoints + 1;
00075 quadPoints.resize(nrPoints);
00076 quadWeights.resize(nrPoints);
00077
00078
00079 quadPoints[0] = Point(0.0);
00080 quadWeights[0] = innerWeights/2.0;
00081
00082 for (int tmp = 1 ; tmp < nrPoints-1 ; tmp++){
00083 quadPoints[tmp] = Point( (double)tmp/(double)(nrPoints-1) );
00084 quadWeights[tmp] = innerWeights;
00085 }
00086
00087
00088 quadPoints[nrPoints-1] = Point(1.0);
00089 quadWeights[nrPoints-1] = innerWeights/2.0;
00090
00091 }
00092
00093
00094 void TrapesoidQuadrature::getTriangleRule(
00095 Array<Point>& quadPoints,
00096 Array<double>& quadWeights) const {
00097
00098 SUNDANCE_ERROR("Triangle rule not available for " << toXML());
00099 }
00100
00101
00102 void TrapesoidQuadrature::getQuadRule(
00103 Array<Point>& quadPoints,
00104 Array<double>& quadWeights) const {
00105
00106 Array<Point> quadPointsLine;
00107 Array<double> quadWeightsLine;
00108
00109 this->getLineRule( quadPointsLine, quadWeightsLine );
00110
00111 int nrPointPerAxis = quadPointsLine.size();
00112
00113 quadPoints.resize(nrPointPerAxis*nrPointPerAxis);
00114 quadWeights.resize(nrPointPerAxis*nrPointPerAxis);
00115
00116 int pcount = 0;
00117 for (int ix = 0 ; ix < nrPointPerAxis ; ix ++){
00118 for (int iy = 0 ; iy < nrPointPerAxis ; iy ++){
00119
00120 quadPoints[pcount] = Point( quadPointsLine[ix][0] , quadPointsLine[iy][0] );
00121 quadWeights[pcount] = quadWeightsLine[ix] * quadWeightsLine[iy];
00122 pcount++;
00123 }
00124 }
00125
00126 }
00127
00128
00129 void TrapesoidQuadrature::getTetRule(
00130 Array<Point>& quadPoints,
00131 Array<double>& quadWeights) const {
00132
00133 SUNDANCE_ERROR("Tet rule not available for " << toXML());
00134 }
00135
00136
00137 void TrapesoidQuadrature::getBrickRule(
00138 Array<Point>& quadPoints,
00139 Array<double>& quadWeights) const {
00140
00141 Array<Point> quadPointsLine;
00142 Array<double> quadWeightsLine;
00143
00144 getLineRule( quadPointsLine, quadWeightsLine );
00145
00146 int nrPointPerAxis = quadPointsLine.size();
00147
00148 quadPoints.resize(nrPointPerAxis*nrPointPerAxis*nrPointPerAxis);
00149 quadWeights.resize(nrPointPerAxis*nrPointPerAxis*nrPointPerAxis);
00150
00151 int pcount = 0;
00152 for (int ix = 0 ; ix < nrPointPerAxis ; ix ++){
00153 for (int iy = 0 ; iy < nrPointPerAxis ; iy ++){
00154 for (int iz = 0 ; iz < nrPointPerAxis ; iz ++){
00155
00156 quadPoints[pcount] = Point( quadPointsLine[ix][0] , quadPointsLine[iy][0] , quadPointsLine[iz][0]);
00157 quadWeights[pcount] = quadWeightsLine[ix] * quadWeightsLine[iy] * quadWeightsLine[iz];
00158 pcount++;
00159 }
00160 }
00161 }
00162 }
00163
00164
00165 void TrapesoidQuadrature::getAdaptedWeights(
00166 const CellType& cellType, int cellDim,
00167 int cellLID, int facetIndex, const Mesh& mesh,
00168 const ParametrizedCurve& globalCurve,
00169 Array<Point>& quadPoints, Array<double>& quadWeights,
00170 bool &weightsChanged) const {
00171
00172 weightsChanged = true;
00173
00174 if (mesh.IsSpecialWeightValid() && mesh.hasSpecialWeight(cellDim, cellLID))
00175 {
00176 mesh.getSpecialWeight(cellDim, cellLID, quadWeights);
00177
00178 return;
00179 }
00180
00181
00182 if (quadPoints.size() <= 1) getPoints(cellType, quadPoints, quadWeights);
00183
00184
00185 weightsChanged = true;
00186 Array<Point> tmpPoints = quadPoints;
00187
00188 Array<int> celLIDs(1);
00189 celLIDs[0] = cellLID;
00190
00191 mesh.pushForward( cellDim, celLIDs, quadPoints, tmpPoints );
00192
00193 quadWeights.resize(tmpPoints.size());
00194
00195 for (int i=0 ; i < tmpPoints.size() ; i++){
00196 quadWeights[i] = quadWeights[i] * globalCurve.integrationParameter(tmpPoints[i]);
00197 }
00198
00199
00200 mesh.setSpecialWeight(cellDim, cellLID, quadWeights);
00201 }