Added: support for nviz != 2 as well as fixing some tabulator indentations

git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1215 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
kjetijo 2011-09-26 12:40:49 +00:00 committed by Knut Morten Okstad
parent b730f43bdd
commit a8e7c6044a

View File

@ -1143,10 +1143,6 @@ bool ASMu2D::getGridParameters (RealArray& prm, int dir, int nSegPerSpan) const
#ifdef SP_DEBUG
std::cout << "ASMu2D::getGridParameters( )\n";
#endif
if(nSegPerSpan != 1) {
std::cerr << "ASMu2D::getGridParameters called with nSegPerSpan != 2\n";
return false;
}
// output is written once for each element resulting in a lot of unnecessary storage
// this is preferable to figuring out all element topology information
@ -1158,10 +1154,10 @@ bool ASMu2D::getGridParameters (RealArray& prm, int dir, int nSegPerSpan) const
double umax = (**el).umax();
double vmin = (**el).vmin();
double vmax = (**el).vmax();
for(int iv=0; iv<2; iv++) {
for(int iu=0; iu<2; iu++) {
double u = (iu==0) ? umin : umax;
double v = (iv==0) ? vmin : vmax;
for(int iv=0; iv<=nSegPerSpan; iv++) {
for(int iu=0; iu<=nSegPerSpan; iu++) {
double u = umin + (umax-umin)/nSegPerSpan*iu;
double v = vmin + (vmax-vmin)/nSegPerSpan*iv;
if(dir==0)
prm.push_back(u);
else
@ -1226,14 +1222,20 @@ bool ASMu2D::tesselate (ElementBlock& grid, const int* npe) const
#endif
if(!lrspline) return false;
if(npe[0] != 2 || npe[1] != 2) {
std::cerr <<" *** ASMu2D::tesselate: unstructured tesselation only allows for 2 tesselation points\n";
if(npe[0] != npe[1]) {
std::cerr << "ASMu2D::tesselate does not support different tesselation resolution in "
<< "u- and v-direction. nviz u = " << npe[0] << ", nviz v = " << npe[1] << "\n";
return false;
}
int nNodesPerElement = npe[0] * npe[1];
int nSubElPerElement = (npe[0]-1)*(npe[1]-1);
int nElements = lrspline->nElements();
// output is written once for each element resulting in a lot of unnecessary storage
// this is preferable to figuring out all element topology information
grid.unStructResize((size_t) lrspline->nElements(), (size_t) lrspline->nElements()*4);
grid.unStructResize(nElements * nSubElPerElement,
nElements * nNodesPerElement);
std::vector<LR::Element*>::iterator el;
int inod = 0;
@ -1244,10 +1246,10 @@ bool ASMu2D::tesselate (ElementBlock& grid, const int* npe) const
double umax = (**el).umax();
double vmin = (**el).vmin();
double vmax = (**el).vmax();
for(int iv=0; iv<2; iv++) {
for(int iu=0; iu<2; iu++) {
double u = (iu==0) ? umin : umax;
double v = (iv==0) ? vmin : vmax;
for(int iv=0; iv<npe[1]; iv++) {
for(int iu=0; iu<npe[0]; iu++) {
double u = umin + (umax-umin)/(npe[0]-1)*iu;
double v = vmin + (vmax-vmin)/(npe[1]-1)*iv;
Go::Point pt;
lrspline->point(pt, u,v, iel);
for(int dim=0; dim<nsd; dim++)
@ -1257,13 +1259,20 @@ bool ASMu2D::tesselate (ElementBlock& grid, const int* npe) const
}
}
// due to duplicate point storage, the element-to-node array is sort of trivial
for(int i=0; i<lrspline->nElements()*4; i+=4) {
// enumerate nodes counter clockwise around the quad
grid.setNode(i , i );
grid.setNode(i+1, i+1);
grid.setNode(i+2, i+3);
grid.setNode(i+3, i+2);
int ip = 0;
iel = 0;
for(int i=0; i<lrspline->nElements(); i++) {
int iStart = i*nNodesPerElement;
for(int iv=0; iv<npe[1]-1; iv++) {
for(int iu=0; iu<npe[0]-1; iu++, iel++) {
// enumerate nodes counterclockwise around the quad
grid.setNode(ip++, iStart + (iv )*npe[0] + (iu ) );
grid.setNode(ip++, iStart + (iv )*npe[0] + (iu+1) );
grid.setNode(ip++, iStart + (iv+1)*npe[0] + (iu+1) );
grid.setNode(ip++, iStart + (iv+1)*npe[0] + (iu ) );
grid.setElmId(iel+1, i+1);
}
}
}
return true;
@ -1305,11 +1314,13 @@ bool ASMu2D::evalSolution (Matrix& sField, const Vector& locSol,
// Evaluate the primary solution field at each point
size_t nPoints = gpar[0].size();
size_t nElements = lrspline->nElements();
size_t nPtsPerElement = nPoints / nElements;
sField.resize(nComp,nPoints);
for (size_t i = 0; i < nPoints; i++)
{
// fetch element containing evaluation point
int iel = i/4; // points are always listed in the same order as the elemnts, 4 pts per element
int iel = i/nPtsPerElement; // points are always listed in the same order as the elemnts
// fetch index of non-zero basis functions on this element
const IntVec& ip = MNPC[iel];
@ -1427,26 +1438,39 @@ bool ASMu2D::evalSolution (Matrix& sField, const Integrand& integrand,
Matrix3D d2Ndu2, d2NdX2, Hess;
size_t nPoints = gpar[0].size();
size_t nElements = lrspline->nElements();
size_t nPtsPerElement = nPoints / nElements;
size_t npe = floor((sqrt(nPtsPerElement)+.5));
double edge_epsilon = 0.01; // percentage offset from element size
bool use2ndDer = integrand.getIntegrandType() == 2;
// Evaluate the secondary solution field at each point
for (size_t i = 0; i < nPoints; i++)
{
// Fetch element containing evaluation point. Points are always listed
int iel = i/4; // in the same order as the elements, 4 pts per element.
int iel = i/nPtsPerElement; // in the same order as the elements
LR::Element *el = lrspline->getElement(iel);
double du = el->umax() - el->umin();
double dv = el->vmax() - el->vmin();
double u = gpar[0][i];
double v = gpar[1][i];
if( i%npe == npe-1 )
u -= edge_epsilon*du;
if( (i%nPtsPerElement) / npe == npe-1)
v -= edge_epsilon*dv;
// Evaluate the basis functions at current parametric point
Vector N(lrspline->getElement(iel)->nBasisFunctions());
if (use2ndDer)
{
Go::BasisDerivsSf2 spline;
lrspline->computeBasis(gpar[0][i],gpar[1][i],spline,iel);
lrspline->computeBasis(u, v, spline,iel);
extractBasis(spline,N,dNdu,d2Ndu2);
}
else
{
Go::BasisDerivsSf spline;
lrspline->computeBasis(gpar[0][i],gpar[1][i],spline,iel);
lrspline->computeBasis(u, v, spline,iel);
extractBasis(spline,N,dNdu);
}