46 #ifndef MUELU_COUPLEDRBMFACTORY_DEF_HPP
47 #define MUELU_COUPLEDRBMFACTORY_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>
75 FactoryMonitor m(*
this,
"Structural acoustics nullspace factory", currentLevel);
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 RCP<MultiVector> Coords = Get<RCP<MultiVector> >(currentLevel,
"Coordinates");
84 GetOStream(
Runtime1) <<
"Generating nullspace for structural acoustics: dimension = " << numPDEs_ << std::endl;
86 nullspace = MultiVectorFactory::Build(xmap, 6);
88 nullspace->putScalar(zero);
91 ArrayRCP<Scalar> nsValues0, nsValues1, nsValues2, nsValues3, nsValues4, nsValues5;
92 int nDOFs = xmap->getLocalNumElements();
93 xnodes = Coords->getDataNonConst(0);
94 ynodes = Coords->getDataNonConst(1);
95 znodes = Coords->getDataNonConst(2);
96 cx = Coords->getVector(0)->meanValue();
97 cy = Coords->getVector(1)->meanValue();
98 cz = Coords->getVector(2)->meanValue();
99 nsValues0 = nullspace->getDataNonConst(0);
100 nsValues1 = nullspace->getDataNonConst(1);
101 nsValues2 = nullspace->getDataNonConst(2);
102 nsValues3 = nullspace->getDataNonConst(3);
103 nsValues4 = nullspace->getDataNonConst(4);
104 nsValues5 = nullspace->getDataNonConst(5);
105 for (
int j = 0; j < nDOFs; j += numPDEs_) {
107 if (xmap->getGlobalElement(j) >= lastAcousticDOF_) {
108 Scalar xdiff = xnodes[j] - cx;
109 Scalar ydiff = ynodes[j] - cy;
110 Scalar zdiff = znodes[j] - cz;
112 nsValues0[j + 0] = one;
113 nsValues1[j + 1] = one;
114 nsValues2[j + 2] = one;
116 nsValues3[j + 0] = -ydiff;
117 nsValues3[j + 1] = xdiff;
119 nsValues4[j + 1] = -zdiff;
120 nsValues4[j + 2] = ydiff;
122 nsValues5[j + 0] = zdiff;
123 nsValues5[j + 2] = -xdiff;
126 nsValues0[j + 0] = one;
128 nsValues1[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
129 nsValues1[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
130 nsValues2[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
131 nsValues2[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
132 nsValues3[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
133 nsValues3[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
134 nsValues4[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
135 nsValues4[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
136 nsValues5[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
137 nsValues5[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
144 Set(currentLevel,
"Nullspace", nullspace);
147 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
149 GetOStream(
Runtime1) <<
"Generating nullspace for structural acoustics: dimension = " << numPDEs_ << std::endl;
151 nullspace = MultiVectorFactory::Build(xmap, 6);
153 nullspace->putScalar(zero);
156 ArrayRCP<Scalar> nsValues0, nsValues1, nsValues2, nsValues3, nsValues4, nsValues5;
157 int nDOFs = xmap->getLocalNumElements();
158 xnodes = Coords->getDataNonConst(0);
159 ynodes = Coords->getDataNonConst(1);
160 znodes = Coords->getDataNonConst(2);
161 cx = Coords->getVector(0)->meanValue();
162 cy = Coords->getVector(1)->meanValue();
163 cz = Coords->getVector(2)->meanValue();
164 nsValues0 = nullspace->getDataNonConst(0);
165 nsValues1 = nullspace->getDataNonConst(1);
166 nsValues2 = nullspace->getDataNonConst(2);
167 nsValues3 = nullspace->getDataNonConst(3);
168 nsValues4 = nullspace->getDataNonConst(4);
169 nsValues5 = nullspace->getDataNonConst(5);
170 for (
int j = 0; j < nDOFs; j += numPDEs_) {
172 if (xmap->getGlobalElement(j) >= lastAcousticDOF_) {
173 Scalar xdiff = xnodes[j] - cx;
174 Scalar ydiff = ynodes[j] - cy;
175 Scalar zdiff = znodes[j] - cz;
177 nsValues0[j + 0] = one;
178 nsValues1[j + 1] = one;
179 nsValues2[j + 2] = one;
181 nsValues3[j + 0] = -ydiff;
182 nsValues3[j + 1] = xdiff;
184 nsValues4[j + 1] = -zdiff;
185 nsValues4[j + 2] = ydiff;
187 nsValues5[j + 0] = zdiff;
188 nsValues5[j + 2] = -xdiff;
191 nsValues0[j + 0] = one;
193 nsValues1[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
194 nsValues1[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
195 nsValues2[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
196 nsValues2[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
197 nsValues3[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
198 nsValues3[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
199 nsValues4[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
200 nsValues4[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
201 nsValues5[j + 1] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
202 nsValues5[j + 2] = (
Scalar)(((
double)rand()) / ((
double)RAND_MAX));
209 #define MUELU_COUPLEDRBMFACTORY_SHORT
210 #endif // MUELU_COUPLEDRBMFACTORY_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.
void DeclareInput(Level ¤tLevel) const
Specifies the data that this class needs, and the factories that generate that data.
void Build(Level ¤tLevel) const
Build an object with this factory.
Timer to be used in factories. Similar to Monitor but with additional timers.
static const NoFactory * get()
void BuildRBM(RCP< Matrix > &A, RCP< MultiVector > &Coords, RCP< MultiVector > &nullspace) const
MueLu::DefaultScalar Scalar
Class that holds all level-specific information.
virtual ~CoupledRBMFactory()
Destructor.
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()
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.