[cig-commits] r13545 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:13:54 PST 2008
Author: luis
Date: 2008-12-09 18:13:54 -0800 (Tue, 09 Dec 2008)
New Revision: 13545
Modified:
cs/cigma/trunk/src/Field.cpp
cs/cigma/trunk/src/Field.h
Log:
Factory and setter methods for Field class
Modified: cs/cigma/trunk/src/Field.cpp
===================================================================
--- cs/cigma/trunk/src/Field.cpp 2008-12-10 02:13:52 UTC (rev 13544)
+++ cs/cigma/trunk/src/Field.cpp 2008-12-10 02:13:54 UTC (rev 13545)
@@ -1,9 +1,79 @@
#include "Field.h"
+#include "Exception.h"
+#include "tri_logger.hpp"
#include <cassert>
+#include <string>
+#include <sstream>
+using namespace std;
using namespace cigma;
using boost::shared_ptr;
+// ----------------------------------------------------------------------------
+
+shared_ptr<Field> Field::NewField(const FieldInfo& field_info)
+{
+ TRI_LOG_STR("Field::NewField()");
+
+ shared_ptr<Field> field(new Field);
+
+ field->dofs = DofHandler::New(field_info.p_field);
+
+ /*
+ if (field_info.p_field)
+ {
+ field->setDofsPath(field_info.p_field);
+ } // */
+
+ field->mesh = MeshPart::New(field_info.mesh_info);
+
+ /*
+ if (field_info.mesh_info.p_mesh)
+ {
+ field->setMeshPath(field_info.mesh_info.p_mesh);
+ }
+ else if (field_info.mesh_info.p_nc &&
+ field_info.mesh_info.p_eb)
+ {
+ field->setMeshPath2(field_info.mesh_info.p_nc,
+ field_info.mesh_info.p_eb);
+ }
+ else
+ {
+ std::ostringstream stream;
+ stream << "Mesh for field '" << field_info.p_field << "'"
+ << " was not specified" << std::ends;
+ throw cigma::Exception("Function::NewFunction", stream.str());
+ } // */
+
+
+ field->fe = FE::New(field_info.fe_info);
+
+ /*
+ if (field_info.fe_info.q_info.p_quadrature)
+ {
+ field->setQuadPath(field_info.fe_info.q_info.p_quadrature);
+ }
+ else if (field_info.fe_info.q_info.p_weights &&
+ field_info.fe_info.q_info.p_points)
+ {
+ field->setQuadPath2(field_info.fe_info.q_info.p_weights,
+ field_info.fe_info.q_info.p_points);
+ }
+
+ if (field_info.fe_info.q_info.cell_type_name != "")
+ {
+ field->setCell(field_info.fe_info.q_info.cell_type_name);
+ }
+
+ field->setBasisAtQuad(field_info.fe_info.p_fe_basis);
+ // */
+
+ return field;
+}
+
+// ----------------------------------------------------------------------------
+
Field::Field()
{
mesh = shared_ptr<MeshPart>(new MeshPart);
@@ -82,3 +152,104 @@
fe->cell->interpolate(local_dofs, uvw, value, valdim);
return true;
}
+
+
+// ----------------------------------------------------------------------------
+
+
+void Field::setDofsPath(const DataPath& p_dofs)
+{
+ TRI_LOG_STR("Field::setDofsPath");
+ TRI_LOG(p_dofs);
+
+ if (!dofs)
+ {
+ dofs = shared_ptr<DofHandler>(new DofHandler);
+ }
+
+ dofs->setPath(p_dofs);
+}
+
+void Field::setMeshPath(const DataPath& p_mesh)
+{
+ TRI_LOG_STR("Field::setMeshPath");
+ TRI_LOG(p_mesh);
+
+ if (!mesh)
+ {
+ mesh = shared_ptr<MeshPart>(new MeshPart);
+ }
+
+ mesh->setPath(p_mesh);
+}
+
+void Field::setMeshPath2(const DataPath& p_nc, const DataPath& p_eb)
+{
+ TRI_LOG_STR("Field::setMeshPart2");
+ TRI_LOG(p_nc);
+ TRI_LOG(p_eb);
+
+ if (!mesh)
+ {
+ mesh = shared_ptr<MeshPart>(new MeshPart);
+ }
+
+ mesh->setPath2(p_nc, p_eb);
+}
+
+void Field::setCell(string cell_name)
+{
+ TRI_LOG_STR("Field::setCell");
+ TRI_LOG(cell_name);
+
+ if (!fe)
+ {
+ fe = shared_ptr<FE>(new FE);
+ }
+
+ fe->setCell(cell_name);
+
+ // XXX: make sure that fe->cell->cell_type() is equal to mesh->cell_type (throw exception otherwise)
+}
+
+void Field::setQuadPath(const DataPath& p_quad)
+{
+ TRI_LOG_STR("Field::setQuadPath");
+ TRI_LOG(p_quad);
+
+ if (!fe)
+ {
+ fe = shared_ptr<FE>(new FE);
+ }
+
+ fe->setQuadPath(p_quad);
+}
+
+void Field::setQuadPath2(const DataPath& p_weights, const DataPath& p_points)
+{
+ TRI_LOG_STR("Field::setQuadPath2");
+ TRI_LOG(p_weights);
+ TRI_LOG(p_points);
+
+ if (!fe)
+ {
+ fe = shared_ptr<FE>(new FE);
+ }
+
+ fe->setQuadPath2(p_weights, p_points);
+}
+
+void Field::setBasisAtQuad(const DataPath& p_basis)
+{
+ TRI_LOG_STR("Field::setBasisAtQuad");
+ TRI_LOG(p_basis);
+
+ if (!fe)
+ {
+ string msg("Failed to initialize quadrature before setting basis tabulation");
+ throw cigma::Exception("Field::setBasisAtQuad", msg);
+ }
+
+ fe->setBasisAtQuad(p_basis);
+}
+
Modified: cs/cigma/trunk/src/Field.h
===================================================================
--- cs/cigma/trunk/src/Field.h 2008-12-10 02:13:52 UTC (rev 13544)
+++ cs/cigma/trunk/src/Field.h 2008-12-10 02:13:54 UTC (rev 13545)
@@ -8,6 +8,8 @@
#include "FE.h"
#include "DofHandler.h"
#include "Function.h"
+#include "DataPath.h"
+#include "core_args.h"
namespace cigma
{
@@ -23,13 +25,25 @@
int n_dim() const;
int n_rank() const;
bool eval(double *point, double *value);
+ void getCellDofs(int cellIndex, double *cellDofs); // XXX: move method to DofHandler
+ /* direct setters */
void setMesh(const boost::shared_ptr<MeshPart> mesh);
void setFE(const boost::shared_ptr<FE> fe);
void setDofHandler(const boost::shared_ptr<DofHandler> dofs);
- void getCellDofs(int cellIndex, double *cellDofs); // XXX: move method to DofHandler
+ /* incremental setters */
+ void setDofsPath(const DataPath& p_dofs);
+ void setMeshPath(const DataPath& p_mesh);
+ void setMeshPath2(const DataPath& p_nc, const DataPath& p_eb);
+ void setCell(std::string cell_name);
+ void setQuadPath(const DataPath& p_quad);
+ void setQuadPath2(const DataPath& p_weights, const DataPath& p_points);
+ void setBasisAtQuad(const DataPath& p_basis);
+ /* static factory method */
+ static boost::shared_ptr<Field> NewField(const FieldInfo& field_info);
+
public:
boost::shared_ptr<MeshPart> mesh;
boost::shared_ptr<FE> fe;
More information about the CIG-COMMITS
mailing list