51 "Writes a Fld file."),
54 "Writes a Fld file."),
68 string filename =
m_config[
"outfile"].as<
string>();
70 if (
m_f->m_writeBndFld)
75 if (
m_f->m_fldToBnd) {
76 for (
int i = 0; i <
m_f->m_exp.size(); ++i)
78 m_f->m_exp[i]->FillBndCondFromField();
84 cout <<
"OutputFld: Writing boundary file(s): ";
85 for(
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
87 if(i < m_f->m_bndRegionsToWrite.size()-1)
95 int nfields =
m_f->m_exp.size();
98 for (
int i = 0; i < nfields; ++i)
100 BndExp[i] =
m_f->m_exp[i]->GetBndCondExpansions();
106 m_f->m_exp[0]->GetGraph());
109 SpatialDomains::BoundaryRegionCollection::const_iterator breg_it;
110 map<int,int> BndRegionMap;
112 for(breg_it = bregions.begin(); breg_it != bregions.end();
115 BndRegionMap[breg_it->first] = cnt;
119 int dot = filename.find_last_of(
'.') + 1;
120 string ext = filename.substr(dot, filename.length() - dot);
121 string name = filename.substr(0, dot-1);
124 m_f->m_session->GetBndRegionOrdering();
126 for(
int i = 0; i <
m_f->m_bndRegionsToWrite.size(); ++i)
128 string outname = name +
"_b"
129 + boost::lexical_cast<
string>(
m_f->m_bndRegionsToWrite[i])
132 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
133 std::vector<std::vector<NekDouble> > FieldData;
135 if(BndRegionMap.count(
m_f->m_bndRegionsToWrite[i]) == 1)
137 int Border = BndRegionMap[
m_f->m_bndRegionsToWrite[i]];
139 FieldDef = BndExp[0][Border]->GetFieldDefinitions();
140 FieldData.resize(FieldDef.size());
142 for (
int j = 0; j < nfields; ++j)
144 for (
int k = 0; k < FieldDef.size(); ++k)
146 BndExp[j][Border]->AppendFieldData(FieldDef[k],
149 if (
m_f->m_fielddef.size() > 0)
151 FieldDef[k]->m_fields.push_back(
152 m_f->m_fielddef[0]->m_fields[j]);
156 FieldDef[k]->m_fields.push_back(
157 m_f->m_session->GetVariable(j));
162 if(
m_f->m_addNormals)
165 "Add normals to extracted boundaries only set up in 3 dimensions");
167 string normstr[3] = {
"Norm_x",
"Norm_y",
"Norm_z"};
174 m_f->m_exp[0]->GetBoundaryToElmtMap(BoundarytoElmtID,
179 for(
int n = 0; n < Border; ++n)
181 cnt += BndExp[0][n]->GetExpSize();
187 for(
int j = 0; j < normdim; ++j)
193 for(
int j = 0; j < BndExp[0][Border]->GetExpSize();
197 int elmtid = BoundarytoElmtID[cnt];
198 elmt =
m_f->m_exp[0]->GetExp(elmtid);
204 int boundary = BoundarytoTraceID[cnt];
209 for(
int k = 0; k < normdim; ++k)
211 bc->FwdTrans(normals[k],tmp_array = NormCoeff[k]+BndExp[0][Border]->GetCoeff_Offset(j));
216 for (
int j = 0; j < normdim; ++j)
220 BndExp[0][Border]->UpdateCoeffs(),1);
222 for (
int k = 0; k < FieldDef.size(); ++k)
224 BndExp[0][Border]->AppendFieldData(FieldDef[k],
226 FieldDef[k]->m_fields.push_back(normstr[j]);
232 if (vm.count(
"error"))
234 int rank =
m_f->m_session->GetComm()->GetRank();
236 for (
int j = 0; j < nfields; ++j)
238 BndExp[j][Border]->BwdTrans(BndExp[j][Border]->GetCoeffs(),
239 BndExp[j][Border]->UpdatePhys());
245 ->L2(BndExp[j][Border]->GetPhys());
248 ->Linf(BndExp[j][Border]->GetPhys());
252 cout <<
"L 2 error (variable "
253 << FieldDef[0]->m_fields[j]
254 <<
") : " << l2err << endl;
256 cout <<
"L inf error (variable "
257 << FieldDef[0]->m_fields[j]
258 <<
") : " << linferr << endl;
264 m_f->m_fld->Write(outname, FieldDef, FieldData,
265 m_f->m_fieldMetaDataMap);
273 cout <<
"OutputFld: Writing file..." << endl;
276 fs::path writefile(filename);
278 if(fs::exists(writefile)&&(vm.count(
"forceoutput") == 0))
281 int rank = comm->GetRank();
287 cout <<
"Did you wish to overwrite " << filename <<
" (y/n)? ";
289 if(answer.compare(
"y") == 0)
295 cout <<
"Not writing file " << filename <<
" because it already exists" << endl;
305 m_f->m_fld->Write(filename,
m_f->m_fielddef,
m_f->m_data);
309 if (vm.count(
"error"))
311 int rank =
m_f->m_session->GetComm()->GetRank();
313 for (
int j = 0; j <
m_f->m_exp.size(); ++j)
315 if (
m_f->m_exp[j]->GetPhysState() ==
false)
317 m_f->m_exp[j]->BwdTrans(
318 m_f->m_exp[j]->GetCoeffs(),
319 m_f->m_exp[j]->UpdatePhys());
323 m_f->m_exp[j]->GetPhys());
326 m_f->m_exp[j]->GetPhys());
329 cout <<
"L 2 error (variable "
330 <<
m_f->m_fielddef[0]->m_fields[j]
331 <<
") : " << l2err << endl;
333 cout <<
"L inf error (variable "
334 <<
m_f->m_fielddef[0]->m_fields[j]
335 <<
") : " << linferr << endl;
#define ASSERTL0(condition, msg)
pair< ModuleType, string > ModuleKey
Abstract base class for output modules.
map< string, ConfigOption > m_config
List of configuration values.
std::map< int, std::vector< unsigned int > > BndRegionOrdering
FieldSharedPtr m_f
Field object.
boost::shared_ptr< StdExpansion2D > StdExpansion2DSharedPtr
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
boost::shared_ptr< Field > FieldSharedPtr
const BoundaryRegionCollection & GetBoundaryRegions(void) const
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.