20 fprintf(stderr,
"Usage: FldAddScalGrad meshfile infld outfld BoundaryID\n");
24 surfID = boost::lexical_cast<
int>(argv[argc - 1]);
26 argv[argc -1] = argv[argc - 2];
29 = LibUtilities::SessionReader::CreateInstance(argc, argv);
33 string meshfile(argv[argc-4]);
39 string fieldfile(argv[argc-3]);
40 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
41 vector<vector<NekDouble> > fielddata;
47 int expdim = graphShPt->GetMeshDimension();
57 ASSERTL0(
false,
"Expansion dimension not recognised");
62 ASSERTL0(
false,
"Expansion dimension not recognised");
70 vSession->GetVariable(0));
72 m_locToGlobalMap = originalfield->GetLocalToGlobalMap();
74 exp[0] = originalfield;
75 for (i=0; i<addfields; i++)
79 vSession->GetVariable(0));
84 ASSERTL0(
false,
"Expansion dimension not recognised");
91 for(j = 0; j < nfields+addfields; ++j)
93 for(
int i = 0; i < fielddata.size(); ++i)
95 exp[j]->ExtractDataToCoeffs(fielddef [i],
97 fielddef [i]->m_fields[0],
98 exp[j]->UpdateCoeffs());
101 exp[j]->BwdTrans(exp[j]->GetCoeffs(),exp[j]->UpdatePhys());
108 int n, cnt, elmtid, nq, offset, nt, boundary, nfq;
109 nt = exp[0]->GetNpoints();
123 exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,BoundarytoTraceID);
126 for (i = 0; i<addfields; i++)
128 BndExp[i] = exp[i]->GetBndCondExpansions();
132 for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
137 for(i = 0; i < BndExp[0][n]->GetExpSize(); ++i, cnt++)
140 elmtid = BoundarytoElmtID[cnt];
141 elmt = exp[0]->GetExp(elmtid);
142 nq = elmt->GetTotPoints();
143 offset = exp[0]->GetPhys_Offset(elmtid);
147 for(j = 0; j < expdim; ++j)
157 for (j = 0; j< addfields; j++)
159 values[j] = BndExp[j][n]->UpdateCoeffs() + BndExp[j][n]->GetCoeff_Offset(i);
169 boundary = BoundarytoTraceID[cnt];
172 U = exp[0]->GetPhys() + offset;
175 elmt->PhysDeriv(U,grad[0],grad[1],grad[2]);
179 for (j = 0; j< nq; j++)
181 cout <<
"element grad: " << grad[0][j] << endl;
185 for(j = 0; j < expdim; ++j)
192 for(j = 0; j < expdim; ++j)
194 elmt->GetFacePhysVals(boundary,bc,grad[j],fgrad[j]);
195 bc->FwdTrans(fgrad[j],values[j]);
200 for (j = 0; j< nfq; j++)
202 cout <<
"face grad: " << fgrad[0][j] << endl;
209 = elmt->GetFaceNormal(boundary);
216 normals[1],1,fgrad[1],1,gradnorm,1);
217 Vmath::Vvtvp (nfq,normals[2],1,fgrad[2],1,gradnorm,1,gradnorm,1);
222 normals[1][0],fgrad[1],1,gradnorm,1);
223 Vmath::Svtvp(nfq,normals[2][0],fgrad[2],1,gradnorm,1,gradnorm,1);
226 for(j = 0; j<expdim; j++)
228 bc->FwdTrans(normals[j],values[j+expdim]);
233 bc->FwdTrans(gradnorm,values[expdim*2]);
240 cnt += BndExp[0][n]->GetExpSize();
244 for(
int j = 0; j < addfields; ++j)
246 int ncoeffs = exp[0]->GetNcoeffs();
249 output=exp[j+1]->UpdateCoeffs();
251 int nGlobal=m_locToGlobalMap->GetNumGlobalCoeffs();
259 for(
int i = 0; i < BndExp[j].num_elements(); ++i)
264 for(
int k = 0; k < (BndExp[j][i])->GetNcoeffs(); ++k)
266 sign = m_locToGlobalMap->GetBndCondCoeffsToGlobalCoeffsSign(bndcnt);
267 outarray[map[bndcnt++]] = sign * coeffs[k];
272 bndcnt += BndExp[j][i]->GetNcoeffs();
275 m_locToGlobalMap->GlobalToLocal(outarray,output);
281 string out(argv[argc-2]);
282 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
283 = exp[0]->GetFieldDefinitions();
284 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
286 vector<string > outname;
288 outname.push_back(
"du/dx");
289 outname.push_back(
"du/dy");
290 outname.push_back(
"du/dz");
291 outname.push_back(
"nx");
292 outname.push_back(
"ny");
293 outname.push_back(
"nz");
294 outname.push_back(
"gradient");
297 for(j = 0; j < nfields+addfields; ++j)
299 for(i = 0; i < FieldDef.size(); ++i)
303 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
307 FieldDef[i]->m_fields.push_back(fielddef[i]->m_fields[j]);
309 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.