50 "Computes scalar gradient field.");
66 int spacedim =
m_f->m_graph->GetSpaceDimension();
67 if ((
m_f->m_numHomogeneousDir) == 1 || (
m_f->m_numHomogeneousDir) == 2)
72 int nfields =
m_f->m_variables.size();
75 for (i = 0; i < nfields; i++)
77 var =
m_f->m_variables[i];
78 stringstream filename;
79 filename << var <<
"_scalar_gradient";
81 m_f->m_variables[i] = var;
83 if (
m_f->m_exp[0]->GetNumElmts() == 0)
90 ASSERTL0(
false,
"Error: scalar gradient for a 1D problem cannot "
95 int n, cnt, elmtid, nq, offset, boundary, nfq;
96 int npoints =
m_f->m_exp[0]->GetNpoints();
106 m_f->m_exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID, BoundarytoTraceID);
108 for (i = 0; i < nfields; i++)
110 BndExp[i] =
m_f->m_exp[i]->GetBndCondExpansions();
115 for (cnt = n = 0; n < BndExp[0].size(); ++n)
117 bool doneBnd =
false;
119 for (
int b = 0; b <
m_f->m_bndRegionsToWrite.size(); ++b)
121 if (n ==
m_f->m_bndRegionsToWrite[b])
124 for (i = 0; i < BndExp[0][n]->GetExpSize(); ++i, cnt++)
127 elmtid = BoundarytoElmtID[cnt];
128 elmt =
m_f->m_exp[0]->GetExp(elmtid);
129 nq = elmt->GetTotPoints();
130 offset =
m_f->m_exp[0]->GetPhys_Offset(elmtid);
136 for (j = 0; j < ngrad; ++j)
147 for (j = 0; j < nfields; j++)
149 outfield[j] = BndExp[j][n]->UpdateCoeffs() +
150 BndExp[j][n]->GetCoeff_Offset(i);
154 bc = std::dynamic_pointer_cast<
156 BndExp[0][n]->GetExp(i));
160 boundary = BoundarytoTraceID[cnt];
171 normals = elmt->GetTraceNormal(boundary);
174 for (j = 0; j < ngrad; ++j)
180 for (k = 0; k < nfields; k++)
184 scalar =
m_f->m_exp[k]->GetPhys() + offset;
185 elmt->PhysDeriv(scalar, grad[0], grad[1], grad[2]);
187 for (j = 0; j < ngrad; ++j)
189 elmt->GetTracePhysVals(boundary, bc, grad[j],
194 if (m_metricinfo->GetGtype() ==
197 for (j = 0; j < ngrad; j++)
200 1, gradnorm, 1, gradnorm, 1);
205 for (j = 0; j < ngrad; j++)
208 1, gradnorm, 1, gradnorm, 1);
211 bc->FwdTrans(gradnorm, outfield[k]);
217 if (doneBnd ==
false)
219 cnt += BndExp[0][n]->GetExpSize();
223 for (j = 0; j < nfields; ++j)
225 for (
int b = 0; b <
m_f->m_bndRegionsToWrite.size(); ++b)
227 m_f->m_exp[j]->UpdateBndCondExpansion(
m_f->m_bndRegionsToWrite[b]) =
228 BndExp[j][
m_f->m_bndRegionsToWrite[b]];
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
ProcessScalGrad(FieldSharedPtr f)
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.
~ProcessScalGrad() override
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
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.