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
00035 #include "Intrepid_CellTools.hpp"
00036 #include "Intrepid_FieldContainer.hpp"
00037 #include "Intrepid_DefaultCubatureFactory.hpp"
00038 #include "Shards_CellTopology.hpp"
00039 #include "Teuchos_GlobalMPISession.hpp"
00040
00045 void vField(double& v1, double& v2, double& v3,
00046 const double& x, const double& y, const double& z);
00047
00048 using namespace std;
00049 using namespace Intrepid;
00050
00051 int main(int argc, char *argv[]) {
00052
00053 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
00054
00055 typedef CellTools<double> CellTools;
00056 typedef RealSpaceTools<double> RealSpaceTools;
00057 typedef shards::CellTopology CellTopology;
00058
00059 std::cout \
00060 << "===============================================================================\n" \
00061 << "| |\n" \
00062 << "| Example use of the CellTools class |\n" \
00063 << "| |\n" \
00064 << "| 1) Computation of face flux, for a given vector field, on a face workset |\n" \
00065 << "| 2) Computation of edge circulation, for a given vector field, on a face |\n" \
00066 << "| workset. |\n" \
00067 << "| |\n" \
00068 << "| Questions? Contact Pavel Bochev (pbboche@sandia.gov) |\n" \
00069 << "| Denis Ridzal (dridzal@sandia.gov), or |\n" \
00070 << "| Kara Peterson (kjpeter@sandia.gov) |\n" \
00071 << "| |\n" \
00072 << "| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
00073 << "| Trilinos website: http://trilinos.sandia.gov |\n" \
00074 << "| |\n" \
00075 << "===============================================================================\n"\
00076 << "| EXAMPLE 1: Computation of face flux on a face workset |\n"\
00077 << "===============================================================================\n";
00078
00079
00094
00095
00096
00097
00098
00099
00100
00101 CellTopology hexahedron_8( shards::getCellTopologyData<shards::Hexahedron<8> >() );
00102
00103
00104 int worksetSize = 2;
00105 int pCellNodeCount = hexahedron_8.getVertexCount();
00106 int pCellDim = hexahedron_8.getDimension();
00107
00108 FieldContainer<double> hexNodes(worksetSize, pCellNodeCount, pCellDim);
00109
00110 hexNodes(0, 0, 0) = 0.00; hexNodes(0, 0, 1) = 0.00, hexNodes(0, 0, 2) = 0.00;
00111 hexNodes(0, 1, 0) = 1.00; hexNodes(0, 1, 1) = 0.00, hexNodes(0, 1, 2) = 0.00;
00112 hexNodes(0, 2, 0) = 1.00; hexNodes(0, 2, 1) = 1.00, hexNodes(0, 2, 2) = 0.00;
00113 hexNodes(0, 3, 0) = 0.00; hexNodes(0, 3, 1) = 1.00, hexNodes(0, 3, 2) = 0.00;
00114
00115 hexNodes(0, 4, 0) = 0.00; hexNodes(0, 4, 1) = 0.00, hexNodes(0, 4, 2) = 1.00;
00116 hexNodes(0, 5, 0) = 1.00; hexNodes(0, 5, 1) = 0.00, hexNodes(0, 5, 2) = 1.00;
00117 hexNodes(0, 6, 0) = 1.00; hexNodes(0, 6, 1) = 1.00, hexNodes(0, 6, 2) = 1.00;
00118 hexNodes(0, 7, 0) = 0.00; hexNodes(0, 7, 1) = 1.00, hexNodes(0, 7, 2) = 1.00;
00119
00120
00121 hexNodes(1, 0, 0) = 0.00; hexNodes(1, 0, 1) = 0.00, hexNodes(1, 0, 2) = 0.00;
00122 hexNodes(1, 1, 0) = 1.00; hexNodes(1, 1, 1) = 0.00, hexNodes(1, 1, 2) = 0.00;
00123 hexNodes(1, 2, 0) = 1.00; hexNodes(1, 2, 1) = 1.00, hexNodes(1, 2, 2) = 0.00;
00124 hexNodes(1, 3, 0) = 0.00; hexNodes(1, 3, 1) = 1.00, hexNodes(1, 3, 2) = 0.00;
00125
00126 hexNodes(1, 4, 0) = 0.00; hexNodes(1, 4, 1) = 0.00, hexNodes(1, 4, 2) = 1.00;
00127 hexNodes(1, 5, 0) = 1.00; hexNodes(1, 5, 1) = 0.00, hexNodes(1, 5, 2) = 1.00;
00128 hexNodes(1, 6, 0) = 1.00; hexNodes(1, 6, 1) = 1.00, hexNodes(1, 6, 2) = 0.75;
00129 hexNodes(1, 7, 0) = 0.00; hexNodes(1, 7, 1) = 1.00, hexNodes(1, 7, 2) = 1.00;
00130
00131
00132
00133 int subcellDim = 2;
00134 int subcellOrd = 1;
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 DefaultCubatureFactory<double> cubFactory;
00149
00150
00151 CellTopology paramQuadFace(shards::getCellTopologyData<shards::Quadrilateral<4> >() );
00152
00153
00154 FieldContainer<double> paramGaussWeights;
00155 FieldContainer<double> paramGaussPoints;
00156
00157
00158 FieldContainer<double> refGaussPoints;
00159
00160
00161 FieldContainer<double> worksetGaussPoints;
00162
00163
00164
00165
00166 Teuchos::RCP<Cubature<double> > hexFaceCubature = cubFactory.create(paramQuadFace, 3);
00167
00168
00169 int cubDim = hexFaceCubature -> getDimension();
00170 int numCubPoints = hexFaceCubature -> getNumPoints();
00171
00172
00173 paramGaussPoints.resize(numCubPoints, cubDim);
00174 paramGaussWeights.resize(numCubPoints);
00175 hexFaceCubature -> getCubature(paramGaussPoints, paramGaussWeights);
00176
00177
00178
00179
00180 refGaussPoints.resize(numCubPoints, pCellDim);
00181
00182
00183 worksetGaussPoints.resize(worksetSize, numCubPoints, pCellDim);
00184
00185
00186 CellTools::mapToReferenceSubcell(refGaussPoints,
00187 paramGaussPoints,
00188 subcellDim,
00189 subcellOrd,
00190 hexahedron_8);
00191
00192
00193 CellTools::mapToPhysicalFrame(worksetGaussPoints,
00194 refGaussPoints,
00195 hexNodes,
00196 hexahedron_8);
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 FieldContainer<double> worksetJacobians(worksetSize, numCubPoints, pCellDim, pCellDim);
00210
00211
00212 CellTools::setJacobian(worksetJacobians,
00213 refGaussPoints,
00214 hexNodes,
00215 hexahedron_8);
00216
00217
00218
00219
00220 FieldContainer<double> worksetFaceTu(worksetSize, numCubPoints, pCellDim);
00221 FieldContainer<double> worksetFaceTv(worksetSize, numCubPoints, pCellDim);
00222 FieldContainer<double> worksetFaceN(worksetSize, numCubPoints, pCellDim);
00223
00224
00225 CellTools::getPhysicalFaceTangents(worksetFaceTu,
00226 worksetFaceTv,
00227 worksetJacobians,
00228 subcellOrd,
00229 hexahedron_8);
00230
00231
00232 RealSpaceTools::vecprod(worksetFaceN, worksetFaceTu, worksetFaceTv);
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 FieldContainer<double> worksetVFieldVals(worksetSize, numCubPoints, pCellDim);
00244
00245
00246 for(int pCellOrd = 0; pCellOrd < worksetSize; pCellOrd++){
00247 for(int ptOrd = 0; ptOrd < numCubPoints; ptOrd++){
00248
00249 double x = worksetGaussPoints(pCellOrd, ptOrd, 0);
00250 double y = worksetGaussPoints(pCellOrd, ptOrd, 1);
00251 double z = worksetGaussPoints(pCellOrd, ptOrd, 2);
00252
00253 vField(worksetVFieldVals(pCellOrd, ptOrd, 0),
00254 worksetVFieldVals(pCellOrd, ptOrd, 1),
00255 worksetVFieldVals(pCellOrd, ptOrd, 2), x, y, z);
00256
00257 }
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 FieldContainer<double> worksetFieldDotNormal(worksetSize, numCubPoints);
00269
00270
00271 RealSpaceTools::dot(worksetFieldDotNormal, worksetVFieldVals, worksetFaceN);
00272
00273
00274 FieldContainer<double> worksetFluxes(worksetSize);
00275
00276
00277
00278
00279 for(int pCellOrd = 0; pCellOrd < worksetSize; pCellOrd++){
00280 worksetFluxes(pCellOrd) = 0.0;
00281 for(int pt = 0; pt < numCubPoints; pt++ ){
00282 worksetFluxes(pCellOrd) += worksetFieldDotNormal(pCellOrd, pt)*paramGaussWeights(pt);
00283 }
00284 }
00285
00286 std::cout << "Face fluxes on workset faces : \n\n";
00287 for(int pCellOrd = 0; pCellOrd < worksetSize; pCellOrd++){
00288
00289 CellTools::printWorksetSubcell(hexNodes, hexahedron_8, pCellOrd, subcellDim, subcellOrd);
00290 std::cout << " Flux = " << worksetFluxes(pCellOrd) << "\n\n";
00291
00292 }
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 std::cout \
00304 << "===============================================================================\n" \
00305 << "| Gauss points on workset faces: |\n" \
00306 << "===============================================================================\n";
00307 for(int pCell = 0; pCell < worksetSize; pCell++){
00308
00309 CellTools::printWorksetSubcell(hexNodes, hexahedron_8, pCell, subcellDim, subcellOrd);
00310
00311 for(int pt = 0; pt < numCubPoints; pt++){
00312 std::cout << "\t 2D Gauss point ("
00313 << std::setw(8) << std::right << paramGaussPoints(pt, 0) << ", "
00314 << std::setw(8) << std::right << paramGaussPoints(pt, 1) << ") "
00315 << std::setw(8) << " --> " << "("
00316 << std::setw(8) << std::right << worksetGaussPoints(pCell, pt, 0) << ", "
00317 << std::setw(8) << std::right << worksetGaussPoints(pCell, pt, 1) << ", "
00318 << std::setw(8) << std::right << worksetGaussPoints(pCell, pt, 2) << ")\n";
00319 }
00320 std::cout << "\n\n";
00321 }
00322
00323
00324
00325 std::cout \
00326 << "===============================================================================\n" \
00327 << "| Face normals (non-unit) at Gauss points on workset faces: |\n" \
00328 << "===============================================================================\n";
00329 for(int pCell = 0; pCell < worksetSize; pCell++){
00330
00331 CellTools::printWorksetSubcell(hexNodes, hexahedron_8, pCell, subcellDim, subcellOrd);
00332
00333 for(int pt = 0; pt < numCubPoints; pt++){
00334 std::cout << "\t 3D Gauss point: ("
00335 << std::setw(8) << std::right << worksetGaussPoints(pCell, pt, 0) << ", "
00336 << std::setw(8) << std::right << worksetGaussPoints(pCell, pt, 1) << ", "
00337 << std::setw(8) << std::right << worksetGaussPoints(pCell, pt, 2) << ")"
00338 << std::setw(8) << " out. normal: " << "("
00339 << std::setw(8) << std::right << worksetFaceN(pCell, pt, 0) << ", "
00340 << std::setw(8) << std::right << worksetFaceN(pCell, pt, 1) << ", "
00341 << std::setw(8) << std::right << worksetFaceN(pCell, pt, 2) << ")\n";
00342 }
00343 std::cout << "\n";
00344 }
00345
00346 return 0;
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356 void vField(double& v1, double& v2, double& v3, const double& x, const double& y, const double& z)
00357 {
00358 v1 = x;
00359 v2 = y;
00360 v3 = z;
00361 }
00362
00363