Skip to content

Commit

Permalink
restore epetra
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Oct 1, 2024
1 parent 9fbaf0a commit d61eca2
Show file tree
Hide file tree
Showing 17 changed files with 1,996 additions and 0 deletions.
21 changes: 21 additions & 0 deletions include/pressio/ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ template<class ...> struct matching_extents;
#include "ops/tpetra_block/ops_multi_vector_update.hpp"
#include "ops/tpetra_block/ops_level2.hpp"
#include "ops/tpetra_block/ops_level3.hpp"

#ifdef PRESSIO_ENABLE_EPETRA
// Epetra
#include "ops/epetra/ops_clone.hpp"
#include "ops/epetra/ops_extent.hpp"
#include "ops/epetra/ops_deep_copy.hpp"
#include "ops/epetra/ops_set_zero.hpp"
#include "ops/epetra/ops_scale.hpp"
#include "ops/epetra/ops_fill.hpp"
#include "ops/epetra/ops_abs.hpp"
#include "ops/epetra/ops_dot.hpp"
#include "ops/epetra/ops_min_max.hpp"
#include "ops/epetra/ops_norms.hpp"
#include "ops/epetra/ops_pow.hpp"
#include "ops/epetra/ops_rank1_update.hpp"
#include "ops/epetra/ops_elementwise_multiply.hpp"
#include "ops/epetra/ops_multi_vector_update.hpp"
#include "ops/epetra/ops_level2.hpp"
#include "ops/epetra/ops_level3.hpp"
#endif // PRESSIO_ENABLE_EPETRA

#endif //PRESSIO_ENABLE_TPL_TRILINOS

// keep this last
Expand Down
68 changes: 68 additions & 0 deletions include/pressio/ops/epetra/ops_abs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
//@HEADER
// ************************************************************************
//
// ops_abs.hpp
// Pressio
// Copyright 2019
// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
//
// Under the terms of Contract DE-NA0003525 with NTESS, the
// U.S. Government retains certain rights in this software.
//
// Pressio is licensed under BSD-3-Clause terms of use:
//
// 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 copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "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 THE
// COPYRIGHT HOLDER OR 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 Francesco Rizzi ([email protected])
//
// ************************************************************************
//@HEADER
*/

#ifndef PRESSIOOPS_OPS_EPETRA_OPS_ABS_HPP_
#define PRESSIOOPS_OPS_EPETRA_OPS_ABS_HPP_

namespace pressio{ namespace ops{

// y= abs(x)
template <typename T1, class T2>
std::enable_if_t<
::pressio::is_vector_epetra<T1>::value
&& ::pressio::is_vector_epetra<T2>::value
>
abs(T1 & y, const T2 & x)
{
assert(::pressio::ops::extent(y, 0) == ::pressio::ops::extent(x, 0));

y.Abs(x);
}

}}//end namespace pressio::ops
#endif // PRESSIOOPS_OPS_EPETRA_OPS_ABS_HPP_
65 changes: 65 additions & 0 deletions include/pressio/ops/epetra/ops_clone.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
//@HEADER
// ************************************************************************
//
// ops_clone.hpp
// Pressio
// Copyright 2019
// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
//
// Under the terms of Contract DE-NA0003525 with NTESS, the
// U.S. Government retains certain rights in this software.
//
// Pressio is licensed under BSD-3-Clause terms of use:
//
// 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 copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "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 THE
// COPYRIGHT HOLDER OR 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 Francesco Rizzi ([email protected])
//
// ************************************************************************
//@HEADER
*/

#ifndef PRESSIOOPS_OPS_EPETRA_OPS_CLONE_HPP_
#define PRESSIOOPS_OPS_EPETRA_OPS_CLONE_HPP_

namespace pressio{ namespace ops{


template <typename T>
std::enable_if_t<
(::pressio::is_vector_epetra<T>::value
|| ::pressio::is_multi_vector_epetra<T>::value), T>
clone(const T & clonable)
{
return T(clonable);
}

}}
#endif // PRESSIOOPS_OPS_EPETRA_OPS_CLONE_HPP_
66 changes: 66 additions & 0 deletions include/pressio/ops/epetra/ops_deep_copy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
//@HEADER
// ************************************************************************
//
// ops_deep_copy.hpp
// Pressio
// Copyright 2019
// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
//
// Under the terms of Contract DE-NA0003525 with NTESS, the
// U.S. Government retains certain rights in this software.
//
// Pressio is licensed under BSD-3-Clause terms of use:
//
// 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 copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "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 THE
// COPYRIGHT HOLDER OR 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 Francesco Rizzi ([email protected])
//
// ************************************************************************
//@HEADER
*/

#ifndef PRESSIOOPS_OPS_EPETRA_OPS_DEEP_COPY_HPP_
#define PRESSIOOPS_OPS_EPETRA_OPS_DEEP_COPY_HPP_

namespace pressio{ namespace ops{

template<typename T>
std::enable_if_t<
// TPL/container specific
::pressio::is_vector_epetra<T>::value or
::pressio::is_multi_vector_epetra<T>::value
>
deep_copy(T & dest, const T & src){
assert((matching_extents<T, T>::compare(dest, src)));
dest = src;
}

}}//end namespace pressio::ops
#endif // PRESSIOOPS_OPS_EPETRA_OPS_DEEP_COPY_HPP_
98 changes: 98 additions & 0 deletions include/pressio/ops/epetra/ops_dot.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
//@HEADER
// ************************************************************************
//
// ops_dot.hpp
// Pressio
// Copyright 2019
// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
//
// Under the terms of Contract DE-NA0003525 with NTESS, the
// U.S. Government retains certain rights in this software.
//
// Pressio is licensed under BSD-3-Clause terms of use:
//
// 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 copyright holder nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "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 THE
// COPYRIGHT HOLDER OR 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 Francesco Rizzi ([email protected])
//
// ************************************************************************
//@HEADER
*/

#ifndef PRESSIOOPS_OPS_EPETRA_OPS_DOT_HPP_
#define PRESSIOOPS_OPS_EPETRA_OPS_DOT_HPP_

namespace pressio{ namespace ops{

template <typename T1, typename T2, typename DotResult>
std::enable_if_t<
// TPL/container specific
::pressio::is_vector_epetra<T1>::value
&& ::pressio::is_vector_epetra<T2>::value
// scalar compatibility
&& ::pressio::all_have_traits_and_same_scalar<T1, T2>::value
&& (std::is_floating_point<typename ::pressio::Traits<T1>::scalar_type>::value
|| std::is_integral<typename ::pressio::Traits<T1>::scalar_type>::value)
&& std::is_convertible<
typename ::pressio::Traits<T1>::scalar_type,
DotResult>::value
>
dot(const T1 & a,
const T2 & b,
DotResult & result)
{
assert(a.MyLength() == b.MyLength());
using sc_t = typename ::pressio::Traits<T1>::scalar_type;
sc_t ret;
a.Dot(b, &ret);
result = static_cast<DotResult>(ret);
}

template <typename T1, typename T2>
std::enable_if_t<
// TPL/container specific
::pressio::is_vector_epetra<T1>::value
&& ::pressio::is_vector_epetra<T2>::value
// scalar compatibility
&& ::pressio::all_have_traits_and_same_scalar<T1, T2>::value
&& (std::is_floating_point<typename ::pressio::Traits<T1>::scalar_type>::value
|| std::is_integral<typename ::pressio::Traits<T1>::scalar_type>::value),
typename ::pressio::Traits<T1>::scalar_type
>
dot(const T1 & a, const T2 & b)
{
using sc_t = typename ::pressio::Traits<T1>::scalar_type;
sc_t result = {};
dot(a, b, result);
return result;
}

}}//end namespace pressio::ops
#endif // PRESSIOOPS_OPS_EPETRA_OPS_DOT_HPP_
Loading

0 comments on commit d61eca2

Please sign in to comment.