14 int main(
int argc, 
char *argv[])
 
   21         fprintf(stderr,
"Usage: FldAddScalGrad meshfile infld outfld BoundaryID\n");
 
   25     surfID = boost::lexical_cast<
int>(argv[argc - 1]);
 
   27     argv[argc -1] = argv[argc - 2];
 
   30             = LibUtilities::SessionReader::CreateInstance(argc, argv);
 
   34     string meshfile(argv[argc-4]);
 
   40     string fieldfile(argv[argc-3]);
 
   41     vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
 
   42     vector<vector<NekDouble> > fielddata;
 
   48     int expdim  = graphShPt->GetMeshDimension();
 
   58             ASSERTL0(
false,
"Expansion dimension not recognised");
 
   63             ASSERTL0(
false,
"Expansion dimension not recognised");
 
   71                                     vSession->GetVariable(0));
 
   73             m_locToGlobalMap = originalfield->GetLocalToGlobalMap();
 
   75             exp[0] = originalfield;
 
   76             for (i=0; i<expdim; i++)
 
   82             for (i=expdim; i<addfields; i++)
 
   86                                         vSession->GetVariable(0));
 
   92             ASSERTL0(
false,
"Expansion dimension not recognised");
 
   99     for(j = 0; j < nfields+addfields; ++j)
 
  101         for(
int i = 0; i < fielddata.size(); ++i)
 
  103             exp[j]->ExtractDataToCoeffs(fielddef [i],
 
  105                                         fielddef [i]->m_fields[0],
 
  106                                         exp[j]->UpdateCoeffs());
 
  109         exp[j]->BwdTrans(exp[j]->GetCoeffs(),exp[j]->UpdatePhys());
 
  116     int n, cnt, elmtid, nq, offset, nt, boundary, nfq;
 
  117     nt = exp[0]->GetNpoints();
 
  131     exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
 
  134     for (i = 0; i<addfields-expdim; i++)
 
  136         BndExp[i] = exp[i+1+expdim]->GetBndCondExpansions();
 
  140     exp[0]->PhysDeriv(exp[0]->GetPhys(),exp[1]->UpdatePhys(),
 
  141                       exp[2]->UpdatePhys(),exp[3]->UpdatePhys());
 
  145     for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
 
  150             for(i = 0; i < BndExp[0][n]->GetExpSize(); ++i, cnt++)
 
  153                 elmtid = BoundarytoElmtID[cnt];
 
  154                 elmt   = exp[0]->GetExp(elmtid);
 
  155                 nq     = elmt->GetTotPoints();
 
  156                 offset = exp[0]->GetPhys_Offset(elmtid);
 
  160                 for(j = 0; j < expdim; ++j)
 
  170                     for (j = 0; j< addfields-expdim; j++)
 
  172                         values[j] = BndExp[j][n]->UpdateCoeffs() + BndExp[0][n]->GetCoeff_Offset(i);
 
  182                     boundary = BoundarytoTraceID[cnt];
 
  185                     U = exp[0]->GetPhys() + offset;
 
  188                     elmt->PhysDeriv(U,grad[0],grad[1],grad[2]);
 
  191                     for(j = 0; j < expdim; ++j)
 
  198                     for(j = 0; j < expdim; ++j)
 
  200                         elmt->GetFacePhysVals(boundary,bc,grad[j],fgrad[j]);
 
  207                                 = elmt->GetFaceNormal(boundary);
 
  214                                        normals[1],1,fgrad[1],1,gradnorm,1);
 
  215                         Vmath::Vvtvp  (nfq,normals[2],1,fgrad[2],1,gradnorm,1,gradnorm,1);
 
  220                                           normals[1][0],fgrad[1],1,gradnorm,1);
 
  221                         Vmath::Svtvp(nfq,normals[2][0],fgrad[2],1,gradnorm,1,gradnorm,1);
 
  224                     for(j = 0; j<expdim; j++)
 
  226                         bc->FwdTrans(normals[j],values[j]);
 
  231                     bc->FwdTrans(gradnorm,values[expdim]);
 
  238             cnt += BndExp[0][n]->GetExpSize();
 
  242     for(j = 0; j< expdim; j++)
 
  244         exp[j+1]->FwdTrans(exp[j+1]->GetPhys(), exp[j+1]->UpdateCoeffs());
 
  247     for(j = 0; j < addfields-expdim; ++j)
 
  249         int ncoeffs = exp[0]->GetNcoeffs();
 
  252         output=exp[j+1+expdim]->UpdateCoeffs();
 
  254         int nGlobal=m_locToGlobalMap->GetNumGlobalCoeffs();
 
  262         for(
int i = 0; i < BndExp[j].num_elements(); ++i)
 
  267                 for(
int k = 0; k < (BndExp[j][i])->GetNcoeffs(); ++k)
 
  269                     sign = m_locToGlobalMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
 
  270                     outarray[map[bndcnt++]] = sign * coeffs[k];
 
  275                 bndcnt += BndExp[j][i]->GetNcoeffs();
 
  278         m_locToGlobalMap->GlobalToLocal(outarray,output);
 
  284     string   out(argv[argc-2]);
 
  285     std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
 
  286                                                 = exp[0]->GetFieldDefinitions();
 
  287     std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
 
  289     vector<string > outname;
 
  291     outname.push_back(
"du/dx");
 
  292     outname.push_back(
"du/dy");
 
  293     outname.push_back(
"du/dz");
 
  294     outname.push_back(
"nx");
 
  295     outname.push_back(
"ny");
 
  296     outname.push_back(
"nz");
 
  297     outname.push_back(
"gradient");
 
  300     for(j = 0; j < nfields+addfields; ++j)
 
  302         for(i = 0; i < FieldDef.size(); ++i)
 
  306                 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
 
  310                 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
 
  312             exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
 
#define ASSERTL0(condition, msg)
 
#define sign(a, b)
return the sign(b)*a 
 
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
 
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y 
 
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y 
 
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
 
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > ElementiDs)
Imports an FLD file. 
 
int GetTotPoints() const 
This function returns the total number of quadrature points used in the element. 
 
boost::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
 
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y. 
 
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object. 
 
void Vvtvvtp(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtp (vector times vector plus vector times vector): 
 
void Svtsvtp(int n, const T alpha, const T *x, int incx, const T beta, const T *y, int incy, T *z, int incz)
vvtvvtp (scalar times vector plus scalar times vector): 
 
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap)
Write a field file in serial only. 
 
boost::shared_ptr< ContField3D > ContField3DSharedPtr
 
boost::shared_ptr< AssemblyMapCG > AssemblyMapCGSharedPtr
 
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
 
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
 
Geometry is curved or has non-constant factors. 
 
int main(int argc, char *argv[])