54 ProcessScalGrad::create,
"Computes scalar gradient field.");
59 f->m_writeBndFld =
true;
60 f->m_declareExpansionAsContField =
true;
61 m_f->m_fldToBnd =
false;
73 cout <<
"ProcessScalGrad: Calculating scalar gradient..." << endl;
77 string bvalues =
m_config[
"bnd"].as<
string>();
79 if(bvalues.compare(
"All") == 0)
82 BndExp =
m_f->m_exp[0]->GetBndCondExpansions();
84 for(i = 0; i < BndExp.num_elements(); ++i)
86 m_f->m_bndRegionsToWrite.push_back(i);
92 m_f->m_bndRegionsToWrite),
"Failed to interpret range string");
95 int spacedim =
m_f->m_graph->GetSpaceDimension();
96 if ((
m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
97 (
m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
102 int nfields =
m_f->m_fielddef[0]->m_fields.size();
107 ASSERTL0(
false,
"Error: scalar gradient for a 1D problem cannot "
112 int ngrad = spacedim;
113 int n, cnt, elmtid, nq, offset, boundary, nfq;
114 int npoints =
m_f->m_exp[0]->GetNpoints();
124 m_f->m_exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
126 for (i = 0; i < nfields; i++)
128 var =
m_f->m_fielddef[0]->m_fields[i];
129 stringstream filename;
130 filename << var <<
"_scalar_gradient";
132 m_f->m_fielddef[0]->m_fields[i] = var;
134 BndExp[i] =
m_f->m_exp[i]->GetBndCondExpansions();
139 for(cnt = n = 0; n < BndExp[0].num_elements(); ++n)
141 bool doneBnd =
false;
143 for(
int b = 0; b <
m_f->m_bndRegionsToWrite.size(); ++b)
145 if(n ==
m_f->m_bndRegionsToWrite[b])
148 for(i = 0; i < BndExp[0][n]->GetExpSize(); ++i, cnt++)
151 elmtid = BoundarytoElmtID[cnt];
152 elmt =
m_f->m_exp[0]->GetExp(elmtid);
153 nq = elmt->GetTotPoints();
154 offset =
m_f->m_exp[0]->GetPhys_Offset(elmtid);
158 for(j = 0; j < ngrad; ++j)
169 for(j = 0; j < nfields; j++)
171 outfield[j] = BndExp[j][n]->UpdateCoeffs() + BndExp[j][n]->GetCoeff_Offset(i);
179 boundary = BoundarytoTraceID[cnt];
185 = elmt->GetFaceNormal(boundary);
188 for(j = 0; j < ngrad; ++j)
194 for(k = 0; k < nfields; k++)
198 scalar =
m_f->m_exp[k]->GetPhys() + offset;
199 elmt->PhysDeriv(scalar, grad[0],grad[1],grad[2]);
201 for(j = 0; j < ngrad; ++j)
203 elmt->GetFacePhysVals(boundary,bc,grad[j],fgrad[j]);
209 for (j=0; j<ngrad; j++)
211 Vmath::Vvtvp(nfq, normals[j], 1, fgrad[j], 1, gradnorm, 1, gradnorm, 1);
216 for (j=0; j<ngrad; j++)
218 Vmath::Svtvp(nfq, normals[j][0], fgrad[j], 1, gradnorm, 1, gradnorm, 1);
221 bc->FwdTrans(gradnorm, outfield[k]);
230 cnt += BndExp[0][n]->GetExpSize();
234 for(j = 0; j < nfields; ++j)
236 for(
int b = 0; b <
m_f->m_bndRegionsToWrite.size(); ++b)
238 m_f->m_exp[j]->UpdateBndCondExpansion(
m_f->m_bndRegionsToWrite[b]) = BndExp[j][
m_f->m_bndRegionsToWrite[b]];
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
static bool GenerateOrderedVector(const char *const str, std::vector< unsigned int > &vec)
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
map< string, ConfigOption > m_config
List of configuration values.
FieldSharedPtr m_f
Field object.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
boost::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
boost::shared_ptr< Field > FieldSharedPtr
Represents a command-line configuration option.
virtual ~ProcessScalGrad()
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
void Zero(int n, T *x, const int incx)
Zero vector.
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
Geometry is curved or has non-constant factors.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.