55 "Computes gradient of fields.");
69 if (
m_f->m_comm->TreatAsRankZero())
71 cout <<
"ProcessGrad: Calculating gradients..." << endl;
76 int expdim =
m_f->m_graph->GetMeshDimension();
77 int spacedim =
m_f->m_fielddef[0]->m_numHomogeneousDir + expdim;
78 int nfields =
m_f->m_fielddef[0]->m_fields.size();
79 int addfields = nfields * spacedim;
81 int npoints =
m_f->m_exp[0]->GetNpoints();
83 m_f->m_exp.resize(nfields + addfields);
85 for (i = 0; i < addfields; ++i)
91 for (
int i = 0; i < spacedim; i++)
102 if (
m_f->m_fieldMetaDataMap.count(
"MappingCartesianVel"))
104 if (
m_f->m_fieldMetaDataMap[
"MappingCartesianVel"] ==
"False")
107 for (
int i = 0; i < spacedim; ++i)
110 if (
m_f->m_exp[0]->GetWaveSpace())
112 m_f->m_exp[0]->HomogeneousBwdTrans(
m_f->m_exp[i]->GetPhys(),
122 mapping->ContravarToCartesian(vel, vel);
124 if (
m_f->m_exp[0]->GetWaveSpace())
126 for (
int i = 0; i < spacedim; ++i)
128 m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
134 for (
int i = 0; i < spacedim; ++i)
143 for (
int i = 0; i < spacedim; ++i)
151 for (i = 0; i < nfields; ++i)
153 for (j = 0; j < spacedim; ++j)
163 m_f->m_exp[i]->GetPhys(), tmp[j]);
166 mapping->CovarToCartesian(tmp, tmp);
167 for (
int j = 0; j < spacedim; j++)
169 Vmath::Vcopy(npoints, tmp[j], 1, grad[i * spacedim + j], 1);
173 for (i = 0; i < addfields; ++i)
175 m_f->m_exp[nfields + i] =
176 m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
177 Vmath::Vcopy(npoints, grad[i], 1,
m_f->m_exp[nfields + i]->UpdatePhys(),
179 m_f->m_exp[nfields + i]->FwdTrans_IterPerExp(
180 grad[i],
m_f->m_exp[nfields + i]->UpdateCoeffs());
183 vector<string> outname;
184 for (i = 0; i < nfields; ++i)
188 outname.push_back(
m_f->m_fielddef[0]->m_fields[i] +
"_x");
190 else if (spacedim == 2)
192 outname.push_back(
m_f->m_fielddef[0]->m_fields[i] +
"_x");
193 outname.push_back(
m_f->m_fielddef[0]->m_fields[i] +
"_y");
195 else if (spacedim == 3)
197 outname.push_back(
m_f->m_fielddef[0]->m_fields[i] +
"_x");
198 outname.push_back(
m_f->m_fielddef[0]->m_fields[i] +
"_y");
199 outname.push_back(
m_f->m_fielddef[0]->m_fields[i] +
"_z");
203 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
204 m_f->m_exp[0]->GetFieldDefinitions();
205 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
207 for (j = 0; j < nfields + addfields; ++j)
209 for (i = 0; i < FieldDef.size(); ++i)
213 FieldDef[i]->m_fields.push_back(outname[j - nfields]);
217 FieldDef[i]->m_fields.push_back(
218 m_f->m_fielddef[0]->m_fields[j]);
220 m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
224 m_f->m_fielddef = FieldDef;
225 m_f->m_data = FieldData;
pair< ModuleType, string > ModuleKey
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
boost::shared_ptr< Field > FieldSharedPtr
virtual void Process(po::variables_map &vm)
Write mesh to output file.
GLOBAL_MAPPING_EXPORT typedef boost::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
MultiRegions::Direction const DirCartesianMap[]
Abstract base class for processing modules.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
ModuleFactory & GetModuleFactory()
FieldSharedPtr m_f
Field object.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.