52 "Computes scalar gradient field.");
68 int spacedim =
m_f->m_graph->GetSpaceDimension();
69 if ((
m_f->m_numHomogeneousDir) == 1 || (
m_f->m_numHomogeneousDir) == 2)
74 int nfields =
m_f->m_variables.size();
77 for (i = 0; i < nfields; i++)
79 var =
m_f->m_variables[i];
80 stringstream filename;
81 filename << var <<
"_scalar_gradient";
83 m_f->m_variables[i] = var;
85 if (
m_f->m_exp[0]->GetNumElmts() == 0)
92 ASSERTL0(
false,
"Error: scalar gradient for a 1D problem cannot "
97 int n, cnt, elmtid, nq, offset, boundary, nfq;
98 int npoints =
m_f->m_exp[0]->GetNpoints();
108 m_f->m_exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
110 for (i = 0; i < nfields; i++)
112 BndExp[i] =
m_f->m_exp[i]->GetBndCondExpansions();
117 for (cnt = n = 0; n < BndExp[0].size(); ++n)
119 bool doneBnd =
false;
121 for (
int b = 0; b <
m_f->m_bndRegionsToWrite.size(); ++b)
123 if (n ==
m_f->m_bndRegionsToWrite[b])
126 for (i = 0; i < BndExp[0][n]->GetExpSize(); ++i, cnt++)
129 elmtid = BoundarytoElmtID[cnt];
130 elmt =
m_f->m_exp[0]->GetExp(elmtid);
131 nq = elmt->GetTotPoints();
132 offset =
m_f->m_exp[0]->GetPhys_Offset(elmtid);
138 for (j = 0; j < ngrad; ++j)
149 for (j = 0; j < nfields; j++)
151 outfield[j] = BndExp[j][n]->UpdateCoeffs() +
152 BndExp[j][n]->GetCoeff_Offset(i);
156 bc = std::dynamic_pointer_cast<
158 BndExp[0][n]->GetExp(i));
162 boundary = BoundarytoTraceID[cnt];
173 normals = elmt->GetTraceNormal(boundary);
176 for (j = 0; j < ngrad; ++j)
182 for (k = 0; k < nfields; k++)
186 scalar =
m_f->m_exp[k]->GetPhys() + offset;
187 elmt->PhysDeriv(scalar, grad[0], grad[1], grad[2]);
189 for (j = 0; j < ngrad; ++j)
191 elmt->GetTracePhysVals(boundary, bc, grad[j],
196 if (m_metricinfo->GetGtype() ==
199 for (j = 0; j < ngrad; j++)
202 1, gradnorm, 1, gradnorm, 1);
207 for (j = 0; j < ngrad; j++)
210 1, gradnorm, 1, gradnorm, 1);
213 bc->FwdTrans(gradnorm, outfield[k]);
219 if (doneBnd ==
false)
221 cnt += BndExp[0][n]->GetExpSize();
225 for (j = 0; j < nfields; ++j)
227 for (
int b = 0; b <
m_f->m_bndRegionsToWrite.size(); ++b)
229 m_f->m_exp[j]->UpdateBndCondExpansion(
m_f->m_bndRegionsToWrite[b]) =
230 BndExp[j][
m_f->m_bndRegionsToWrite[b]];
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
virtual ~ProcessScalGrad()
ProcessScalGrad(FieldSharedPtr f)
virtual void v_Process(po::variables_map &vm) override
Write mesh to output file.
static ModuleKey className
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
const SpatialDomains::GeomFactorsSharedPtr & GetMetricInfo() const
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
The above copyright notice and this permission notice shall be included.
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
void Zero(int n, T *x, const int incx)
Zero vector.