Commit 660b8781 authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Code formatting

parent d61fa001
......@@ -538,8 +538,6 @@ namespace Nektar
if (Vmath::Vmin(pts, &jac[0], 1) < 0)
{
NekDouble dumb = Vmath::Vmin(pts, &jac[0],1);
cout << dumb << '\n';
m_valid = false;
}
}
......
......@@ -2002,7 +2002,6 @@ namespace Nektar
{
LibUtilities::PointsKey pkey(nmodes[cnt], LibUtilities::eGaussLobattoLegendre);
if(numPointDef&&pointDef)
{
const LibUtilities::PointsKey pkey2(npoints[cnt],points[0]);
......
......@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
scal2 = boost::lexical_cast<double>(argv[argc-4]);
//default meshgraph
SpatialDomains::MeshGraph graph;
SpatialDomains::MeshGraph graph;
//----------------------------------------------
// Import fieldfile1.
......@@ -42,19 +42,23 @@ int main(int argc, char *argv[])
ASSERTL0(fielddata1.size() == fielddata2.size(),"Inner has different size");
//----------------------------------------------
// Add fielddata2 to fielddata1 using m_fields definition to align data.
// Add fielddata2 to fielddata1 using m_fields definition to align data.
for(int i = 0; i < fielddata2.size(); ++i)
int i = 0;
int j = 0;
int k = 0;
int n = 0;
for(i = 0; i < fielddata2.size(); ++i)
{
ASSERTL0(fielddef2[i]->m_numHomogeneousDir == 1,"Expected second fld to have one homogeneous direction");
ASSERTL0(fielddef2[i]->m_numModes[2] == 2,"Expected Fourier field to have 2 modes");
int j;
int datalen1 = fielddata1[i].size()/fielddef1[i]->m_fields.size();
int datalen2 = fielddata2[i].size()/fielddef2[i]->m_fields.size();
ASSERTL0(datalen1*2 == datalen2,"Data per fields is note compatible");
// Determine the number of coefficients per element
int ncoeffs = 0;
switch(fielddef2[i]->m_shapeType)
......@@ -69,33 +73,23 @@ int main(int argc, char *argv[])
ASSERTL0(false,"Shape not recognised");
break;
}
// array for zero packing
// array for zero packing
Array<OneD,NekDouble> Zero(ncoeffs,0.0);
// scale first field
for(j = 0; j < fielddata1[i].size(); ++j)
{
fielddata1[i][j] *= scal1;
}
// scale second field
for(j = 0; j < fielddata2[i].size(); ++j)
{
fielddata2[i][j] *= scal2;
}
std::vector<NekDouble>::iterator vec_iter;
// scale first and second fields
Vmath::Smul(fielddata1[i].size(), scal1, &fielddata1[i][0], 1,
&fielddata1[i][0], 1);
Vmath::Smul(fielddata2[i].size(), scal2, &fielddata2[i][0], 1,
&fielddata2[i][0], 1);
std::vector<NekDouble>::iterator vec_iter;
vector<NekDouble> newdata;
vec_iter = fielddata2[i].begin();
for(int k = 0; k < fielddef2[i]->m_fields.size(); ++k)
for(k = 0; k < fielddef2[i]->m_fields.size(); ++k)
{
// get location of 2D field information in order of field2 ordering
int offset = 0;
for(j = 0; j < fielddef1[i]->m_fields.size(); ++j)
......@@ -106,32 +100,35 @@ int main(int argc, char *argv[])
}
offset += datalen1;
}
if(j != fielddef1[i]->m_fields.size())
{
for(int n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
for(n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
{
// Real zero component
newdata.insert(newdata.end(),&(fielddata1[i][offset+n*ncoeffs]),
&(fielddata1[i][offset+n*ncoeffs]) + ncoeffs);
// Imaginary zero component;
// Real zero component
newdata.insert(newdata.end(),
&(fielddata1[i][offset+n*ncoeffs]),
&(fielddata1[i][offset+n*ncoeffs])
+ ncoeffs);
// Imaginary zero component;
newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
// Put orginal mode in here.
// Put orginal mode in here.
newdata.insert(newdata.end(),vec_iter, vec_iter+2*ncoeffs);
vec_iter += 2*ncoeffs;
}
}
else
{
for(int n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
for(n = 0; n < fielddef2[i]->m_elementIDs.size(); ++n)
{
// Real & Imag zero component
// Real & Imag zero component
newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
newdata.insert(newdata.end(),&Zero[0],&Zero[0] + ncoeffs);
// Put orginal mode in here.
// Put orginal mode in here.
newdata.insert(newdata.end(),vec_iter, vec_iter+2*ncoeffs);
vec_iter += 2*ncoeffs;
}
......@@ -144,7 +141,7 @@ int main(int argc, char *argv[])
// check to see if any field in fielddef1[i]->m_fields is
// not defined in fielddef2[i]->m_fields
for(int k = 0; k < fielddef1[i]->m_fields.size(); ++k)
for(k = 0; k < fielddef1[i]->m_fields.size(); ++k)
{
for(j = 0; j < fielddef2[i]->m_fields.size(); ++j)
{
......@@ -153,19 +150,20 @@ int main(int argc, char *argv[])
break;
}
}
if(j == fielddef2[i]->m_fields.size())
{
cout << "Warning: Field \'" << fielddef1[i]->m_fields[k] << "\' was not included in output " << endl;
cout << "Warning: Field \'" << fielddef1[i]->m_fields[k]
<< "\' was not included in output " << endl;
}
}
}
//----------------------------------------------
//-----------------------------------------------
// Write out datafile.
// Write out datafile.
LibUtilities::Write(argv[argc-1], fielddef2, combineddata);
//-----------------------------------------------
......
......@@ -31,8 +31,9 @@ SET(AliasingSources Aliasing.cpp
)
ADD_SOLVER_EXECUTABLE(Fld2DTo2D5 solvers Fld2DTo2D5.cpp)
ADD_SOLVER_EXECUTABLE(Fld2DTo2D5 solvers Fld2DTo2D5.cpp)
ADD_SOLVER_EXECUTABLE(FldAddFalknerSkanBL solvers FldAddFalknerSkanBL.cpp)
ADD_SOLVER_EXECUTABLE(AddModeTo2DFld solvers AddModeTo2DFld.cpp)
ADD_SOLVER_EXECUTABLE(ExtractMeanModeFromHomo1DFld solvers ExtractMeanModeFromHomo1DFld.cpp)
ADD_SOLVER_EXECUTABLE(Aliasing solvers ${AliasingSources})
ADD_SOLVER_EXECUTABLE(AddModeTo2DFld solvers AddModeTo2DFld.cpp)
ADD_SOLVER_EXECUTABLE(ExtractMeanModeFromHomo1DFld
solvers ExtractMeanModeFromHomo1DFld.cpp)
ADD_SOLVER_EXECUTABLE(Aliasing solvers ${AliasingSources})
......@@ -12,9 +12,14 @@ int main(int argc, char *argv[])
fprintf(stderr,"Usage: ExtractmeanModeFromHomo1DFld fieldfile outfield\n");
exit(1);
}
int i = 0;
int k = 0;
int n = 0;
int nz = 0;
int ncoeffs = 0;
//default meshgraph
SpatialDomains::MeshGraph graph;
SpatialDomains::MeshGraph graph;
//----------------------------------------------
// Import fieldfile.
......@@ -24,15 +29,15 @@ int main(int argc, char *argv[])
LibUtilities::Import(fieldfile,fielddef,fielddata);
//----------------------------------------------
vector<vector<NekDouble> > combineddata;
vector<LibUtilities::FieldDefinitionsSharedPtr> newfielddef;
//----------------------------------------------
// put mean data consecutively
for(int i = 0; i < fielddata.size(); ++i)
// put mean data consecutively
for(i = 0; i < fielddata.size(); ++i)
{
ASSERTL0(fielddef[i]->m_numHomogeneousDir == 1,"Expected fieldfile to have one homogeneous direction");
ASSERTL0(fielddef[i]->m_numHomogeneousDir == 1,
"Expected fieldfile to have one homogeneous direction");
if(fielddef[i]->m_homogeneousZIDs[0] != 0)
{
......@@ -40,19 +45,19 @@ int main(int argc, char *argv[])
}
else
{
int nz = fielddef[i]->m_homogeneousZIDs.size();
nz = fielddef[i]->m_homogeneousZIDs.size();
fielddef[i]->m_numHomogeneousDir = 0;
fielddef[i]->m_basis.resize(2);
newfielddef.push_back(fielddef[i]);
// Determine the number of coefficients per element
int ncoeffs;
switch(fielddef[i]->m_shapeType)
{
case LibUtilities::eTriangle:
ncoeffs = LibUtilities::StdTriData::getNumberOfCoefficients(fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
ncoeffs = LibUtilities::StdTriData::getNumberOfCoefficients(
fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
break;
case LibUtilities::eQuadrilateral:
ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
......@@ -61,20 +66,20 @@ int main(int argc, char *argv[])
ASSERTL0(false,"Shape not recognised");
break;
}
std::vector<NekDouble>::iterator vec_iter;
std::vector<NekDouble>::iterator vec_iter;
vector<NekDouble> newdata;
vec_iter = fielddata[i].begin();
for(int k = 0; k < fielddef[i]->m_fields.size(); ++k)
for(k = 0; k < fielddef[i]->m_fields.size(); ++k)
{
// copy data from each field into consecutive order
for(int n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
// copy data from each field into consecutive order
for(n = 0; n < fielddef[i]->m_elementIDs.size(); ++n)
{
// put zero mode into newdata
newdata.insert(newdata.end(),vec_iter, vec_iter+ncoeffs);
vec_iter += nz*ncoeffs;
vec_iter += nz*ncoeffs;
}
}
combineddata.push_back(newdata);
......@@ -83,7 +88,7 @@ int main(int argc, char *argv[])
//----------------------------------------------
//-----------------------------------------------
// Write out datafile.
// Write out datafile.
LibUtilities::Write(argv[argc-1], newfielddef, combineddata);
//-----------------------------------------------
......
......@@ -22,10 +22,10 @@ int main(int argc, char *argv[])
exit(1);
}
string datasave(argv[5]);
string mesh2d(argv[1]);
string mesh3d(argv[3]);
//create 2d session
LibUtilities::SessionReaderSharedPtr vSession2d
= LibUtilities::SessionReader::CreateInstance(2, argv);
......@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
//create 3D session
LibUtilities::SessionReaderSharedPtr vSession3d
= LibUtilities::SessionReader::CreateInstance(2, argv, filenames, vSession2d->GetComm());
SpatialDomains::MeshGraphSharedPtr graphShPt2d = SpatialDomains::MeshGraph::Read(vSession2d);
SpatialDomains::MeshGraphSharedPtr graphShPt3d = SpatialDomains::MeshGraph::Read(vSession3d);
//2D
......@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
Array<OneD, MultiRegions::ExpListSharedPtr> Exp3d(nfields3d);
MultiRegions::ExpList3DHomogeneous1DSharedPtr Exp3DH1;
// Define Homogeneous expansion
int nplanes;
int nplanes;
//vSession3d->LoadParameter("HomModesZ",nplanes,field3ddef[0]->m_numModes[2]);
nplanes = field3ddef[0]->m_numModes[2];
cout<< nplanes << endl;
......@@ -102,27 +102,27 @@ int main(int argc, char *argv[])
Exp3DH1 = MemoryManager<MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(vSession3d,Bkey,lz,useFFT,dealiasing,graphShPt3d);
Exp3d[0] = Exp3DH1;
for(j = 1; j < nfields3d; ++j)
{
{
Exp3d[j] = MemoryManager<MultiRegions::ExpList3DHomogeneous1D>::AllocateSharedPtr(*Exp3DH1);
}
k=0;
for(j = 0; j < nfields2d; ++j)
{
{
if (j< nfields2d-1)
{
for(int i = 0; i < field2ddata.size(); ++i)
{
for(int i = 0; i < field2ddata.size(); ++i)
{
Exp2d[j]->ExtractDataToCoeffs(
field2ddef[i],
field2ddata[i],
field2ddef[i]->m_fields[j],
Exp3d[j]->GetPlane(k)->UpdateCoeffs());
}
field2ddata[i],
field2ddef[i]->m_fields[j],
Exp3d[j]->GetPlane(k)->UpdateCoeffs());
}
}
if (j==nfields2d-1)
{
for(int i = 0; i < field2ddata.size(); ++i)
for(int i = 0; i < field2ddata.size(); ++i)
{
Exp2d[j]->ExtractDataToCoeffs(
field2ddef[i],
......@@ -137,9 +137,9 @@ int main(int argc, char *argv[])
{
fieldcoeffs[j] = Exp3d[j]->UpdateCoeffs();
for(int i = 0; i < field3ddef.size(); ++i)
{
{
Exp3d[0]->AppendFieldData(field3ddef[i], field3ddatanew[i],fieldcoeffs[j]);
}
}
}
LibUtilities::Write(datasave,field3ddef,field3ddatanew);
return 0;
......
/* ==========================================================================
* Generation of a .fld file for the Falkner-Skan boundary layer starting
* from a session file with some physical data for the definition of the
* BL and a .txt file with the similarity solution.
* Generation of a .fld file for the Falkner-Skan boundary layer starting
* from a session file with some physical data for the definition of the
* BL and a .txt file with the similarity solution.
* ======================================================================== */
/* =====================================
* Author: Gianmarco Mengaldo
* Author: Gianmarco Mengaldo
* Generation: dd/mm/aa = 08/03/12
* Mantainer: Gianmarco Mengaldo
===================================== */
===================================== */
//! Loading cc libraries
#include <cstdio>
......@@ -32,19 +32,19 @@ int main(int argc, char *argv[])
{
//! Setting up the decimal precision to machine precision
setprecision (16);
//! Auxiliary counters for the x and y directions
int i, j, numModes, nFields;
//! Usage check
if((argc != 2) && (argc != 3))
if((argc != 2) && (argc != 3))
{
fprintf(stderr,"Usage: ./FldAddFalknerSkanBL sessionFile [SysSolnType]\n");exit(1);
}
//! Reading the session file
LibUtilities::SessionReaderSharedPtr vSession = LibUtilities::SessionReader::CreateInstance(argc, argv);
//! Loading the parameters to define the BL
NekDouble Re;
NekDouble L;
......@@ -55,17 +55,17 @@ int main(int argc, char *argv[])
string BL_type;
string txt_file;
string stability_solver;
int numLines;
int numLines;
BL_type = vSession->GetSolverInfo("BL_type");
txt_file = vSession->GetSolverInfo("txt_file");
stability_solver = vSession->GetSolverInfo("stability_solver");
if(stability_solver != "velocity_correction_scheme" &&
if(stability_solver != "velocity_correction_scheme" &&
stability_solver != "coupled_scheme")
{
fprintf(stderr,"Error: You must specify the stability solver in the session file properly.\n");
fprintf(stderr,"Error: You must specify the stability solver in the session file properly.\n");
fprintf(stderr,"Options: 'velocity_correction_scheme' [output ===> (u,v,p)]; 'coupled_scheme' [output ===>(u,v)]\n");
exit(1);
}
......@@ -83,14 +83,14 @@ int main(int argc, char *argv[])
fprintf(stderr,"Error: x must be positive ===> CHECK the session file\n");
exit(1);
}
if(x_0 < 0)
{
fprintf(stderr,"Error: x_0 must be positive or at least equal to 0 ===> CHECK the session file\n");
exit(1);
}
std::cout<<"\n=========================================================================\n";
std::cout<<"Falkner-Skan Boundary Layer Generation (version of July 12th 2012)\n";
std::cout<<"Falkner-Skan Boundary Layer Generation (version of July 12th 2012)\n";
std::cout<<"=========================================================================\n";
std::cout<<"*************************************************************************\n";
std::cout<<"DATA FROM THE SESSION FILE:\n";
......@@ -106,23 +106,23 @@ int main(int argc, char *argv[])
std::cout<<"*************************************************************************\n";
std::cout<<"-------------------------------------------------------------------------\n";
std::cout<<"MESH and EXPANSION DATA:\n";
//! Computation of the kinematic viscosity
nu = U_inf * L / Re;
//! Read in mesh from input file and create an object of class MeshGraph2D
SpatialDomains::MeshGraphSharedPtr graphShPt;
SpatialDomains::MeshGraphSharedPtr graphShPt;
graphShPt = MemoryManager<SpatialDomains::MeshGraph2D>::AllocateSharedPtr(vSession);
//! Feed our spatial discretisation object
MultiRegions::ContField2DSharedPtr Domain;
Domain = MemoryManager<MultiRegions::ContField2D>::AllocateSharedPtr(vSession,graphShPt,vSession->GetVariable(0));
//! Get the total number of elements
int nElements;
nElements = Domain->GetExpSize();
std::cout << "Number of elements = " << nElements << std::endl;
//! Get the total number of quadrature points (depends on n. modes)
int nQuadraturePts;
nQuadraturePts = Domain->GetTotPoints();
......@@ -144,12 +144,12 @@ int main(int argc, char *argv[])
//! Open the .txt file with the BL data
ifstream pFile(txt_file_char);
if (!pFile)
if (!pFile)
{
cout << "Errro: Unable to open the .txt file with the BL data\n";
exit(1);
}
exit(1);
}
numLines = numLines/3;
NekDouble d;
std::vector<std::vector<NekDouble> > GlobalArray (3);
......@@ -183,29 +183,29 @@ int main(int argc, char *argv[])
}
//! --------------------------------------------------------------------------------------------
//! Inizialisation of the arrays for computations on the Quadrature points ---------------------
//! Inizialisation of the arrays for computations on the Quadrature points ---------------------
Array<OneD,NekDouble> eta_QuadraturePts;
eta_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
Array<OneD,NekDouble> f_QuadraturePts;
f_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
Array<OneD,NekDouble> df_QuadraturePts;
df_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
Array<OneD,NekDouble> u_QuadraturePts;
u_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
Array<OneD,NekDouble> v_QuadraturePts;
v_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
Array<OneD,NekDouble> p_QuadraturePts;
p_QuadraturePts = Array<OneD,NekDouble>(nQuadraturePts);
//! --------------------------------------------------------------------------------------------
//! PARALLEL CASE ------------------------------------------------------------------------------
if(BL_type == "Parallel")
{
......@@ -216,16 +216,16 @@ int main(int argc, char *argv[])
{
if(eta_QuadraturePts[i] >= eta[j] && eta_QuadraturePts[i] <= eta[j+1])
{
f_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (f[j+1] - f[j]) / (eta[j+1] - eta[j]) + f[j];
f_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (f[j+1] - f[j]) / (eta[j+1] - eta[j]) + f[j];
df_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (df[j+1] - df[j]) / (eta[j+1] - eta[j]) + df[j];
}
else if(eta_QuadraturePts[i] == 1000000)
{
f_QuadraturePts[i] = f[numLines-1];
df_QuadraturePts[i] = df[numLines-1];
}
else if(eta_QuadraturePts[i] > eta[numLines-1])
{
f_QuadraturePts[i] = f[numLines-1] + df[numLines-1] * (eta_QuadraturePts[i] - eta[numLines-1]);
......@@ -241,79 +241,79 @@ int main(int argc, char *argv[])
}
//! --------------------------------------------------------------------------------------------
//! NON-PARALLEL CASE --------------------------------------------------------------------------
if(BL_type == "nonParallel")
{
for(i=0; i<nQuadraturePts; i++)
{
eta_QuadraturePts[i] = y_QuadraturePts[i] * sqrt(U_inf / (2 * (x_QuadraturePts[i] + x_0) * nu));
if((x_QuadraturePts[i] + x_0) == 0)
{
eta_QuadraturePts[i] = 1000000;
eta_QuadraturePts[i] = 1000000;
}
for(j=0; j<numLines-1; j++)
{
if(eta_QuadraturePts[i] >= eta[j] && eta_QuadraturePts[i] <= eta[j+1])
{
f_QuadraturePts[i] = (eta_QuadraturePts[i] - eta[j]) * (f[j+1] - f[j]) / (eta[j+1] - eta[j]) + f[j];