// bool matchesPoint(double x, double y) { // return true; // } bool matchesPoints(FieldContainer<bool> &pointsMatch, BasisCachePtr basisCache) { const FieldContainer<double> *points = &(basisCache->getPhysicalCubaturePoints()); const FieldContainer<double> *normals = &(basisCache->getSideNormals()); int numCells = (*points).dimension(0); int numPoints = (*points).dimension(1); FieldContainer<double> beta_pts(numCells,numPoints,2); _beta->values(beta_pts,basisCache); double tol=1e-14; bool somePointMatches = false; for (int cellIndex=0; cellIndex<numCells; cellIndex++) { for (int ptIndex=0; ptIndex<numPoints; ptIndex++) { double n1 = (*normals)(cellIndex,ptIndex,0); double n2 = (*normals)(cellIndex,ptIndex,1); double beta_n = beta_pts(cellIndex,ptIndex,0)*n1 + beta_pts(cellIndex,ptIndex,1)*n2 ; // cout << "beta = (" << beta_pts(cellIndex,ptIndex,0)<<", "<< // beta_pts(cellIndex,ptIndex,1)<<"), n = ("<<n1<<", "<<n2<<")"<<endl; pointsMatch(cellIndex,ptIndex) = false; if (beta_n < 0) { pointsMatch(cellIndex,ptIndex) = true; somePointMatches = true; } } } return somePointMatches; }
bool matchesPoints(FieldContainer<bool> &pointsMatch, BasisCachePtr basisCache) { const FieldContainer<double> *points = &(basisCache->getPhysicalCubaturePoints()); const FieldContainer<double> *normals = &(basisCache->getSideNormals()); int numCells = (*points).dimension(0); int numPoints = (*points).dimension(1); double tol = 1e-3; bool somePointMatches = false; for (int cellIndex=0; cellIndex<numCells; cellIndex++) { for (int ptIndex=0; ptIndex<numPoints; ptIndex++) { double x = (*points)(cellIndex,ptIndex,0); double y = (*points)(cellIndex,ptIndex,1); double n1 = (*normals)(cellIndex,ptIndex,0); double n2 = (*normals)(cellIndex,ptIndex,1); double beta_n = _beta[0]*n1 + _beta[1]*n2 ; pointsMatch(cellIndex,ptIndex) = false; if (abs((x-.5)*(x-.5)+y*y) < 0.75+tol && beta_n < 0) { pointsMatch(cellIndex,ptIndex) = true; somePointMatches = true; } } } return somePointMatches; }
void ExactSolution::solutionValues(FieldContainer<double> &values, int trialID, BasisCachePtr basisCache) { if (_exactFunctions.find(trialID) != _exactFunctions.end() ) { _exactFunctions[trialID]->values(values,basisCache); return; } // TODO: change ExactSolution::solutionValues (below) to take a *const* points FieldContainer, to avoid this copy: FieldContainer<double> points = basisCache->getPhysicalCubaturePoints(); if (basisCache->getSideIndex() >= 0) { FieldContainer<double> unitNormals = basisCache->getSideNormals(); this->solutionValues(values,trialID,points,unitNormals); } else { this->solutionValues(values,trialID,points); } }
void values(FieldContainer<double> &values, BasisCachePtr basisCache) { FieldContainer<double> points = basisCache->getPhysicalCubaturePoints(); FieldContainer<double> normals = basisCache->getSideNormals(); int numCells = points.dimension(0); int numPoints = points.dimension(1); FieldContainer<double> Tv(numCells,numPoints); FieldContainer<double> u1v(numCells,numPoints);; _u1->values(u1v,basisCache); _T->values(Tv,basisCache); bool isSubsonic = false; double min_y = YTOP; double max_y = 0.0; values.initialize(0.0); for (int cellIndex=0; cellIndex<numCells; cellIndex++) { for (int ptIndex=0; ptIndex<numPoints; ptIndex++) { double x = points(cellIndex,ptIndex,0); double y = points(cellIndex,ptIndex,1); double T = Tv(cellIndex,ptIndex); double un = u1v(cellIndex,ptIndex); // WARNING: ASSUMES NORMAL AT OUTFLOW = (1,0) double c = sqrt(_gamma * (_gamma-1.0) * _cv * T); bool outflowMatch = ((abs(x-2.0) < _tol) && (y > 0.0) && (y < YTOP)); bool subsonicMatch = (un < c) && (un > 0.0); if (subsonicMatch && outflowMatch) { values(cellIndex,ptIndex) = 1.0; isSubsonic = true; min_y = min(y,min_y); max_y = max(y,max_y); // cout << "y = " << y << endl; } } } if (isSubsonic) { // cout << "subsonic in interval y =(" << min_y << "," << max_y << ")" << endl; } }
void UnitNormalFunction::values(Intrepid::FieldContainer<double> &values, BasisCachePtr basisCache) { this->CHECK_VALUES_RANK(values); int numCells = values.dimension(0); int numPoints = values.dimension(1); int spaceDim = basisCache->getSpaceDim(); if (_comp == -1) { // check the the "D" dimension of values is correct: if (_spaceTime) { TEUCHOS_TEST_FOR_EXCEPTION(values.dimension(2) != spaceDim+1, std::invalid_argument, "For space-time normals, values.dimension(2) should be spaceDim + 1."); } else { TEUCHOS_TEST_FOR_EXCEPTION(values.dimension(2) != spaceDim, std::invalid_argument, "For spatial normals, values.dimension(2) should be spaceDim."); } } const Intrepid::FieldContainer<double> *sideNormals = _spaceTime ? &(basisCache->getSideNormalsSpaceTime()) : &(basisCache->getSideNormals()); int comp = _comp; if (comp == -2) { // want to select the temporal component, t() comp = spaceDim; } for (int cellIndex=0; cellIndex<numCells; cellIndex++) { for (int ptIndex=0; ptIndex<numPoints; ptIndex++) { if (comp == -1) { for (int d=0; d<spaceDim; d++) { double nd = (*sideNormals)(cellIndex,ptIndex,d); values(cellIndex,ptIndex,d) = nd; } if (_spaceTime) { double nd = (*sideNormals)(cellIndex,ptIndex,spaceDim); values(cellIndex,ptIndex,spaceDim) = nd; } } else { double ni = (*sideNormals)(cellIndex,ptIndex,comp); values(cellIndex,ptIndex) = ni; } } } }