Commit a46f3a45 authored by Kilian Lackhove's avatar Kilian Lackhove

transform the templates/executable example into a small Laplace eq. solver

parent ed6b11ea
......@@ -7,7 +7,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# TODO - Put the name of your project here.
SET(ProjectName Sample)
SET(ProjectName ExampleSolver)
PROJECT(${ProjectName})
# Setup where CMake will look for modules. You probably
......@@ -28,12 +28,13 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed")
# TODO - Add an entry here for every source file in your project. Must not be empty!
SET(SourceFileNames
main.cpp
ExampleSolver.cpp
EquationSystems/Laplace.cpp
)
# TODO - Add an entry here for every header file in your project. Must not be empty!
SET(HeaderFileNames
main.cpp
EquationSystems/Laplace.h
)
ADD_EXECUTABLE(${ProjectName} ${SourceFileNames} ${HeaderFileNames})
......
///////////////////////////////////////////////////////////////////////////////
//
// File Laplace.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: Laplace solve routines
//
///////////////////////////////////////////////////////////////////////////////
#include "Laplace.h"
namespace Nektar
{
string Laplace::className = GetEquationSystemFactory().
RegisterCreatorFunction("Laplace", Laplace::create);
Laplace::Laplace(
const LibUtilities::SessionReaderSharedPtr& pSession)
: EquationSystem(pSession),
m_factors()
{
m_factors[StdRegions::eFactorLambda] = 0.0;
m_factors[StdRegions::eFactorTau] = 1.0;
}
void Laplace::v_InitObject()
{
EquationSystem::v_InitObject();
}
Laplace::~Laplace()
{
}
void Laplace::v_GenerateSummary(SolverUtils::SummaryList& s)
{
EquationSystem::SessionSummary(s);
SolverUtils::AddSummaryItem(s, "Lambda",
m_factors[StdRegions::eFactorLambda]);
}
void Laplace::v_DoSolve()
{
for(int i = 0; i < m_fields.num_elements(); ++i)
{
// Zero field so initial conditions are zero
Vmath::Zero(m_fields[i]->GetNcoeffs(),
m_fields[i]->UpdateCoeffs(), 1);
m_fields[i]->HelmSolve(m_fields[i]->GetPhys(),
m_fields[i]->UpdateCoeffs(),
NullFlagList,
m_factors);
m_fields[i]->SetPhysState(false);
}
}
Array<OneD, bool> Laplace::v_GetSystemSingularChecks()
{
return Array<OneD, bool>(m_session->GetVariables().size(), true);
}
}
///////////////////////////////////////////////////////////////////////////////
//
// File Laplace.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: Laplace solve routines
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_SOLVERS_ADRSOLVER_EQUATIONSYSTEMS_LAPLACE_H
#define NEKTAR_SOLVERS_ADRSOLVER_EQUATIONSYSTEMS_LAPLACE_H
#include <SolverUtils/EquationSystem.h>
using namespace Nektar::SolverUtils;
namespace Nektar
{
class Laplace : public EquationSystem
{
public:
/// Class may only be instantiated through the MemoryManager.
friend class MemoryManager<Laplace>;
/// Creates an instance of this class
static EquationSystemSharedPtr create(
const LibUtilities::SessionReaderSharedPtr& pSession)
{
EquationSystemSharedPtr p = MemoryManager<Laplace>::AllocateSharedPtr(pSession);
p->InitObject();
return p;
}
/// Name of class
static std::string className;
protected:
StdRegions::ConstFactorMap m_factors;
Laplace(const LibUtilities::SessionReaderSharedPtr& pSession);
virtual ~Laplace();
virtual void v_InitObject();
virtual void v_GenerateSummary(SolverUtils::SummaryList& s);
virtual void v_DoSolve();
private:
virtual Array<OneD, bool> v_GetSystemSingularChecks();
};
}
#endif
///////////////////////////////////////////////////////////////////////////////
//
// File IncNavierStokesSolver.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: Example Solver
//
///////////////////////////////////////////////////////////////////////////////
#include <SolverUtils/Driver.h>
#include <LibUtilities/BasicUtils/SessionReader.h>
int main(int argc, char *argv[])
{
Nektar::LibUtilities::SessionReaderSharedPtr session;
string vDriverModule;
Nektar::SolverUtils::DriverSharedPtr drv;
try
{
// Create session reader.
session = Nektar::LibUtilities::SessionReader::CreateInstance(argc, argv);
// Create driver
session->LoadSolverInfo("Driver", vDriverModule, "Standard");
drv = Nektar::SolverUtils::GetDriverFactory().CreateInstance(vDriverModule, session);
// Execute driver
drv->Execute();
// Finalise communications
session->Finalise();
}
catch (const std::runtime_error&)
{
return 1;
}
catch (const std::string& eStr)
{
cout << "Error: " << eStr << endl;
}
return 0;
}
#include <LibUtilities/LinearAlgebra/NekMatrix.hpp>
int main()
{
ASSERTL0(false, "False Test");
return 0;
}
\ No newline at end of file
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