forked from idaholab/magpie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/**********************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ | ||
/* */ | ||
/* Copyright 2017 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/**********************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <complex> | ||
|
||
#include "RankTwoTensor.h" | ||
#include "RankThreeTensor.h" | ||
#include "RankFourTensor.h" | ||
|
||
#include "libmesh/vector_value.h" | ||
|
||
typedef std::complex<Real> Complex; | ||
typedef VectorValue<std::complex<Real>> ComplexVectorValue; | ||
typedef RankTwoTensorTempl<std::complex<Real>> ComplexRankTwoTensor; | ||
typedef RankThreeTensorTempl<std::complex<Real>> ComplexRankThreeTensor; | ||
typedef RankFourTensorTempl<std::complex<Real>> ComplexRankFourTensor; | ||
|
||
// helper template to select the corresponding complex tensor type | ||
template <typename T> | ||
struct ComplexType; | ||
|
||
template <> | ||
struct ComplexType<Real> | ||
{ | ||
using type = Complex; | ||
}; | ||
|
||
template <> | ||
struct ComplexType<RealVectorValue> | ||
{ | ||
using type = ComplexVectorValue; | ||
}; | ||
|
||
template <> | ||
struct ComplexType<RankTwoTensor> | ||
{ | ||
using type = ComplexRankTwoTensor; | ||
}; | ||
|
||
template <> | ||
struct ComplexType<RankThreeTensor> | ||
{ | ||
using type = ComplexRankThreeTensor; | ||
}; | ||
|
||
template <> | ||
struct ComplexType<RankFourTensor> | ||
{ | ||
using type = ComplexRankFourTensor; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/**********************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */ | ||
/* */ | ||
/* Copyright 2017 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/**********************************************************************/ | ||
|
||
#include "ComplexTypes.h" | ||
#include "MooseError.h" | ||
#include "MooseUtils.h" | ||
|
||
namespace MooseUtils | ||
{ | ||
|
||
template <> | ||
bool | ||
absoluteFuzzyEqual(const std::complex<Real> & var1, | ||
const std::complex<Real> & var2, | ||
const std::complex<Real> & tol) | ||
{ | ||
return (std::abs(var1 - var2) <= std::abs(tol)); | ||
} | ||
|
||
template <> | ||
bool | ||
absoluteFuzzyEqual(const std::complex<Real> & var1, | ||
const Real & var2, | ||
const std::complex<Real> & tol) | ||
{ | ||
return (std::abs(var1 - var2) <= std::abs(tol)); | ||
} | ||
|
||
} // namespace MooseUtils | ||
|
||
#include "RankTwoTensorImplementation.h" | ||
#include "RankThreeTensorImplementation.h" | ||
#include "RankFourTensorImplementation.h" | ||
|
||
template class VectorValue<std::complex<Real>>; | ||
|
||
template class RankTwoTensorTempl<std::complex<Real>>; | ||
template class RankThreeTensorTempl<std::complex<Real>>; | ||
template class RankFourTensorTempl<std::complex<Real>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
#include <cmath> | ||
#include <gtest/gtest.h> | ||
|
||
#include "ComplexTypes.h" | ||
|
||
TEST(ComplexTypesTest, rankTwo) | ||
{ | ||
Complex c_1; | ||
ComplexType<Real>::type c_2; | ||
auto c = c_1 + c_2; | ||
|
||
ComplexVectorValue v_1; | ||
ComplexType<RealVectorValue>::type v_2; | ||
auto v = v_1 + v_2; | ||
|
||
ComplexRankTwoTensor r2_1; | ||
ComplexType<RankTwoTensor>::type r2_2; | ||
auto r2 = r2_1 + r2_2; | ||
|
||
ComplexRankThreeTensor r3_1; | ||
ComplexType<RankThreeTensor>::type r3_2; | ||
auto r3 = r3_1 + r3_2; | ||
} |