Commit 8eea9ea4 authored by Douglas Serson's avatar Douglas Serson
Browse files

Move FieldUtils to library

parent fa7d77ec
......@@ -277,7 +277,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
# Build active components
IF (NEKTAR_BUILD_LIBRARY)
SET(NEKTAR++_LIBRARIES SolverUtils LibUtilities StdRegions SpatialDomains LocalRegions
MultiRegions Collections GlobalMapping NekMeshUtils)
MultiRegions Collections GlobalMapping FieldUtils NekMeshUtils)
INCLUDE_DIRECTORIES(library)
ADD_SUBDIRECTORY(library)
INSTALL(EXPORT Nektar++Libraries DESTINATION ${LIB_DIR}/cmake COMPONENT dev)
......
......@@ -760,6 +760,7 @@ INPUT = @CMAKE_SOURCE_DIR@/docs/doxygen/ \
@CMAKE_SOURCE_DIR@/library/LocalRegions/ \
@CMAKE_SOURCE_DIR@/library/MultiRegions/ \
@CMAKE_SOURCE_DIR@/library/GlobalMapping/ \
@CMAKE_SOURCE_DIR@/library/FieldUtils/ \
@CMAKE_SOURCE_DIR@/library/SolverUtils/ \
@CMAKE_SOURCE_DIR@/library/NekMeshUtils/ \
@CMAKE_SOURCE_DIR@/solvers/ \
......
SET(LibrarySubDirs GlobalMapping LibUtilities LocalRegions Collections
MultiRegions SpatialDomains StdRegions SolverUtils NekMeshUtils)
SET(LibrarySubDirs FieldUtils GlobalMapping LibUtilities LocalRegions
Collections MultiRegions SpatialDomains StdRegions SolverUtils NekMeshUtils)
SET(UnitTestSubDirs UnitTests)
SET(DemoSubDirs Demos)
SET(TimingsSubDirs Timings)
......
SET(FieldUtilsHeaders
Module.h
Field.hpp
InputModules/InputDat.h
InputModules/InputFld.h
InputModules/InputXml.h
InputModules/InputPts.h
OutputModules/OutputInfo.h
OutputModules/OutputTecplot.h
OutputModules/OutputVtk.h
OutputModules/OutputFld.h
OutputModules/OutputStdOut.h
OutputModules/OutputPts.h
OutputModules/OutputXml.h
ProcessModules/ProcessAddFld.h
ProcessModules/ProcessBoundaryExtract.h
ProcessModules/ProcessConcatenateFld.h
ProcessModules/ProcessDeform.h
ProcessModules/ProcessDisplacement.h
ProcessModules/ProcessEquiSpacedOutput.h
ProcessModules/ProcessGrad.h
ProcessModules/ProcessHomogeneousPlane.h
ProcessModules/ProcessInnerProduct.h
ProcessModules/ProcessInterpField.h
ProcessModules/ProcessInterpPoints.h
ProcessModules/ProcessInterpPointDataToFld.h
ProcessModules/ProcessIsoContour.h
ProcessModules/ProcessJacobianEnergy.h
ProcessModules/ProcessMapping.h
ProcessModules/ProcessNumModes.h
ProcessModules/ProcessMeanMode.h
ProcessModules/ProcessPointDataToFld.h
ProcessModules/ProcessPrintFldNorms.h
ProcessModules/ProcessScaleInFld.h
ProcessModules/ProcessSurfDistance.h
ProcessModules/ProcessVorticity.h
ProcessModules/ProcessScalGrad.h
ProcessModules/ProcessMultiShear.h
ProcessModules/ProcessWSS.h
ProcessModules/ProcessC0Projection.h
ProcessModules/ProcessQCriterion.h
ProcessModules/ProcessQualityMetric.h
)
SET(FieldUtilsSources
Module.cpp
InputModules/InputDat.cpp
InputModules/InputFld.cpp
InputModules/InputXml.cpp
InputModules/InputPts.cpp
OutputModules/OutputInfo.cpp
OutputModules/OutputTecplot.cpp
OutputModules/OutputVtk.cpp
OutputModules/OutputFld.cpp
OutputModules/OutputStdOut.cpp
OutputModules/OutputPts.cpp
OutputModules/OutputXml.cpp
ProcessModules/ProcessAddFld.cpp
ProcessModules/ProcessBoundaryExtract.cpp
ProcessModules/ProcessConcatenateFld.cpp
ProcessModules/ProcessDeform.cpp
ProcessModules/ProcessDisplacement.cpp
ProcessModules/ProcessEquiSpacedOutput.cpp
ProcessModules/ProcessGrad.cpp
ProcessModules/ProcessHomogeneousPlane.cpp
ProcessModules/ProcessInnerProduct.cpp
ProcessModules/ProcessInterpField.cpp
ProcessModules/ProcessInterpPoints.cpp
ProcessModules/ProcessInterpPointDataToFld.cpp
ProcessModules/ProcessIsoContour.cpp
ProcessModules/ProcessJacobianEnergy.cpp
ProcessModules/ProcessMapping.cpp
ProcessModules/ProcessNumModes.cpp
ProcessModules/ProcessMeanMode.cpp
ProcessModules/ProcessPointDataToFld.cpp
ProcessModules/ProcessPrintFldNorms.cpp
ProcessModules/ProcessScaleInFld.cpp
ProcessModules/ProcessVorticity.cpp
ProcessModules/ProcessScalGrad.cpp
ProcessModules/ProcessSurfDistance.cpp
ProcessModules/ProcessMultiShear.cpp
ProcessModules/ProcessWSS.cpp
ProcessModules/ProcessC0Projection.cpp
ProcessModules/ProcessQCriterion.cpp
ProcessModules/ProcessQualityMetric.cpp
)
ADD_NEKTAR_LIBRARY(FieldUtils lib ${NEKTAR_LIBRARY_TYPE} ${FieldUtilsSources} ${FieldUtilsHeaders})
TARGET_LINK_LIBRARIES(FieldUtils LINK_PUBLIC GlobalMapping)
ADD_DEFINITIONS(-DFIELD_UTILS_EXPORTS)
INSTALL(DIRECTORY ./ DESTINATION ${NEKTAR_INCLUDE_DIR}/FieldUtils COMPONENT dev FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
......@@ -33,6 +33,9 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef FIELDUTILS_FIELD
#define FIELDUTILS_FIELD
#include <boost/shared_ptr.hpp>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
......@@ -56,17 +59,17 @@
#include <MultiRegions/DisContField2D.h>
#include <MultiRegions/DisContField3D.h>
#include <utilities/FieldConvert/FieldConvertDeclspec.h>
#include "FieldUtilsDeclspec.h"
using namespace std;
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
struct Field {
FIELD_CONVERT_EXPORT Field() : m_verbose(false),
FIELD_UTILS_EXPORT Field() : m_verbose(false),
m_declareExpansionAsContField(false),
m_declareExpansionAsDisContField(false),
m_declareAsNewField(false),
......@@ -76,7 +79,7 @@ struct Field {
m_setUpEquiSpacedFields(false),
m_fieldPts(LibUtilities::NullPtsField){}
FIELD_CONVERT_EXPORT ~Field()
FIELD_UTILS_EXPORT ~Field()
{
if (m_comm)
{
......@@ -114,7 +117,7 @@ struct Field {
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap;
FIELD_CONVERT_EXPORT MultiRegions::ExpListSharedPtr SetUpFirstExpList(
FIELD_UTILS_EXPORT MultiRegions::ExpListSharedPtr SetUpFirstExpList(
int NumHomogeneousDir,
bool fldfilegiven = false)
{
......@@ -402,7 +405,7 @@ struct Field {
return exp;
};
FIELD_CONVERT_EXPORT MultiRegions::ExpListSharedPtr AppendExpList(
FIELD_UTILS_EXPORT MultiRegions::ExpListSharedPtr AppendExpList(
int NumHomogeneousDir,
string var = "DefaultVar",
bool NewField = false)
......@@ -700,3 +703,4 @@ typedef boost::shared_ptr<Field> FieldSharedPtr;
}
}
#endif
......@@ -30,20 +30,20 @@
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_FIELD_CONVERT_DECLSPEC_H
#define NEKTAR_FIELD_CONVERT_DECLSPEC_H
#ifndef NEKTAR_FIELD_UTILS_DECLSPEC_H
#define NEKTAR_FIELD_UTILS_DECLSPEC_H
#if defined(_MSC_VER)
#ifdef FIELD_CONVERT_EXPORTS
#define FIELD_CONVERT_EXPORT _declspec(dllexport)
#ifdef FIELD_UTILS_EXPORTS
#define FIELD_UTILS_EXPORT _declspec(dllexport)
#else
#define FIELD_CONVERT_EXPORT _declspec(dllimport)
#define FIELD_UTILS_EXPORT _declspec(dllimport)
#endif
#else
#define FIELD_CONVERT_EXPORT
#define FIELD_UTILS_EXPORT
#endif
#define LOKI_CLASS_LEVEL_THREADING
#endif //NEKTAR_FIELD_CONVERT_DECLSPEC_H
#endif //NEKTAR_FIELD_UTILS_DECLSPEC_H
......@@ -46,7 +46,7 @@ using namespace std;
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
ModuleKey InputDat::m_className[1] = {
......
......@@ -33,14 +33,14 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTDAT
#define UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTDAT
#ifndef FIELDUTILS_INPUTDAT
#define FIELDUTILS_INPUTDAT
#include "../Module.h"
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
/// Input module for Xml files.
......
......@@ -45,7 +45,7 @@ static std::string npts = LibUtilities::SessionReader::RegisterCmdLineArgument(
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
ModuleKey InputFld::m_className[4] = {
......
......@@ -33,14 +33,14 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTFLD
#define UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTFLD
#ifndef FIELDUTILS_INPUTFLD
#define FIELDUTILS_INPUTFLD
#include "../Module.h"
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
/**
......
......@@ -46,7 +46,7 @@ using namespace std;
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
ModuleKey InputPts::m_className[5] = {
......
......@@ -33,14 +33,14 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTPTS
#define UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTPTS
#ifndef FIELDUTILS_INPUTPTS
#define FIELDUTILS_INPUTPTS
#include "../Module.h"
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
......
......@@ -47,7 +47,7 @@ static std::string npts = LibUtilities::SessionReader::RegisterCmdLineArgument(
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
ModuleKey InputXml::m_className[5] = {
......
......@@ -33,14 +33,14 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTXML
#define UTILITIES_PREPROCESSING_FIELDCONVERT_INPUTXML
#ifndef FIELDUTILS_INPUTXML
#define FIELDUTILS_INPUTXML
#include "../Module.h"
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
/**
......
......@@ -41,131 +41,131 @@ using namespace std;
namespace Nektar
{
namespace Utilities
namespace FieldUtils
{
/**
* Returns an instance of the module factory, held as a singleton.
*/
ModuleFactory& GetModuleFactory()
{
/**
* Returns an instance of the module factory, held as a singleton.
*/
ModuleFactory& GetModuleFactory()
{
typedef Loki::SingletonHolder<ModuleFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
}
typedef Loki::SingletonHolder<ModuleFactory,
Loki::CreateUsingNew,
Loki::NoDestroy,
Loki::SingleThreaded> Type;
return Type::Instance();
}
/**
* Prints a given module key to a stream.
*/
std::ostream& operator<<(std::ostream& os, const ModuleKey& rhs)
{
return os << ModuleTypeMap[rhs.first] << ": " << rhs.second;
}
InputModule::InputModule(FieldSharedPtr m) : Module(m)
{
m_config["infile"] = ConfigOption(false, "", "Input filename.");
}
OutputModule::OutputModule(FieldSharedPtr m) : Module(m)
{
m_config["outfile"] = ConfigOption(false, "", "Output filename.");
}
/**
* Prints a given module key to a stream.
*/
std::ostream& operator<<(std::ostream& os, const ModuleKey& rhs)
void InputModule::AddFile(string fileType, string fileName)
{
// Check to see if this file type is allowed
if (m_allowedFiles.count(fileType) == 0)
{
return os << ModuleTypeMap[rhs.first] << ": " << rhs.second;
cerr << "File type " << fileType << " not supported for this "
<< "module." << endl;
}
InputModule::InputModule(FieldSharedPtr m) : Module(m)
m_f->m_inputfiles[fileType].push_back(fileName);
}
/**
* @brief Open a file for output.
*/
void OutputModule::OpenStream()
{
string fname = m_config["outfile"].as<string>();
m_fldFile.open(fname.c_str());
if (!m_fldFile.good())
{
m_config["infile"] = ConfigOption(false, "", "Input filename.");
cerr << "Error opening file: " << fname << endl;
abort();
}
}
OutputModule::OutputModule(FieldSharedPtr m) : Module(m)
/**
* @brief Register a configuration option with a module.
*/
void Module::RegisterConfig(string key, string val)
{
map<string, ConfigOption>::iterator it = m_config.find(key);
if (it == m_config.end())
{
m_config["outfile"] = ConfigOption(false, "", "Output filename.");
cerr << "WARNING: Unrecognised config option " << key
<< ", proceeding anyway." << endl;
}
void InputModule::AddFile(string fileType, string fileName)
{
// Check to see if this file type is allowed
if (m_allowedFiles.count(fileType) == 0)
{
cerr << "File type " << fileType << " not supported for this "
<< "module." << endl;
}
it->second.m_beenSet = true;
m_f->m_inputfiles[fileType].push_back(fileName);
}
/**
* @brief Open a file for output.
*/
void OutputModule::OpenStream()
if (it->second.m_isBool)
{
string fname = m_config["outfile"].as<string>();
m_fldFile.open(fname.c_str());
if (!m_fldFile.good())
{
cerr << "Error opening file: " << fname << endl;
abort();
}
it->second.m_value = "1";
}
/**
* @brief Register a configuration option with a module.
*/
void Module::RegisterConfig(string key, string val)
else
{
map<string, ConfigOption>::iterator it = m_config.find(key);
if (it == m_config.end())
{
cerr << "WARNING: Unrecognised config option " << key
<< ", proceeding anyway." << endl;
}
it->second.m_value = val;
}
}
it->second.m_beenSet = true;
/**
* @brief Print out all configuration options for a module.
*/
void Module::PrintConfig()
{
map<string, ConfigOption>::iterator it;
if (it->second.m_isBool)
{
it->second.m_value = "1";
}
else
{
it->second.m_value = val;
}
if (m_config.size() == 0)
{
cerr << "No configuration options for this module." << endl;
return;
}
/**
* @brief Print out all configuration options for a module.
*/
void Module::PrintConfig()
for (it = m_config.begin(); it != m_config.end(); ++it)
{
map<string, ConfigOption>::iterator it;
if (m_config.size() == 0)
{
cerr << "No configuration options for this module." << endl;
return;
}
for (it = m_config.begin(); it != m_config.end(); ++it)
{
cerr << setw(10) << it->first << ": " << it->second.m_desc
<< endl;
}
cerr << setw(10) << it->first << ": " << it->second.m_desc
<< endl;
}
}
/**
* @brief Sets default configuration options for those which have not
* been set.
*/
void Module::SetDefaults()
{
map<string, ConfigOption>::iterator it;
/**
* @brief Sets default configuration options for those which have not
* been set.
*/
void Module::SetDefaults()
{
map<string, ConfigOption>::iterator it;
for (it = m_config.begin(); it != m_config.end(); ++it)
for (it = m_config.begin(); it != m_config.end(); ++it)
{
if (!it->second.m_beenSet)
{
if (!it->second.m_beenSet)
{
it->second.m_value = it->second.m_defValue;
}
it->second.m_value = it->second.m_defValue;
}
}
}
/**
* @brief Print a brief summary of information.
*/
void InputModule::PrintSummary()
{
cout << "Field size = " <<
m_f->m_data[0].size() * sizeof(NekDouble) << endl;
}
/**
* @brief Print a brief summary of information.
*/
void InputModule::PrintSummary()
{
cout << "Field size = " <<
m_f->m_data[0].size() * sizeof(NekDouble) << endl;
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: Module.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: Field converter module base classes.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef FIELDUTILS_MODULE
#define FIELDUTILS_MODULE
#include <string>
#include <map>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <set>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <StdRegions/StdNodalTriExp.h>
#include <LibUtilities/Communication/CommSerial.h>
#include <LibUtilities/BasicUtils/Timer.h>
#include "Field.hpp"
#include "FieldUtilsDeclspec.h"
namespace po = boost::program_options;