-
Notifications
You must be signed in to change notification settings - Fork 11
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
9 changed files
with
372 additions
and
82 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
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,109 @@ | ||
#pragma once | ||
|
||
/* | ||
* Copyright (c) 2016, Yung-Yu Chen <yyc@solvcon.net> | ||
* BSD 3-Clause License, see COPYING | ||
*/ | ||
|
||
#include <utility> | ||
#include <string> | ||
|
||
#include "march/core/core.hpp" | ||
|
||
#include "march/mesh/LookupTable.hpp" | ||
|
||
namespace march | ||
{ | ||
|
||
namespace mesh | ||
{ | ||
|
||
/** | ||
* SOLVCON legacy C interface for boundary conditions. | ||
*/ | ||
struct sc_bound_t { | ||
index_type nbound, nvalue; | ||
index_type *facn; | ||
real_type *value; | ||
}; /* end struct sc_bound_t */ | ||
|
||
class BoundaryData { | ||
|
||
public: | ||
|
||
static constexpr size_t BFREL = 3; | ||
|
||
private: | ||
|
||
/** | ||
* First column is the face index in block. The second column is the face | ||
* index in bndfcs. The third column is the face index of the related | ||
* block (if exists). | ||
*/ | ||
LookupTable<index_type, BFREL> m_facn; | ||
|
||
/** | ||
* Values attached (specified) for each boundary face. Each row is a | ||
* boundary face, and each column is a value. | ||
*/ | ||
LookupTableCore m_values; | ||
|
||
public: | ||
|
||
BoundaryData() {} | ||
|
||
BoundaryData(index_type nvalue) | ||
: m_values(0, 0, {0, nvalue}, type_to<real_type>::id) | ||
{} | ||
|
||
BoundaryData(const BoundaryData &) = delete; | ||
|
||
BoundaryData(BoundaryData && other) { | ||
m_facn = std::move(other.m_facn); | ||
m_values = std::move(other.m_values); | ||
} | ||
|
||
BoundaryData & operator=(const BoundaryData &) = delete; | ||
|
||
BoundaryData & operator=(BoundaryData && other) { | ||
m_facn = std::move(other.m_facn); | ||
m_values = std::move(other.m_values); | ||
return *this; | ||
} | ||
|
||
~BoundaryData() = default; | ||
|
||
index_type nvalue() const { return m_values.ncolumn(); } | ||
|
||
LookupTable<index_type, BFREL> const & facn() const { return m_facn; } | ||
|
||
LookupTable<index_type, BFREL> & facn() { return m_facn; } | ||
|
||
LookupTableCore const & values() const { return m_values; } | ||
|
||
LookupTableCore & values() { return m_values; } | ||
|
||
template< size_t NVALUE > | ||
LookupTable< real_type, NVALUE > const & values() const { | ||
assert(NVALUE == m_values.ncolumn()); | ||
return *reinterpret_cast< LookupTable< real_type, NVALUE > const * >(&m_values); | ||
} | ||
|
||
template< size_t NVALUE > | ||
LookupTable< real_type, NVALUE > & values() { | ||
assert(NVALUE == m_values.ncolumn()); | ||
return *reinterpret_cast< LookupTable< real_type, NVALUE > * >(&m_values); | ||
} | ||
|
||
bool good_shape() const { | ||
return m_facn.nghost() == 0 && m_values.nghost() == 0 | ||
&& m_facn.nbody() == m_values.nbody(); | ||
} | ||
|
||
}; /* end class BoundaryData */ | ||
|
||
} /* end namespace mesh */ | ||
|
||
} /* end namespace march */ | ||
|
||
// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4: |
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
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
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
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,42 @@ | ||
/* | ||
* Copyright (c) 2016, Yung-Yu Chen <yyc@solvcon.net> | ||
* BSD 3-Clause License, see LICENSE.txt | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <vector> | ||
|
||
#include "march/march.hpp" | ||
|
||
using namespace march; | ||
using namespace march::mesh; | ||
|
||
TEST(BoundaryDataTest, DefaultConstruction) { | ||
BoundaryData bnd; | ||
EXPECT_EQ(bnd.facn().nbyte(), 0); | ||
EXPECT_EQ(bnd.values().nbyte(), 0); | ||
EXPECT_EQ(bnd.nvalue(), 0); | ||
} | ||
|
||
TEST(BoundaryDataTest, UsefulConstruction) { | ||
BoundaryData bnd(5); | ||
EXPECT_EQ((bnd.values<5>().nelem()), 0); | ||
bnd.values<5>() = LookupTable<real_type, 5>(0, 10); | ||
EXPECT_EQ((bnd.values<5>().nelem()), 50); | ||
} | ||
|
||
TEST(BoundaryDataTest, InVector) { | ||
std::vector<BoundaryData> bvec; | ||
bvec.push_back(BoundaryData(5)); | ||
EXPECT_EQ((bvec[0].values<5>().nelem()), 0); | ||
EXPECT_TRUE(bvec[0].good_shape()); | ||
bvec[0].values<5>() = LookupTable<real_type, 5>(0, 10); | ||
EXPECT_EQ((bvec[0].values<5>().nelem()), 50); | ||
EXPECT_FALSE(bvec[0].good_shape()); | ||
} | ||
|
||
TEST(BoundaryDataTest, SetValue) { | ||
} | ||
|
||
// vim: set ff=unix fenc=utf8 nobomb et sw=4 ts=4: |
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
Oops, something went wrong.