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;
73 if(
m_f->m_comm->GetRank() == 0)
75 cout <<
"ProcessC0Projection: Projecting field into C0 space..."
82 if(
m_f->m_graph->GetMeshDimension() == 3)
84 if(boost::iequals(
m_f->m_session->GetSolverInfo(
"GLOBALSYSSOLN"),
85 "IterativeStaticCond"))
87 if(boost::iequals(
m_f->m_session->GetSolverInfo(
"PRECONDITIONER"),
90 m_f->m_session->SetSolverInfo(
"PRECONDITIONER",
"LowEnergyBlock");
92 if(boost::iequals(
m_f->m_session->GetSolverInfo(
"PRECONDITIONER"),
93 "FullLinearSpaceWithDiagonal"))
95 m_f->m_session->SetSolverInfo(
"PRECONDITIONER",
"FullLinearSpaceWithLowEnergyBlock");
100 if(
m_f->m_comm->GetRank() == 0)
102 cout <<
"Resetting diagonal precondition to low energy block " << endl;
107 bool JustPerformLocToGloMap =
m_config[
"localtoglobalmap"].as<
bool>();
108 bool HelmSmoother = (boost::iequals(
m_config[
"helmsmoothing"].as<string>(),
"Not Set"))?
false:
true;
109 int nfields =
m_f->m_exp.size();
111 if(
m_config[
"usexmlbcs"].as<bool>())
113 for(
int i = 0; i < nfields; ++i)
115 C0ProjectExp[i] =
m_f->m_exp[i];
121 bool savedef =
m_f->m_declareExpansionAsContField;
122 m_f->m_declareExpansionAsContField =
true;
123 C0ProjectExp[0] =
m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir,
125 m_f->m_declareExpansionAsContField = savedef;
126 for(
int i = 1; i < nfields; ++i)
128 C0ProjectExp[i] = C0ProjectExp[0];
132 string fields =
m_config[
"fields"].as<
string>();
133 vector<unsigned int> processFields;
135 if(fields.compare(
"All") == 0)
137 for(
int i = 0; i < nfields; ++i)
139 processFields.push_back(i);
146 "Failed to interpret field string in C0Projection");
149 for (
int i = 0; i < processFields.size(); ++i)
151 ASSERTL0(processFields[i] < nfields,
152 "Attempt to process field that is larger than then number of "
157 if(
m_f->m_comm->GetRank() == 0)
159 cout <<
"\t Processing field: " << processFields[i] << endl;
163 if(JustPerformLocToGloMap)
165 int ncoeffs =
m_f->m_exp[0]->GetNcoeffs();
167 C0ProjectExp[processFields[i]]->UpdateCoeffs(),1);
168 C0ProjectExp[processFields[i]]->LocalToGlobal();
169 C0ProjectExp[processFields[i]]->GlobalToLocal();
170 Vmath::Vcopy(ncoeffs,C0ProjectExp[processFields[i]]->GetCoeffs(),1,
171 m_f->m_exp[processFields[i]]->UpdateCoeffs(),1);
177 int dim =
m_f->m_graph->GetSpaceDimension();
178 int npoints =
m_f->m_exp[0]->GetNpoints();
180 lambda = 2*M_PI/lambda;
181 lambda = lambda*lambda;
185 cout <<
"Setting up Helmholtz smoother with lambda = " << lambda << endl;
193 for(
int j =0; j < dim; ++j)
198 C0ProjectExp[processFields[i]]->BwdTrans(
m_f->m_exp[processFields[i]]->GetCoeffs(),
199 m_f->m_exp[processFields[i]]->UpdatePhys());
201 Vmath::Smul(npoints,-lambda,
m_f->m_exp[processFields[i]]->GetPhys(),1,
210 C0ProjectExp[processFields[i]]->LinearAdvectionDiffusionReactionSolve(Velocity,
212 m_f->m_exp[processFields[i]]->UpdateCoeffs(),
217 C0ProjectExp[processFields[i]]->BwdTrans(
m_f->m_exp[processFields[i]]->GetCoeffs(),
218 m_f->m_exp[processFields[i]]->UpdatePhys());
219 C0ProjectExp[processFields[i]]->FwdTrans(
m_f->m_exp[processFields[i]]->GetPhys(),
220 m_f->m_exp[processFields[i]]->UpdateCoeffs());
226 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
227 =
m_f->m_exp[0]->GetFieldDefinitions();
229 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
231 for(
int i = 0; i < nfields; ++i)
233 for (
int j = 0; j < FieldDef.size(); ++j)
235 FieldDef[j]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[i]);
236 m_f->m_exp[i]->AppendFieldData(FieldDef[j], FieldData[j]);
240 m_f->m_fielddef = FieldDef;
241 m_f->m_data = FieldData;
#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.
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.