46 #ifndef MUELU_RIGIDBODYMODEFACTORY_DEF_HPP
47 #define MUELU_RIGIDBODYMODEFACTORY_DEF_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;
83 RCP<Matrix> A = Get< RCP<Matrix> >(currentLevel,
"A");
84 GetOStream(
Runtime1) <<
"Generating rigid body modes: dimension = " << numPDEs_ << std::endl;
86 if(numPDEs_==1) { nullspace = MultiVectorFactory::Build(xmap, 1); }
87 else if(numPDEs_==2) { nullspace = MultiVectorFactory::Build(xmap, 3); }
88 else if(numPDEs_==3) { nullspace = MultiVectorFactory::Build(xmap, 6); }
90 nullspace -> putScalar(zero);
91 RCP<MultiVector> Coords = Get< RCP<MultiVector> >(currentLevel,
"Coordinates");
94 ArrayRCP<Scalar> nsValues0, nsValues1, nsValues2, nsValues3, nsValues4, nsValues5;
95 int nDOFs=xmap->getNodeNumElements();
97 nsValues0 = nullspace->getDataNonConst(0);
98 for(
int j=0; j<nDOFs; j++) {
103 else if(numPDEs_==2) {
104 xnodes = Coords->getDataNonConst(0);
105 ynodes = Coords->getDataNonConst(1);
106 cx = Coords->getVector(0)->meanValue();
107 cy = Coords->getVector(1)->meanValue();
108 nsValues0 = nullspace->getDataNonConst(0);
109 nsValues1 = nullspace->getDataNonConst(1);
110 nsValues2 = nullspace->getDataNonConst(2);
111 for (
int j=0; j<nDOFs; j+=numPDEs_) {
113 nsValues0[j+0] = 1.0;
114 nsValues1[j+1] = 1.0;
116 nsValues2[j+0] = -(ynodes[j]-cy);
117 nsValues2[j+1] = (xnodes[j]-cx);
120 else if(numPDEs_==3) {
121 xnodes = Coords->getDataNonConst(0);
122 ynodes = Coords->getDataNonConst(1);
123 znodes = Coords->getDataNonConst(2);
124 cx = Coords->getVector(0)->meanValue();
125 cy = Coords->getVector(1)->meanValue();
126 cz = Coords->getVector(2)->meanValue();
127 nsValues0 = nullspace->getDataNonConst(0);
128 nsValues1 = nullspace->getDataNonConst(1);
129 nsValues2 = nullspace->getDataNonConst(2);
130 nsValues3 = nullspace->getDataNonConst(3);
131 nsValues4 = nullspace->getDataNonConst(4);
132 nsValues5 = nullspace->getDataNonConst(5);
133 for (
int j=0; j<nDOFs; j+=numPDEs_) {
135 nsValues0[j+0] = 1.0;
136 nsValues1[j+1] = 1.0;
137 nsValues2[j+2] = 1.0;
139 nsValues3[j+0] = -(ynodes[j]-cy);
140 nsValues3[j+1] = (xnodes[j]-cx);
142 nsValues4[j+1] = -(znodes[j]-cz);
143 nsValues4[j+2] = (ynodes[j]-cy);
145 nsValues5[j+0] = (znodes[j]-cz);
146 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()
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.