Skip to content

Commit 434e389

Browse files
committed
Merge branch 'master' into testFixes2
2 parents 6aea2e7 + 2c8b2ab commit 434e389

File tree

13 files changed

+1422
-2
lines changed

13 files changed

+1422
-2
lines changed

insertVoltagSource.srn5

Lines changed: 447 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2015 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
/*
30+
* ApplyFEMVoltageSource.cc: Builds the RHS of the FE matrix for voltage sources
31+
*
32+
* Written by:
33+
* David Weinstein
34+
* University of Utah
35+
* May 1999
36+
* Modified by:
37+
* Alexei Samsonov, March 2001
38+
* Frank B. Sachse, February 2006
39+
*
40+
*/
41+
42+
#include <Core/Algorithms/Legacy/FiniteElements/ApplyFEM/ApplyFEMVoltageSourceAlgo.h>
43+
44+
#include <Core/Datatypes/Matrix.h>
45+
#include <Core/Datatypes/DenseMatrix.h>
46+
#include <Core/Datatypes/DenseColumnMatrix.h>
47+
#include <Core/Datatypes/SparseRowMatrix.h>
48+
#include <Core/Datatypes/MatrixTypeConversions.h>
49+
#include <Core/Datatypes/Legacy/Field/Mesh.h>
50+
#include <Core/Datatypes/Legacy/Field/VMesh.h>
51+
#include <Core/Datatypes/Legacy/Field/VField.h>
52+
#include <Core/Datatypes/Legacy/Field/Field.h>
53+
#include <Core/Datatypes/Legacy/Field/FieldInformation.h>
54+
#include <Core/Logging/LoggerInterface.h>
55+
56+
#include <Dataflow/Network/Module.h>
57+
#include <vector>
58+
59+
using namespace SCIRun;
60+
using namespace SCIRun::Core::Algorithms;
61+
using namespace SCIRun::Core::Algorithms::FiniteElements;
62+
using namespace SCIRun::Core::Datatypes;
63+
using namespace SCIRun::Core::Geometry;
64+
65+
ApplyFEMVoltageSourceAlgo::ApplyFEMVoltageSourceAlgo()
66+
{
67+
68+
}
69+
70+
71+
void ApplyFEMVoltageSourceAlgo::ExecuteAlgorithm(const DenseMatrixHandle& dirBC, DenseColumnMatrixHandle& rhs, SparseRowMatrixHandle& mat)
72+
{
73+
//! adjusting matrix for Dirichlet BC
74+
index_type *idcNz;
75+
double *valNz;
76+
index_type idcNzsize;
77+
78+
std::vector<double> dbc;
79+
index_type idx;
80+
size_type size = dirBC->nrows();
81+
for(idx = 0; idx<size; ++idx)
82+
{
83+
index_type ni = (*dirBC)(idx, 1);
84+
double val = (*dirBC)(idx, 2);
85+
86+
// -- getting column indices of non-zero elements for the current row
87+
mat->getRowNonzerosNoCopy(ni, idcNzsize, idcNz, valNz);
88+
89+
// -- updating rhs
90+
for (index_type i=0; i<idcNzsize; ++i)
91+
{
92+
index_type j = idcNz ? idcNz[i] : i;
93+
(*rhs)[j] += -val * valNz[i];
94+
}
95+
}
96+
97+
//! zeroing matrix row and column corresponding to the dirichlet nodes
98+
size = dirBC->nrows();
99+
for(idx = 0; idx<size; ++idx)
100+
{
101+
index_type ni = (*dirBC)(idx, 1);
102+
double val = (*dirBC)(idx, 2);
103+
104+
mat->getRowNonzerosNoCopy(ni, idcNzsize, idcNz, valNz);
105+
106+
for (index_type i=0; i<idcNzsize; ++i)
107+
{
108+
index_type j = idcNz?idcNz[i]:i;
109+
mat->put(ni, j, 0.0);
110+
mat->put(j, ni, 0.0);
111+
}
112+
113+
//! updating dirichlet node and corresponding entry in rhs
114+
mat->put(ni, ni, 1);
115+
(*rhs)[ni] = val;
116+
}
117+
118+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
For more information, please see: http://software.sci.utah.edu
3+
4+
The MIT License
5+
6+
Copyright (c) 2015 Scientific Computing and Imaging Institute,
7+
University of Utah.
8+
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a
11+
copy of this software and associated documentation files (the "Software"),
12+
to deal in the Software without restriction, including without limitation
13+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
14+
and/or sell copies of the Software, and to permit persons to whom the
15+
Software is furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included
18+
in all copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26+
DEALINGS IN THE SOFTWARE.
27+
*/
28+
29+
/*
30+
* ApplyFEMVoltageSource.cc: Builds the RHS of the FE matrix for voltage sources
31+
*
32+
* Written by:
33+
* David Weinstein
34+
* University of Utah
35+
* May 1999
36+
* Modified by:
37+
* Alexei Samsonov, March 2001
38+
* Frank B. Sachse, February 2006
39+
*
40+
*/
41+
42+
#ifndef CORE_ALGORITHMS_LEGACY_FORWARD_APPLYFEMVOLTAGESOURCEALGO_H
43+
#define CORE_ALGORITHMS_LEGACY_FORWARD_APPLYFEMVOLTAGESOURCEALGO_H
44+
45+
#include <Core/Datatypes/MatrixFwd.h>
46+
#include <Core/Algorithms/Base/AlgorithmBase.h>
47+
#include <Core/Algorithms/Legacy/FiniteElements/share.h>
48+
49+
namespace SCIRun {
50+
namespace Core {
51+
namespace Algorithms {
52+
namespace FiniteElements {
53+
54+
class SCISHARE ApplyFEMVoltageSourceAlgo
55+
{
56+
public:
57+
ApplyFEMVoltageSourceAlgo();
58+
void ExecuteAlgorithm(const Datatypes::DenseMatrixHandle& dirBC, Datatypes::DenseColumnMatrixHandle& rhs, Datatypes::SparseRowMatrixHandle& mat);
59+
};
60+
}
61+
}
62+
}
63+
}
64+
65+
#endif

src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
# Headers of Core/Algorithms/Legacy/FiniteElements classes
3030
SET(Core_Algorithms_Legacy_FiniteElements_HEADERS
31+
ApplyFEM/ApplyFEMVoltageSourceAlgo.h
3132
BuildMatrix/BuildTDCSMatrix.h
3233
BuildMatrix/BuildFEMatrix.h
3334
BuildRHS/BuildFEVolRHS.h
@@ -38,6 +39,7 @@ SET(Core_Algorithms_Legacy_FiniteElements_HEADERS
3839
# Sources of Core/Algorithms/Legacy/FiniteElements classes
3940
SET(Core_Algorithms_Legacy_FiniteElements_SRCS
4041
#Periodic/DefinePeriodicBoundaries.cc
42+
ApplyFEM/ApplyFEMVoltageSourceAlgo.cc
4143
Mapping/BuildFEGridMapping.cc
4244
Mapping/BuildNodeLink.cc
4345
BuildMatrix/BuildFEMatrix.cc

0 commit comments

Comments
 (0)