55 ProcessGrad::create,
"Computes gradient of fields.");
69 cout <<
"ProcessGrad: Calculating gradients..." << endl;
73 int expdim =
m_f->m_graph->GetMeshDimension();
74 int spacedim =
m_f->m_fielddef[0]->m_numHomogeneousDir + expdim;
75 int nfields =
m_f->m_fielddef[0]->m_fields.size();
76 int addfields = nfields*spacedim;
78 int npoints =
m_f->m_exp[0]->GetNpoints();
80 m_f->m_exp.resize(nfields+addfields);
82 for (i = 0; i < addfields; ++i)
88 for(
int i = 0; i<spacedim; i++)
100 if (
m_f->m_fieldMetaDataMap.count(
"MappingCartesianVel"))
102 if(
m_f->m_fieldMetaDataMap[
"MappingCartesianVel"] ==
"False")
105 for (
int i =0; i<spacedim; ++i )
108 if (
m_f->m_exp[0]->GetWaveSpace())
110 m_f->m_exp[0]->HomogeneousBwdTrans(
111 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 )
144 for (
int i =0; i<spacedim; ++i )
153 for (i = 0; i < nfields; ++i)
155 for (j = 0; j < spacedim; ++j)
166 m_f->m_exp[i]->GetPhys(),
170 mapping->CovarToCartesian(tmp, tmp);
171 for(
int j = 0; j<spacedim; j++)
173 Vmath::Vcopy(npoints, tmp[j], 1, grad[i*spacedim+j], 1 );
177 for (i = 0; i < addfields; ++i)
179 m_f->m_exp[nfields + i] =
m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
180 m_f->m_exp[nfields + i]->UpdatePhys() = grad[i];
181 m_f->m_exp[nfields + i]->FwdTrans_IterPerExp(grad[i],
182 m_f->m_exp[nfields + i]->UpdateCoeffs());
185 vector<string > outname;
186 for (i = 0; i<nfields; ++i)
190 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_x");
192 else if (spacedim == 2)
194 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_x");
195 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_y");
197 else if (spacedim == 3)
199 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_x");
200 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_y");
201 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_z");
205 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
206 =
m_f->m_exp[0]->GetFieldDefinitions();
207 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
209 for (j = 0; j < nfields + addfields; ++j)
211 for (i = 0; i < FieldDef.size(); ++i)
215 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
219 FieldDef[i]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[j]);
221 m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
225 m_f->m_fielddef = FieldDef;
226 m_f->m_data = FieldData;
pair< ModuleType, string > ModuleKey
FieldSharedPtr m_f
Field object.
static GlobalMapping::MappingSharedPtr GetMapping(FieldSharedPtr f)
boost::shared_ptr< Field > FieldSharedPtr
GLOBAL_MAPPING_EXPORT typedef boost::shared_ptr< Mapping > MappingSharedPtr
A shared pointer to a Mapping object.
MultiRegions::Direction const DirCartesianMap[]
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.