55 ProcessGrad::create,
"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++)
103 if (
m_f->m_fieldMetaDataMap.count(
"MappingCartesianVel"))
105 if(
m_f->m_fieldMetaDataMap[
"MappingCartesianVel"] ==
"False")
108 for (
int i =0; i<spacedim; ++i )
111 if (
m_f->m_exp[0]->GetWaveSpace())
113 m_f->m_exp[0]->HomogeneousBwdTrans(
114 m_f->m_exp[i]->GetPhys(),
125 mapping->ContravarToCartesian(vel, vel);
127 if (
m_f->m_exp[0]->GetWaveSpace())
129 for (
int i =0; i<spacedim; ++i )
131 m_f->m_exp[0]->HomogeneousFwdTrans(vel[i], vel[i]);
137 for (
int i =0; i<spacedim; ++i )
147 for (
int i =0; i<spacedim; ++i )
156 for (i = 0; i < nfields; ++i)
158 for (j = 0; j < spacedim; ++j)
169 m_f->m_exp[i]->GetPhys(),
173 mapping->CovarToCartesian(tmp, tmp);
174 for(
int j = 0; j<spacedim; j++)
176 Vmath::Vcopy(npoints, tmp[j], 1, grad[i*spacedim+j], 1 );
180 for (i = 0; i < addfields; ++i)
182 m_f->m_exp[nfields + i] =
m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
183 m_f->m_exp[nfields + i]->UpdatePhys() = grad[i];
184 m_f->m_exp[nfields + i]->FwdTrans_IterPerExp(grad[i],
185 m_f->m_exp[nfields + i]->UpdateCoeffs());
188 vector<string > outname;
189 for (i = 0; i<nfields; ++i)
193 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_x");
195 else if (spacedim == 2)
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");
200 else if (spacedim == 3)
202 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_x");
203 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_y");
204 outname.push_back(
m_f->m_fielddef[0]->m_fields[i]+
"_z");
208 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
209 =
m_f->m_exp[0]->GetFieldDefinitions();
210 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
212 for (j = 0; j < nfields + addfields; ++j)
214 for (i = 0; i < FieldDef.size(); ++i)
218 FieldDef[i]->m_fields.push_back(outname[j-nfields]);
222 FieldDef[i]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[j]);
224 m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
228 m_f->m_fielddef = FieldDef;
229 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.