50 ModuleKey ProcessC0Projection::className =
53 ProcessC0Projection::create,
"Computes C0 projection.");
58 m_config[
"localtoglobalmap"] =
ConfigOption(
true,
"0",
"Just perform a local to global mapping and back");
59 m_config[
"usexmlbcs"] =
ConfigOption(
true,
"0",
"Use boundary conditions given in xml file. Requires all projected fields to be defined in xml file");
60 m_config[
"helmsmoothing"] =
ConfigOption(
false,
"Not Set",
"Use a Helmholtz smoother to remove high frequency components above specified L");
62 f->m_declareExpansionAsContField =
true;
75 if(
m_f->m_comm->GetRank() == 0)
77 cout <<
"ProcessC0Projection: Projecting field into C0 space..."
85 if(
m_f->m_graph->GetMeshDimension() == 3)
87 if(boost::iequals(
m_f->m_session->GetSolverInfo(
"GLOBALSYSSOLN"),
88 "IterativeStaticCond"))
90 if(boost::iequals(
m_f->m_session->GetSolverInfo(
"PRECONDITIONER"),
93 m_f->m_session->SetSolverInfo(
"PRECONDITIONER",
"LowEnergyBlock");
95 if(boost::iequals(
m_f->m_session->GetSolverInfo(
"PRECONDITIONER"),
96 "FullLinearSpaceWithDiagonal"))
98 m_f->m_session->SetSolverInfo(
"PRECONDITIONER",
"FullLinearSpaceWithLowEnergyBlock");
103 if(
m_f->m_comm->GetRank() == 0)
105 cout <<
"Resetting diagonal precondition to low energy block " << endl;
110 bool JustPerformLocToGloMap =
m_config[
"localtoglobalmap"].as<
bool>();
111 bool HelmSmoother = (boost::iequals(
m_config[
"helmsmoothing"].as<string>(),
"Not Set"))?
false:
true;
112 int nfields =
m_f->m_exp.size();
114 if(
m_config[
"usexmlbcs"].as<bool>())
116 for(
int i = 0; i < nfields; ++i)
118 C0ProjectExp[i] =
m_f->m_exp[i];
124 bool savedef =
m_f->m_declareExpansionAsContField;
125 m_f->m_declareExpansionAsContField =
true;
126 C0ProjectExp[0] =
m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir,
128 m_f->m_declareExpansionAsContField = savedef;
129 for(
int i = 1; i < nfields; ++i)
131 C0ProjectExp[i] = C0ProjectExp[0];
135 string fields =
m_config[
"fields"].as<
string>();
136 vector<unsigned int> processFields;
138 if(fields.compare(
"All") == 0)
140 for(
int i = 0; i < nfields; ++i)
142 processFields.push_back(i);
149 "Failed to interpret field string in C0Projection");
152 for (
int i = 0; i < processFields.size(); ++i)
154 ASSERTL0(processFields[i] < nfields,
155 "Attempt to process field that is larger than then number of "
160 if(
m_f->m_comm->GetRank() == 0)
162 cout <<
"\t Processing field: " << processFields[i] << endl;
166 if(JustPerformLocToGloMap)
168 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
170 C0ProjectExp[processFields[i]]->UpdateCoeffs(),1);
171 C0ProjectExp[processFields[i]]->LocalToGlobal();
172 C0ProjectExp[processFields[i]]->GlobalToLocal();
173 Vmath::Vcopy(ncoeffs,C0ProjectExp[processFields[i]]->GetCoeffs(),1,
174 m_f->m_exp[processFields[i]]->UpdateCoeffs(),1);
180 int dim =
m_f->m_graph->GetSpaceDimension();
181 int npoints =
m_f->m_exp[0]->GetNpoints();
183 lambda = 2*M_PI/lambda;
184 lambda = lambda*lambda;
188 cout <<
"Setting up Helmholtz smoother with lambda = " << lambda << endl;
196 for(
int i =0; i < dim; ++i)
201 C0ProjectExp[processFields[i]]->BwdTrans(
m_f->m_exp[processFields[i]]->GetCoeffs(),
202 m_f->m_exp[processFields[i]]->UpdatePhys());
204 Vmath::Smul(npoints,-lambda,
m_f->m_exp[processFields[i]]->GetPhys(),1,
213 C0ProjectExp[processFields[i]]->LinearAdvectionDiffusionReactionSolve(Velocity,
215 m_f->m_exp[processFields[i]]->UpdateCoeffs(),
220 C0ProjectExp[processFields[i]]->BwdTrans(
m_f->m_exp[processFields[i]]->GetCoeffs(),
221 m_f->m_exp[processFields[i]]->UpdatePhys());
222 C0ProjectExp[processFields[i]]->FwdTrans(
m_f->m_exp[processFields[i]]->GetPhys(),
223 m_f->m_exp[processFields[i]]->UpdateCoeffs());
229 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
230 =
m_f->m_exp[0]->GetFieldDefinitions();
232 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
234 for(
int i = 0; i < nfields; ++i)
236 for (
int j = 0; j < FieldDef.size(); ++j)
238 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
239 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
243 m_f->m_fielddef = FieldDef;
244 m_f->m_data = FieldData;
248 if(
m_f->m_comm->GetRank() == 0)
254 ss << cpuTime <<
"s";
255 cout <<
"C0 Projection CPU Time: " << setw(8) << left
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
static bool GenerateOrderedVector(const char *const str, std::vector< unsigned int > &vec)
virtual ~ProcessC0Projection()
map< string, ConfigOption > m_config
List of configuration values.
std::map< ConstFactorType, NekDouble > ConstFactorMap
FieldSharedPtr m_f
Field object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
boost::shared_ptr< Field > FieldSharedPtr
Represents a command-line configuration option.
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
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.