46 #ifndef MUELU_COUPLEDRBMFACTORY_DEF_HPP
47 #define MUELU_COUPLEDRBMFACTORY_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>
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;
83 RCP<Matrix> A = Get< RCP<Matrix> >(currentLevel,
"A");
84 RCP<MultiVector> Coords = Get< RCP<MultiVector> >(currentLevel,
"Coordinates");
85 GetOStream(
Runtime1) <<
"Generating nullspace for structural acoustics: dimension = " << numPDEs_ << std::endl;
87 nullspace = MultiVectorFactory::Build(xmap, 6);
88 Scalar zero = (Scalar) 0.0;
89 nullspace -> putScalar(zero);
92 ArrayRCP<Scalar> nsValues0, nsValues1, nsValues2, nsValues3, nsValues4, nsValues5;
93 int nDOFs=xmap->getNodeNumElements();
94 xnodes = Coords->getDataNonConst(0);
95 ynodes = Coords->getDataNonConst(1);
96 znodes = Coords->getDataNonConst(2);
97 cx = Coords->getVector(0)->meanValue();
98 cy = Coords->getVector(1)->meanValue();
99 cz = Coords->getVector(2)->meanValue();
100 nsValues0 = nullspace->getDataNonConst(0);
101 nsValues1 = nullspace->getDataNonConst(1);
102 nsValues2 = nullspace->getDataNonConst(2);
103 nsValues3 = nullspace->getDataNonConst(3);
104 nsValues4 = nullspace->getDataNonConst(4);
105 nsValues5 = nullspace->getDataNonConst(5);
106 for (
int j=0; j<nDOFs; j+=numPDEs_) {
107 Scalar one = (Scalar) 1.0;
108 if( xmap->getGlobalElement(j) >= lastAcousticDOF_ ) {
109 Scalar xdiff = xnodes[j]-cx;
110 Scalar ydiff = ynodes[j]-cy;
111 Scalar zdiff = znodes[j]-cz;
113 nsValues0[j+0] = one;
114 nsValues1[j+1] = one;
115 nsValues2[j+2] = one;
117 nsValues3[j+0] = -ydiff;
118 nsValues3[j+1] = xdiff;
120 nsValues4[j+1] = -zdiff;
121 nsValues4[j+2] = ydiff;
123 nsValues5[j+0] = zdiff;
124 nsValues5[j+2] = -xdiff;
128 nsValues0[j+0] = one;
130 nsValues1[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
131 nsValues1[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
132 nsValues2[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
133 nsValues2[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
134 nsValues3[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
135 nsValues3[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
136 nsValues4[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
137 nsValues4[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
138 nsValues5[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
139 nsValues5[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
147 Set(currentLevel,
"Nullspace", nullspace);
150 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
152 GetOStream(
Runtime1) <<
"Generating nullspace for structural acoustics: dimension = " << numPDEs_ << std::endl;
154 nullspace = MultiVectorFactory::Build(xmap, 6);
155 Scalar zero = (Scalar) 0.0;
156 nullspace -> putScalar(zero);
159 ArrayRCP<Scalar> nsValues0, nsValues1, nsValues2, nsValues3, nsValues4, nsValues5;
160 int nDOFs=xmap->getNodeNumElements();
161 xnodes = Coords->getDataNonConst(0);
162 ynodes = Coords->getDataNonConst(1);
163 znodes = Coords->getDataNonConst(2);
164 cx = Coords->getVector(0)->meanValue();
165 cy = Coords->getVector(1)->meanValue();
166 cz = Coords->getVector(2)->meanValue();
167 nsValues0 = nullspace->getDataNonConst(0);
168 nsValues1 = nullspace->getDataNonConst(1);
169 nsValues2 = nullspace->getDataNonConst(2);
170 nsValues3 = nullspace->getDataNonConst(3);
171 nsValues4 = nullspace->getDataNonConst(4);
172 nsValues5 = nullspace->getDataNonConst(5);
173 for (
int j=0; j<nDOFs; j+=numPDEs_) {
174 Scalar one = (Scalar) 1.0;
175 if( xmap->getGlobalElement(j) >= lastAcousticDOF_ ) {
176 Scalar xdiff = xnodes[j]-cx;
177 Scalar ydiff = ynodes[j]-cy;
178 Scalar zdiff = znodes[j]-cz;
180 nsValues0[j+0] = one;
181 nsValues1[j+1] = one;
182 nsValues2[j+2] = one;
184 nsValues3[j+0] = -ydiff;
185 nsValues3[j+1] = xdiff;
187 nsValues4[j+1] = -zdiff;
188 nsValues4[j+2] = ydiff;
190 nsValues5[j+0] = zdiff;
191 nsValues5[j+2] = -xdiff;
195 nsValues0[j+0] = one;
197 nsValues1[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
198 nsValues1[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
199 nsValues2[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
200 nsValues2[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
201 nsValues3[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
202 nsValues3[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
203 nsValues4[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
204 nsValues4[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
205 nsValues5[j+1] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
206 nsValues5[j+2] = (Scalar) (((
double) rand()) / ((
double) RAND_MAX));
213 #define MUELU_COUPLEDRBMFACTORY_SHORT
214 #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
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.