Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#197: NOX: Provide Tpetra versions of LOCA_TestProblems tests #199

Draft
wants to merge 13 commits into
base: NGA-FY23-develop
Choose a base branch
from
Draft
3 changes: 3 additions & 0 deletions packages/nox/test/tpetra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ IF(NOX_ENABLE_ABSTRACT_IMPLEMENTATION_THYRA AND
ENDIF()

ENDIF()

ADD_SUBDIRECTORY(LOCA_TestProblems)
ADD_SUBDIRECTORY(LOCA_UnitTests)
89 changes: 89 additions & 0 deletions packages/nox/test/tpetra/LOCA_TestProblems/Basis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// $Id$
// $Source$

//@HEADER
// ************************************************************************
//
// LOCA: Library of Continuation Algorithms Package
// Copyright (2005) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Roger Pawlowski ([email protected]) or
// Eric Phipps ([email protected]), Sandia National Laboratories.
// ************************************************************************
// CVS Information
// $Source$
// $Author$
// $Date$
// $Revision$
// ************************************************************************
//@HEADER

#include "Basis.hpp"

// Constructor
Basis::Basis() :
phi(2),
dphide(2),
uu(0.0),
xx(0.0),
duu(0.0),
eta(0.0),
wt(0.0),
dx(0.0)
{ }

// Calculates a linear 1D basis
void Basis::getBasis(int gp, std::vector<double> x, std::vector<double> u) {
int N = 2;
if (gp==0) {eta=-1.0/std::sqrt(3.0); wt=1.0;}
if (gp==1) {eta=1.0/std::sqrt(3.0); wt=1.0;}

// Calculate basis function and derivatives at nodel pts
phi[0]=(1.0-eta)/2.0;
phi[1]=(1.0+eta)/2.0;
dphide[0]=-0.5;
dphide[1]=0.5;

// Caculate basis function and derivative at GP.
dx=0.5*(x[1]-x[0]);
xx=0.0;
uu=0.0;
duu=0.0;
for (int i=0; i < N; i++) {
xx += x[i] * phi[i];
uu += u[i] * phi[i];
duu += u[i] * dphide[i];
}

return;
}
81 changes: 81 additions & 0 deletions packages/nox/test/tpetra/LOCA_TestProblems/Basis.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// $Id$
// $Source$

//@HEADER
// ************************************************************************
//
// LOCA: Library of Continuation Algorithms Package
// Copyright (2005) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Roger Pawlowski ([email protected]) or
// Eric Phipps ([email protected]), Sandia National Laboratories.
// ************************************************************************
// CVS Information
// $Source$
// $Author$
// $Date$
// $Revision$
// ************************************************************************
//@HEADER

// 1D Linear basis function for finite element method

#ifndef _NOX_EXAMPLE_TPETRA_LINEAR_BASIS_H
#define _NOX_EXAMPLE_TPETRA_LINEAR_BASIS_H

#include <vector>
#include <cstddef>
#include <cmath>

class Basis
{
public:
// Constructor
Basis();

// Calculates the values of u and x at the specified gauss point
void getBasis(int gp, std::vector<double> x, std::vector<double> u);

private:
// Private to prohibit copying
Basis(const Basis&);
Basis& operator=(const Basis&);

public:
// Variables that are calculated at the gauss point
std::vector<double> phi, dphide;
double uu, xx, duu, eta, wt;
double dx;
};

#endif
39 changes: 39 additions & 0 deletions packages/nox/test/tpetra/LOCA_TestProblems/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

SET(HEADERS "")
SET(SOURCES "")

TRIBITS_INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

APPEND_SET(HEADERS
Basis.hpp
FiniteElementProblem.hpp
# Problem_Interface.hpp
# Tcubed_FiniteElementProblem.hpp
Pitchfork_FiniteElementProblem.hpp # --> WIP, TESTING
# NormConstraint.hpp
# LOCALinearConstraint.hpp --> WIP
)

APPEND_SET(SOURCES
Basis.cpp
# Problem_Interface.cpp
# Tcubed_FiniteElementProblem.cpp
Pitchfork_FiniteElementProblem.cpp # --> WIP, TESTING
# NormConstraint.cpp
# LOCALinearConstraint.cpp --> WIP
)

# Add this below:
# IF(NOX_ENABLE_ABSTRACT_IMPLEMENTATION_EPETRA AND NOX_ENABLE_LOCA)

IF(NOX_ENABLE_LOCA)

TRIBITS_ADD_LIBRARY(
locatpetratestproblems
HEADERS ${HEADERS}
SOURCES ${SOURCES}
TESTONLY
DEPLIBS loca locatpetra
)

ENDIF()
Loading
Loading