46 #ifndef MUELU_RIGIDBODYMODEFACTORY_DEF_HPP
47 #define MUELU_RIGIDBODYMODEFACTORY_DEF_HPP
50 #include <Xpetra_MultiVectorFactory.hpp>
59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 Input(currentLevel,
"A");
69 currentLevel.
DeclareInput(
"Nullspace", GetFactory(nspName_).
get(),
this);
73 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 GetOStream(
Runtime1) <<
"Use user-given rigid body modes " << nspName_ <<
": nullspace dimension=" << nullspace->getNumVectors() <<
" nullspace length=" << nullspace->getGlobalLength() << std::endl;
82 RCP<Matrix> A = Get<RCP<Matrix> >(currentLevel,
"A");
83 GetOStream(
Runtime1) <<
"Generating rigid body modes: dimension = " << numPDEs_ << std::endl;
86 nullspace = MultiVectorFactory::Build(xmap, 1);
87 }
else if (numPDEs_ == 2) {
88 nullspace = MultiVectorFactory::Build(xmap, 3);
89 }
else if (numPDEs_ == 3) {
90 nullspace = MultiVectorFactory::Build(xmap, 6);
93 nullspace->putScalar(zero);
94 RCP<MultiVector> Coords = Get<RCP<MultiVector> >(currentLevel,
"Coordinates");
97 ArrayRCP<Scalar> nsValues0, nsValues1, nsValues2, nsValues3, nsValues4, nsValues5;
98 int nDOFs = xmap->getLocalNumElements();
100 nsValues0 = nullspace->getDataNonConst(0);
101 for (
int j = 0; j < nDOFs; j++) {
105 }
else if (numPDEs_ == 2) {
106 xnodes = Coords->getDataNonConst(0);
107 ynodes = Coords->getDataNonConst(1);
108 cx = Coords->getVector(0)->meanValue();
109 cy = Coords->getVector(1)->meanValue();
110 nsValues0 = nullspace->getDataNonConst(0);
111 nsValues1 = nullspace->getDataNonConst(1);
112 nsValues2 = nullspace->getDataNonConst(2);
113 for (
int j = 0; j < nDOFs; j += numPDEs_) {
115 nsValues0[j + 0] = 1.0;
116 nsValues1[j + 1] = 1.0;
118 nsValues2[j + 0] = -(ynodes[j] - cy);
119 nsValues2[j + 1] = (xnodes[j] - cx);
121 }
else if (numPDEs_ == 3) {
122 xnodes = Coords->getDataNonConst(0);
123 ynodes = Coords->getDataNonConst(1);
124 znodes = Coords->getDataNonConst(2);
125 cx = Coords->getVector(0)->meanValue();
126 cy = Coords->getVector(1)->meanValue();
127 cz = Coords->getVector(2)->meanValue();
128 nsValues0 = nullspace->getDataNonConst(0);
129 nsValues1 = nullspace->getDataNonConst(1);
130 nsValues2 = nullspace->getDataNonConst(2);
131 nsValues3 = nullspace->getDataNonConst(3);
132 nsValues4 = nullspace->getDataNonConst(4);
133 nsValues5 = nullspace->getDataNonConst(5);
134 for (
int j = 0; j < nDOFs; j += numPDEs_) {
136 nsValues0[j + 0] = 1.0;
137 nsValues1[j + 1] = 1.0;
138 nsValues2[j + 2] = 1.0;
140 nsValues3[j + 0] = -(ynodes[j] - cy);
141 nsValues3[j + 1] = (xnodes[j] - cx);
143 nsValues4[j + 1] = -(znodes[j] - cz);
144 nsValues4[j + 2] = (ynodes[j] - cy);
146 nsValues5[j + 0] = (znodes[j] - cz);
147 nsValues5[j + 2] = -(xnodes[j] - cx);
154 Set(currentLevel,
"Nullspace", nullspace);
159 #define MUELU_RIGIDBODYMODEFACTORY_SHORT
160 #endif // MUELU_RIGIDBODYMODEFACTORY_DEF_HPP
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
Timer to be used in factories. Similar to Monitor but with additional timers.
virtual ~RigidBodyModeFactory()
Destructor.
static const NoFactory * get()
MueLu::DefaultScalar Scalar
Class that holds all level-specific information.
void Build(Level ¤tLevel) const
Build an object with this factory.
int GetLevelID() const
Return level number.
Description of what is happening (more verbose)
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.