10 #ifndef MUELU_RIGIDBODYMODEFACTORY_DEF_HPP
11 #define MUELU_RIGIDBODYMODEFACTORY_DEF_HPP
14 #include <Xpetra_MultiVectorFactory.hpp>
23 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
26 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
29 Input(currentLevel,
"A");
33 currentLevel.
DeclareInput(
"Nullspace", GetFactory(nspName_).
get(),
this);
37 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
44 GetOStream(
Runtime1) <<
"Use user-given rigid body modes " << nspName_ <<
": nullspace dimension=" << nullspace->getNumVectors() <<
" nullspace length=" << nullspace->getGlobalLength() << std::endl;
46 RCP<Matrix> A = Get<RCP<Matrix> >(currentLevel,
"A");
47 GetOStream(
Runtime1) <<
"Generating rigid body modes: dimension = " << numPDEs_ << std::endl;
50 nullspace = MultiVectorFactory::Build(xmap, 1);
51 }
else if (numPDEs_ == 2) {
52 nullspace = MultiVectorFactory::Build(xmap, 3);
53 }
else if (numPDEs_ == 3) {
54 nullspace = MultiVectorFactory::Build(xmap, 6);
57 nullspace->putScalar(zero);
58 RCP<MultiVector> Coords = Get<RCP<MultiVector> >(currentLevel,
"Coordinates");
61 ArrayRCP<Scalar> nsValues0, nsValues1, nsValues2, nsValues3, nsValues4, nsValues5;
62 int nDOFs = xmap->getLocalNumElements();
64 nsValues0 = nullspace->getDataNonConst(0);
65 for (
int j = 0; j < nDOFs; j++) {
69 }
else if (numPDEs_ == 2) {
70 xnodes = Coords->getDataNonConst(0);
71 ynodes = Coords->getDataNonConst(1);
72 cx = Coords->getVector(0)->meanValue();
73 cy = Coords->getVector(1)->meanValue();
74 nsValues0 = nullspace->getDataNonConst(0);
75 nsValues1 = nullspace->getDataNonConst(1);
76 nsValues2 = nullspace->getDataNonConst(2);
77 for (
int j = 0; j < nDOFs; j += numPDEs_) {
79 nsValues0[j + 0] = 1.0;
80 nsValues1[j + 1] = 1.0;
82 nsValues2[j + 0] = -(ynodes[j] - cy);
83 nsValues2[j + 1] = (xnodes[j] - cx);
85 }
else if (numPDEs_ == 3) {
86 xnodes = Coords->getDataNonConst(0);
87 ynodes = Coords->getDataNonConst(1);
88 znodes = Coords->getDataNonConst(2);
89 cx = Coords->getVector(0)->meanValue();
90 cy = Coords->getVector(1)->meanValue();
91 cz = Coords->getVector(2)->meanValue();
92 nsValues0 = nullspace->getDataNonConst(0);
93 nsValues1 = nullspace->getDataNonConst(1);
94 nsValues2 = nullspace->getDataNonConst(2);
95 nsValues3 = nullspace->getDataNonConst(3);
96 nsValues4 = nullspace->getDataNonConst(4);
97 nsValues5 = nullspace->getDataNonConst(5);
98 for (
int j = 0; j < nDOFs; j += numPDEs_) {
100 nsValues0[j + 0] = 1.0;
101 nsValues1[j + 1] = 1.0;
102 nsValues2[j + 2] = 1.0;
104 nsValues3[j + 0] = -(ynodes[j] - cy);
105 nsValues3[j + 1] = (xnodes[j] - cx);
107 nsValues4[j + 1] = -(znodes[j] - cz);
108 nsValues4[j + 2] = (ynodes[j] - cy);
110 nsValues5[j + 0] = (znodes[j] - cz);
111 nsValues5[j + 2] = -(xnodes[j] - cx);
118 Set(currentLevel,
"Nullspace", nullspace);
123 #define MUELU_RIGIDBODYMODEFACTORY_SHORT
124 #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.