Commit 5c777bd4 authored by Bastien Jordi's avatar Bastien Jordi

Merge branch 'master' into fix/fieldconvert

Conflicts:
	utilities/PostProcessing/FieldConvert/CMakeLists.txt
parents 15283a5e 516a141e
......@@ -1272,7 +1272,7 @@ namespace Nektar
{
normal[0][j+k*nqe0] = df[1][nqe0*(nqe1-1)+j+nqe0*nqe1*k]*jac[nqe0*(nqe1-1)+j+nqe01*k];
normal[1][j+k*nqe0] = df[4][nqe0*(nqe1-1)+j+nqe0*nqe1*k]*jac[nqe0*(nqe1-1)+j+nqe01*k];
normal[1][j+k*nqe0] = df[7][nqe0*(nqe1-1)+j+nqe0*nqe1*k]*jac[nqe0*(nqe1-1)+j+nqe01*k];
normal[2][j+k*nqe0] = df[7][nqe0*(nqe1-1)+j+nqe0*nqe1*k]*jac[nqe0*(nqe1-1)+j+nqe01*k];
}
}
break;
......
......@@ -10,6 +10,7 @@ SET(FieldConvertHeaders
ProcessConcatenateFld.h
ProcessVorticity.h
ProcessC0Projection.h
ProcessQCriterion.h
)
SET(FieldConvertSources
......@@ -24,6 +25,7 @@ SET(FieldConvertSources
ProcessConcatenateFld.cpp
ProcessVorticity.cpp
ProcessC0Projection.cpp
ProcessQCriterion.cpp
)
ADD_UTILITIES_EXECUTABLE(FieldConvert util ${FieldConvertSources} ${FieldConvertHeaders})
......
......@@ -47,79 +47,79 @@ namespace Nektar
namespace Utilities
{
ModuleKey ProcessC0Projection::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "C0Projection"),
ProcessC0Projection::create, "Computes C0 projection.");
ProcessC0Projection::ProcessC0Projection(FieldSharedPtr f) : ProcessModule(f)
{
m_config["fields"] = ConfigOption(false,"All","Start field to project");
}
ProcessC0Projection::~ProcessC0Projection()
{
}
void ProcessC0Projection::Process(po::variables_map &vm)
{
// generate an C0 expansion field with no boundary conditions.
bool savedef = m_f->m_declareExpansionAsContField;
m_f->m_declareExpansionAsContField = true;
m_c0ProjectExp = m_f->AppendExpList("DefaultVar",true);
m_f->m_declareExpansionAsContField = savedef;
if (m_f->m_verbose)
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "C0Projection"),
ProcessC0Projection::create, "Computes C0 projection.");
ProcessC0Projection::ProcessC0Projection(FieldSharedPtr f) : ProcessModule(f)
{
cout << "ProcessC0Projection: Projects fiels into C0 space..." << endl;
m_config["fields"] = ConfigOption(false,"All","Start field to project");
}
int nfields = m_f->m_exp.size();
string fields = m_config["fields"].as<string>();
vector<unsigned int> processFields;
if(fields.compare("All") == 0)
ProcessC0Projection::~ProcessC0Projection()
{
for(int i = 0; i < nfields; ++i)
{
processFields.push_back(i);
}
}
else
void ProcessC0Projection::Process(po::variables_map &vm)
{
// generate an C0 expansion field with no boundary conditions.
bool savedef = m_f->m_declareExpansionAsContField;
m_f->m_declareExpansionAsContField = true;
m_c0ProjectExp = m_f->AppendExpList("DefaultVar",true);
m_f->m_declareExpansionAsContField = savedef;
if (m_f->m_verbose)
{
cout << "ProcessC0Projection: Projects fiels into C0 space..." << endl;
}
int nfields = m_f->m_exp.size();
string fields = m_config["fields"].as<string>();
vector<unsigned int> processFields;
if(fields.compare("All") == 0)
{
for(int i = 0; i < nfields; ++i)
{
ASSERTL0(ParseUtils::GenerateOrderedVector(fields.c_str(),
processFields),
"Failed to interpret field string in C0Projection");
processFields.push_back(i);
}
}
else
{
ASSERTL0(ParseUtils::GenerateOrderedVector(fields.c_str(),
processFields),
"Failed to interpret field string in C0Projection");
}
for (int i = 0; i < processFields.size(); ++i)
{
ASSERTL0(processFields[i] < nfields,"Attempt to process field that is larger than then number of fields available");
for (int i = 0; i < processFields.size(); ++i)
if (m_f->m_verbose)
{
ASSERTL0(processFields[i] < nfields,"Attempt to process field that is larger than then number of fields available");
if (m_f->m_verbose)
{
cout << "\t Processing field: " << processFields[i] << endl;
}
m_c0ProjectExp->BwdTrans(m_f->m_exp[processFields[i]]->GetCoeffs(),
m_f->m_exp[processFields[i]]->UpdatePhys());
m_c0ProjectExp->FwdTrans(m_f->m_exp[processFields[i]]->GetPhys(),
m_f->m_exp[processFields[i]]->UpdateCoeffs());
cout << "\t Processing field: " << processFields[i] << endl;
}
// reset up FieldData with new values before projecting
std::vector<std::vector<NekDouble> > FieldData(m_f->m_fielddef.size());
for(int i = 0; i < nfields; ++i)
{
for (int j = 0; j < m_f->m_fielddef.size(); ++j)
{
m_f->m_exp[i]->AppendFieldData(m_f->m_fielddef[j], FieldData[j]);
}
}
m_c0ProjectExp->BwdTrans(m_f->m_exp[processFields[i]]->GetCoeffs(),
m_f->m_exp[processFields[i]]->UpdatePhys());
m_c0ProjectExp->FwdTrans(m_f->m_exp[processFields[i]]->GetPhys(),
m_f->m_exp[processFields[i]]->UpdateCoeffs());
}
m_f->m_data = FieldData;
// reset up FieldData with new values before projecting
std::vector<std::vector<NekDouble> > FieldData(m_f->m_fielddef.size());
for(int i = 0; i < nfields; ++i)
{
for (int j = 0; j < m_f->m_fielddef.size(); ++j)
{
m_f->m_exp[i]->AppendFieldData(m_f->m_fielddef[j], FieldData[j]);
}
}
}
m_f->m_data = FieldData;
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessQCriterion.cpp
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Computes Q Criterion field.
//
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
using namespace std;
#include "ProcessQCriterion.h"
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
namespace Nektar
{
namespace Utilities
{
ModuleKey ProcessQCriterion::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "QCriterion"),
ProcessQCriterion::create, "Computes Q-Criterion.");
ProcessQCriterion::ProcessQCriterion(FieldSharedPtr f) :
ProcessModule(f)
{
}
ProcessQCriterion::~ProcessQCriterion()
{
}
void ProcessQCriterion::Process(po::variables_map &vm)
{
if (m_f->m_verbose)
{
cout << "ProcessQCriterion: Calculating Q Criterion..." << endl;
}
int i, j;
int expdim = m_f->m_graph->GetMeshDimension();
int spacedim = expdim;
if ((m_f->m_fielddef[0]->m_numHomogeneousDir) == 1 ||
(m_f->m_fielddef[0]->m_numHomogeneousDir) == 2)
{
spacedim = 3;
}
int nfields = m_f->m_fielddef[0]->m_fields.size();
if (spacedim == 1 || spacedim == 2)
{
cerr << "\n Error: ProcessQCriterion must be computed for a 3D"
" (or quasi-3D) case. \n" << endl;
}
//For calculating Q-Criterion only 1 field must be added
int addfields = 1;
int npoints = m_f->m_exp[0]->GetNpoints();
Array<OneD, Array<OneD, NekDouble> > grad(nfields * nfields);
Array<OneD, Array<OneD, NekDouble> > omega(nfields * nfields);
Array<OneD, Array<OneD, NekDouble> > S (nfields * nfields);
Array<OneD, Array<OneD, NekDouble> > outfield (addfields);
Array<OneD, Array<OneD, NekDouble> > outfield1(addfields);
Array<OneD, Array<OneD, NekDouble> > outfield2(addfields);
Array<OneD, Array<OneD, NekDouble> > outfield3(addfields);
m_f->m_exp.resize(nfields+addfields);
for (i = 0; i < nfields*nfields; ++i)
{
grad[i] = Array<OneD, NekDouble>(npoints);
}
for (i = 0; i < addfields; ++i)
{
//Will store the Q-Criterion
outfield[i] = Array<OneD, NekDouble>(npoints);
outfield1[i] = Array<OneD, NekDouble>(npoints);
outfield2[i] = Array<OneD, NekDouble>(npoints);
outfield3[i] = Array<OneD, NekDouble>(npoints);
omega[i] = Array<OneD, NekDouble>(npoints);
S[i] = Array<OneD, NekDouble>(npoints);
}
for (i = 0; i < nfields; ++i)
{
m_f->m_exp[i]->PhysDeriv(m_f->m_exp[i]->GetPhys(),
grad[i*nfields],
grad[i*nfields+1],
grad[i*nfields+2]);
}
// W_x = Wy - Vz
Vmath::Vsub(npoints, grad[2 * nfields + 1], 1,
grad[1 * nfields + 2], 1,
outfield1[0], 1);
// W_x^2
Vmath::Vmul(npoints, outfield1[0], 1,
outfield1[0], 1,
outfield1[0], 1);
// W_y = Uz - Wx
Vmath::Vsub(npoints, grad[0 * nfields + 2], 1,
grad[2 * nfields + 0], 1,
outfield2[0], 1);
// W_y^2
Vmath::Vmul(npoints, outfield2[0], 1,
outfield2[0], 1,
outfield2[0], 1);
// W_z = Vx - Uy
Vmath::Vsub(npoints, grad[1 * nfields + 0], 1,
grad[0 * nfields + 1], 1,
outfield3[0], 1);
// W_z^2
Vmath::Vmul(npoints, outfield3[0], 1,
outfield3[0], 1,
outfield3[0], 1);
// add fields omega = 0.5*(W_x^2 + W_y^2 + W_z^2)
NekDouble fac = 0.5;
Vmath::Vadd(npoints, &outfield1[0][0], 1,
&outfield2[0][0], 1,
&omega[0][0], 1);
Vmath::Vadd(npoints, &omega[0][0], 1,
&outfield3[0][0], 1,
&omega[0][0], 1);
for (int k = 0; k < addfields; ++k)
{
Vmath::Smul(npoints, fac, &omega[k][0], 1, &omega[k][0], 1);
}
Vmath::Zero(npoints, &outfield1[0][0], 1);
Vmath::Zero(npoints, &outfield2[0][0], 1);
Vmath::Zero(npoints, &outfield3[0][0], 1);
Vmath::Vmul(npoints, grad[0 * nfields + 0], 1,
grad[0 * nfields + 0], 1,
outfield1[0], 1);
Vmath::Vmul(npoints, grad[1 * nfields + 1], 1,
grad[1 * nfields + 1], 1,
outfield2[0], 1);
Vmath::Vmul(npoints, grad[2 * nfields + 2], 1,
grad[2 * nfields + 2], 1,
outfield3[0], 1);
Vmath::Vadd(npoints, &outfield1[0][0], 1,
&outfield2[0][0], 1,
&S[0][0], 1);
Vmath::Vadd(npoints, &S[0][0], 1,
&outfield3[0][0], 1,
&S[0][0], 1);
// W_y + V_z
Vmath::Vadd(npoints, grad[2 * nfields + 1], 1,
grad[1 * nfields + 2], 1,
outfield1[0], 1);
Vmath::Vmul(npoints, &outfield1[0][0], 1,
&outfield1[0][0], 1,
&outfield1[0][0], 1);
// U_z + W_x
Vmath::Vadd(npoints, grad[0 * nfields + 2], 1,
grad[2 * nfields + 0], 1,
outfield2[0], 1);
Vmath::Vmul(npoints, &outfield2[0][0], 1,
&outfield2[0][0], 1,
&outfield2[0][0], 1);
// V_x + U_y
Vmath::Vadd(npoints, grad[1 * nfields + 0], 1,
grad[0 * nfields + 1], 1,
outfield3[0], 1);
Vmath::Vmul(npoints, &outfield3[0][0], 1,
&outfield3[0][0], 1,
&outfield3[0][0], 1);
Vmath::Vadd(npoints, &outfield1[0][0], 1,
&outfield2[0][0], 1,
&outfield2[0][0], 1);
Vmath::Vadd(npoints, &outfield2[0][0], 1,
&outfield3[0][0], 1,
&outfield3[0][0], 1);
for (int k = 0; k < addfields; ++k)
{
Vmath::Smul(npoints, fac, &outfield3[k][0], 1,
&outfield3[k][0], 1);
}
Vmath::Vadd(npoints, &outfield3[0][0], 1, &S[0][0], 1, &S[0][0], 1);
Vmath::Vsub(npoints, omega[0], 1, S[0], 1, outfield[0], 1);
for (int k = 0; k < addfields; ++k)
{
Vmath::Smul(npoints, fac, &outfield[k][0], 1,
&outfield[k][0], 1);
}
for (i = 0; i < addfields; ++i)
{
m_f->m_exp[nfields + i] = m_f->AppendExpList();
m_f->m_exp[nfields + i]->UpdatePhys() = outfield[i];
m_f->m_exp[nfields + i]->FwdTrans(outfield[i],
m_f->m_exp[nfields + i]->UpdateCoeffs());
}
vector<string> outname;
outname.push_back("Q");
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
= m_f->m_exp[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
for (j = 0; j < nfields + addfields; ++j)
{
for (i = 0; i < FieldDef.size(); ++i)
{
if (j >= nfields)
{
FieldDef[i]->m_fields.push_back(outname[j-nfields]);
}
else
{
FieldDef[i]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[j]);
}
m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
}
}
m_f->m_fielddef = FieldDef;
m_f->m_data = FieldData;
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessQCriterion.h
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Computes Q Criterion field.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSQCRITERION
#define UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSQCRITERION
#include "Module.h"
namespace Nektar
{
namespace Utilities
{
/**
* @brief This processing module calculates the Q Criterion and adds it
* as an extra-field to the output file.
*/
class ProcessQCriterion : public ProcessModule
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(FieldSharedPtr f) {
return MemoryManager<ProcessQCriterion>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessQCriterion(FieldSharedPtr f);
virtual ~ProcessQCriterion();
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
};
}
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment