Index: FieldEngine.Lagrangian.h =================================================================== RCS file: FieldEngine.Lagrangian.h diff -N FieldEngine.Lagrangian.h *** /tmp/cvsBYwNoC Thu Sep 20 12:08:14 2001 --- /dev/null Fri Mar 23 21:37:44 2001 *************** *** 1,275 **** - // -*- C++ -*- - // ACL:license - // ---------------------------------------------------------------------- - // This software and ancillary information (herein called "SOFTWARE") - // called POOMA (Parallel Object-Oriented Methods and Applications) is - // made available under the terms described here. The SOFTWARE has been - // approved for release with associated LA-CC Number LA-CC-98-65. - // - // Unless otherwise indicated, this SOFTWARE has been authored by an - // employee or employees of the University of California, operator of the - // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with - // the U.S. Department of Energy. The U.S. Government has rights to use, - // reproduce, and distribute this SOFTWARE. The public may copy, distribute, - // prepare derivative works and publicly display this SOFTWARE without - // charge, provided that this Notice and any statement of authorship are - // reproduced on all copies. Neither the Government nor the University - // makes any warranty, express or implied, or assumes any liability or - // responsibility for the use of this SOFTWARE. - // - // If SOFTWARE is modified to produce derivative works, such modified - // SOFTWARE should be clearly marked, so as not to confuse it with the - // version available from LANL. - // - // For more information about POOMA, send e-mail to address@hidden, - // or visit the POOMA web page at http://www.acl.lanl.gov/pooma/. - // ---------------------------------------------------------------------- - // ACL:license - - //----------------------------------------------------------------------------- - // Classes: - // Lagrangian - // FieldEngine, T, EngineTag> - //----------------------------------------------------------------------------- - - #ifndef POOMA_FIELD_FIELDENGINE_LAGRANGIAN_H - #define POOMA_FIELD_FIELDENGINE_LAGRANGIAN_H - - //----------------------------------------------------------------------------- - // Overview: - // - // FieldEngine - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // Includes: - //----------------------------------------------------------------------------- - - #include "Field/FieldEngine/FieldEngineBase.h" - - #include "Array/Array.h" - #include "CoordinateSystems/Cartesian.h" - #include "Domain/Interval.h" - #include "Engine/ConstantFunctionEngine.h" - #include "Engine/EnginePatch.h" - #include "Engine/IndexFunctionEngine.h" - #include "Layout/INode.h" - #include "PETE/PETE.h" - #include "Pooma/Indices.h" - #include "Tiny/Vector.h" - #include "Utilities/PAssert.h" - - - //----------------------------------------------------------------------------- - // Forward Declarations: - //----------------------------------------------------------------------------- - - template class FieldEngine; - - - //----------------------------------------------------------------------------- - // Full Description: - // - // Lagrangian tag class. - //----------------------------------------------------------------------------- - - template > - struct Lagrangian; - - - //----------------------------------------------------------------------------- - // Full Description: - // - // FieldEngine, specialized for a rudimentary Lagrangian mesh. - //----------------------------------------------------------------------------- - - template - class FieldEngine, T, EngineTag> : - public FieldEngineBase - { - public: - - //--------------------------------------------------------------------------- - // Exported typedefs and enumerations. - - // This class. - - typedef FieldEngine, T, EngineTag> - This_t; - - // Our base class. - - typedef FieldEngineBase Base_t; - - // The geometry tag. - - typedef Lagrangian GeometryTag_t; - - // The engine tag. - - typedef EngineTag EngineTag_t; - - // The coordinate system. - - typedef CoordinateSystem CoordinateSystem_t; - - // The domain type. - - typedef typename Base_t::Domain_t Domain_t; - - // The number of indices required to select a point in this mesh. - - enum { dimensions = Dim }; - - // The type used to represent a point in the mesh. - - typedef Vector PointType_t; - - // Our engine type. - - typedef Engine Engine_t; - - // Our layout type. - - typedef typename Engine_t::Layout_t Layout_t; - - - //--------------------------------------------------------------------------- - // Constructors. We don't use default arguments for the origin and spacings - // because that produces ambiguities. - - template - FieldEngine(const BaseInitializer &baseInit, - const Layout_t &layout, - const PointType_t &origin, - const PointType_t &spacings) - : Base_t(baseInit, layout), - positions_m(layout) - { - positions_m = origin + iota(growRight(totalCellDomain(), 1) - - physicalCellDomain().firsts()) * spacings; - } - - // Copy constructor. - - FieldEngine(const This_t &model) - : Base_t(model), - positions_m(model.positions_m) - { } - - // Copy constructor (except for updaters). - - FieldEngine(const This_t &model, const Pooma::Updaters::DontCopyUpdaters &d) - : Base_t(model, d), - positions_m(model.positions_m) - { } - - // Sub-field constructor. - - FieldEngine(const This_t &model, const int &iSubField) - : Base_t(model, iSubField), - positions_m(model.positions_m) - { } - - // Domain view constructors. - - template - FieldEngine(const FieldEngine &model, - const Domain_t &d) - : Base_t(model, d), - positions_m(model.vertexPositions()(translateToVertexDomain(d))) - { } - - template - FieldEngine(const FieldEngine &model, - const INode &inode) - : Base_t(model, inode), - positions_m(model.vertexPositions()(inode)) - { } - - // Note there is no change to the vertex positions, because EngineView - // currently is only used to support RemoteView operations which don't - // change the domain. - template - FieldEngine(const FieldEngine &model, - const EngineView &engineView) - : Base_t(model, engineView), - positions_m(forEach(model.vertexPositions(), engineView, TreeCombine())) - { } - - // Expression-engine constructor. - - FieldEngine(const Engine &e) - : Base_t(e), - positions_m(referenceField().fieldEngine().vertexPositions()) - { } - - // Patch constructor. - - template - FieldEngine(const FieldEngine &model, - const FieldEnginePatch &p) - : Base_t(model, p), - positions_m(model.vertexPositions().patchLocal(p.patch_m)) - { } - - - //--------------------------------------------------------------------------- - // Copy assignment operator (shallow). - - This_t &operator=(const This_t &rhs); - - - //--------------------------------------------------------------------------- - // Empty destructor is fine. - - ~FieldEngine() { } - - - //--------------------------------------------------------------------------- - // Return the vertex centers. - - typedef Array VertexPositionsArray_t; - - const VertexPositionsArray_t &vertexPositions() const - { - return positions_m; - } - - private: - - VertexPositionsArray_t positions_m; - - }; - - template - struct LeafFunctor< - FieldEngine, T, EngineTag>, - ExpressionApply > - { - typedef Lagrangian GeometryTag_t; - typedef FieldEngine Subject_t; - typedef typename Subject_t::Engine_t Engine_t; - typedef LeafFunctor > LeafFunctor_t; - typedef int Type_t; - - inline static - Type_t apply(const Subject_t &fieldEngine, const ExpressionApply &tag) - { - forEach(fieldEngine.vertexPositions(), tag, NullCombine()); - - return LeafFunctor_t::apply(fieldEngine.engine(), tag); - } - }; - - #endif // POOMA_FIELD_FIELDENGINE_LAGRANGIAN_H - - // ACL:rcsinfo - // ---------------------------------------------------------------------- - // $RCSfile: FieldEngine.Lagrangian.h,v $ $Author: oldham $ - // $Revision: 1.1 $ $Date: 2001/08/30 01:15:10 $ - // ---------------------------------------------------------------------- - // ACL:rcsinfo - --- 0 ---- Index: FieldEngine.NoGeometry.h =================================================================== RCS file: FieldEngine.NoGeometry.h diff -N FieldEngine.NoGeometry.h *** /tmp/cvsbKOjVk Thu Sep 20 12:08:14 2001 --- /dev/null Fri Mar 23 21:37:44 2001 *************** *** 1,348 **** - // -*- C++ -*- - // ACL:license - // ---------------------------------------------------------------------- - // This software and ancillary information (herein called "SOFTWARE") - // called POOMA (Parallel Object-Oriented Methods and Applications) is - // made available under the terms described here. The SOFTWARE has been - // approved for release with associated LA-CC Number LA-CC-98-65. - // - // Unless otherwise indicated, this SOFTWARE has been authored by an - // employee or employees of the University of California, operator of the - // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with - // the U.S. Department of Energy. The U.S. Government has rights to use, - // reproduce, and distribute this SOFTWARE. The public may copy, distribute, - // prepare derivative works and publicly display this SOFTWARE without - // charge, provided that this Notice and any statement of authorship are - // reproduced on all copies. Neither the Government nor the University - // makes any warranty, express or implied, or assumes any liability or - // responsibility for the use of this SOFTWARE. - // - // If SOFTWARE is modified to produce derivative works, such modified - // SOFTWARE should be clearly marked, so as not to confuse it with the - // version available from LANL. - // - // For more information about POOMA, send e-mail to address@hidden, - // or visit the POOMA web page at http://www.acl.lanl.gov/pooma/. - // ---------------------------------------------------------------------- - // ACL:license - - //----------------------------------------------------------------------------- - // Classes: - // NoGeometry - // FieldEngine - //----------------------------------------------------------------------------- - - #ifndef POOMA_FIELD_FIELDENGINE_NOGEOMETRY_H - #define POOMA_FIELD_FIELDENGINE_NOGEOMETRY_H - - //----------------------------------------------------------------------------- - // Overview: - // - // FieldEngine - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // Includes: - //----------------------------------------------------------------------------- - #include "Field/FieldEngine/FieldEngineBase.h" - - #include "Array/Array.h" - #include "Domain/Interval.h" - #include "Engine/ConstantFunctionEngine.h" - #include "Engine/IndexFunctionEngine.h" - #include "Layout/INode.h" - #include "Field/Updater/UpdaterList.h" - #include "Tiny/Vector.h" - #include "Utilities/PAssert.h" - - - //----------------------------------------------------------------------------- - // Forward Declarations: - //----------------------------------------------------------------------------- - - template class ComponentWrapper; - template class Engine; - template class FieldEngine; - - - //----------------------------------------------------------------------------- - // NoGeometry tag class. - //----------------------------------------------------------------------------- - - template - struct NoGeometry; - - - //----------------------------------------------------------------------------- - // FieldEngine, specialized for no geometry. This is really just a field - // wrapper of a single engine. - //----------------------------------------------------------------------------- - - template - class FieldEngine, T, EngineTag> - { - public: - - //--------------------------------------------------------------------------- - // Exported typedefs and enumerations. - - // This class. - - typedef FieldEngine, T, EngineTag> This_t; - - // Our base class. - - typedef FieldEngineBase Base_t; - - // The geometry tag. - - typedef NoGeometry GeometryTag_t; - - // The engine tag. - - typedef EngineTag EngineTag_t; - - // The domain type. - - typedef typename Base_t::Domain_t Domain_t; - - // The number of indices required to select a point in this mesh. - - enum { dimensions = Dim }; - - // Our engine type. - - typedef Engine Engine_t; - - // Our layout type. - - typedef typename Engine_t::Layout_t Layout_t; - - // Our guard layers type. - - typedef GuardLayers GuardLayers_t; - - - //--------------------------------------------------------------------------- - // Constructors. - // - // There is no sub-field constructor because this field-engine can't have - // subfields. - - // Default constructor. - FieldEngine() - : engine_m(Pooma::NoInit()), - guards_m(0), - updaters_m() - { } - - // Copy constructor. - - FieldEngine(const This_t &model) - : engine_m(model.engine_m), - guards_m(model.guards_m), - updaters_m(model.updaters_m) - { } - - // Domain view constructor, including INodes and non-interval - // views. - - template - FieldEngine(const FieldEngine &model, - const Domain &d) - : engine_m(NewEngineEngine::Engine_t, Domain>::apply(model.engine(), d), - NewEngineDomain::Engine_t, Domain>::apply(model.engine(), d)), - updaters_m(model.updaters()) - { } - - // Sub-field constructor. Needs to exist, but shouldn't be called since we - // have no subfields. - - template - FieldEngine(const FieldEngine &model, const int &) - : engine_m(model.engine()) - { - PError("Can't create a sub-field of a FieldEngine."); - } - - // Expression-engine constructor. - - FieldEngine(const Engine &e) - : engine_m(e) - { - } - - // Patch constructor. - - template - FieldEngine(const FieldEngine &model, - const FieldEnginePatch &p) - : engine_m(engineFunctor(model.engine(), p)), - updaters_m(model.updaters()) - { } - - // ComponentView constructor. The geometry for the model should be the - // same since a component view simply mutates the elements. - - template - FieldEngine(const FieldEngine &model, - const ComponentWrapper &c) - : engine_m(model.engine(), c.components()), - updaters_m(model.updaters()) - { } - - // EngineView version used for remote computations. - - template - FieldEngine(const FieldEngine &model, - const EngineView &engineView) - : engine_m(leafFunctor(model.engine(), engineView)), - updaters_m(model.updaters()) - { } - - //--------------------------------------------------------------------------- - // Copy assignment operator (disabled). - - This_t &operator=(const This_t &rhs); - - - //--------------------------------------------------------------------------- - // Empty destructor is fine. - - ~FieldEngine() { } - - - //--------------------------------------------------------------------------- - // Accessors and modifiers. - - inline int numSubFields() const - { - return 0; - } - - const Loc offsets() const - { - // Always vert-centered... - - return Loc(1); - } - - Engine_t &engine() - { - return engine_m; - } - - const Engine_t &engine() const - { - return engine_m; - } - - const UpdaterList &updaters() const - { - return updaters_m; - } - - UpdaterList &updaters() - { - return updaters_m; - } - - const GuardLayers_t &guardLayers() const - { - return guards_m; - } - - - //--------------------------------------------------------------------------- - // Domain accessor functions. - // - // This field-engine always has vert-centering and the total domain is - // given by the engine. - - inline const Domain_t physicalCellDomain() const - { - return shrinkRight(physicalDomain(), 1); - } - - inline Domain_t totalCellDomain() const - { - return shrinkRight(engine_m.domain(), 1); - } - - Domain_t physicalDomain() const - { - return shrink(engine_m.domain(), guards_m); - } - - Domain_t totalDomain() const - { - return engine_m.domain(); - } - - Domain_t physicalDomain(int iSubField) const - { - // This field engine cannot have subfields. - PAssert(iSubField == 0); - return physicalDomain(); - } - - Domain_t totalDomain(int iSubField) const - { - // This field engine cannot have subfields. - PAssert(iSubField == 0); - return engine_m.domain(); - } - - - //--------------------------------------------------------------------------- - // Make a distinct copy of this fieldEngineBase. - - template - void makeOwnCopy(const Subject &s) - { - // Deepen the copies of the engine & updaters list. - - engine().makeOwnCopy(); - updaters().makeOwnCopy(s); - } - - private: - - Engine_t engine_m; - GuardLayers_t guards_m; - UpdaterList updaters_m; - }; - - // This version of field engine requires a specialization of ExpressionApply, - // since the default version assume a field engine that uses FieldEngineBase. - - template - struct LeafFunctor< - FieldEngine, T, EngineTag>, - ExpressionApply > - { - typedef NoGeometry GeometryTag_t; - typedef FieldEngine Subject_t; - typedef typename Subject_t::Engine_t Engine_t; - typedef LeafFunctor > LeafFunctor_t; - typedef int Type_t; - - inline static - Type_t apply(const Subject_t &fieldEngine, const ExpressionApply &tag) - { - return LeafFunctor_t::apply(fieldEngine.engine(), tag); - } - }; - - - #endif // POOMA_FIELD_FIELDENGINE_NOGEOMETRY_H - - // ACL:rcsinfo - // ---------------------------------------------------------------------- - // $RCSfile: FieldEngine.NoGeometry.h,v $ $Author: oldham $ - // $Revision: 1.1 $ $Date: 2001/08/30 01:15:10 $ - // ---------------------------------------------------------------------- - // ACL:rcsinfo - --- 0 ---- Index: FieldEngine.UR.h =================================================================== RCS file: FieldEngine.UR.h diff -N FieldEngine.UR.h *** /tmp/cvs4HJ4r3 Thu Sep 20 12:08:14 2001 --- /dev/null Fri Mar 23 21:37:44 2001 *************** *** 1,377 **** - // -*- C++ -*- - // ACL:license - // ---------------------------------------------------------------------- - // This software and ancillary information (herein called "SOFTWARE") - // called POOMA (Parallel Object-Oriented Methods and Applications) is - // made available under the terms described here. The SOFTWARE has been - // approved for release with associated LA-CC Number LA-CC-98-65. - // - // Unless otherwise indicated, this SOFTWARE has been authored by an - // employee or employees of the University of California, operator of the - // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with - // the U.S. Department of Energy. The U.S. Government has rights to use, - // reproduce, and distribute this SOFTWARE. The public may copy, distribute, - // prepare derivative works and publicly display this SOFTWARE without - // charge, provided that this Notice and any statement of authorship are - // reproduced on all copies. Neither the Government nor the University - // makes any warranty, express or implied, or assumes any liability or - // responsibility for the use of this SOFTWARE. - // - // If SOFTWARE is modified to produce derivative works, such modified - // SOFTWARE should be clearly marked, so as not to confuse it with the - // version available from LANL. - // - // For more information about POOMA, send e-mail to address@hidden, - // or visit the POOMA web page at http://www.acl.lanl.gov/pooma/. - // ---------------------------------------------------------------------- - // ACL:license - - //----------------------------------------------------------------------------- - // Classes: - // UniformRectilinear - // FieldEngine - //----------------------------------------------------------------------------- - - #ifndef POOMA_FIELD_FIELDENGINE_UR_H - #define POOMA_FIELD_FIELDENGINE_UR_H - - //----------------------------------------------------------------------------- - // Overview: - // - // FieldEngine - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // Includes: - //----------------------------------------------------------------------------- - - #include "Field/FieldEngine/FieldEngineBase.h" - - #include "Array/Array.h" - #include "CoordinateSystems/Cartesian.h" - #include "Domain/Interval.h" - #include "Engine/ConstantFunctionEngine.h" - #include "Engine/IndexFunctionEngine.h" - #include "Layout/INode.h" - #include "Tiny/Vector.h" - #include "Utilities/PAssert.h" - - - //----------------------------------------------------------------------------- - // Forward Declarations: - //----------------------------------------------------------------------------- - - template class FieldEngine; - template class ComponentWrapper; - - - //----------------------------------------------------------------------------- - // Full Description: - // - // UniformRectilinear tag class. - //----------------------------------------------------------------------------- - - template > - struct UniformRectilinear; - - - //----------------------------------------------------------------------------- - // Full Description: - // - // FieldEngine, specialized for uniform rectilinear meshes. - //----------------------------------------------------------------------------- - - template - class FieldEngine, T, EngineTag> - : public FieldEngineBase - { - public: - - //--------------------------------------------------------------------------- - // Exported typedefs and enumerations. - - // This class. - - typedef - FieldEngine, T, EngineTag> - This_t; - - // Our base class. - - typedef FieldEngineBase Base_t; - - // The geometry tag. - - typedef UniformRectilinear GeometryTag_t; - - // The engine tag. - - typedef EngineTag EngineTag_t; - - // The coordinate system. - - typedef CoordinateSystem CoordinateSystem_t; - - // The domain type. - - typedef typename Base_t::Domain_t Domain_t; - - // The number of indices required to select a point in this mesh. - - enum { dimensions = Dim }; - - // The type used to represent a point in the mesh. - - typedef Vector PointType_t; - - // Our engine type. - - typedef Engine Engine_t; - - // Our layout type. - - typedef typename Engine_t::Layout_t Layout_t; - - - //--------------------------------------------------------------------------- - // Constructors. We don't use default arguments for the origin and spacings - // because that produces ambiguities. - - FieldEngine() - : Base_t() - { } - - template - FieldEngine(const BaseInitializer &baseInit, - const Layout_t &layout, - const PointType_t &origin, - const PointType_t &spacings) - : Base_t(baseInit, layout), - origin_m(origin), - spacings_m(spacings) - { } - - // Version that constructs a field with a new centering but based on the - // same geometry. - - template - FieldEngine(const BaseInitializer &baseInit, - const FieldEngine &model) - : Base_t(baseInit, model), - origin_m(model.origin()), - spacings_m(model.spacings()) - { - } - - // Copy constructor. - - FieldEngine(const This_t &model) - : Base_t(model), - origin_m(model.origin_m), - spacings_m(model.spacings_m) - { } - - // Copy constructor (except for updaters). - - FieldEngine(const This_t &model, const Pooma::Updaters::DontCopyUpdaters &d) - : Base_t(model, d), - origin_m(model.origin_m), - spacings_m(model.spacings_m) - { } - - // Sub-field constructor. - - template - FieldEngine(const FieldEngine &model, - const int &iSubField) - : Base_t(model, iSubField), - origin_m(model.origin()), - spacings_m(model.spacings()) - { } - - // Domain view constructor. - - template - FieldEngine(const FieldEngine &model, - const Domain_t &d) - : Base_t(model, d), - origin_m(model.origin()), - spacings_m(model.spacings()) - { - for (int i = 0; i < Dim; i++) - origin_m(i) += - (d[i].first() - model.physicalCellDomain()[i].first()) * - spacings_m(i); - } - - template - FieldEngine(const FieldEngine &model, - const INode &inode) - : Base_t(model, inode), - origin_m(model.origin()), - spacings_m(model.spacings()) - { - for (int i = 0; i < Dim; i++) - origin_m(i) += - (inode.domain()[i].first() - model.physicalCellDomain()[i].first()) * - spacings_m(i); - } - - template - FieldEngine(const FieldEngine &model, - const EngineView &engineView) - : Base_t(model, engineView), - origin_m(model.origin()), - spacings_m(model.spacings()) - { - // Will need to fix up origin_m if EnginView replaces INode<> view. - } - - // Expression-engine constructor. - - FieldEngine(const Engine &e) - : Base_t(e) - { - origin_m = referenceField().fieldEngine().origin(); - spacings_m = referenceField().fieldEngine().spacings(); - } - - // Patch constructor. - - template - FieldEngine(const FieldEngine &model, - const FieldEnginePatch &p) - : Base_t(model, p), - spacings_m(model.spacings()) - { - for (int i = 0; i < Dim; i++) - origin_m(i) += - (physicalCellDomain()[i].first() - - model.physicalCellDomain()[i].first()) * - spacings_m(i); - } - - // ComponentView constructor. The geometry for the model should be the - // same since a component view simply mutates the elements. - - template - FieldEngine(const FieldEngine &model, - const ComponentWrapper &c) - : Base_t(model, c), - origin_m(model.origin()), - spacings_m(model.spacings()) - { } - - - //--------------------------------------------------------------------------- - // Copy assignment operator (shallow). - - This_t &operator=(const This_t &rhs) - { - origin_m = rhs.origin(); - spacings_m = rhs.spacings(); - initialize(rhs); - return *this; - } - - //--------------------------------------------------------------------------- - // Empty destructor is fine. - - ~FieldEngine() { } - - - //--------------------------------------------------------------------------- - // Accessors. - - inline const PointType_t &origin() const { return origin_m; } - inline const PointType_t &spacings() const { return spacings_m; } - - - //--------------------------------------------------------------------------- - // Return an index-function-engine-based array that can return the positions - // of the geometric center of a cell's faces. - - class FaceCenterFunctor - { - public: - - FaceCenterFunctor() { } - - FaceCenterFunctor(const PointType_t &origin, const PointType_t &spacings, - const Domain_t &pcd, int orientation) - : origin_m(origin), spacings_m(spacings) - { - for (int i = 0; i < PointType_t::dimensions; i++) - { - if (i != orientation) - origin_m(i) += 0.5 * spacings_m(i); - origin_m(i) -= pcd[i].first() * spacings_m(i); - } - } - - PointType_t operator()(int i0) const - { - return origin_m + PointType_t(i0) * spacings_m; - } - - PointType_t operator()(int i0, int i1) const - { - return origin_m + PointType_t(i0, i1) * spacings_m; - } - - PointType_t operator()(int i0, int i1, int i2) const - { - return origin_m + PointType_t(i0, i1, i3) * spacings_m; - } - - private: - - PointType_t origin_m, spacings_m; - }; - - typedef Array > - FaceCentersArray_t; - - FaceCentersArray_t faceCenters(int orientation, const Domain_t &d) const; - - private: - - PointType_t origin_m, spacings_m; - - }; - - - /////////////////////////////////////////////////////////////////////////////// - // - // Non-inline members. - // - /////////////////////////////////////////////////////////////////////////////// - - //----------------------------------------------------------------------------- - // Return the face centers. - //----------------------------------------------------------------------------- - - template - typename - FieldEngine, T, EngineTag>:: - FaceCentersArray_t - FieldEngine, T, EngineTag>:: - faceCenters(int orientation, const Domain_t &d) const - { - FaceCentersArray_t array(d); - FaceCenterFunctor functor(origin_m, spacings_m, physicalCellDomain(), - orientation); - array.engine().setFunctor(functor); - return array; - } - - #endif // POOMA_FIELD_FIELDENGINE_UR_H - - // ACL:rcsinfo - // ---------------------------------------------------------------------- - // $RCSfile: FieldEngine.UR.h,v $ $Author: oldham $ - // $Revision: 1.1 $ $Date: 2001/08/30 01:15:10 $ - // ---------------------------------------------------------------------- - // ACL:rcsinfo - --- 0 ---- Index: FieldEngineApply.h =================================================================== RCS file: FieldEngineApply.h diff -N FieldEngineApply.h *** /tmp/cvsALibZL Thu Sep 20 12:08:14 2001 --- /dev/null Fri Mar 23 21:37:44 2001 *************** *** 1,34 **** - - - template - struct LeafFunctor, EngineApply > - { - typedef Field Subject_t; - typedef typename Subject_t::FieldEngine_t FieldEngine_t; - typedef LeafFunctor > LeafFunctor_t; - typedef typename LeafFunctor_t::Type_t Type_t; - - inline static - Type_t apply(const Subject_t &field, - const EngineApply &tag) - { - return LeafFunctor_t::apply(field.fieldEngine(), tag); - } - }; - - template - struct LeafFunctor, EngineApply > - { - typedef FieldEngine Subject_t; - typedef typename Subject_t::Engine_t Engine_t; - typedef LeafFunctor > LeafFunctor_t; - typedef typename LeafFunctor_t::Type_t Type_t; - - inline static - Type_t apply(const Subject_t &fieldEngine, - const EngineApply &tag) - { - return LeafFunctor_t::apply(fieldEngine.engine(), tag); - } - }; - --- 0 ---- Index: FieldEngineBase.h =================================================================== RCS file: FieldEngineBase.h diff -N FieldEngineBase.h *** /tmp/cvsu3ikwu Thu Sep 20 12:08:14 2001 --- /dev/null Fri Mar 23 21:37:44 2001 *************** *** 1,589 **** - // -*- C++ -*- - // ACL:license - // ---------------------------------------------------------------------- - // This software and ancillary information (herein called "SOFTWARE") - // called POOMA (Parallel Object-Oriented Methods and Applications) is - // made available under the terms described here. The SOFTWARE has been - // approved for release with associated LA-CC Number LA-CC-98-65. - // - // Unless otherwise indicated, this SOFTWARE has been authored by an - // employee or employees of the University of California, operator of the - // Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with - // the U.S. Department of Energy. The U.S. Government has rights to use, - // reproduce, and distribute this SOFTWARE. The public may copy, distribute, - // prepare derivative works and publicly display this SOFTWARE without - // charge, provided that this Notice and any statement of authorship are - // reproduced on all copies. Neither the Government nor the University - // makes any warranty, express or implied, or assumes any liability or - // responsibility for the use of this SOFTWARE. - // - // If SOFTWARE is modified to produce derivative works, such modified - // SOFTWARE should be clearly marked, so as not to confuse it with the - // version available from LANL. - // - // For more information about POOMA, send e-mail to address@hidden, - // or visit the POOMA web page at http://www.acl.lanl.gov/pooma/. - // ---------------------------------------------------------------------- - // ACL:license - - //----------------------------------------------------------------------------- - // Classes: - // FieldEngineBase - //----------------------------------------------------------------------------- - - #ifndef POOMA_FIELD_FIELDENGINE_FIELDENGINEBASE_H - #define POOMA_FIELD_FIELDENGINE_FIELDENGINEBASE_H - - //----------------------------------------------------------------------------- - // Overview: - // - // FieldEngineBase and related classes. POOMA supports a flexible form - // of "centering" that allows a hierarchy of multiple centering points per - // cell. The centering information, managed by the FieldEngineBase - // class, is initialized using a flexible set of functors. - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - // Includes: - //----------------------------------------------------------------------------- - - #include "Domain/Interval.h" - #include "Domain/Loc.h" - #include "Domain/Shrink.h" - #include "Layout/INode.h" - #include "Layout/GuardLayers.h" - #include "Utilities/PAssert.h" - #include "Utilities/RefCountedBlockPtr.h" - #include "Engine/EnginePatch.h" - #include "Engine/EngineFunctor.h" - #include "Field/Updater/UpdaterList.h" - #include "Field/FieldEngine/FieldEnginePatch.h" - - //----------------------------------------------------------------------------- - // Forward declarations: - //----------------------------------------------------------------------------- - - template class Engine; - template class ComponentWrapper; - - - // ---------------------------------------------------------------------------- - // FieldEngineBaseData holds offset information about the centering along - // with a copy of the engine containing the data associated with the centering. - // ---------------------------------------------------------------------------- - - template - class FieldEngineBaseData : public RefCounted - { - public: - - template - FieldEngineBaseData(const Loc &offsets, - const Initializer &init) - : offsets_m(offsets), - engine_m(init) - { } - - template - FieldEngineBaseData(const Loc &offsets, - const Initializer &init, const UpdaterList &l) - : offsets_m(offsets), - engine_m(init), - updaters_m(l) - { } - - template - FieldEngineBaseData(const Loc &offsets, const Engine &e, - const Domain &d, const UpdaterList &l) - : offsets_m(offsets), - engine_m(NewEngineEngine::apply(e, d), - NewEngineDomain::apply(e, d)), - updaters_m(l) - { } - - const Loc &offsets() const { return offsets_m; } - - const Engine &engine() const { return engine_m; } - Engine &engine() { return engine_m; } - - const UpdaterList &updaters() const { return updaters_m; } - UpdaterList &updaters() { return updaters_m; } - - private: - - Loc offsets_m; - Engine engine_m; - UpdaterList updaters_m; - }; - - - // ---------------------------------------------------------------------------- - // FieldEngineBase manages a hierarchy of engines, making it possible for - // FieldEngine specializations to implement geometry-specific behavior only. - // ---------------------------------------------------------------------------- - - template - class FieldEngineBase - { - public: - - //--------------------------------------------------------------------------- - // Exported typedefs and enumerations. - - typedef FieldEngineBase This_t; - typedef FieldEngineBaseData Data_t; - typedef Engine Engine_t; - typedef typename Engine_t::Domain_t Domain_t; - typedef typename Engine_t::Layout_t Layout_t; - typedef typename Engine_t::Element_t Element_t; - typedef typename Engine_t::ElementRef_t ElementRef_t; - enum { dimensions = Dim }; - typedef GuardLayers GuardLayers_t; - - - //--------------------------------------------------------------------------- - // Constructors. - - // Default constructor. - - FieldEngineBase() - : physicalCellDomain_m(Pooma::NoInit()), - guards_m(0) - { } - - // Layout constructor. Takes a layout appropriate for the contained - // engines and, based on the logic contained in the InitFunctor, sets - // up centering information and the engines. - - template - FieldEngineBase(const InitFunctor &f, const Layout_t &layout) - : physicalCellDomain_m(layout.domain()), - guards_m(layout.externalGuards()) - { - shrinkInPlace(physicalCellDomain_m, guards_m); - shrinkRightInPlace(physicalCellDomain_m, 1); - f.initialize(*this, layout); - } - - // Initialize with a new centering from a model. - - template - FieldEngineBase(const InitFunctor &f, - const FieldEngineBase &model) - : physicalCellDomain_m(model.physicalCellDomain()), - guards_m(model.guardLayers()) - { - f.initialize(*this, Pooma::NoInit()); - } - - // Copy constructor. - - FieldEngineBase(const This_t &model) - : subFields_m(model.subFields_m), - data_m(model.data_m), - physicalCellDomain_m(model.physicalCellDomain_m), - guards_m(model.guards_m) - { } - - // Sub-field view constructor. This is when we want to construct a view of - // one of the subFields in our top-level list. - - FieldEngineBase(const This_t &model, const int &iSubField) - : subFields_m(model.subFields_m[iSubField].subFields_m), - data_m(model.subFields_m[iSubField].data_m), - physicalCellDomain_m(model.physicalCellDomain_m), - guards_m(model.guards_m) - { } - - // View constructor. - - template - FieldEngineBase(const FieldEngineBase &model, - const Initializer &i) - { - initialize(*this, model, i); - } - - //--------------------------------------------------------------------------- - // Initialize functions. - - template - void initialize(const Loc &loc, const Initializer &init) - { - data_m = new Data_t(loc, init); - } - - template - void initialize(const Loc &loc, const Initializer &init, - const UpdaterList &l) - { - data_m = new Data_t(loc, init, l); - } - - template - void initialize(const Loc &loc, const Engine &e, const Domain &d, - const UpdaterList &l) - { - data_m = new Data_t(loc, e, d, l); - } - - void initialize(const This_t &model) - { - subFields_m = model.subFields_m; - data_m = model.data_m; - physicalCellDomain_m = model.physicalCellDomain_m; - guards_m = model.guards_m; - } - - template - void initialize(This_t &s, - const FieldEngineBase &model, const Domain_t &d) - { - int n = model.numSubFields(); - if (n == 0) - { - s.physicalCellDomain_m = shrinkRight(d - d.firsts(), - model.offsets()); - s.initialize(model.offsets(), model.engine(), d, model.updaters()); - } - else - { - s.physicalCellDomain_m = d - d.firsts(); - s.addSubFields(n); - for (int i = 0; i < n; i++) - initialize(s.subFields_m[i], model.subField(i), - model.subField(i).translateDomain(d)); - } - } - - template - void initialize(This_t &s, - const FieldEngineBase &model, const INode &i) - { - int n = model.numSubFields(); - if (n == 0) - { - s.physicalCellDomain_m = - shrinkRight(i.domain() - i.domain().firsts(), model.offsets()); - s.initialize(model.offsets(), model.engine(), i, model.updaters()); - } - else - { - s.physicalCellDomain_m = i.domain() - i.domain().firsts(); - s.addSubFields(n); - for (int j = 0; j < n; j++) - initialize(s.subFields_m[j], model.subField(j), - model.subField(j).translateDomain(i)); - } - } - - template - void initialize(This_t &s, - const FieldEngineBase &model, - const EngineView &ev) - { - typedef typename FieldEngineBase::Engine_t EngIn_t; - int n = model.numSubFields(); - if (n == 0) - { - s.physicalCellDomain_m = model.physicalCellDomain(); - s.guards_m = model.guardLayers(); - s.initialize(model.offsets(), - LeafFunctor >::apply(model.engine(), ev), - model.updaters()); - } - else - { - s.physicalCellDomain_m = model.physicalCellDomain(); - s.guards_m = model.guardLayers(); - s.addSubFields(n); - for (int i = 0; i < n; i++) - initialize(s.subFields_m[i], model.subField(i), ev); - } - } - - template - void initialize(This_t &s, - const FieldEngineBase &model, - const FieldEnginePatch &p) - { - PAssert(model.numSubFields() == 0); - s.initialize(model.offsets(), engineFunctor(model.engine(), - EnginePatch(p.patch_m))); - s.physicalCellDomain_m = shrinkRight(p.domain_m, model.offsets()); - s.guards_m = model.guardLayers(); - } - - template - void initialize(This_t &s, - const FieldEngineBase &model, - const ComponentWrapper &c) - { - int n = model.numSubFields(); - if (n == 0) - { - s.physicalCellDomain_m = model.physicalCellDomain(); - s.guards_m = model.guardLayers(); - s.initialize(model.offsets(), - Engine_t(model.engine(), c.components()), - model.updaters()); - } - else - { - s.physicalCellDomain_m = model.physicalCellDomain(); - s.guards_m = model.guardLayers(); - s.addSubFields(n); - for (int i = 0; i < n; i++) - initialize(s.subFields_m[i], model.subField(i), c); - } - } - - void initialize(This_t &s, const This_t &model, - const Pooma::Updaters::DontCopyUpdaters &d) - { - int n = model.numSubFields(); - s.physicalCellDomain_m = model.physicalCellDomain(); - s.guards_m = model.guardLayers(); - if (n == 0) - { - s.initialize(model.offsets(), model.engine()); - } - else - { - s.addSubFields(n); - for (int i = 0; i < n; i++) - initialize(s.subFields_m[i], model.subField(i), d); - } - } - - - //--------------------------------------------------------------------------- - // Accessors and modifiers. - - void addSubFields(int n) - { - PAssert(subFields_m.size() == 0); - - subFields_m.reserve(n); - subFields_m.resize(n); - for (int i = 0; i < n; i++) - { - subFields_m[i].physicalCellDomain_m = physicalCellDomain_m; - subFields_m[i].guards_m = guards_m; - } - } - - inline int numSubFields() const - { - return subFields_m.size(); - } - - This_t &subField(int i) - { - return subFields_m[i]; - } - - const This_t &subField(int i) const - { - return subFields_m[i]; - } - - const Loc &offsets() const - { - PAssert(data_m.isValid()); - return data_m->offsets(); - } - - Engine_t &engine() - { - PAssert(data_m.isValid()); - return data_m->engine(); - } - - const Engine_t &engine() const - { - PAssert(data_m.isValid()); - return data_m->engine(); - } - - const UpdaterList &updaters() const - { - PAssert(data_m.isValid()); - return data_m->updaters(); - } - - UpdaterList &updaters() - { - PAssert(data_m.isValid()); - return data_m->updaters(); - } - - const GuardLayers_t &guardLayers() const - { - return guards_m; - } - - GuardLayers_t &guardLayers() - { - return guards_m; - } - - - //--------------------------------------------------------------------------- - // Domain accessor functions. - - inline const Domain_t physicalCellDomain() const - { - return physicalCellDomain_m; - } - - inline Domain_t totalCellDomain() const - { - return grow(physicalCellDomain_m, guards_m); - } - - Domain_t physicalDomain(int iSubField) const - { - return subFields_m[iSubField]. - translateDomain(physicalCellDomain_m); - } - - Domain_t totalDomain(int iSubField) const - { - return subFields_m[iSubField]. - translateDomain(totalCellDomain()); - } - - Domain_t physicalDomain() const - { - return translateDomain(physicalCellDomain_m); - } - - Domain_t totalDomain() const - { - return translateDomain(totalCellDomain()); - } - - - //--------------------------------------------------------------------------- - // Make a distinct copy of this fieldEngineBase. - - template - void makeOwnCopy(const Subject &s) - { - // This only make sense if we have no subfields. - - PAssert(data_m.isValid()); - - // Create a new data block with shallow copies of the engine and the - // updaters. - - initialize(offsets(), engine(), updaters()); - - // Deepen the copies of the engine & updaters list. - - engine().makeOwnCopy(); - updaters().makeOwnCopy(s); - } - - - //--------------------------------------------------------------------------- - // Domain translation function. - - inline Domain_t - translateDomain(const Domain_t &d) const - { - if (subFields_m.size() == 0) - return growRight(d, offsets()); - else - return d; - } - - inline INode - translateDomain(const INode &inode) const - { - return INode(inode, translateDomain(inode.domain())); - } - - inline Domain_t - translateToVertexDomain(const Domain_t &d) const - { - if (subFields_m.size() == 0) - return d; - else - return growRight(d, 1); - } - - - private: - - RefCountedBlockPtr subFields_m; - RefCountedPtr data_m; - Domain_t physicalCellDomain_m; - GuardLayers_t guards_m; - }; - - template - struct LeafFunctor, - ExpressionApply > - { - typedef FieldEngineBase Subject_t; - typedef typename Subject_t::Engine_t Engine_t; - typedef LeafFunctor > LeafFunctor_t; - typedef int Type_t; - - inline static - Type_t apply(const Subject_t &fieldEngineBase, - const ExpressionApply &tag) - { - int n = fieldEngineBase.numSubFields(); - - if (n == 0) - { - LeafFunctor_t::apply(fieldEngineBase.engine(), tag); - } - else - { - int i; - for (i = 0; i < n; ++i) - { - apply(fieldEngineBase.subField(i), tag); - } - } - return 0; - } - }; - - // This function applies a generic thing to all the FieldEngineBase - // objects that contain an engine. - - template - void - applyThingToFieldEngineBase(FieldEngineBase &fieldEngineBase, - const Thing &thing) - { - int n = fieldEngineBase.numSubFields(); - - if (n == 0) - { - thing(fieldEngineBase); - } - else - { - int i; - for (i = 0; i < n; ++i) - { - applyThingToFieldEngineBase(fieldEngineBase.subField(i), thing); - } - } - } - - #endif // POOMA_FIELD_FIELDENGINE_FIELDENGINEBASE_H - - // ACL:rcsinfo - // ---------------------------------------------------------------------- - // $RCSfile: FieldEngineBase.h,v $ $Author: oldham $ - // $Revision: 1.1 $ $Date: 2001/08/30 01:15:11 $ - // ---------------------------------------------------------------------- - // ACL:rcsinfo --- 0 ----