Skip to content
Snippets Groups Projects
Commit ba58bf73 authored by Dave Moxey's avatar Dave Moxey
Browse files

Rework a bit so that Field has multiple components

parent 6d02d9bb
No related branches found
No related tags found
No related merge requests found
......@@ -20,34 +20,45 @@ struct StatePhys;
struct StateCoeff;
using DefaultState = StatePhys;
struct CollectionInfo {
size_t offset;
// other polynomial order stuff
enum ShapeType {
eQuadrilateral,
eTriangle
};
struct VariableInfo {
std::string name;
struct BlockAttributes {
ShapeType shape;
std::array<int, 3> dofs;
size_t num_elements;
};
template<typename TType = double, typename TState = DefaultState, typename tBackend = DefaultBackend>
class Field
{
public:
Field() : m_storage(10)
Field(std::vector<BlockAttributes> &blocks) : block_attributes(blocks), m_storage(blocks.size())
{
for (int i = 0; i < blocks.size(); ++i)
{
auto &block = blocks[i];
size_t blockSize = block.num_elements * block.dofs[0] * block.dofs[1] * block.dofs[2]; // wasteful but an upper bound
m_storage[i] = MemRef<TType, tBackend>(blockSize);
}
}
Field(const Field&) = default;
~Field() = default;
MemRef<TType, tBackend> &GetStorage()
MemRef<TType, tBackend> &GetStorage(size_t i)
{
return m_storage;
return m_storage[i];
}
private:
MemRef<TType, tBackend> m_storage;
size_t GetNumComponents()
{
return component_names.size();
}
std::vector<CollectionInfo> coll_info;
size_t nvar;
std::vector<VariableInfo> var_info;
private:
std::vector<MemRef<TType, tBackend>> m_storage;
std::vector<BlockAttributes> block_attributes;
std::vector<std::string> component_names;
};
......@@ -5,6 +5,7 @@ template<typename tData>
class MemRef<tData, BackendCPU>
{
public:
MemRef() {}
MemRef(size_t n)
{
m_host = new tData[n];
......
#include <boost/core/demangle.hpp>
#include <iostream>
......@@ -10,8 +11,10 @@ int main() {
using DefaultMethod = MethodLocMat;
using TData = double;
Field<double, StateCoeff> in;
Field<double, StatePhys> out;
std::vector<BlockAttributes> blocks = { {eQuadrilateral, {4, 4, 4}, 100} };
Field<double, StateCoeff> in(blocks);
Field<double, StatePhys> out(blocks);
auto test2 = std::make_shared<Operator<double, OpBwdTrans>>();
auto test = std::dynamic_pointer_cast<OperatorBase<Operator<double, OpBwdTrans>, double, StateCoeff, StatePhys>>(test2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment