Commit ee24062e authored by Kilian Lackhove's avatar Kilian Lackhove

CWIPI: Port to pure CWIPI

parent 60bd978b
......@@ -191,13 +191,15 @@ INCLUDE (ThirdPartyTriangle)
INCLUDE (ThirdPartyTetGen)
INCLUDE (ThirdPartyCCM)
set(OPENPALM_DIR "/home/lackhove/code/OpenPalm/PALM_MP/linux64r4openmpi_debug" CACHE PATH "openPALM base path")
find_package(OpenPALM)
include_directories(${OPENPALM_INCLUDE_DIRS})
set(CWIPI_DIR "/home/lackhove/code/OpenPalm/cwipi-0.8.1/dist" CACHE PATH "CWIPI base path")
find_package(Cwipi)
include_directories(${CWIPI_INCLUDE_DIRS})
OPTION(NEKTAR_USE_CWIPI
"Use CWIPI." OFF)
IF ( NEKTAR_USE_CWIPI )
set(CWIPI_DIR "/usr/local/cwipi" CACHE PATH "CWIPI base path")
find_package(Cwipi)
include_directories(${CWIPI_INCLUDE_DIRS})
ADD_DEFINITIONS(-DNEKTAR_USE_CWIPI)
ENDIF ( NEKTAR_USE_CWIPI )
INCLUDE (Doxygen)
......
......@@ -12,12 +12,24 @@ find_path(CWIPI_INCLUDE_DIR cwipi.h
)
find_library(CWIPI_LIBRARY
NAMES "libcwipi.a"
NAMES "libcwipi.so"
HINTS "${CWIPI_DIR}/lib64/" "${CWIPI_DIR}/lib/"
)
find_library(CWIPI_LIBRARY_FVMC
NAMES "libfvmc.so"
HINTS "${CWIPI_DIR}/lib64/" "${CWIPI_DIR}/lib/"
)
find_library(CWIPI_LIBRARY_BFTC
NAMES "libbftc.so"
HINTS "${CWIPI_DIR}/lib64/" "${CWIPI_DIR}/lib/"
)
set(CWIPI_LIBRARIES
${CWIPI_LIBRARY}
${CWIPI_LIBRARY_FVMC}
${CWIPI_LIBRARY_BFTC}
)
set(CWIPI_INCLUDE_DIRS ${CWIPI_INCLUDE_DIR})
......@@ -26,6 +38,8 @@ include(FindPackageHandleStandardArgs)
# if all listed variables are TRUE
find_package_handle_standard_args(cwipi DEFAULT_MSG
CWIPI_LIBRARY
CWIPI_LIBRARY_FVMC
CWIPI_LIBRARY_BFTC
CWIPI_INCLUDE_DIR
)
......
# - Try to find openPALM
# Once done this will define
# OPENPALM_FOUND - System has openPALM
# OPENPALM_INCLUDE_DIRS - The openPALM include directories
# OPENPALM_LIBRARIES - The libraries needed to use openPALM
# OPENPALM_DEFINITIONS - Compiler switches required for using openPALM
set(OPENPALM_DEFINITIONS "")
find_path(OPENPALM_INCLUDE_DIR palmlib.h
HINTS ${OPENPALM_DIR}/include/
)
find_library(OPENPALM_LIBRARY
NAMES "libpalm.a"
HINTS "${OPENPALM_DIR}/lib64/" "${OPENPALM_DIR}/lib/"
)
set(OPENPALM_LIBRARIES
${OPENPALM_LIBRARY}
)
set(OPENPALM_INCLUDE_DIRS ${OPENPALM_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set OPENPALM_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(openPALM DEFAULT_MSG
OPENPALM_LIBRARY
OPENPALM_INCLUDE_DIR
)
mark_as_advanced(OPENPALM_LIBRARY OPENPALM_INCLUDE_DIR)
......@@ -1581,9 +1581,9 @@ namespace Nektar
else
{
string vCommModule("Serial");
if (GetCommFactory().ModuleExists("ParallelMPI"))
if (GetCommFactory().ModuleExists("CWIPI"))
{
vCommModule = "ParallelMPI";
vCommModule = "CWIPI";
}
m_comm = GetCommFactory().CreateInstance(vCommModule,argc,argv);
......
......@@ -82,9 +82,14 @@ IF(NEKTAR_USE_MPI)
SET(CommunicationHeaders ${CommunicationHeaders}
./Communication/CommMpi.h)
SET(CommunicationSources ${CommunicationSources}
./Communication/CommMpi.cpp
./Communication/CommOpenPalm.cpp)
./Communication/CommMpi.cpp)
ENDIF(NEKTAR_USE_MPI)
IF ( NEKTAR_USE_CWIPI )
SET(CommunicationHeaders ${CommunicationHeaders}
./Communication/CommCwipi.h)
SET(CommunicationSources ${CommunicationSources}
./Communication/CommCwipi.cpp)
ENDIF ()
SET(FFTHeaders
./FFT/NektarFFT.h
......
///////////////////////////////////////////////////////////////////////////////
//
// File CommOpenPalm.cpp
// File CommCwipi.cpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2015 Kilian Lackhove
// 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).
......@@ -33,63 +34,60 @@
//
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/Communication/CommOpenPalm.h>
#include <LibUtilities/Communication/CommCwipi.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <palmlibc.h>
#include <cwipi.h>
namespace Nektar
{
namespace LibUtilities
{
std::string CommOpenPalm::className
= GetCommFactory().RegisterCreatorFunction("OpenPalm", CommOpenPalm::create,
"Parallel communication using MPI with OpenPalm.");
std::string CommCwipi::className
= GetCommFactory().RegisterCreatorFunction("CWIPI", CommCwipi::create,
"Parallel communication using MPI with CWIPI.");
/**
*
*/
CommOpenPalm::CommOpenPalm(int narg, char* arg[])
CommCwipi::CommCwipi(int narg, char* arg[])
: CommMpi()
{
int init = 0;
MPI_Initialized(&init);
ASSERTL0(!init, "MPI has already been initialised.");
m_comm = PL_COMM_EXEC;
MPI_Comm_size( m_comm, &m_size );
MPI_Comm_rank( m_comm, &m_rank );
int retval = MPI_Init(&narg, &arg);
if (retval != MPI_SUCCESS)
{
ASSERTL0(false, "Failed to initialise MPI");
}
m_type = "Parallel MPI with OpenPalm";
}
MPI_Comm localComm;
cwipi_init(MPI_COMM_WORLD, "nektar", &localComm);
m_comm = localComm;
/**
*
*/
CommOpenPalm::CommOpenPalm(MPI_Comm pComm)
: CommMpi()
{
m_comm = pComm;
MPI_Comm_size( m_comm, &m_size );
MPI_Comm_rank( m_comm, &m_rank );
m_type = "Parallel MPI with OpenPalm";
m_type = "Parallel MPI with CWIPI";
}
/**
*
*/
CommOpenPalm::~CommOpenPalm()
CommCwipi::~CommCwipi()
{
}
/**
*
*/
void CommOpenPalm::v_Finalise()
void CommCwipi::v_Finalise()
{
// do nothing
cwipi_finalize();
}
......
///////////////////////////////////////////////////////////////////////////////
//
// File CommOpenPalm.h
// File CommCwipi.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2015 Kilian Lackhove
// 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).
......@@ -29,11 +30,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: CommOpenPalm header
// Description: CommCwipi header
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_COMMOPENPALM_H
#define NEKTAR_LIB_UTILITIES_COMMOPENPALM_H
#ifndef NEKTAR_LIB_UTILITIES_COMMCWIPI_H
#define NEKTAR_LIB_UTILITIES_COMMCWIPI_H
#include <string>
#include <mpi.h>
......@@ -46,35 +47,32 @@ namespace Nektar
namespace LibUtilities
{
// Forward declarations
class CommOpenPalm;
class CommCwipi;
/// Pointer to a Communicator object.
typedef boost::shared_ptr<CommOpenPalm> CommOpenPalmSharedPtr;
typedef boost::shared_ptr<CommCwipi> CommCwipiSharedPtr;
/// A global linear system.
class CommOpenPalm : public CommMpi
class CommCwipi : public CommMpi
{
public:
/// Creates an instance of this class
static CommSharedPtr create(int narg, char* arg[])
{
return MemoryManager<CommOpenPalm>::AllocateSharedPtr(narg, arg);
return MemoryManager<CommCwipi>::AllocateSharedPtr(narg, arg);
}
/// Name of class
static std::string className;
CommOpenPalm(int narg, char* arg[]);
CommCwipi(int narg, char* arg[]);
virtual ~CommOpenPalm();
virtual ~CommCwipi();
protected:
virtual void v_Finalise();
private:
CommOpenPalm(MPI_Comm pComm);
};
......
......@@ -7,6 +7,7 @@ SET(SOLVER_UTILS_SOURCES
Advection/AdvectionFR.cpp
Advection/AdvectionNonConservative.cpp
Advection/AdvectionWeakDG.cpp
CwipiExchange.cpp
Diffusion/Diffusion.cpp
Diffusion/Diffusion3DHomogeneous1D.cpp
Diffusion/DiffusionLDG.cpp
......@@ -53,6 +54,7 @@ SET(SOLVER_UTILS_HEADERS
Advection/Advection3DHomogeneous1D.h
Advection/AdvectionNonConservative.h
Advection/AdvectionWeakDG.h
CwipiExchange.h
Diffusion/Diffusion.h
Diffusion/Diffusion3DHomogeneous1D.h
Diffusion/DiffusionLDG.h
......
///////////////////////////////////////////////////////////////////////////////
//
// File OpenPalmExchange.h
// File CwipiExchange.h
//
// For more information, please see: http://www.nektar.info
//
......@@ -27,12 +27,12 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: openPALM Exchange class
// Description: CWIPI Exchange class
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_OPENPALMEXCHANGE
#define NEKTAR_OPENPALMEXCHANGE
#ifndef NEKTAR_CWIPIEXCHANGE
#define NEKTAR_CWIPIEXCHANGE
#include <SolverUtils/EquationSystem.h>
#include <SolverUtils/Exchange.h>
......@@ -40,19 +40,19 @@
namespace Nektar
{
class OpenPalmCoupling : public SolverUtils::Coupling
class CwipiCoupling : public SolverUtils::Coupling
{
public:
OpenPalmCoupling()
CwipiCoupling()
{
};
OpenPalmCoupling(MultiRegions::ExpListSharedPtr field,
CwipiCoupling(MultiRegions::ExpListSharedPtr field,
string name, int outputFreq, double geomTol);
~OpenPalmCoupling();
~CwipiCoupling();
protected:
......@@ -76,21 +76,21 @@ private:
typedef boost::shared_ptr<OpenPalmCoupling> OpenPalmCouplingSharedPointer;
typedef boost::shared_ptr<CwipiCoupling> CwipiCouplingSharedPointer;
class OpenPalmExchange : public SolverUtils::Exchange
class CwipiExchange : public SolverUtils::Exchange
{
public:
OpenPalmExchange()
CwipiExchange()
{
};
OpenPalmExchange(SolverUtils::CouplingSharedPointer coupling, string name,
CwipiExchange(SolverUtils::CouplingSharedPointer coupling, string name,
int nEVars);
~OpenPalmExchange();
~CwipiExchange();
......@@ -112,7 +112,7 @@ protected:
};
typedef boost::shared_ptr<OpenPalmExchange> OpenPalmExchangeSharedPtr;
typedef boost::shared_ptr<CwipiExchange> CwipiExchangeSharedPtr;
}
#endif
//PALM_UNIT -name APESolver\
// -functions {C APESolver}\
// -parallel mpi\
// -minproc 1\
// -maxproc 100000\
// -object_files {APESolver.o APESolver/EquationSystems/APE.o APESolver/RiemannSolvers/APESolver.o APESolver/RiemannSolvers/UpwindSolver.o APESolver/RiemannSolvers/LaxFriedrichsSolver.o OpenPalmExchange.o}\
// -comment {APESolver openPALM unit}
//
//PALM_CWIPI_COUPLING -name PRECISE-Nektar
//
//PALM_CWIPI_OBJECT -name basefields\
// -coupling PRECISE-Nektar\
// -intent IN
//
///////////////////////////////////////////////////////////////////////////////
//
// File APESolver.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: APE Equations framework solver
//
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <SolverUtils/Driver.h>
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <LibUtilities/Communication/Comm.h>
#include "OpenPalmExchange.h"
#include <palmlibc.h>
#include <cwipi.h>
using namespace std;
using namespace Nektar;
using namespace Nektar::SolverUtils;
extern "C" int APESolver()
{
// redirect stdout to a file
FILE *logFile;
logFile = fopen ("nektar.log","wt");
dup2(fileno(logFile), STDOUT_FILENO);
dup2(fileno(logFile), STDERR_FILENO);
// set casename
int argc = 1;
char *argv[] = {
"APESolverExt",
};
LibUtilities::SessionReaderSharedPtr session;
string vDriverModule;
DriverSharedPtr drv;
try
{
ASSERTL0(LibUtilities::GetCommFactory().ModuleExists("OpenPalm"), "OpenPalm comm module not found");
LibUtilities::CommSharedPtr comm = LibUtilities::GetCommFactory().CreateInstance("OpenPalm", argc, argv);
std::vector<std::string> filenames;
filenames.push_back("APE_3DPulseWall_FRDG_MODIFIED.xml");
// Create session reader.
session = LibUtilities::SessionReader::CreateInstance(argc, argv, filenames, comm);
// Create driver
session->LoadSolverInfo("Driver", vDriverModule, "Standard");
drv = GetDriverFactory().CreateInstance(vDriverModule, session);
// this initializes the APE system
// Execute driver
drv->Execute();
// This runs UnsteadySystem::v_DoSolve() exchange should happen in APE:v_preIntegrate()
// Finalise session
session->Finalise();
}
catch (const std::runtime_error& e)
{
return 1;
}
catch (const std::string& eStr)
{
cout << "Error: " << eStr << endl;
}
fclose(logFile);
return 0;
}
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